feat: Implement Shell V2 WebSocket backend with portal integration#1829
Conversation
- 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: KCarretto <16250309+KCarretto@users.noreply.github.com>
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
* 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>
This PR completes the backend implementation for the V2 Shell WebSocket handler. It enables interactive shell sessions via Portals and fallback to database polling for non-interactive sessions. Key features include multi-user stream tracking (using
stream_id), deduplicated output handling, and proper control flow messaging (e.g., "Task Queued"). Integration tests verify the behavior across different modes.PR created automatically by Jules for task 2020359382156425003 started by @KCarretto