Skip to content

Conversation

@MBanucu
Copy link
Contributor

@MBanucu MBanucu commented Jan 28, 2026

Summary

This PR addresses CI pipeline issues and introduces a comprehensive web UI for PTY session management.

Key Changes

  • CI Enhancements: Enabled matrix strategy for faster parallel test execution, updated workflows for Bun/Node compatibility, added security scanning, and fixed runner issues (migrated to Ubuntu 24.04).
  • Web UI: Implemented full browser-based interface with xterm.js terminal, real-time WebSocket streaming, session switching, and interactive input/output.
  • Testing: Added extensive E2E tests (Playwright), unit/integration tests, and fixes for test isolation/reliability.
  • Refactoring: Improved logging (Pino), code modularization, permissions handling, and removed debug artifacts for production readiness.

Impact

  • No breaking changes; enhances stability, adds UI capabilities, and resolves CI failures.
  • All changes follow project conventions (camelCase, ESLint/Prettier compliance).

Preview of this branch is available at: https://www.npmjs.com/package/opencode-pty-test

Add reproducible Nix-based development environment using flakes and bun2nix
for managing JavaScript dependencies offline. Provides alternative to manual
Bun installation with consistent tool versions and offline support.
- Add Bun.serve() web server with HTTP API and WebSocket support
- Implement event-driven real-time output broadcasting
- Create React-based UI for session listing and live output viewing
- Add session management controls (send input, kill session)
- Integrate server startup with plugin initialization
- Test successful: server starts, sessions created, output streams correctly
- Web server lifecycle and configuration tests
- HTTP API endpoint tests (sessions, input, kill)
- WebSocket connection and message handling tests
- PTY manager integration tests
- Type definition validation tests
- Full integration workflow tests
- Error handling and edge case tests
- Performance and cleanup tests

All 37 tests passing with 94 assertions covering:
- Server startup/shutdown
- REST API functionality
- Real-time WebSocket communication
- Session management integration
- Error conditions and recovery
- Concurrent client handling
- Type safety validation
- Add required data parameter to server.upgrade() call
- Fix TypeScript compilation error
- All tests still pass
- Add comprehensive local development setup guide
- Create example opencode.json configuration
- Add automated setup script for easy local installation
- Include troubleshooting and development workflow tips
- Update model config from object to string format per schema
- Change permissions to permission (correct key name)
- Use proper permission values (allow/ask/deny)
- Add granular bash permissions for safety
- Include read permissions to deny .env files
- Update setup script with corrected config
- Change model from anthropic/claude-3-5-sonnet-20241022 to opencode/grok-code
- Update setup script comments to mention OpenCode Zen authentication
- Grok Code Fast 1 is free and optimized for coding tasks
- Maintain all existing permission and plugin configurations
- Remove plugin field from opencode.json (not needed for local plugins)
- Local plugins in .opencode/plugins/ are loaded automatically by OpenCode
- Update documentation and setup script to reflect correct local plugin usage
- Add PLUGIN_LOADING.md guide explaining npm vs local plugin loading
- Verified: plugin loads correctly without config entry

This follows OpenCode's documented plugin loading mechanism where:
- npm plugins use 'plugin' config field
- local plugins use .opencode/plugins/ directory structure
Implement complete React-based web interface for managing PTY sessions
with real-time WebSocket updates, session creation/killing, and output
streaming. Includes comprehensive testing suite with unit tests (Bun)
and end-to-end tests (Playwright), plus Pino structured logging integration.

- Add React components for session sidebar, output display, and controls
- Implement WebSocket server for real-time session updates
- Create REST API endpoints for session management
- Set up Bun test runner with 37 unit tests and Playwright E2E tests
- Integrate Pino logger with pretty printing and structured output
- Configure Vite bundling and update development dependencies
Add new REST API endpoints to the web server for comprehensive PTY session management:
- POST /api/sessions: Create new PTY sessions
- POST /api/sessions/clear: Clear all active sessions
- GET /api/sessions/:id/output: Retrieve session output with pagination

Enhance server to serve built web assets in test mode for e2e testing.

Refactor test scripts to properly separate unit and e2e test execution, preventing conflicts between testing frameworks.

Update Playwright configuration to reuse existing test server for better performance.

