fix(terminal): wait for home sidebar geometry#523
Conversation
Greptile SummaryThis PR fixes a race where the home sidebar terminal-agent session was started before the agent panel was visible, resulting in incorrect terminal geometry. It gates session startup on
Confidence Score: 4/5Safe to merge; the gating logic, geometry-wait flow, and all async cancellation paths are correctly guarded. The async startup sequence now has multiple await points and several interleaved ref-based guards. The guards are all present and correct, but the 300 ms polling window in prepareWaitForTerminalGeometry is a fixed constant: on a reused terminal that happens to be mid-write-queue flush when reset() is enqueued, requestResize fires after the queue drains, which could exceed 300 ms and silently fall back to the sidebar-width estimate instead of the measured geometry. This is a latent imprecision rather than a hard failure, and the fallback is reasonable, but it is a timing assumption worth knowing about. web-ui/src/hooks/use-home-agent-session.ts — the async startup block has the most moving parts and is the place to look first if geometry-related start regressions appear.
|
| Filename | Overview |
|---|---|
| web-ui/src/hooks/use-home-agent-session.ts | Core logic change: gates terminal startup on canStartTerminalSession, adds geometry-wait flow, and removes stale sessionSummaries dep; logic is carefully guarded for disposal, task-ID drift, and visibility transitions. |
| web-ui/src/hooks/use-home-agent-session.test.tsx | Two new test cases cover the reported-geometry fast path and the canStartTerminalSession=false gate; mock setup and assertions are correct. |
| web-ui/src/hooks/use-home-sidebar-agent-panel.tsx | Passes new homeSidebarWidth and isAgentSectionActive props through to useHomeAgentSession; otherwise unchanged. |
| web-ui/src/App.tsx | Moves useProjectNavigationLayout call earlier so sidebarWidth/isCollapsed are available when building homeSidebarAgentPanel props; no functional change to other callers. |
| web-ui/src/terminal/persistent-terminal-manager.ts | One-line addition of requestResize() after terminal.reset() in the write queue; safely guarded by !this.visibleContainer inside requestResize. |
Reviews (1): Last reviewed commit: "fix(terminal): wait for home sidebar geo..." | Re-trigger Greptile
Summary
Validation