Repository navigation
refactor(site/src/pages/AgentsPage): compose the right panel from SidebarTab children - #31568
Conversation
…ebarTab children SidebarTabView now takes <SidebarTab> children and owns the effective tab and close-to-neighbor selection. Each SidebarTab provides its active, panel-open and expanded state through useSidebarTab(), so each panel derives its own visibility flags with its existing rules instead of AgentChatPageView computing per-panel props. AppPanel wraps WorkspaceAppFrame for the Browser and workspace app tabs, and UserTabPanel replaces the inline UserTabContent. The built-in Terminal renders as the first user terminal tab. Behavior is unchanged.
DanielleMaywood
left a comment
There was a problem hiding this comment.
This review was performed by ai-review, an automated review bot.
2 inline findings.
Coverage
Coverage: 17 of 17 files reviewed; 35 rules.
Candidates: 179 found, 160 outside changed lines, 0 already discussed, 19 evaluated.
Findings: 2 (8 sites, 0 pre-existing sites), 0 over budget, 0 failed.
Model: deepseek/deepseek-v4.1-flash; 19 questions, 19 answered, 0 abstained, 0 cached; 0 uncalibrated findings held back; 18823 input and 7464 output tokens.
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b7d11318ba
ℹ️ 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".
| type TabPanelState = { | ||
| isActive: boolean; | ||
| /** Whether the right panel is open, regardless of the active tab. */ | ||
| isPanelOpen: boolean; | ||
| isExpanded: boolean; | ||
| }; |
There was a problem hiding this comment.
The "is this panel visible?" rule now lives in each panel. isPanelOpen && isActive is repeated in ChatSummaryPanel, DebugPanel and TerminalPanel, while DesktopPanel and AppPanel check isActive alone, with nothing saying that difference is intentional. The design doc names "the flags disagree" as a root cause, and spreading the rule over five files makes that disagreement harder to spot and easy to copy wrong in the next panel.
Suggestion: derive it once here.
type TabPanelState = {
isActive: boolean;
/** Whether the right panel is open, regardless of the active tab. */
isPanelOpen: boolean;
isExpanded: boolean;
/** The right panel is open and this tab is active. */
isVisible: boolean;
};Compute it in SidebarTab (and the default context value), then have Summary, Debug and Terminal read isVisible instead of re-deriving it. Where a panel deliberately uses isActive alone (Desktop, AppPanel), a one-line comment saying why would keep it from looking like a bug.
There was a problem hiding this comment.
Note
This reply was generated by Coder Agents on behalf of @DanielleMaywood.
Thanks, the repetition is real, but I'm keeping this PR as is:
isVisiblewould not replace anything.TerminalPanel'sisHotisisPanelOpen && (isActive || isPending), soisPanelOpenhas to stay in the state. AddingisVisiblegives three fields where one is derived from the other two, to save two one-line derivations (Summary and Debug).- There is no "why" to write for Desktop and
AppPanel. History shows Desktop'sisActive-only gate was never a decision: it came in fix(site): delay desktop VNC connection until tab is selected #23861, whenSidebarTabViewhad no panel-open input at all, and was never revisited while Summary and Debug later gated on the panel being open. Today that means Desktop activates VNC and keeps its zoom shortcuts registered while the panel is closed, which looks like a latent bug.AppPanel'sactiveonly togglesflex/hidden, so panel-open makes no difference there, but that is also not recorded intent. A rationale comment would be invented.
This PR is a behavior-preserving refactor, so it keeps each panel's existing rule. Making Desktop respect the panel being closed changes behavior and belongs in a separate PR, where unifying the rule is the natural place to do it.
| const nextActiveTabId = | ||
| effectiveTabId === tabId | ||
| ? remainingTabIds[Math.min(closedTabIndex, remainingTabIds.length - 1)] | ||
| : undefined; |
…-in-terminal-tab # Conflicts: # site/src/pages/AgentsPage/AgentChatPage/AgentChatPageView.tsx
Note
This PR was generated by Coder Agents on behalf of @DanielleMaywood.
Stage 2 of the
AgentChatPageViewsimplification (stage 1: #31476). Behavior is unchanged.The right panel is now composed as children instead of being built from config arrays and a render switch:
LLM Slop Description
SidebarTabViewis a compound component. It reads its<SidebarTab>children for the tab bar and owns the effective-tab fallback and close-to-neighbor selection (SidebarTab.onClosereceives the next active tab id).SidebarTabprovides{isActive, isPanelOpen, isExpanded}throughuseTabPanelState().ChatSummaryPanel,DebugPanel,DesktopPanel,GitPanelandTerminalPanelderive their own flags from it with the rules they had before, so theirisVisible,isExpanded,isHotandautoFocusprops are gone.AppPanel(Browser and workspace app tabs) andUserTabPanel(terminal, workspace app, port), replacingUserTabContentandrenderTabContent.nameUnlabeledTerminalsgives unlabeled terminals "Terminal", "Terminal 2", and so on.sidebarTabConfigs,getEffectiveTabId, the neighbor logic,handleToggleSingletonTaband the per-panel flag computations. The View goes from 1060 to 960 lines.TabPanelStateContextdecorator. No new tests.Checks:
pnpm check,pnpm lint(including the compiler check),pnpm lint:types, AgentsPage unit (134 files) and storybook (87 files) tests, the frontend-deep-review roles and the FE1 to FE10 audit.Design review and plan
AgentChatPageView: why it looks like this, and how to simplify it
Scope:
site/src/pages/AgentsPage/AgentChatPage/AgentChatPageView.tsx(1125 lines) and its containerAgentChatPage.tsx(870 lines), onorigin/maina512a7f (2026-10-29). Line numbers below refer to that commit. "View" = AgentChatPageView.tsx, "Page" = AgentChatPage.tsx.Method: four read-only research lanes (git history, PR bodies, review threads), one cross-check of the 8 most load-bearing claims (7 confirmed, 1 uncertain, 0 refuted), then three parallel design passes under different constraints. Confidence is high unless marked.
1. Headline numbers
editingfields. It had 82 before refactor(site/src/pages/AgentsPage): extract AgentChatPage helpers and hooks #29032.AgentChatPageLoadingView, and the router Suspense fallbackAgentChatPageSkeleton. They have drifted three times (fix(site): prevent layout shift when agent chat right panel loads #22983 layout shift, fix(site/src/pages/AgentsPage): preserve chat input typed while loading #26415 lost typing, fix(site/src/pages/AgentsPage): size embedded agent chat to viewport #29602 missingh-full).2. Root causes
<ChatPageInput />#29118) moved reads into the leaves but deliberately stopped at the send pipeline. refactor(site/src/pages/AgentsPage): extract AgentChatPage helpers and hooks #29032 says the send pipeline and View "stay put". refactor(site/src/pages/AgentsPage): pass Chat instead of sliced chat flags #29064 says "Handlers stay props". refactor(site): drive plan mode from mutation pending state #29117 made mutation pending state driveisInputDisabled. The View became a relay. You noted the cost on refactor(site/src/pages/AgentsPage): extract AgentChatPage helpers and hooks #29032 ("So many props getting drilled").chatnorstore, so it was split off (refactor(site): separate AgentsPage and AgentDetail into container/view pairs #22812) and its layout copied.3. Catalogue: what each part does, why, and whether the reason still holds
Verdict key: Keep, Move (to the owner named), Delete.
3.1 Prop relay (Page to View)
submitChatTurnandisInputDisabledread them (Page 507-520, 654-698). #29032, #29064, #29117providerCount,modelCount,unsupportedProviderNames,canConfigureAgentSetup)AgentCreateFormalready derives the same values itself (AgentCreateForm.tsx 542-652)sshCommand(Page 613-616)SSHButtonalready readsdeploymentSSHConfigitselfurlTransform,gitWatcher3.2 Chat column
liveChatStatus(326, 834)isViewerNotOwner. #30483 itself lists "one viewer-permission check" as a follow-upattachedWorkspace,preferredFolder(397-421)onImplementPlan/onSendAskUserQuestionResponsegating (894-903)isOtherUserReadOnly ||is redundant in production:isInputDisabledalready includes viewer-not-owner (Page 242-243, 515-520)undefinedwhen a turn can't be submittedonEditUserMessagegating (886-890)QueuedForCapacityCalloutis the only consumer, and the stories already drive it through providers (cross-check confirmed)initialActiveTurnMaxMessageId+initialMessages(332-341)key={agentId}on the View (Page 787) and on ChatPageTimeline (875)KeyedAgentChatPagealready keys the whole subtree (Page 854-867)3.3 Right-panel tab model
sidebarTabIdsave is historical only. The effects write"[]"on every mount, and they rewrite state if a chat is unarchived while open (cross-check confirmed)validateUserRightPanelTabs(445)UserTabContentfallbacks (200-265)defaultTerminalHidden, 357, 450, 549-554, 688-704)reconnectionToken = chatId(cross-check confirmed)getEffectiveTabIdfalls back to the first tab (496)ChatsSidebar/3.4 Activation and tab content
onOpenDesktoponly when the panel can render (511-518)onReadyonce per mount, so the guard is requiredWorkspaceAppFrame.activedisplay:noneto invisible-but-laid-outTerminalClientSessionContext(366, 809)ChatWorkspaceContext(810)3.5 Layout, expansion, loading
isOpen(cross-check confirmed)isOpen &&into RightPaneldragVisualExpandedrelay (342-349, 971)hidden, which is visually redundant because the expanded panel isabsolute inset-0 z-30(medium)--agents-chat-panel-min-width,max-lg:hidden,h-fullshouldShowSidebar,flex-row,data-testid="agents-chat-panel",{" "}handleLoadingDraftChangeseed4. The three alternative designs
All three agree on Section 3's Delete/Move rows. They differ on the right panel and on page composition.
Design A: Delete and colocate (no new abstractions)
composernode.AgentChatRightPanel(about 440 lines, 16 props): user tabs, the terminal flag, pending, expansion, content.AgentChatLayout(about 35 lines): the frame shared by loading, loaded and Suspense.:hasdata-attribute coupling.Design B: Layout shell with slots (dissolve the View)
AgentChatPageShell(about 140 lines) withtopBar,notices,main,composerandrightPanelslots renders every state: loading, loaded, error, not-found and Suspense.ChatRightPanelowns all tab state. Tools reach it through an imperativeref.open(target).Design C: Feature-owned tabs
{ isActive, isShown, isExpanded }once and callstab.render(view).useSingletonTab,reduceRightprovider nesting, hooks returning render closures.Comparison
5. Recommendation: A's cleanup, then decide on C's ownership principle (without its framework)
Measure progress by contracts, duplicated decisions and effects removed, not by the View's line count.
Stage 1: design-agnostic cleanup (all three designs agree). Each item is an independent PR.
UserTabContentfallbacks, repeated support checks, aliases, no-op classes, unused test id, inner keys, the redundant read-only gating term.sshCommandinto WorkspacePillChatWorkspaceContextaround the timeline onlyattachedWorkspace, and the Page gates the turn-action handlers. Making the timeline a node too is a separate, optional PR.Stage 2: reassess. After Stage 1 the View is mostly a list of regions plus tab activation. Two choices:
Stage 3, only if Preview still hurts: apply C's principle at the smallest scale.
reduceRight, no storage migration, no shared read-modify-write keys.Not recommended for now: B's imperative ref, C's registry and seeded-terminal migration, and any new controller or provider around the whole page.
6. Decisions needed from you
7. Risks to validate during implementation