Repository navigation
chat: keep the unsent composer draft when the live pane opens (#155) - #158
Merged
Merged
Conversation
openTerminalTab() switched activeTabId to the pane before the composer was saved. switchTab() has always called saveComposerState() on the same path, so the draft survived a switch between existing tabs but not the FIRST opening of the pane: the text, its attachments and the reply target were replaced by the terminal tab's empty state, and coming back found nothing. The call sits above the openTabs push and the activeTabId assignment, so the state is written while activeTabId still names the chat being left. Pinned by an order assertion in test/composer-terminal.test.js.
Codex Review Summary: ✅ CompletedThis 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. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #155.
What was wrong
openTerminalTab()is a tab switch, but it was the only one that did not save the composer first.switchTab()callssaveComposerState(activeTabId)before it changesactiveTabId(its terminal branch included), so a draft survived a switch between existing tabs. The FIRST click on "Open pane" changedactiveTabIdstraight to the pane, so the chat's draft, attachments and reply target were overwritten by the terminal tab's empty state, andrestoreComposerState()on the way back found nothing.The fix
One line, at the same place
switchTab()puts it — before the tab is pushed and beforeactiveTabIdchanges:The early returns (terminal unavailable, xterm missing) sit above it, so a failed open still writes nothing.
Verification
test/composer-terminal.test.jsgains a section that pins the ORDER, not just presence: the save must come beforeactiveTabId = sessionId, andshowTerminalView()after both. Present-but-late is exactly the bug.node test/composer-terminal.test.js— 71 passed, 0 failed.npm test— see the PR checks; the suite also runs in this repo's CI on Node 20 and 24.