Skip to content

The phone hides a closed tab with the same record as the desktop - #27563

Draft
brennanb2025 wants to merge 9 commits into
brennanb2025/tab-close-ledgerfrom
brennanb2025/tab-close-phone-ledger
Draft

brennanb2025 wants to merge 9 commits into
brennanb2025/tab-close-ledgerfrom
brennanb2025/tab-close-phone-ledger

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

A phone could re-show a closed tab when the computer sent an older tab list. The phone maintained its own hiding rules, separate from the desktop. It also mistook some refused closes for success, and a close reply arriving after a host switch could hide a tab on the new host.

The phone now uses the desktop's shared close rules. A live tab stays visible when its host refuses the close, and a reply from the previous host cannot change the screen you have switched to. Close-related background reads also stop when that temporary need ends, even if the reads keep failing.

What Changed

Stacked on #27561. Review this PR against that parent; the changes here are mobile only.

The phone still waits for the host to accept a close before removing a tab. Accepted closes use the shared record, scoped to the host and workspace. Every incoming tab list passes through that record; absence confirms removal, and an unconfirmed accepted close has the shared 20-second fallback instead of the phone's previous 10 seconds. Closing one terminal pane hides only that pane; a whole-tab close covers its panes. A healthy tab stream requests recovery only while a live reason remains; a failed recovery read no longer creates an obligation that outlives the close record. Explicit refreshes and fallback for an unhealthy stream keep their existing retry behavior.

Each close captures the host, workspace and client that started it. An accepted close is recorded under that host and workspace, while its screen changes run only if the captured owner still belongs to the current screen. Switching away and back retires the old screen operation. This reuses the ownership mechanism already used for resume actions and preserves the existing controller, text drafts and unsent image attachments. Close-result interpretation comes from the same shared function the desktop uses, including older success replies.

Why

Reusing the existing lifecycle removes a second implementation and gives both clients the same refusal and expiry rules. One captured owner protects the complete local close transaction while preserving composer state across navigation.

The phone retains its existing removal-after-acceptance behavior. Intended compatibility limit: existing hosts do not return a tab-list revision with a close reply, so confirmation remains observed absence plus a time bound. This PR adds no wire fields or capabilities and makes no claim to solve every host publication or reopen race; the host changes remain separate.

Linked Issue

Part of the tab-close lifecycle series beginning with #27561; no separate issue.

Visual Proof

Native iPhone 17 Pro Simulator, iOS 26.5, paired with a hidden desktop on M4Air, using a real Claude session. The rows ran on 90af3963. The latest parent merge changes surrounding runtime code; the complete 29-file phone patch and core close, refusal, ownership and recovery files remain unchanged. Native QA was not repeated on that later merge.

Phone closes a busy real Claude chat

Working Close action Empty after 33 seconds
Real Claude chat working Phone close action Phone empty after busy close

The desktop recorded the agent working 0.7 seconds before the close. The host accepted it; the phone became empty within 3 seconds and stayed empty through 42.8 seconds, with the desktop also empty.

Desktop closes a real Claude chat

Before After
Desktop closes a real Claude chat: before Desktop closes a real Claude chat: after

Host refuses a pinned chat close; phone retains the tab

Before After
Host refuses a pinned chat close; phone retains the tab: before Host refuses a pinned chat close; phone retains the tab: after

The phone dropped the desktop-closed chat within about 3.9 seconds and stayed empty for 43.6 seconds across 12 samples. Sampling does not rule out sub-second flashes. The native refusal was a host error for a pinned tab; the separate successful-reply refusal shape is covered by unit tests, rather than this native run.

Capture limitation: Orca’s Simulator accessibility screenshot command failed despite granted permissions. These are unchanged originals captured read-only from the exact Simulator window with screencapture; that Orca screenshot checklist did not pass. Phone input used Orca emulator and desktop input used hidden CDP. Android and physical devices were not tested.

Testing

  • Native iOS Simulator and hidden desktop flow tested on M4Air
  • Automated tests added/updated

