Skip to content

🤖 fix: an open edit loses its typed changes on a workspace switch (#5801), plus two older edit races #5808

Description

@ThomasK33

Follow-ups from the final readiness check of PR #5801 (edit text lives only in the composer's memory, #5672 / #5571).

1. A workspace switch drops an open edit's typed changes (introduced by #5801, blocks it)

What happens: you open an edit, type changes (text, attachments), switch to another workspace, and come back. The edit reopens with the original message text, and the typed changes are gone.

Cause: ChatInput is keyed by workspace (ChatPane.tsx ~2011), so a switch remounts it. ChatPane keeps editingState per workspace (~381-386), so the edit itself survives the switch. The memory-only edit buffer lives in the remounted ChatInput (useComposerDraft), so the buffer does not survive. When you come back, the composer refills the edit from the original message (ChatInput/index.tsx ~1448).

On main the edit text survived a switch but replaced the unsent draft. #5801 keeps the unsent draft but loses the edit changes. The accepted tradeoff of #5801 covers reload only.

Fix idea: give the edit buffer a stable per-workspace, memory-only owner that survives the ChatInput remount (next to ChatPane's editingState, or an equivalent). It must survive workspace switches, stay out of other windows, and still disappear on reload. Failing-first test: switch away and back with edit text and an attachment, and check that the edit keeps both and the unsent draft stays intact.

2. Starting a second edit while one is open leaks the first edit's notes (pre-existing on main, not part of the #5801 repair)

beginEditingMessage does not check for an open edit (ChatPane.tsx ~416-427). The new session snapshots preEditReviews: draftReviews (index.tsx ~1444), and those are the first edit's notes. Cancelling the second edit then puts the first edit's notes on the unsent draft. Main had the same snapshot.

3. A Stop restore can race with opening an edit (pre-existing on main, narrow, not part of the #5801 repair)

A restore event that arrives before the edit opens, with its async acceptedSendIds lookup resolving after (index.tsx ~1632), skips the edit check (~1656). setInput(mergedText) (~1665) then replaces the edit buffer, and a later cancel loses the restored text. Main lost it in the same race.

Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high • Cost: $35.15

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions