mirror of
https://github.com/NanmiCoder/cc-haha
synced 2026-07-16 13:03:31 +08:00
The desktop client already had a conversation-level rewind UI concept on the CLI side, but the web/desktop surface lacked the protocol, session trimming, and file checkpoint restore path needed to make rewind trustworthy. This change adds a desktop-specific rewind API, wires the message-level UI affordance and confirmation modal, enables SDK file checkpointing for desktop sessions, and covers the restore path with service tests plus a real agent-browser workflow. Constraint: Desktop sessions run the CLI in SDK/print mode, so file checkpointing had to be enabled explicitly for that path Constraint: main branch is checked out in a separate worktree, so merge-back must happen from the primary worktree after commit Rejected: UI-only rewind that only trims local state | would leave persisted transcript and disk state inconsistent after refresh Rejected: Reuse getLastSessionLog as the sole snapshot source | active rewind must read file-history metadata directly from the session file Confidence: high Scope-risk: moderate Reversibility: clean Directive: Keep desktop rewind keyed to persisted user-message order unless the UI model starts carrying stable transcript UUIDs end-to-end Tested: bun test src/server/__tests__/conversation-service.test.ts src/server/__tests__/sessions.test.ts; desktop MessageList vitest; desktop tsc no-emit; live agent-browser E2E on isolated ports with file edit then rewind Not-tested: Browser E2E matrix for multi-file and second-edit scenarios is still covered at service-test level rather than full UI level