Skip to content

Persist Pi sessions by GSD session ID#52

Merged
glittercowboy merged 1 commit intomainfrom
codex/pi-session-persistence
Apr 27, 2026
Merged

Persist Pi sessions by GSD session ID#52
glittercowboy merged 1 commit intomainfrom
codex/pi-session-persistence

Conversation

@glittercowboy
Copy link
Copy Markdown
Contributor

@glittercowboy glittercowboy commented Apr 27, 2026

What

Daemon Pi task execution passes a stable local Pi session file for each GSD session.

Why

Pi requires --session <path> to preserve conversation context across spawned task processes. The GSD session ID is the stable local key for that conversation.

How

  • Builds a Pi session file path under ~/.gsd-cloud/pi-sessions/<session-id>.jsonl.
  • Creates the Pi session directory with user-only permissions.
  • Passes that path through pi.Options.ResumeSession so the Pi CLI runs with --session.
  • Keeps Pi synthetic result session IDs out of the cloud-facing Claude session field.

Verification

  • go test ./internal/session -run 'TestPiSessionFileForSessionUsesGSDSessionID|TestActorPiExecutorUsesPersistentSessionFile|TestHandleResultDoesNotPersistPiSyntheticSession'
  • go test ./internal/session ./internal/pi
  • go test ./...

Post-merge

Daemon runtime behavior changes require a daemon release tag and release workflow before installed machines receive the fix.

Summary by CodeRabbit

Release Notes

  • New Features

    • PI executor now persists and resumes sessions across invocations, enabling continuous progress tracking.
  • Tests

    • Added test coverage for session persistence and resumption functionality.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 27, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

The changes implement session resumption for the PI executor by introducing a new session persistence helper function that derives per-session file paths, modifying the PI execution path to compute and pass the resumption file to the executor, and adding comprehensive test coverage for the session storage behavior.

Changes

Cohort / File(s) Summary
Session Resumption Implementation
internal/session/actor.go
Derives per-session resume file path using piSessionFileForSession, adds early error handling, and passes the computed file to pi.Options via ResumeSession field to enable session resumption behavior.
Session File Path Helpers
internal/session/pi_session.go
Introduces piSessionFileForSession function that validates session ID, resolves user home directory, ensures ~/.gsd-cloud/pi-sessions directory exists with restrictive permissions, and returns sanitized .jsonl filename; includes safePiSessionFilename for filename sanitization.
Session Resumption Tests
internal/session/actor_test.go
Adds test utilities to simulate PI process and capture command-line arguments, verifies session file path computation using GSD SessionID, and ensures --session flag is correctly passed to PI binary while --no-session is absent.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • gsd-build/daemon#42: Directly modifies the same PI session resumption behavior in internal/session/actor.go but removes ResumeSession to avoid resuming synthetic PI sessions.

Poem

🐰 A rabbit hops through session files,
Deriving paths with worthy wiles,
PI executor now persists with grace,
Sessions saved in their rightful place!
~/.gsd-cloud/ blooms so bright,
Each .jsonl a fluffy delight!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Persist Pi sessions by GSD session ID' accurately and specifically describes the main change: implementing session persistence for the Pi CLI using GSD session IDs as the stable key.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/pi-session-persistence

Comment @coderabbitai help to get the list of available commands and usage tips.

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