You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(web): the terminal button reopens the drawer after its last terminal closed - #39260
After you close the last terminal in a thread, the next click on the terminal button opens the drawer and closes it again about 20 ms later. A second click works. Steps are in #39259.
The terminal store remembers which terminal ids the server last listed (serverObservationsByThreadKey), and closes a local terminal that later drops off that list. A terminal you closed yourself stayed on the list, because the drawer unmounts before it sees the server drop the id. Reopening creates the same id (term-1), and the first reconcile treated it as closed elsewhere.
Change
When the client places a terminal id it doesn't already have, that id leaves the list. Whatever put it there, that listing is older than the new terminal, so it is about an earlier one. The next reconcile lists the id again if the server has it, so a terminal another client closes later still leaves the drawer.
This one rule covers the drawer unmounting right after the close, the drawer seeing the closing terminal once more during its close animation, and an entry saved in localStorage before this fix.
The store test gets two rows, one where the drawer unmounts right after the close and one where it lists the closing terminal once more first. Both fail on main with expected false to be true and pass with the fix.
vp run scenarios:prove with an uncommitted scenario (open a terminal, close it with the trash icon, click the terminal button once) fails on base e37e45fd5b and passes on the fix.
vp run check:changed passes.
Before: the first click on the terminal button does nothing, the second opens the drawer.
terminal-reopen-before.mp4
After: the first click opens the drawer.
terminal-reopen-after.mp4
Not checked: the mobile app, which has no copy of this store logic, and remote or relay connections.
Implemented by Claude Opus 5.5 in Claude Code (running in T3 Code). Reviewed by Claude Fable 5.2 and GPT-6.1 Sol.
…nal closed
The terminal store remembers which terminal ids the server last listed, and
closes a local terminal that later drops off that list. A terminal the user
closed stayed on it, because the drawer unmounts before it sees the server
drop the id. Reopening the drawer creates the same id, and the first
reconcile closed it again.
A closed id now leaves the list when it closes, and stays off it while it is
still closing.
The store forgot a closed id at close time and kept it out of later
reconciles. An id saved by an older build never went through either path,
so its first reopen still took two clicks. Placing a fresh local id now
drops it from the observed list instead, which covers the close, the close
animation and the saved entry with one rule.
Reviewing files that changed from the base of the PR and between b7ba5aa and 85b1162.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
The terminal UI store now clears a stale server observation when an absent terminal is unsuppressed. Regression tests cover reopening the default terminal after closing it, including when a stale reconciliation occurs first.
Changes: Terminal reopening
Layer / File(s)
Summary
Clear stale terminal observations apps/web/src/terminalUiStateStore.ts, apps/web/src/terminalUiStateStore.test.ts
When an unsuppressed terminal ID is absent from the thread’s UI state, the store removes it from the observed server IDs. Tests verify that reopening the default terminal keeps the drawer open after an empty server reconciliation, with and without an earlier stale reconciliation.
This fixes the terminal drawer closing shortly after the first reopen. The change is small and covered by regression tests. No remaining merge-blocking risk is identified.
Pre-merge checks: 3 · 1
Failed checks: 1 inconclusive
Check name
Status
Explanation
Resolution
Linked Issues check
Directly linked issue #39259 requires that, after the last terminal is closed, the next click on the terminal button opens the drawer with a new terminal. The cause is that a reused id (term-1) stay…
Make the changed blobs for apps/web/src/terminalUiStateStore.ts and apps/web/src/terminalUiStateStore.test.ts available to the checkout, or provide a narrower read of the updateTerminal and forgetObservedTerminalId hunks. Then confi…
Passed checks: 3 passed
Check name
Status
Explanation
Title check
The title states the main change: the terminal button no longer reopens the drawer after the last terminal was closed. It follows the conventional commit format and matches the fix in terminalUiStateS…
Description check
The description follows the template. It covers Problem, Change, Scope (links #39259 and a regression from #38998), and Verification with focused store tests, a scenario proof, and before/after record…
Out of Scope Changes check
The PR summary lists changes only in apps/web/src/terminalUiStateStore.ts (+34/-1) and apps/web/src/terminalUiStateStore.test.ts (+19/-0). Both files hold the terminal UI state logic named in #392…
Full details: Title check
Explanation
The title states the main change: the terminal button no longer reopens the drawer after the last terminal was closed. It follows the conventional commit format and matches the fix in terminalUiStateStore. It is specific and clear.
Full details: Description check
Explanation
The description follows the template. It covers Problem, Change, Scope (links #39259 and a regression from #38998), and Verification with focused store tests, a scenario proof, and before/after recordings. It also states what was not checked. The Problem section gives reproduction steps by reference to the linked issue, and the Change section explains the single rule and why it covers the cases. The template's agent attribution line is present. The description is complete.
Full details: Out of Scope Changes check
Explanation
The PR summary lists changes only in apps/web/src/terminalUiStateStore.ts (+34/-1) and apps/web/src/terminalUiStateStore.test.ts (+19/-0). Both files hold the terminal UI state logic named in #39259. The added helper forgetObservedTerminalId and the regression test relate directly to the reported stale-observation behavior. No unrelated files or features appear in the summary. The diff itself could not be read, so this verdict relies on the summary's file list and descriptions.
Full details: Linked Issues check
Explanation
Directly linked issue #39259 requires that, after the last terminal is closed, the next click on the terminal button opens the drawer with a new terminal. The cause is that a reused id (term-1) stays in serverObservationsByThreadKey after a local close, so the next reconcile closes the reopened terminal. The PR summary describes a fix in apps/web/src/terminalUiStateStore.ts: forgetObservedTerminalId runs in updateTerminal when an unsuppressed terminal is absent from existing UI state, and a new regression test in apps/web/src/terminalUiStateStore.test.ts covers the unmount and closing-animation cases. The repository diff could not be read because the changed blobs are missing from the checkout. The head terminalUiStateStore.ts read was truncated before updateTerminal, so the new logic was not verified in source. The test results and the scenarios:prove run are author-reported only. The requirement is therefore not confirmed from code.
Resolution
Make the changed blobs for apps/web/src/terminalUiStateStore.ts and apps/web/src/terminalUiStateStore.test.ts available to the checkout, or provide a narrower read of the updateTerminal and forgetObservedTerminalId hunks. Then confirm that a fresh local id removes the stale observed id and that the regression test runs against the reviewed head.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Reviewing files that changed from the base of the PR and between 803f21f and b7ba5aa.
Files selected for processing: 2
apps/web/src/terminalUiStateStore.test.ts
apps/web/src/terminalUiStateStore.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Chromium, 1280×800, light theme; fresh synthetic project and replay thread on each commit. Open the thread, open the terminal drawer, close its only terminal with the trash button and confirm, then click the terminal button exactly once.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size:M30-99 changed lines (additions + deletions).vouch:unvouchedAuthor is not yet trusted in the VOUCHED list.
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
After you close the last terminal in a thread, the next click on the terminal button opens the drawer and closes it again about 20 ms later. A second click works. Steps are in #39259.
The terminal store remembers which terminal ids the server last listed (
serverObservationsByThreadKey), and closes a local terminal that later drops off that list. A terminal you closed yourself stayed on the list, because the drawer unmounts before it sees the server drop the id. Reopening creates the same id (term-1), and the first reconcile treated it as closed elsewhere.Change
When the client places a terminal id it doesn't already have, that id leaves the list. Whatever put it there, that listing is older than the new terminal, so it is about an earlier one. The next reconcile lists the id again if the server has it, so a terminal another client closes later still leaves the drawer.
This one rule covers the drawer unmounting right after the close, the drawer seeing the closing terminal once more during its close animation, and an entry saved in localStorage before this fix.
Scope
Fixes #39259, a regression from #38998.
Verification
mainwithexpected false to be trueand pass with the fix.vp run scenarios:provewith an uncommitted scenario (open a terminal, close it with the trash icon, click the terminal button once) fails on basee37e45fd5band passes on the fix.vp run check:changedpasses.Before: the first click on the terminal button does nothing, the second opens the drawer.
terminal-reopen-before.mp4
After: the first click opens the drawer.
terminal-reopen-after.mp4
Not checked: the mobile app, which has no copy of this store logic, and remote or relay connections.
Implemented by Claude Opus 5.5 in Claude Code (running in T3 Code). Reviewed by Claude Fable 5.2 and GPT-6.1 Sol.
🤖 Generated with Claude Code