Final integrated head: fff3c7e7adf2f5d6ff9d1e0d54327b95e05ef774, stacked on parent a26946013e1ea2fb7c825ec178c63d56e46177b3. Fresh checks on this head pass: 1,947 mobile tests across 33 explicit files, 183 desktop/shared tests across 18 files, mobile production types, the mobile test typecheck ratchet, main-process and renderer types, the changed-file writer gate and additional CI lint. The full local checker completed 21/23; its failures are five inherited import-cycle warnings in unchanged files and local Bun 1.3.14 lacking the CI compiler command. GitHub CI passes on this final head, including static analysis/typechecks, the mobile bundle and verification. Skipped end-to-end, packaging and cross-version jobs remain unverified.

Coverage includes stale inventories, pane matching, refusals inside successful replies, legacy replies, host/workspace/client switches during a close, returning to the original host, unmount, background completion, retained text/image drafts, expiry despite failed/stale/unusable inventories, explicit refresh retries and existing resume behavior.

Review

Four correctness rounds, architecture challenges at the start and after round three, final readiness, and independent reviews of the parent integrations are complete. The final integration verdict is KEEP, with no new meaningful phone-branch finding. The loop fixed late reply ownership, refusal handling and recovery reads continuing after close expiry while preserving text drafts and unsent attachments.

Deferred compatibility limit: observed absence is not a causal close receipt; a repeated identifier can return after omission or expiry, and startup clears the record. Host follow-ups remain #27565, #27583 and #27586. This PR makes no permanent or cross-navigation suppression guarantee.

Agent skill upstream boundary

  • Not applicable; no upstream skill source is copied or translated.

Notes

Client-only change: new phones use the close replies and tab lists old hosts already send; old phones see no host publication change from this PR. Host execution, folder workspace identifiers, Git provider support and platform APIs remain unchanged.

Checklist

  • Focused scope and user-facing before/after explained
  • Before/after native evidence attached
  • Final correctness, compatibility, performance and readiness reviews complete
  • Final automated checks complete and any limitations documented

This PR remains a draft.

…g-close record

The phone kept its own 10 s close tombstone map. It now records an accepted
close in the shared SessionTabCloseLedger (partition = worktree id), filters
every applied tab list through it, and keeps its 2 s poll keyed on pending
closes. A close now ends 20 s after acceptance when no list confirms it, and a
pane close hides only that pane while a whole-tab close hides all its panes.
Keep local close effects with the active host and workspace, honor the shared refusal policy, and stop close-driven polling when its pending record expires.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Closed phone tabs could return when the desktop published an older tab list. The review also found that a late reply could hide a replacement host’s tab, some refused closes were treated as success, and close-driven recovery could continue after its temporary need ended.

The phone now shares the desktop’s bounded close rules. Refused tabs stay visible, late replies cannot change a replacement screen, and recovery reads stop when their close record expires. Existing text drafts and unsent image attachments survive navigation.

  • Fixed: reply ownership, refusal interpretation, draft preservation, and derived recovery lifetime. Four correctness rounds, architecture challenges and final readiness are complete; both parent integrations received independent KEEP reviews with no new meaningful phone-branch finding.
  • Verified: final fff3c7e passes 1,947 mobile cases, 183 desktop/shared cases, affected types, the mobile test typecheck ratchet, writer checking and CI lint. Final GitHub CI passes; all six executed checks passed. The full local checker completed 21/23; its failures are unchanged inherited import cycles and the local Bun version lacking the CI compiler command.
  • Native proof: a real Claude chat was working 0.7 seconds before its phone close; the phone then stayed empty through 42.8 seconds, and the desktop was also empty. A desktop close stayed absent on the phone through 43.6 seconds. A genuine pinned-tab host rejection kept the phone tab visible. These rows ran on 90af3963; final fff3c7e retains the inspected close mechanisms but includes surrounding inherited runtime changes that were not rerun in native QA. Original screenshots are in the PR body. Orca’s accessibility capture failed; read-only captures of the exact Simulator window supplied the proof instead.
  • Deferred/unverified: absence and the 20-second bound do not establish a permanent close receipt; repeated identifiers and startup reset remain limited, with host follow-ups Keep closed browser, editor, and proven terminal tabs out of the host list #27565, Fix native chat close and stale tab reopening #27583 and The window closes a chat with one command on hosts that support it #27586. Successful-reply refusals are unit-tested; the native refusal used a host error. Android, physical devices, sub-second flashes and skipped end-to-end/packaging/platform/cross-version jobs remain unverified.

Owned QA processes and terminals are stopped, the remote QA worktree is removed, and private evidence is preserved. This PR remains a draft; it was not marked ready or merged.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant