Add Happy Codex resume workflow and replay-safe restore#838
Open
KevinCJM wants to merge 9 commits intoslopus:mainfrom
Open
Add Happy Codex resume workflow and replay-safe restore#838KevinCJM wants to merge 9 commits intoslopus:mainfrom
KevinCJM wants to merge 9 commits intoslopus:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a complete
happy codex resumeworkflow for restoring a previously closed Happy Codex session with its prior conversation context and memory, while preventing restore-time replay bugs that could resend historical prompts to the model.The changes are focused on
happy-cliand include a usage guide for this branch.Problems addressed
Before this change:
resumelaunched a detached process only, which made it difficult to observe the restored session directly in the terminal.What changed
1. Added a first-class
happy codex resumecommandFile:
packages/happy-cli/src/index.tsNew command:
happy codex resume <session-id>Capabilities:
--metadata-file--path--pid--session-tag--home-dir--happy-home-dir--dry-runto validate a restore before launching.--detachfor background restore mode.This removes the need to manually assemble restore environment variables and makes session restoration a supported CLI workflow.
2. Reused the original Happy session encryption key on restore
File:
packages/happy-cli/src/api/api.tsChanges:
~/.happy-session-crypto.dataKeyexists for the session, the restore path reuses it instead of generating a new key.Effect:
3. Added a native Codex app-server restore client
File:
packages/happy-cli/src/codex/codexAppServerClient.tsNew functionality:
app-serverover stdio.thread/resumeturn/startturn/interruptEffect:
4. Added Codex identifier seeding to the MCP client
File:
packages/happy-cli/src/codex/codexMcpClient.tsChanges:
seedSessionIdentifiers()support so previously saved Codex identifiers can be injected back into the client.Effect:
5. Implemented a full restore pipeline in
runCodexFile:
packages/happy-cli/src/codex/runCodex.tsChanges:
Effect:
6. Fixed message cursor replay on reconnect
Files:
packages/happy-cli/src/api/apiSession.tspackages/happy-cli/src/api/apiSession.test.tsChanges:
ApiSessionClientno longer restarts its message cursor from an implicit zero-equivalent position.session.seqso already-seen messages are not re-fetched.Effect:
7. Prevented restore from replaying historical prompts into the model
Files:
packages/happy-cli/src/codex/runCodex.tspackages/happy-cli/src/codex/__tests__/resumeReplayFilter.test.tsChanges:
MessageQueue2.thread/resumebefore normal queue processing resumes.Effect:
resume.8. Added branch usage documentation
File:
docs/happy-codex-resume-fork.mdContents:
Effect:
User-facing improvements
After this PR:
happy codex resumeis a supported CLI command instead of a manual recovery procedure.Validation
Targeted tests executed:
Manual end-to-end validation performed:
happy codex resume.Scope
Included in this PR:
happy-clirestore workflow improvementsNot included: