Skip to content

chat: keep the unsent composer draft when the live pane opens (#155) - #158

Merged
Lexus2016 merged 1 commit into
mainfrom
fix/155-composer-draft-before-pane
Nov 26, 2026
Merged

Lexus2016 merged 1 commit into
mainfrom
fix/155-composer-draft-before-pane

Conversation

@Lexus2016

Copy link
Copy Markdown
Owner

Fixes #155.

What was wrong

openTerminalTab() is a tab switch, but it was the only one that did not save the composer first. switchTab() calls saveComposerState(activeTabId) before it changes activeTabId (its terminal branch included), so a draft survived a switch between existing tabs. The FIRST click on "Open pane" changed activeTabId straight to the pane, so the chat's draft, attachments and reply target were overwritten by the terminal tab's empty state, and restoreComposerState() on the way back found nothing.

The fix

One line, at the same place switchTab() puts it — before the tab is pushed and before activeTabId changes:

if (activeTabId) saveComposerState(activeTabId);

The early returns (terminal unavailable, xterm missing) sit above it, so a failed open still writes nothing.

Verification

  • test/composer-terminal.test.js gains a section that pins the ORDER, not just presence: the save must come before activeTabId = sessionId, and showTerminalView() after both. Present-but-late is exactly the bug.
  • node test/composer-terminal.test.js — 71 passed, 0 failed.
  • Full npm test — see the PR checks; the suite also runs in this repo's CI on Node 20 and 24.

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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T18:08:39.036381Z cfafb1c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Lexus2016
Lexus2016 merged commit b3ff7f7 into main Nov 26, 2026
3 checks passed
@Lexus2016
Lexus2016 deleted the fix/155-composer-draft-before-pane branch November 26, 2026 18:20
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.

Opening the live pane loses the unsent chat draft

1 participant