Skip to content

feat(chat): add thread revert support across providers#278

Draft
gianpieropa wants to merge 1 commit intocoollabsio:mainfrom
gianpieropa:feature/thread-revert-support
Draft

feat(chat): add thread revert support across providers#278
gianpieropa wants to merge 1 commit intocoollabsio:mainfrom
gianpieropa:feature/thread-revert-support

Conversation

@gianpieropa
Copy link
Copy Markdown

Summary

Introduce a hybrid revert system that restores both workspace files and provider conversation state to any prior user message in a chat session.

This change:

  • adds a git-backed checkpoint store capturing workspace state before and after each chat run
  • adds backend commands to surface revertable targets and execute thread revert
  • wires provider-specific rollback support for Claude, Codex, and OpenCode
  • exposes revert on eligible user messages
  • updates E2E coverage and developer docs for the revert model

Details

Revert behavior

  • Revert is attached to the user message
  • Reverting restores the workspace to the checkpoint captured before that prompt
  • The reverted prompt, its assistant response, and all later turns are removed from local history
  • Revert availability is per run, not global to the session

Implementation

  • Added checkpoints.rs, a git-backed snapshot store capturing checkpoint_before / checkpoint_after for chat runs
  • Added get_revert_targets and revert_to_message Tauri commands
  • Registered the new commands in both src-tauri/src/lib.rs and src-tauri/src/http_server/dispatch.rs
  • Surfaced revert in MessageItem and ChatWindow

Provider support

  • Claude: uses --resume-session-at / --fork-session rewind anchors
  • Codex: uses thread/rollback for the discarded turn count
  • OpenCode: uses native session/:id/revert with the parentID anchor

Compatibility

  • Older chats still load normally
  • Older turns created before checkpoint metadata usually do not show the revert action
  • New turns created in older chats can still become revertable

Tests

  • Added e2e/tests/revert.spec.ts
  • Extended E2E mock fixtures with dynamic handlers for:
    • get_revert_targets
    • revert_to_message

Docs updated

  • docs/developer/architecture-guide.md
  • docs/developer/data-persistence.md
  • docs/developer/testing.md

Validation

  • bun run lint
  • bun run typecheck
  • cargo check --manifest-path src-tauri/Cargo.toml

Manual testing

  • Created fresh Claude chat sessions with multiple turns and verified reverting from a user message removes that prompt and newer turns, while restoring files to the pre-prompt state
  • Created fresh Codex chat sessions with multiple turns and verified revert works correctly without runtime panics
  • Created fresh OpenCode chat sessions with multiple turns and verified native provider rollback works together with Jean file restore
  • Verified revert is only shown on eligible user messages
  • Verified older pre-feature turns do not show revert
  • Verified newer turns created in existing chats can become revertable
  • Verified the confirmation dialog appears before revert and uses the new checkpoint warning copy

Notes

bun run check:all is still blocked by existing repo-wide Rust clippy failures unrelated to this change.

Introduce a hybrid revert system that restores both workspace files and
provider conversation state to any prior user message in a chat session.

- Add `checkpoints.rs`: git-backed snapshot store capturing workspace
  state before/after each chat run (`checkpoint_before`/`checkpoint_after`)
- Add `get_revert_targets` and `revert_to_message` Tauri commands,
  registered in both `lib.rs` and `http_server/dispatch.rs`
- Wire provider-specific rollback per backend:
  - Claude: `--resume-session-at` / `--fork-session` anchor flags
  - Codex: `thread/rollback` for discarded turn count
  - OpenCode: native `session/:id/revert` via `parentID` anchor
- Expose revert action on user messages in `MessageItem` and
  `ChatWindow`; revert availability is per-run, not global
- Add e2e test suite (`revert.spec.ts`) and extend mock fixtures with
  `get_revert_targets` / `revert_to_message` dynamic handlers
- Document the revert model in `architecture-guide.md` and
  `data-persistence.md`
@gianpieropa gianpieropa marked this pull request as draft April 1, 2026 17:05
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