fix(agent-chat): preserve draft text when pane splits#140
fix(agent-chat): preserve draft text when pane splits#140justinchoo93 wants to merge 1 commit intomainfrom
Conversation
Pane splits restructure the React tree, causing ChatComposer to unmount/remount and lose its useState text. Add a module-level Map<paneId, string> draft store that survives React lifecycle. ChatComposer reads from the store on mount and syncs on every keystroke. Drafts are cleaned up when panes or tabs are closed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3e459bd2e5
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (content.kind === 'agent-chat') { | ||
| clearDraft(paneId) |
There was a problem hiding this comment.
Clear draft when closing panes after content replacement
This cleanup only runs when the pane is currently agent-chat, but drafts are keyed by paneId and survive content switches. If a user types a draft, replaces that pane with another kind via updatePaneContent, and then closes the pane, this branch is skipped and the old draft remains in the module-level map indefinitely. That creates a leak over repeated replace/close cycles and can surface stale text if that pane id is reused; draft cleanup should also happen on pane close by paneId regardless of current content or when replacing away from agent-chat.
Useful? React with 👍 / 👎.
Summary
ChatComposerto unmount/remount and lose typed text fromuseStateMap<paneId, string>draft store (src/lib/draft-store.ts) that survives React lifecycle — ChatComposer reads from the store on mount and syncs on every keystrokePaneContainer) and tab close (tabsSlice)paneIdprop changes in-place (resyncs text + textarea height)Test plan
draft-store(get/set/clear, independent per paneId, empty string cleanup)ChatComposerdraft preservation (restore after remount, clear on send, independent per paneId, no-paneId fallback)🤖 Generated with Claude Code