feat: edit and fork historical user messages - #72
Conversation
Independent Agent review: changes requestedReview round 1/2 for The feature architecture (SDK branch-at-predecessor plus fresh prompt for edit, existing branch primitive plus fork label for fork) matches the issue, and the pure helpers are reasonable, but two defects make the destructive flow unsafe: Edit/Fork buttons stay clickable while a run is in progress (render-time-only hiding, no extension-side guard) and the rewrite can delete a session file that is still being appended; and an aborted or failed rewrite discards the new branch while leaking an orphan session file, with the destructive core carrying no focused tests. Findings
Reviewer checks
Generated by the independent sandboxed Reviewer Agent. The PR still requires human review and merge. |
Agent review repair 1Addressed both blocking findings. (1) Edit/Fork buttons are now disabled on agent-start and re-enabled on agent-end (plus the existing creation-time gate), and both commands plus the edit helper refuse while sw.isStreaming; the superseded session is re-checked as idle before its file is deleted so a streaming file is never removed. (2) The rewrite now commits once the replacement reply actually starts: sendPrompt is observed via waitForReplyStart, a started (or cleanly settled) run keeps the replacement session on later abort/error, and rollback — which disposes the replacement and deletes the forked branch file — happens only when no run ever started; init failure also cleans up the branch file. The destructive flow decisions are covered by focused edit-flow tests (streaming guard, commit-on-start, settle-without-start rollback, stalled-prompt rollback, started-then-fails keep) plus extended wiring assertions. Independent Agent review will run on the updated commit. The PR still requires human review and merge. |
Independent Agent review: approvedReview round 2/2 for The round-2 patch addresses both round-1 blockers: Edit/Fork are disabled at agent-start and re-enabled at agent-end on top of the creation-time gate, both commands and the edit helper refuse while sw.isStreaming, and the superseded session is re-checked idle immediately before its file is deleted; the rewrite commits as soon as the replacement reply starts (waitForReplyStart), rolling back and deleting the branch file only when no run ever started, with init-failure cleanup and keep-on-later-failure behavior. The destructive-flow decisions are extracted into tested pure helpers with focused tests, and all validation passes. Reviewer checks
Generated by the independent sandboxed Reviewer Agent. The PR still requires human review and merge. |
Summary
Historical user messages now expose Edit and Fork actions on hover. Edit opens an inline editor; saving it rewrites the conversation by branching everything before that message (keeping prior entry ids so the prefix cache is reused), sending the edited text as the fresh user message, and retiring/deleting the superseded session, so the AI reply continues from the new text. Fork creates an independent session at that message via the existing createBranchedSession primitive, names it <fork: Original Title>, and leaves the original session untouched. Actions are hidden while a run is in progress.
Validation
Closes #70