Skip to content

fix: restore conversation when loading checkpoints - #1370

Open
saksham-rathore wants to merge 1 commit into
Nano-Collective:mainfrom
saksham-rathore:fix/checkpoint-restore-messages
Open

saksham-rathore wants to merge 1 commit into
Nano-Collective:mainfrom
saksham-rathore:fix/checkpoint-restore-messages

Conversation

@saksham-rathore

Copy link
Copy Markdown
Contributor

Description

Fix checkpoint loading so that both workspace files and conversation messages are restored from the selected checkpoint.

Previously, loading a checkpoint restored the workspace files but did not restore the conversation state.

Fixes #1242

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Changeset

  • Added a changeset (pnpm changeset) describing this change for the changelog

Testing

Automated Tests

  • New features include passing tests in .spec.ts/tsx files
  • All existing tests pass (pnpm test:all completes successfully)
  • Tests cover both success and error scenarios

Manual Testing

  • Tested with Ollama
  • Tested with OpenRouter
  • Tested with OpenAI-compatible API
  • Tested MCP integration (if applicable)

Checklist

  • If this was for an open issue, I was assigned to it
  • Code follows project style guidelines
  • Self-review completed
  • Documentation updated (if needed)
  • No breaking changes (or clearly documented)
  • Appropriate logging added using structured logging (see CONTRIBUTING.md)

@github-actions github-actions Bot added area:tools Tool implementations and tool-calling area:tui Terminal UI area:docs Documentation labels Sep 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

nc-review: needs work — 1 blocking, 3 important, 1 nit

@saksham-rathore — there is a blocking item below.

The PR fixes the documented bug (workspace files restored but conversation messages discarded) by wiring setMessages through the command registry and rolling the transcript back in both the loadCheckpoint and handleCheckpointSelect code paths, plus clearing the read tracker and resetting client context. However, the new tests cannot run: the test file dynamically imports restoreCheckpointConversation from ./checkpoint, but the diff declares the function without export. There is also an unrelated drive-by edit to formatGitStatusSummary in source/tools/git/utils.ts that strips the default branch marker (a behavioural change to the /status panel and boot summary unrelated to this fix), and a large block of pre-existing tests in source/commands/checkpoint.spec.tsx was deleted.

🔴 blocking · tests · source/commands/checkpoint.spec.tsx:25

The new test file does const {restoreCheckpointConversation} = await import('./checkpoint'), but the new function declared in source/commands/checkpoint.tsx is async function restoreCheckpointConversation(...) — without an export keyword. The dynamic import will resolve to a module object with no restoreCheckpointConversation property, so all four new tests will throw TypeError: restoreCheckpointConversation is not a function at runtime and the test file will fail. Either add export to the function declaration in source/commands/checkpoint.tsx, or rewrite the tests to exercise restoreCheckpointConversation through checkpointCommand.handler(['load', '<name>'], ...) instead.

🟠 important · completeness · source/commands/checkpoint.tsx:138

restoreCheckpointConversation clears the read tracker and resets client.clearContext(), but unlike createClearMessagesHandler (used by /clear — see source/app/utils/app-util.ts:765) it does not call clearExpandableToolResults() (@/utils/tool-result-display) or clearPendingHookContext() (@/services/lifecycle-hooks). After a restore, /expand can resurrect cached tool results that point at a transcript that's been thrown away, and the next user prompt can be prepended with stale session-start hook output. Either route the restore through createClearMessagesHandler (passing the restored messages) or call the same three clearers.

🟠 important · scope · source/tools/git/utils.ts:253

The diff deletes the only default branch from formatGitStatusSummary:

if (status.isDefault) return {branch: status.branch, marker: 'default'};

The /status panel (source/components/status.tsx) renders branch (marker), so users on the default branch used to see main (default) and now see just main. This is an unrelated UX change mixed into a checkpoint fix — it has no connection to issue #1242 and is the kind of drive-by edit that CONTRIBUTING and the rubric explicitly call out as worth flagging. Revert this hunk; if the change is wanted, do it in its own PR.

🟠 important · tests · source/commands/checkpoint.spec.tsx

The diff replaces ~250 lines of pre-existing tests (help rendering, create/list/load/delete subcommand paths, multi-word checkpoint names, handler-returns-React-element checks, alias handling, unknown-subcommand error path, case-insensitive dispatch, etc.) with only four new tests covering restoreCheckpointConversation. None of the deleted tests touched conversation restoration, so this is a net loss of coverage for unrelated behaviour. The new tests don't even cover the restoration path through checkpointCommand.handler(['load', ...]) end-to-end — restoreCheckpointConversation is exercised in isolation. Add back the original suite (or the parts worth keeping) and add at least one test that exercises the wired-up flow (checkpointCommand.handler(['load', '<name>'], messages, {setMessages, ...}) -> setMessages called with the checkpointed transcript).

⚪ nit · changeset · .changeset/goofy-bars-lead.md:5

The changeset body is literally solved. CONTRIBUTING.md and the project rubric are explicit: "The markdown body you write IS the changelog entry, verbatim." A user reading the changelog learns nothing from this. Write something like:

Fix `/checkpoint load` so it restores both workspace files and conversation history; previously only files were reverted, leaving the model context desynchronised. (Fixes #1242.)

🔴 blocking · 🟠 a reviewer would ask for a change · ⚪ optional

Automated code review — correctness, security, design, tests, plus duplicates and scope. A human still decides; this is not a substitute for review and is not exhaustive. The required status checks separately cover lint, formatting, types, unused dependencies, the test suite and the build. This bot never merges. Maintainers can rerun with /re-review.

@github-actions github-actions Bot added the agent:needs-work nc-review found blocking findings label Sep 17, 2026
@saksham-rathore
saksham-rathore force-pushed the fix/checkpoint-restore-messages branch from 7d5485e to 4e2de1c Compare September 17, 2026 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent:needs-work nc-review found blocking findings area:docs Documentation area:tools Tool implementations and tool-calling area:tui Terminal UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] /checkpoint load restores workspace files but discards conversation messages

1 participant