This enables end-to-end testing against a fully functional live server with real WebSocket connections and session management.
- Remove unused session update callback system from manager.ts
- Eliminate circular reference in clearAllSessions export
- Update test-web-server.ts to use manager.clearAllSessions() directly
- Add comprehensive unit tests for ptySpawn, ptyRead, ptyList, and RingBuffer
- Replace mocked WebSocket/fetch in UI tests with real API calls and WebSocket connections
- Add session creation/clearing helpers for integration testing
- Implement pino logger with reduced output in test environment
- Simplify App.test.tsx to focus on basic rendering validation
- Skip e2e tests that depend on incompatible mock implementations
- Configure LOG_LEVEL=error for cleaner test output

These changes improve test realism and reliability by validating actual
WebSocket and API functionality instead of mocked interactions.
- Add dynamic port selection and health checks for test server to prevent port conflicts
- Switch to happy-dom for better browser environment simulation in Vitest
- Replace console.log with pino logger for consistent test output
- Fix act warning in integration tests with proper async handling
- Exclude web and e2e tests from unit test runs to prevent interference
- Rename e2e test files to .spec.ts for better tool compatibility

These changes ensure the test suite runs reliably across different environments without conflicts or timing issues.
- Reduce bash sleep interval from 1 second to 0.1 seconds to send messages faster
- Replace fixed 5-second wait with dynamic loop waiting for at least 5 WebSocket streaming updates
- Update test assertions to require exactly 5 WS messages for validation
- Unskip integration and e2e tests
- Replace mocks with real PTY server in e2e tests
- Wrap render calls in act() to fix React warnings
- Add session status broadcasting on exit
- Fix logging level filtering in test server

This improves test reliability and coverage by using actual server interactions instead of mocks.
- Migrate UI tests from Vitest to Playwright for real browser environment
- Simplify test scripts: combine UI and e2e testing under single 'test:integration' command
- Remove complex background server management from test scripts
- Update Playwright config to handle dynamic test server ports
- Remove unused React Testing Library dependencies
- Keep Bun for unit tests, Playwright for integration testing

This resolves test framework conflicts and provides consistent DOM testing across all UI components.
- Mark TypeScript fixes and test framework unification as completed
- Update test pass rate from 77% to 97% (56/58 tests passing)
- Reflect current implementation status and next priorities
- Document major improvements achieved in workspace health
- Replace setup-node with oven-sh/setup-bun action
- Update package.json version reading to use bun commands
- Change dependency installation from npm to bun install
- Update TypeScript checking to use bun run typecheck
- Add test execution step before publishing
- Use bunx for npm publish to ensure compatibility

This ensures CI/CD uses the same runtime as local development.
- Add pull_request triggers to release workflow
- Create separate CI workflow for testing on all branches
- Ensure CI runs on PRs and pushes to feature branches
- Separate testing CI from release publishing workflow
- Remove playwright-report/ directory from git tracking
- Remove test-results/ directory from git tracking
- Add playwright-report/ and test-results/ to .gitignore
- Prevent future commits of generated test outputs

Reduces repository size and follows best practices for generated files.
- @opencode-ai/plugin: 1.1.3 → 1.1.31 (8 minor versions)
- @opencode-ai/sdk: 1.1.3 → 1.1.31 (8 minor versions)
- bun-pty: 0.4.2 → 0.4.8 (latest patch)

Security patches, API improvements, and compatibility fixes.
Updated test mocks to match new ToolContext interface with metadata/ask methods.
- build: now runs clean + typecheck + vite build for consistent builds
- build:dev: new development build variant (faster, dev optimizations)
- build:prod: new production build with full clean + typecheck + prod mode
- clean: new script to remove dist/, playwright-report/, test-results/

Provides better build consistency, faster development builds, and clean artifact management.
- Install and configure ESLint with TypeScript and React support
- Add Prettier for consistent code formatting
- Configure appropriate globals for Node.js, Bun, and browser environments
- Set up lint and format npm scripts
- Focus on essential rules with warnings for less critical issues

Provides automated code quality checking and consistent formatting.
- Apply consistent code formatting across all files
- Convert double quotes to single quotes
- Standardize indentation and spacing
- Format markdown, JSON, and configuration files
- Ensure consistent style for future development

Part of code quality tools implementation for consistent formatting.
- Update AGENTS.md with complete sections including code style conventions,
  error handling patterns, security best practices, dependency management,
  release process, contributing guidelines, and troubleshooting
