Skip to content

feat: ShellV2 Typed WebSocket Protocol & Improved Rendering#1830

Merged
KCarretto merged 2 commits intofeat/shellv2-backendfrom
shellv2-websocket-protocol-3101717163247646096
Feb 18, 2026
Merged

feat: ShellV2 Typed WebSocket Protocol & Improved Rendering#1830
KCarretto merged 2 commits intofeat/shellv2-backendfrom
shellv2-websocket-protocol-3101717163247646096

Conversation

@KCarretto
Copy link
Collaborator

This PR updates the ShellV2 frontend to use a structured, typed WebSocket protocol mirroring the backend definitions in tavern/internal/http/shell/websocket.go.

Key changes include:

  • Typed Protocol: Introduced websocket.ts with interfaces for Input, Output, TaskError, ControlFlow, etc.
  • Improved Rendering: The ShellV2 terminal now correctly handles asynchronous output (e.g., from long-running tasks or other users) by clearing the current input line, printing the output, and restoring the prompt and user input buffer. This prevents output from clobbering the user's current command.
  • Adapter Update: The HeadlessWasmAdapter now parses the full JSON message structure to distinguish between message kinds.

Verification:

  • Manually verified using a mock WebSocket server and Playwright script (mocking the backend communication) to ensure output appears correctly above the input line and errors are highlighted.

PR created automatically by Jules for task 3101717163247646096 started by @KCarretto

…put rendering

- Created `tavern/internal/www/src/pages/shellv2/websocket.ts` to mirror backend WebSocket message types.
- Updated `headless-adapter.ts` to use typed messages and correct input format.
- Refactored `ShellV2` component to handle asynchronous output by clearing and redrawing the input line.
- Implemented specific handling for task errors (red) and control flow messages.

Co-authored-by: KCarretto <16250309+KCarretto@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@KCarretto KCarretto marked this pull request as ready for review February 18, 2026 01:29
@KCarretto KCarretto merged commit f8d981f into feat/shellv2-backend Feb 18, 2026
@KCarretto KCarretto deleted the shellv2-websocket-protocol-3101717163247646096 branch February 18, 2026 01:29
github-merge-queue bot pushed a commit that referenced this pull request Feb 18, 2026
* feat(shellv2): implement new shell endpoint, task tracking, and frontend (#1824)

- Update `Shell` ent schema to make task optional and add `ShellTask` relation.
- Create `ShellTask` ent schema with history mixin.
- Update `portal.proto` to include `ShellPayload`.
- Add `createShell` mutation to GraphQL schema and implement resolver.
- Implement `ShellV2Handler` with WebSocket upgrade, shell verification, auth check, and pubsub integration.
- Update `tavern/app.go` to register new endpoint.
- Update `ShellV2` frontend to verify shell status via GraphQL and handle errors.
- Fix generated resolvers to avoid panics.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: KCarretto <16250309+KCarretto@users.noreply.github.com>

* some backend work

* artisnal websockets

* stubbed it out... artisnally :chefskiss:

* Implement Shell V2 WebSocket backend logic (#1829)

- Update `ShellPayload` in `portal.proto` to include `stream_id` for multi-user session tracking.
- Implement `writeMessagesFromWebsocket` in `tavern/internal/http/shell/handler.go` to handle user input, create `ShellTask` ents, and route messages to active portals or queue them if no portal is active.
- Implement `writeMessagesFromShell` to handle output from portals (interactive) or DB polling (non-interactive), with support for "Other Stream" output notifications.
- Add `WebsocketMessageKindOutputFromOtherStream` and associated message struct in `websocket.go`.
- Add integration tests in `tavern/internal/http/shell/integration_test.go` covering interactive, non-interactive, and multi-user scenarios.
- Fix WebSocket handler to accept both `TextMessage` and `BinaryMessage` frames.
- Ensure thread-safe access to `activePortal` state using `ShellSession`.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: KCarretto <16250309+KCarretto@users.noreply.github.com>

* feat: ShellV2 Typed WebSocket Protocol & Improved Rendering (#1830)

* feat: update ShellV2 to use typed WebSocket protocol and improved output rendering

- Created `tavern/internal/www/src/pages/shellv2/websocket.ts` to mirror backend WebSocket message types.
- Updated `headless-adapter.ts` to use typed messages and correct input format.
- Refactored `ShellV2` component to handle asynchronous output by clearing and redrawing the input line.
- Implemented specific handling for task errors (red) and control flow messages.

Co-authored-by: KCarretto <16250309+KCarretto@users.noreply.github.com>

* minor changes

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: KCarretto <16250309+KCarretto@users.noreply.github.com>

* tried fixing but it didn't work

* fixed

* remove old code

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: KCarretto <16250309+KCarretto@users.noreply.github.com>
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.

1 participant