Skip to content

fix(ios): keep the composer off a pane that has left the screen - #539

Open
BunsDev wants to merge 1 commit into
mainfrom
fix/ios-composer-switch
Open

BunsDev wants to merge 1 commit into
mainfrom
fix/ios-composer-switch

Conversation

@BunsDev

@BunsDev BunsDev commented Oct 3, 2026

Copy link
Copy Markdown
Member

Fixes #538

Cause. PaneComposer targeted registry.focusedPaneID. A chip tap updates store.primaryPaneID (and the visible terminal) immediately, but TerminalSessionRegistry.show(...) moves focus only after it reattaches. Until then the composer showed, and would send to, a pane no longer on screen.

Fix. PaneComposerModel.target(focusedPaneID:shownPaneIDs:) returns the focused pane only while it is one of the workspace's shown panes (primaryPaneID, secondaryPaneID). Otherwise there is no target: the field is empty and disabled, with a "Switching panes…" placeholder. The draft binding, the send target and canSend all use that one target, so a draft and its send can never point at different panes. No send path, persistence or registry behaviour changed.

Evidence (local Xcode 26.6, iPhone 16 Pro simulator; CI pins 26.2):

  • xcodebuild test -scheme PsycheApp -only-testing:PsycheAppTests/PaneComposerTests: 17/17 pass, including two new tests:
    • testComposerTargetsTheFocusedPaneOnlyWhileItIsShown
    • testPaneSwitchWindowHasNoTargetSoThePreviousDraftIsNeitherShownNorSent. During the switch window there is no target, nothing is sent and the previous draft is kept. After show(...) the target is the shown pane.
  • Full PsycheApp scheme: 117 unit tests pass. UI tests: 48 run, 8 skipped, and one test fails, testPullRequestReviewSupportsEditingAndRelatedFileNavigation at PsycheAppUITests.swift:741. It fails the same way on unmodified main (97db32c) on this host, so it is environmental and unrelated to this change. CI is the authority.
  • testADraftStaysWithItsOwnPane (hardened in test(ios): synchronize the two #510 flakes on explicit state transitions #537) passes.

Risk R2 (iOS product behaviour). Rollback: revert this commit.

🤖 Generated with Claude Code

A pane switch shows the new terminal at once, while the session registry
moves focus only after it reattaches. In that window the composer targeted
the registry's focused pane, so it showed the previous pane's draft under the
new pane's terminal and would have sent there.

The composer now targets the focused pane only while the workspace shows it.
Otherwise it has no target: the field is empty and disabled with a
"Switching panes…" placeholder until focus catches up. Drafts and sends stay
keyed on the same pane.

Fixes #538

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 3, 2026 17:59
@vercel

vercel Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
psyche-build-docs Ready Ready Preview Oct 3, 2026 5:59pm UTC

Request Review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

A focused secondary pane remains targetable after portrait layout hides it.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

Prevents the iOS composer from targeting a previously shown pane while focus catches up.

Changes:

  • Restricts composer targeting to focused, selected panes.
  • Adds a disabled switching state and regression tests.
File Description
PaneComposer.swift Adds target validation and switching placeholder.
PaneComposerTests.swift Tests pane-switch targeting and send prevention.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

private var targetPaneID: String? {
PaneComposerModel.target(
focusedPaneID: registry.focusedPaneID,
shownPaneIDs: [store.primaryPaneID, store.secondaryPaneID]

This branch was successfully deployed

1 active deployment
Preview — 0e5f171f Deployed Oct 3, 2026 by vercel[bot]
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.

iOS composer briefly shows the previous pane's draft after a pane switch

2 participants