- Update README.md with accurate repository URL, complete tool descriptions,
  correct REST API endpoints, proper WebSocket message examples, and
  accurate development instructions
- Correct inaccuracies and add missing information based on thorough
  codebase analysis
- Improve documentation quality and completeness for developers and users
…esolution

Remove the separate pty_server_url tool and handle the 'background-pty-server-url' command directly in the plugin's command.execute.before hook. This simplifies the implementation and removes unnecessary files.

Modify startWebServer to handle port conflicts by falling back to an OS-assigned port (port 0) if the default port is in use. Add getServerUrl utility function for retrieving the current server URL.

These changes improve code maintainability and system reliability without altering the user-facing functionality.
This removes the planning document for server routing simplification,
as the implementation has been completed and merged into the main
codebase. The document detailed the migration from custom routing to
Bun's built-in routing features, which has been successfully
implemented.
Update package version following the test release of the web UI
features and bug fixes. This version includes the merged changes
from npm-test-release branch with upstream compatibility.
Rename the slash command from /background-pty-server-url to
/pty-server-url for better consistency and clarity. Update
documentation in README.md to include the new slash commands
section with the updated command name.
Change package name from opencode-pty-test to opencode-pty,
update author to shekohex, and modify repository, bugs, and
homepage URLs to point to shekohex/opencode-pty repository.
Remove the CodeQL security analysis job and associated
security-events permission from the CI workflow to streamline
the build process and reduce complexity.
Remove web-ui-implementation branch from push and pull_request
triggers, keeping only the main branch for CI runs.
This commit corrects import statements across web client components and test files to use the current package name 'opencode-pty' instead of the outdated 'opencode-pty-test'. Previously, these mismatched paths caused TypeScript compilation failures due to unresolved module exports defined in package.json. The changes ensure proper module resolution, fixing build errors and maintaining compatibility with the package's export mappings.
- Add list-tests job to dynamically list test files
- Modify test job to use matrix for individual file execution
- Update checkout action version in dependency-review
@shekohex
Copy link
Owner

Can you share some screenshots or a demo video of the web UI?

Also some tests are failing.

Will review once it is fully ready.

- Change triggers from push/pull_request to workflow_run on CI completion
- Add condition to skip publish job if CI failed
- Remove typecheck and test steps from workflow as they are handled by CI
- Remove local test scripts from package.json

This ensures releases only occur after successful CI runs.
- Add KeyboardEvent and NodeJS globals for client files
- Add Request, Headers, TextEncoder globals for server files
- Fix empty catch blocks in NotificationManager and manager with comments
- Add TODO comment for unimplemented permission check in permissions.ts

This resolves all ESLint errors, ensuring code quality standards are met.
Re-enable the lint step that was commented out due to ESLint errors.
Now that all lint errors have been fixed, CI will run lint checks
to ensure code quality standards are maintained.
@MBanucu
Copy link
Contributor Author

MBanucu commented Jan 28, 2026

Can you share some screenshots or a demo video of the web UI?

Also some tests are failing.

Will review once it is fully ready.
#13 (comment)

Let me make a video

Finalize package version from test to stable release.
@MBanucu
Copy link
Contributor Author

MBanucu commented Jan 28, 2026

There is a bug/missing feature in pun-pty. It seams like it is not possible for the event registration to happen for sure before there is any output from the terminal.

sursaone/bun-pty#35

Let me fix that.

@MBanucu
Copy link
Contributor Author

MBanucu commented Jan 28, 2026

There is a bug/missing feature in pun-pty. It seams like it is not possible for the event registration to happen for sure before there is any output from the terminal.

sursaone/bun-pty#35

Let me fix that.
#13 (comment)

Now this is going to take a week or so until it is published?
sursaone/bun-pty#37

What should I do?

@shekohex
Copy link
Owner

What should I do?

This a needed feature of this PR? if Yes, nothing we can do for now until it is merged there and updated.

Add temporary monkey patch to bun-pty _startReadLoop to prevent race condition until upstream PR is merged.

Update echo test to use echo command for simpler testing. Add spawn repeat test.
Add runtime check for bun-pty version using Bun's built-in semver. Throw error if version > 0.4.8 to prevent unnecessary patching on newer versions where the race condition may be fixed.

Update spawn repeat test for better isolation and logging.
Remove matrix strategy for individual test files in CI workflow. Run all tests in a single job for better efficiency and to avoid potential matrix issues.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants