Skip to content

feat(site): add terminal panel to chat sidebar - #23231

Merged
ThomasK33 merged 23 commits into
mainfrom
chat-sidebar-4hqq
Apr 1, 2026
Merged

ThomasK33 merged 23 commits into
mainfrom
chat-sidebar-4hqq

Conversation

@ThomasK33

@ThomasK33 ThomasK33 commented Mar 18, 2026 •

Copy link
Copy Markdown
Member

Add terminal panel to chat sidebar

Extract the reusable terminal runtime from TerminalPage into modules/terminal/ and wire it into the agents chat right sidebar as a new Terminal tab.

Changes

  • modules/terminal/WorkspaceTerminal.tsx — Shared xterm + websocket terminal component (container-sized, no route dependency)
  • modules/terminal/WorkspaceTerminalAlerts.tsx — Moved from TerminalPage/ to shared module
  • pages/AgentsPage/TerminalPanel.tsx — Sidebar wrapper around WorkspaceTerminal
  • pages/AgentsPage/AgentDetailView.tsx — Terminal tab added (gated on hasWorkspace)
  • pages/TerminalPage/TerminalPage.tsx — Slimmed to page-shell using shared component

Demo

dogfood-terminal-demo.webm

Behavior

  • Terminal tab appears only when the chat has a workspace with a connected agent
  • Connects via the existing workspace agent PTY websocket
  • Resizes correctly on panel width changes, expand/collapse, and viewport resize
  • fitAddon.fit() guarded against pre-renderer crashes (fixes proxy access)
  • Tab switching unmounts/remounts cleanly (reconnects via session token)
  • No changes to Git or Desktop panel behavior

Generated with mux • Model: anthropic:claude-opus-4-6 • Thinking: xhigh

@ThomasK33 ThomasK33 changed the title feat(agents): add terminal panel to chat sidebar feat(site): add terminal panel to chat sidebar Mar 18, 2026
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 149e22c2af

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions github-actions Bot added the stale This issue is like stale bread. label Mar 26, 2026
@johnstcn

Copy link
Copy Markdown
Member

+1 to this

@johnstcn johnstcn removed the stale This issue is like stale bread. label Mar 27, 2026
@ThomasK33
ThomasK33 force-pushed the chat-sidebar-4hqq branch 2 times, most recently from da24888 to f73a658 Compare March 27, 2026 10:15
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f73a6589da

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown
Member Author

@codex review

@DanielleMaywood DanielleMaywood left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 This review was written by Coder Agent on behalf of Danielle Maywood 🤖

Code review by Pluto 🐕 and team — 6 reviewers, 26 hypotheses tested, 5 unique findings verified by independent fact-checkers.


return (
<div className="flex h-full min-h-0 flex-col">
<WorkspaceTerminalAlerts

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2 — Improvement] RRT002: RefreshSessionButton calls window.location.reload(), destructive in sidebar context

RefreshSessionButton (in WorkspaceTerminalAlerts.tsx, line 198) unconditionally calls window.location.reload(). This was fine when the component only lived on the standalone TerminalPage (where the terminal IS the page). Now that it's used here in the sidebar, clicking "Refresh session" reloads the entire Agents page — destroying the chat, git panel state, sidebar position, and any unsaved work.

The DisconnectedAlert shows this button when the WebSocket disconnects, which is a realistic scenario (network blip, server restart).

Suggestion: Accept an optional onRefresh callback prop in WorkspaceTerminalAlerts. When provided, use it instead of window.location.reload(). TerminalPanel can pass a handler that resets the terminal connection (e.g. bumping the reconnection token via state) without reloading. TerminalPage continues passing nothing (or () => window.location.reload()) to preserve existing behavior.

Found by react-robustness-top-down.

🤖 This comment was written by Coder Agent on behalf of Danielle Maywood 🤖

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inherited from existing TerminalAlerts (moved, not modified). Should be fixed for sidebar context in a follow-up.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inherited from existing TerminalAlerts (moved, not modified). Should be addressed for sidebar context as a follow-up.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Re-raising: still no ticket for this. RefreshSessionButton calls window.location.reload(), which in the sidebar destroys the entire page: chat history scroll position, git panel state, and the terminal itself. The user clicked a button scoped to the terminal panel and lost everything else. (Nami)

The component moved from TerminalPanel.tsx to WorkspaceTerminalAlerts.tsx but the behavior is unchanged. For the sidebar consumer, this needs a scoped action (e.g., regenerate the reconnection token to force a new WS connection) instead of a full page reload.

🤖

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acknowledged — this is a real UX issue in the sidebar context. The fix (scoped reconnection instead of full page reload) requires changes to WorkspaceTerminalAlerts which is shared with the standalone page. Tracking as a follow-up to avoid scope creep in this PR.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 585e579256

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ThomasK33
ThomasK33 force-pushed the chat-sidebar-4hqq branch 2 times, most recently from b5d6bf0 to 2deae76 Compare March 27, 2026 12:37
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 73484bb027

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ThomasK33
ThomasK33 force-pushed the chat-sidebar-4hqq branch 5 times, most recently from 3707027 to 6fd84b7 Compare March 30, 2026 08:35
ThomasK33 added 23 commits April 1, 2026 13:30
Extract a reusable WorkspaceTerminal component from TerminalPage and
wire it into the agents chat right sidebar as a new Terminal tab.

- Extract shared terminal runtime into modules/terminal/
- Add TerminalPanel wrapper for the chat sidebar
- Add Terminal tab (gated on workspace availability)
- Add Storybook stories for all panel states
- Guard fitAddon.fit() against pre-renderer crashes
- Report workspace usage and route links through port-forward rewriting
- Convert terminal styles from emotion to tailwind
- Extract shared terminal config helper
- Migrate TerminalPage test from jest to vitest
…latch, guard all ws handlers

- Convert reportTerminalError from useCallback to useEffectEvent for
  stability, matching handleOpenLink and handleStatusChange patterns.
- Add one-way activation latch (activated state) so tab switches via
  SidebarTabView's CSS hidden toggling don't tear down the WebSocket.
  Terminal creation and WS connection effects now gate on activated
  instead of isVisible. The refit effect still uses isVisible.
- Add disposed guards to open, message, and reconnect WebSocket
  handlers (error and close already had them).
- Soften transient zero-size resize: when getTerminalDimensions returns
  null in scheduleTerminalResize and reconnect handler, just return
  instead of forcing disconnected status on a healthy socket.
@ThomasK33
ThomasK33 force-pushed the chat-sidebar-4hqq branch from a2b799a to 6ad55f3 Compare April 1, 2026 13:30
@ThomasK33
ThomasK33 enabled auto-merge (squash) April 1, 2026 13:36
@ThomasK33
ThomasK33 merged commit 12f87ac into main Apr 1, 2026
26 of 27 checks passed
@ThomasK33
ThomasK33 deleted the chat-sidebar-4hqq branch April 1, 2026 13:38
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 1, 2026
@ThomasK33
ThomasK33 restored the chat-sidebar-4hqq branch April 1, 2026 14:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants