Skip to content

Allow message edits while background work is running - #5792

Merged
ymichael merged 4 commits into
mainfrom
bb/allow-message-edits-while-background-work-is-run-thr_pc5riqrbav
Oct 19, 2026
Merged

ymichael merged 4 commits into
mainfrom
bb/allow-message-edits-while-background-work-is-run-thr_pc5riqrbav

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Editing a sent message was refused while the thread had background work running (a background command, agent, or workflow). The server rejected with 409 "Wait for background work to finish before editing the message", and the app independently hid the Edit action and disabled the edit composer's Submit button on the same condition. Once a turn ended with background work still open, there was no way to edit without stopping the thread first. The app kept its own copies of the server's thread-level edit rules (provider supports session rewind, thread not archived/deleted, no background work), so the rules could drift between client and server, as they did while fixing this.

What changed

  • apps/server/src/services/threads/thread-edit-message.ts: removed the background-work 409. After stopping the active turn, if the thread still has open background tasks, the edit performs a full stop with requireStopped (settling those tasks as stopped/interrupted) before rewinding. If that stop fails, the edit is rejected and history is untouched. Together with Keep background work settlements across message edits #5656, a task card that started before the edited message is kept with its stopped status; cards after it are removed with the replaced history.
  • apps/server/src/services/threads/thread-message-edit-policy.ts (new): one function for the thread-level edit rules (provider supports session rewind, thread not archived or deleted). The edit route enforces it at each checkpoint, and toThreadResponseFromThread exposes it as the new canEditMessages field on the thread response (packages/server-contract). The plugin runtime's thread DTO reports false when the host has no provider registry.
  • apps/app: canEditSentMessages reads thread.canEditMessages instead of re-deriving provider capability and archive state, and the background-work gates were removed from both the Edit action and the edit composer's Submit (ThreadDetailView.tsx, ThreadDetailPromptArea.tsx); the now-unused activeBackgroundAgentCount prop is removed.
  • Docs: the bb guide's "Editing a sent message" section describes stopping background work on edit and the canEditMessages field.
  • Fixtures updated for the new field (app, demo-server, plugin SDK testing).

No host-daemon wire change.

How you verified

  • New server tests in apps/server/test/threads/thread-edit-message.test.ts: for each of local_bash, local_agent, local_subagent, local_workflow, the edit stops background work before the rewind, the earlier card ends stopped/interrupted, the later card is removed, and nothing is left open; a failed stop leaves history unchanged; the thread payload's canEditMessages and the edit route agree for an unsupported provider and an archived thread.
  • pnpm exec turbo run typecheck lint --filter='...[origin/main]': 122/122 tasks pass. Focused vitest runs: edit-message + environment-restore server tests (66 passed), ThreadDetailPromptArea tests (54 passed).
  • Manual, on pnpm start:worktree with a Claude Code thread, driving the UI in a browser:
    • Editing the message that started a still-running background loop: Submit is enabled, the loop process is killed, its card is removed with the replaced history, and the replacement turn runs.
    • Loop started by an earlier message, editing a later message: the loop is killed, the earlier card remains with status stopped, the replacement turn runs, and the running-background-command banner clears.
    • bb thread show --json reports canEditMessages: true.

AGENT GENERATED

🤖 Generated with Claude Code

ymichael and others added 4 commits October 19, 2026 15:35
… thread payload

The app re-derived edit eligibility from the provider capability and the
thread's archive state, separately from the server's edit route. Expose
canEditMessages on the thread response, computed by the same function the
edit route enforces, and gate the app on it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael force-pushed the bb/allow-message-edits-while-background-work-is-run-thr_pc5riqrbav branch from 002a3af to f1892a8 Compare October 19, 2026 22:35
@ymichael
ymichael merged commit b96ef7b into main Oct 19, 2026
84 of 89 checks passed
@ymichael
ymichael deleted the bb/allow-message-edits-while-background-work-is-run-thr_pc5riqrbav branch October 19, 2026 22:58
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.

1 participant