Skip to content

fix(web): the terminal button reopens the drawer after its last terminal closed - #39260

Merged
juliusmarminge merged 4 commits into
pingdotgg:mainfrom
viktorce:fix/terminal-reopen-two-clicks
Nov 19, 2026
Merged

juliusmarminge merged 4 commits into
pingdotgg:mainfrom
viktorce:fix/terminal-reopen-two-clicks

Conversation

@viktorce

Copy link
Copy Markdown
Contributor

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

  • 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.

🤖 Generated with Claude Code

…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.
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

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.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related PRs

  • pingdotgg/t3code#28614: Changes terminal drawer state and controls, which overlap with the drawer behavior addressed here.
  • pingdotgg/t3code#38998: Changes terminal session reconciliation and the drawer state after the last terminal closes.

Suggested labels: bugfix

Suggested reviewers: stienswout, only21mil, maria-rcks

Merge Risk: Minimal · previous review b7ba5

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: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Linked Issues check Inconclusive 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 Passed checks: 3 passed

Check name Status Explanation
Title check Passed 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 Passed 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 Passed 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
Recent review info

Run configuration

Commits

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.

@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

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.

Before After
Commit 106a1e03b7 85b11622d4
Result Drawer closes again; terminal absent New terminal remains open
After one reopen click Before: drawer closed After: terminal open
Final state Before: terminal still absent After: new shell remains open
Recording Before interaction After interaction

Scenario source. scenarios:prove exited 0: failed on base and passed on head.

@juliusmarminge juliusmarminge added takeover:ready Takeover done; auto-lands when gates pass and removed takeover:in-progress A takeover lead is working on this PR labels Nov 19, 2026
@juliusmarminge
juliusmarminge merged commit 80cf4f7 into pingdotgg:main Nov 19, 2026
56 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Terminal button needs two clicks after the last terminal was closed

2 participants