Skip to content

feat(history): add native file and conversation rewind with redo - #3930

Open
S2thend wants to merge 2 commits into
tailcallhq:mainfrom
extracurricular-ai:feat/filesnap-integration
Open

S2thend wants to merge 2 commits into
tailcallhq:mainfrom
extracurricular-ai:feat/filesnap-integration

Conversation

@S2thend

@S2thend S2thend commented Sep 23, 2026

Copy link
Copy Markdown

Summary

Add native rewind and redo that restore captured workspace files and the persisted conversation together. This lets users return to an earlier prompt, retry an approach from its corresponding file state, and reverse a rewind.

  • /rewind opens a prompt selector and, after confirmation, restores files and conversation to before the selected prompt.
  • /redo restores the state before the last rewind, with support for multiple levels.
  • /rewind-recover recovers an interrupted restore before the next prompt can proceed.

Checkpoints are captured before prompts, and supported local file tools preserve pre-edit contents, including the absence of newly created files. A new prompt clears redo. These commands do not call a model.

Implementation and compatibility

  • Use the published filesnap = "=0.5.0" Rust crate in-process; no separate executable or Node/npm runtime is required.
  • Preserve the existing per-file snapshot API and readability of legacy .snap files. New snapshots use content-addressed storage, and failed restores retain their checkpoint for retry.
  • Write a durable recovery journal before restoring files, persist the destination conversation after successful file restoration, and then commit the history state. A workspace lock protects turns and restores from concurrent operations.
  • Restore captured binary files as bytes. Coverage remains bounded by capture rules and pre-edit declarations: ignored, uncaptured, and remote resources are not guaranteed to be restored. Shell/MCP writes require their local files to have been captured beforehand.

Related to #1192, #232, and #432. Those completed issues provide the background for per-file undo and snapshots; this PR adds prompt-level file-and-conversation recovery and redo while retaining per-file compatibility.

The workflow draws on my own codex-rewind, which also integrates the engine in Rust, and pi-better-rewind-redo projects.

Related to #1192, #232, #432

Also related to Discussion #2631, where a user asks how to step back in a conversation. This PR adds explicit prompt-level rewind with corresponding file restoration and redo.

Validation

Validated on Linux with Rust 1.98.1 after rebasing onto daf8bf80:

  • 891 tests passed, 1 skipped across forge_snaps, forge_repo, forge_services, and forge_main, using cargo nextest run --locked --offline --test-threads 2. The default-parallelism run had one runtime-heartbeat timing failure; the complete run passed with two test threads.
  • All-target Clippy passed for those four crates with -D warnings.
  • Locked debug CLI build and launcher --version/CLI --help checks passed.
  • Changed Rust files pass formatting. Workspace-wide formatting still reports differences in unchanged upstream files.
  • Manually verified file and conversation rewind/redo in the Linux TUI: create hello.py, add a greeting function, rewind to the earlier state, then redo to restore the function and its conversation state.

macOS and Windows runtime validation has not been performed locally.

Screenshots

Native command selection, including rewind, redo, and recovery:

forge-redo-and-selection-menu-cropped

Select the prompt whose preceding file and conversation state should be restored:

forge-rewind-select-cropped

Confirm the rewind:

forge-rewind-confirmation-cropped

Rewind followed by redo restores the greeting-function conversation state. File contents were also checked during manual testing:

forge-redo-cropped

Co-Authored-By: ForgeCode noreply@forgecode.dev

Use the published filesnap 0.5.0 Rust crate for content-addressed snapshots
and native prompt history. Preserve compatibility with existing per-file
snapshot references while keeping recovery checkpoints and garbage
collection within the snapshot store.

Capture before prompts and declare known file writes before mutation,
including paths that do not exist yet. Add a native /rewind picker,
multi-level /redo, and /rewind-recover. Restore files and persisted
conversation state together with workspace locking and a durable recovery
journal, then refresh the terminal conversation.

Document capture boundaries, ignore policy, binary-file coverage and
recovery behavior. Link the engine into Forge without an external CLI or
local filesnap source override.

Validation: 12 snapshot/history tests, affected-crate clippy and CLI checks,
and a complete locked debug build plus launcher version check. Verified the
resolved filesnap source against every file in the published crate archive.

Co-Authored-By: ForgeCode <noreply@forgecode.dev>
@github-actions github-actions Bot added the type: feature Brand new functionality, features, pages, workflows, endpoints, etc. label Sep 23, 2026
@CLAassistant

CLAassistant commented Sep 23, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Replace direct checkpoint indexing and slicing with checked access to satisfy the string-safety Clippy checks. Document public snapshot and conversation-history parameters, errors, and lease requirements.

Validation: related-crate Clippy with warnings and string-safety lints denied; 12 snapshot/history tests; changed-file rustfmt checks.

Co-Authored-By: ForgeCode <noreply@forgecode.dev>

This branch has not been deployed

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

Labels

type: feature Brand new functionality, features, pages, workflows, endpoints, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants