Repository navigation
fix(ui): keep panels and terminals through reconnects - #174046
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review blockedAutomated review did not run, so no review verdict was produced. Reason: The input-safety check rejected material in this revision. No detected value, path, or scanner output is reproduced here. Automatic review is on hold, including after source changes. Request a fresh re-review after resolving the failure; maintainers can also release the hold through an intentional scanner-policy update. Next step: If this is a genuine credential, remove and rotate it. If it is an intentional test fixture, a maintainer must review and qualify it. |
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: 4896590fbd
ℹ️ 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".
| await Promise.all( | ||
| [...this.streams].map(([sessionId, stream]) => { | ||
| stream.abort.abort(); | ||
| stream.abort = new AbortController(); | ||
| return this.reattachStream(sessionId, stream); |
There was a problem hiding this comment.
Isolate failed terminal reattachments
When multiple terminal tabs survive a disconnect and one PTY exits or is reaped before reconnect, that tab's failed terminal.attach rejects this Promise.all. resumeTransport() therefore never reaches the loop that makes any tab writable, while the failed stream remains registered, so every retry repeats the failure and all otherwise healthy tabs stay read-only until the missing tab is manually closed. Settle and reconcile reattachments per session so one missing PTY can be marked exited without blocking the others.
AGENTS.md reference: ui/AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Already addressed: Fixed in 39cbaa7 by resuming each retained session independently and reconciling confirmed missing sessions without blocking surviving terminals.
| return JSON.stringify([ | ||
| gatewayPresentationScope(context.gateway).key, | ||
| context.gateway.snapshot.phase === "connected", | ||
| available(), | ||
| value.agentId, | ||
| value.sessionKey, | ||
| ]); |
There was a problem hiding this comment.
Revalidate prepared app sessions after reconnect
For catalog callers with prepareSession() enabled, removing connection state from discoveryIdentity also leaves preparedSessionIdentity valid across reconnects. If the selected session is deleted by another client or lost during a Gateway restart while this UI is offline, reconnect skips sessions.describe/createResult, mcp.app.discover fails for the missing session, and Retry keeps skipping preparation because the identity never changes. Keep the displayed catalog identity stable, but retire or generation-scope the preparation stamp when reconnecting so the session is reconciled with Gateway authority.
AGENTS.md reference: ui/AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in eb62a6f: Reconnect now expires the catalog session preparation receipt so discovery can recreate a session deleted offline while retaining the displayed catalog.
Keep terminal sessions, upload batches, embedded app and Canvas frames, link-reader content, and downloaded speech through same-client transport loss. Preserve request fencing and retire presentation on identity or confirmed access changes. Expose terminal delivery uncertainty and reconnect Retry, retain saved session IDs after failed restores, and handle Talk abort rejections. Local proof is limited to formatting, i18n baseline generation, and whitespace checks under the coordinator work order; focused tests, typecheck, lint, and review are delegated to the coordinator.
4896590 to
f1f2709
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f1f2709143
ℹ️ 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".
| (this.activeTab.view.status === "idle" || this.reloadPending) | ||
| ) { | ||
| this.reloadPending = false; |
There was a problem hiding this comment.
Refresh every retained link-reader tab after reconnect
When a multi-tab reader reconnects, the panel-wide reloadPending flag is consumed while refreshing only the active tab. Other ready tabs keep their pre-disconnect documents, and selecting one later does not call loadDetail() because its status remains "ready" and this flag is already false; those tabs can therefore display stale content indefinitely, while their image loaders remain fenced to the old connection generation. Track refresh-needed state per tab or mark retained tabs for reload when selected.
AGENTS.md reference: ui/AGENTS.md:L17-L20
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in eb62a6f: Each retained reader tab now refreshes its document and image loader when selected after reconnect, including interrupted refreshes.
| !gapFrame && | ||
| replayStart <= previouslyObservedThrough && | ||
| offset >= previouslyObservedThrough | ||
| ? "resume" | ||
| : "recovery", |
There was a problem hiding this comment.
Preserve recovery mode until terminal replay succeeds
If a reconnect requires a full recovery replay and the hidden replacement terminal fails to initialize, expectedSeq has already advanced before onReplay rejects. On the next Retry, this predicate classifies the same authoritative snapshot as "resume", so only the suffix—often empty—is appended to the old emulator, leaving its screen permanently missing the recovered output. Commit the offset only after replay succeeds, or retain a forced-recovery marker after failure.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in eb62a6f: The terminal replay offset now advances only after the emulator successfully applies the replay, preserving missing output for a later retry.
| createdResources.reconnect = async () => { | ||
| await notifications.reconnect(); | ||
| if (payload.updateModelContextSupported) { | ||
| await refreshModelContext(); |
There was a problem hiding this comment.
Preserve MCP model context when reconnect refresh fails
For an app advertising updateModelContextSupported, reconnect now invokes refreshModelContext(), whose request failure is converted to null and published to the retained iframe. A transient mcp.app.modelContext failure immediately after reconnect therefore silently clears previously valid model context and is treated as a successful reconnect, with no retry; retain the existing context on failure and publish only an authoritative response.
AGENTS.md reference: ui/AGENTS.md:L17-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in eb62a6f: Failed model context reads now preserve retained context while an authoritative null response still clears it.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 882f226a4b
ℹ️ 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".
| if (snapshot.phase !== "connected") { | ||
| const previous = terminalAccess.get(snapshot.client); | ||
| return Boolean( | ||
| previous && previous.recoveryScope === snapshot.client.recoveryScope && previous.allowed, | ||
| ); |
There was a problem hiding this comment.
Preserve focused terminal tabs during reconnects
When a focused terminal document encounters a connection blip, this cached availability remains true, but FocusPanels in ui/src/app/app-root.tsx still passes client={null} while disconnected and never supplies gatewayConnected. The terminal controller consequently treats the outage as a client identity change and calls disposeAllTabs(), losing the focused view's scrollback, selection, and retained upload state rather than suspending it. Update this remaining caller to retain the client and pass the real connection state, as the shell, chat, and terminal-page callers now do.
AGENTS.md reference: AGENTS.md:L50-L53
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in eb62a6f: The focused Terminal now retains its client through transport loss and receives connection availability separately, with regression coverage for reconnect and identity replacement.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c0a1f16cd2
ℹ️ 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".
| onNew={props.view().onNew} | ||
| newLabel={t("terminal.newSession")} | ||
| newDisabled={props.view().booting} | ||
| newDisabled={!props.view().connected || props.view().booting} |
There was a problem hiding this comment.
Disable terminal tab closure while offline
When the global terminal dock is visible during a Gateway disconnect, the new connected state disables New, uploads, and retries but leaves the tab strip's close action enabled. Closing a connection-owned tab in that state immediately removes it and forgets its persisted session ID, while TerminalConnection.close() suppresses the failed offline RPC; the PTY therefore continues running invisibly on the Gateway until its detach timeout and this browser cannot reattach it. Disable closing while disconnected or retain and reconcile the close intent after reconnect.
AGENTS.md reference: ui/AGENTS.md:L17-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in eb62a6f: Live terminal tabs cannot be closed offline, and both close controls are disabled while exited diagnostic tabs remain dismissible.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c0a1f16cd2
ℹ️ 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".
| onNew={props.view().onNew} | ||
| newLabel={t("terminal.newSession")} | ||
| newDisabled={props.view().booting} | ||
| newDisabled={!props.view().connected || props.view().booting} |
There was a problem hiding this comment.
Disable terminal tab closure while offline
When the global terminal dock is visible during a Gateway disconnect, the new connected state disables New, uploads, and retries but leaves the tab strip's close action enabled. Closing a connection-owned tab in that state immediately removes it and forgets its persisted session ID, while TerminalConnection.close() suppresses the failed offline RPC; the PTY therefore continues running invisibly on the Gateway until its detach timeout and this browser cannot reattach it. Disable closing while disconnected or retain and reconcile the close intent after reconnect.
AGENTS.md reference: ui/AGENTS.md:L17-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in eb62a6f: The terminal owner now preserves live sessions when offline close is attempted, with disabled close controls and regression coverage for saved session retention.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4fd99a1dc2
ℹ️ 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".
| if ( | ||
| request && | ||
| this.host.client?.connected && | ||
| request.generation !== this.host.client.connectionGeneration |
There was a problem hiding this comment.
Trigger hovercard recovery on reconnect
For plugin previews inside the activity-feed provider, which does not supply pagePreviewContext, a same-client reconnect with unchanged reader descriptors only invokes propertyChanged("readers"); its reference-equality fast path returns without calling update(). Consequently this generation-mismatch recovery branch never runs, so a preview request interrupted by the disconnect remains in its old error or pending state until another property changes or the user closes and reopens the hovercard. Subscribe this owner to the connection lifecycle or include the connection generation in its update decision.
AGENTS.md reference: ui/AGENTS.md:L17-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing: The activity feed unmounts this hover provider when its pull request snapshots retire and recreates it after reconnect, so this path recovers without a manual page reload.
Keep retained terminal sessions recoverable during offline close and failed replay, refresh reader tabs and MCP session preparation after reconnect, and retain confirmed App context on transient reads. Repair terminal action receipts and Gateway subscription fixtures after the main merge, preserving strict delivery error handling.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eb62a6f9de
ℹ️ 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".
| await Promise.all( | ||
| [...this.streams].map(([sessionId, stream]) => { | ||
| stream.abort.abort(); | ||
| stream.abort = new AbortController(); | ||
| return this.reattachStream(sessionId, stream).catch((error: unknown) => { |
There was a problem hiding this comment.
Make healthy tabs read-only while Retry reattaches them
When one of several sessions fails the initial reconnect, the successful tabs are made writable before the Retry action is exposed. Clicking Retry invokes resume() again, and this loop re-enters recovery for every stream without first making those healthy tabs read-only. Keystrokes entered in a healthy tab during the attach then pass the UI's canSend() check, but requestAction() rejects them because stream.recovering is true, discarding the input and replacing it with a generic delivery error. Retry only the failed streams or publish read-only state before reattaching all streams.
AGENTS.md reference: ui/AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
| try { | ||
| const listed = await this.connectionFor(operation).list(); | ||
| if (!this.isTerminalOperationCurrent(operation, restore)) { | ||
| return false; | ||
| } | ||
| const known = new Map(listed.map((session) => [session.sessionId, session])); | ||
| for (const sessionId of restore.pending.keys()) { | ||
| const session = known.get(sessionId); | ||
| if (!session) { | ||
| await this.restoreExitedSession(sessionId, restore); | ||
| } else { | ||
| await this.attachSession( | ||
| sessionId, | ||
| operation, | ||
| session.owner?.startsWith("agent:") === true, | ||
| restore, | ||
| ); | ||
| } | ||
| if (!this.isTerminalOperationCurrent(operation, restore)) { | ||
| return false; | ||
| await this.recovery.resume(operation, (tab) => { |
There was a problem hiding this comment.
Clear obsolete resume errors after automatic recovery
If a reconnect fails and sets the resume retry error, a later transport disconnect can automatically run this method again and successfully recover every tab, but the old error is never cleared; only the manual retryOpen() path clears it. The panel therefore continues showing “attach failed” with a Retry button even though its tabs are live and writable, and that unnecessary Retry also reattaches every healthy stream. Clear the unchanged resume error once recovery succeeds.
AGENTS.md reference: ui/AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 65f1e8a0eb
ℹ️ 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".
| if (isCurrent() && tab.view.status !== "ready") { | ||
| tab.view = { status: "error", message: linkReaderErrorMessage(error) }; | ||
| this.requestUpdate(); | ||
| } |
There was a problem hiding this comment.
Keep failed reconnect refreshes retryable
When a retained ready tab's reconnect refresh reaches the current connection but its detailMethod fails transiently, loadDetail() has already cleared reloadPending, and this branch preserves the old ready view without restoring that marker or exposing an error. Selecting the tab again therefore never retries, while its retained LinkReaderImages is fenced to the pre-disconnect generation, so uncached images remain unusable until a manual refresh or another reconnect. This is distinct from the earlier per-tab scheduling issue: the refresh is now dispatched, but its failure outcome is dropped.
AGENTS.md reference: ui/AGENTS.md:L17-L19
Useful? React with 👍 / 👎.
| onLoad={() => { | ||
| initialized = true; |
There was a problem hiding this comment.
Retry failed raw Canvas frames after reconnect
When a raw Canvas iframe loads an HTTP error document for an expired capability URL, this handler still marks it initialized because iframe errors also dispatch load. createCanvasFramePresentation() then preserves that failed frame when reconnect publishes a fresh capability URL, leaving the sidebar stuck until the panel is recreated; the sibling widget test already documents that an HTTP error produces load. Only retain the frame after verifiable initialization, or refresh unverifiable frames when the capability changes.
AGENTS.md reference: ui/AGENTS.md:L17-L19
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b27544dbfe
ℹ️ 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".
| priorMetadata.previewMethod === metadata.previewMethod && | ||
| priorMetadata.imageMethod === metadata.imageMethod && | ||
| priorMetadata.hosts.length === metadata.hosts.length && | ||
| priorMetadata.hosts.every((host, index) => host === metadata.hosts[index]) |
There was a problem hiding this comment.
Compare all reader behavior flags before retaining descriptors
When a live capability refresh changes sessionScoped or progressive for the same plugin/reader while the compared fields remain unchanged, this branch retains the old descriptor. Downstream detail and preview requests then continue omitting a newly required session key or sending the wrong progressive-section shape, and the panel sees the same reader object so it does not invalidate the stale document until the client or recovery scope changes. Include both behavior flags, or the complete metadata shape, in the retention comparison.
AGENTS.md reference: AGENTS.md:L75-L75
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e4828da13c
ℹ️ 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".
| } catch (error: unknown) { | ||
| if (this.host.isCurrent(operation, restore)) { | ||
| this.host.setError(`${t("terminal.attachFailed")}: ${formatUiError(error)}`); | ||
| return true; |
There was a problem hiding this comment.
Keep failed saved-session restores retryable
When a persisted-session attach fails transiently during startup restoration, this return true is interpreted by terminal-pending-actions.ts as userClosedTab, so the restore action is retired as "cancelled-restore"; the remaining saved sessions are never attempted, and setError supplies no retry action. This is separate from retained-stream resume recovery: users must close/reopen the panel or wait for another reconnect to retry otherwise-live saved sessions. Return a failure/retryable outcome here rather than the user-closed sentinel.
AGENTS.md reference: AGENTS.md:L82-L82
Useful? React with 👍 / 👎.
Keep terminal delivery-error callbacks bound to their controller. Load the Gateway confirmation and standalone dashboard loader/renderer on demand, with feature chunks that stay outside ordinary startup and chat boot. Preserve loading, cancellation, and same-identity offline presentation. Measure dictation controls in one browser task so reactive status replacement cannot detach a control between lookup and geometry inspection. Keep the existing visibility and containment assertions, and await lazy confirmation registration in the Gateway-lineage fixture. Focused unit coverage passes across four files. Production gzip measures 339154 bytes at startup and 1489193 bytes at chat boot, below unchanged limits.
Preserve terminal availability through reconnects while retaining main projection cleanup. Keep MCP transport fixtures and reconnect subscription coverage. Repair the mobile dictation geometry selector without changing its assertions.
|
Merged via squash.
|
* fix(ui): retain panels across gateway reconnects Keep terminal sessions, upload batches, embedded app and Canvas frames, link-reader content, and downloaded speech through same-client transport loss. Preserve request fencing and retire presentation on identity or confirmed access changes. Expose terminal delivery uncertainty and reconnect Retry, retain saved session IDs after failed restores, and handle Talk abort rejections. Local proof is limited to formatting, i18n baseline generation, and whitespace checks under the coordinator work order; focused tests, typecheck, lint, and review are delegated to the coordinator. * fix(ui): resolve offline panel validation failures * fix(ui): retire revoked reader data and retain delivery errors * fix(ui): preserve terminal refresh fencing and repair panel fixtures * fix(ui): recover surviving terminals after detached sessions expire * fix(ui): handle missing link reader presentation snapshots * fix(ui): preserve panel recovery across reconnects Keep retained terminal sessions recoverable during offline close and failed replay, refresh reader tabs and MCP session preparation after reconnect, and retain confirmed App context on transient reads. Repair terminal action receipts and Gateway subscription fixtures after the main merge, preserving strict delivery error handling. * test(ui): tighten panel fixture types * fix(ui): settle offline terminal availability changes * fix(ui): repair offline panel integration after main merge * refactor(ui): keep terminal session controller within line limit * fix(ui): repair offline panel CI and defer optional boot views Keep terminal delivery-error callbacks bound to their controller. Load the Gateway confirmation and standalone dashboard loader/renderer on demand, with feature chunks that stay outside ordinary startup and chat boot. Preserve loading, cancellation, and same-identity offline presentation. Measure dictation controls in one browser task so reactive status replacement cannot detach a control between lookup and geometry inspection. Keep the existing visibility and containment assertions, and await lazy confirmation registration in the Gateway-lineage fixture. Focused unit coverage passes across four files. Production gzip measures 339154 bytes at startup and 1489193 bytes at chat boot, below unchanged limits.
What Problem This Solves
Fixes: terminals, embedded apps and canvas previews are torn down and rebuilt on every brief Gateway disconnect.
On a blip the Terminal panel disposed every emulator (scrollback, tabs, selection) and aborted upload batches; a failed restore could prune saved session ids, and input/resize failures were swallowed as success. MCP app iframes and raw canvas previews were keyed on the handshake or connection generation, so they remounted and lost in-app state. The link reader reset fetched documents and cached transport failures as missing previews, read-aloud stopped already-downloaded audio, and an aborted Talk
chat.abortproduced an unhandled rejection.User Impact
User impact: terminals, embedded apps and previews stay as they were through a short disconnect. Terminal input is disabled while offline and the session reattaches with its output when the Gateway returns; nothing typed is replayed later.
Why This Change Was Made
Part of the offline-first series.
Evidence
Landing repair at
7830e8fcb30merges main33b5bee3901, retaining the newer chat projections and MCP transport fixtures alongside the offline availability and subscription-reconnect contracts. The branch-caused dictation E2E failure selected the hidden desktop button at a mobile viewport; its selector now targets the visible mobile control, with every geometry and visibility assertion unchanged.Focused validation: three unit files (MCP bridge, chat pane, warm boot), 52 tests passed in 192.48s; the dictation E2E file passed all 13 tests in one rerun (159.47s total, 60.94s test time). The browser suite proves actual dictation controls and layout through the production UI. Scoped formatting, lint, and diff checks passed. Independent selector review and merge-resolution review found no actionable issues. These are focused local results; current-head GitHub CI remains the broad landing gate.