trail: add resume command#1511
Conversation
Entire-Checkpoint: 1cf96d1dbe7e
Entire-Checkpoint: 79bf8e72decd
# Conflicts: # .gitignore
Add trail resume with checkpoint-session discovery, interactive session selection, agent resume launching, and integration coverage for restoring sessions when local state is missing. Entire-Checkpoint: 33d13fdff5ab
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 894aa84. Configure here.
| slog.String("error", err.Error()), | ||
| ) | ||
| return checkRemoteMetadata(ctx, w, errW, checkpointID, stores.Refs()) | ||
| return nil, checkRemoteMetadata(ctx, w, errW, checkpointID, stores.Refs()) |
There was a problem hiding this comment.
Trail resume skips agent launch
Medium Severity
entire trail resume restores via restoreByCheckpointID / restoreFromCurrentBranch, then only launches the agent when those helpers return a non-empty []RestoredSession. When metadata is fetched through checkRemoteMetadata (which finishes via resumeSession) or when restoreResumeSessions falls back to resumeSingleSession, restore succeeds and prints resume output but returns no session slice, so continueTrailRestoredSessions exits without launching the agent on interactive runs.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 894aa84. Configure here.
| @@ -0,0 +1 @@ | |||
| test 1 | |||
There was a problem hiding this comment.
Accidental test file committed
Low Severity
The diff adds t1.txt containing only test 1, which looks like scratch content unrelated to trail resume and should not ship in the repository.
Reviewed by Cursor Bugbot for commit 894aa84. Configure here.
There was a problem hiding this comment.
Pull request overview
Adds a new entire trail resume command that can show trail context plus checkpoint-backed session listings, then restore and (optionally) launch an agent-native resume flow. This builds on the existing resume/restore machinery by reusing checkpoint restore logic and enhancing restored session metadata (prompt/kind/review prompt) to improve selection and display.
Changes:
- Introduces
entire trail resumewith context output, interactive picker/default behavior, and--session/--checkpointtargeting. - Reuses/refactors resume restore internals to return restored session slices and includes review metadata for better prompt previews.
- Adds agent “resume launchers” (subprocess-spawnable resume) plus unit/integration tests covering missing-local-state behavior.
Reviewed changes
Copilot reviewed 22 out of 23 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| t1.txt | Adds a new text file (appears unrelated to this feature). |
| cmd/entire/cli/trail_resume_cmd.go | Implements entire trail resume command, context rendering, selection, restore, and optional agent launch. |
| cmd/entire/cli/trail_resume_cmd_test.go | Unit tests for option validation, context rendering/JSON encoding, and restored-session choice behavior. |
| cmd/entire/cli/trail_cmd.go | Registers the new trail resume subcommand. |
| cmd/entire/cli/strategy/strategy.go | Extends RestoredSession to carry kind/review prompt metadata. |
| cmd/entire/cli/strategy/rewind_test.go | Adds tests for restored prompt preview fallback; updates test agent to satisfy prompt extraction needs. |
| cmd/entire/cli/strategy/manual_commit_rewind.go | Improves restored prompt preview derivation (sidecar → review prompt → transcript-derived prompts). |
| cmd/entire/cli/resume.go | Refactors restore paths to return restored sessions so callers (like trail resume) can decide how to display/launch. |
| cmd/entire/cli/resume_picker.go | Adds shared unknownAgentLabel constant for consistent UI strings. |
| cmd/entire/cli/integration_test/trail_resume_test.go | Integration test ensuring checkpoint sessions are used when local session state is missing. |
| cmd/entire/cli/agent/registry.go | Adds ResumeLauncherFor to resolve agents that can be subprocess-launched for resume. |
| cmd/entire/cli/agent/registry_test.go | Tests ResumeLauncherFor. |
| cmd/entire/cli/agent/pi/pi.go | Adds LaunchResumeCmd for Pi agent. |
| cmd/entire/cli/agent/opencode/opencode.go | Adds LaunchResumeCmd for OpenCode agent. |
| cmd/entire/cli/agent/geminicli/gemini.go | Adds LaunchResumeCmd for Gemini CLI agent. |
| cmd/entire/cli/agent/factoryaidroid/factoryaidroid.go | Adds LaunchResumeCmd for Factory AI Droid agent. |
| cmd/entire/cli/agent/copilotcli/copilotcli.go | Adds LaunchResumeCmd for Copilot CLI agent. |
| cmd/entire/cli/agent/codex/codex.go | Adds LaunchResumeCmd for Codex agent. |
| cmd/entire/cli/agent/codex/codex_test.go | Adds a LaunchResumeCmd shape test (skips if binary missing). |
| cmd/entire/cli/agent/claudecode/claude.go | Adds LaunchResumeCmd for Claude Code agent. |
| cmd/entire/cli/agent/agent.go | Introduces the ResumeLauncher interface. |
| cmd/entire/cli/agent/foreground.go | Adds helper to build foreground-wired subprocess commands (NewForegroundCommand). |
| .gitignore | Ignores a few additional local artifact directories. |
| @@ -0,0 +1 @@ | |||
| test 1 | |||
Resolve .gitignore by keeping /skills/, remove stray t1.txt, and preserve restored sessions from resume fallback paths so trail resume can launch agents after restore. Entire-Checkpoint: 1cfc6d5a6270
# Conflicts: # cmd/entire/cli/resume.go
Entire-Checkpoint: 032d11e360b1
| } | ||
|
|
||
| func (c *ClaudeCodeAgent) LaunchResumeCmd(ctx context.Context, sessionID string) (*exec.Cmd, error) { | ||
| cmd, err := agent.NewForegroundCommand(ctx, "claude", "-r", sessionID) |
There was a problem hiding this comment.
So far, we were outputting the CLI commands to resume a session. This left the decision when to resume to the user. I'm wondering if we need to update each agent to support immediately resuming the session. This adds additional complexity while making assumptions that might not be necessarily true. 🤔
Entire-Checkpoint: 98c72f60a218
Entire-Checkpoint: edbbfc484319
Entire-Checkpoint: d9163150e6c7
Entire-Checkpoint: 6ae8eb6ff73d
Entire-Checkpoint: aac146a80d97
Entire-Checkpoint: d5ecffddba59


https://entire.io/gh/entireio/cli/trails/650
Summary
entire trail resumewith trail context, checkpoint session listing, picker/default resume behavior, and--session/--checkpointtargetingVerification
mise run checkgo test ./cmd/entire/cli/integration_test -tags=integration -run TestTrailResume_UsesCheckpointSessionsWhenLocalStateIsMissing -count=1Note
Medium Risk
Touches git checkpoint restore, branch checkout/worktree clashes, and foreground subprocess launches of external agent binaries; behavior is mostly delegated to existing resume strategy but the new trail/API path increases user-facing surface area.
Overview
Adds
entire trail resumeto resolve a trail (API), show trail/findings/checkpoint-session context, restore transcripts from the trail branch’s latest checkpoint metadata (even when local session state is gone), and either print resume commands or spawn the agent via new resume launchers.Checkpoint resume plumbing is refactored so restore returns
[]strategy.RestoredSession(restoreByCheckpointID,restoreFromCurrentBranch,restoreResumeSessions) while display/launch stay separate—trail resume reuses the same restore path asentire resume. Branch checkpoint discovery can anchor on a named branch ref (local ororigin/), not only HEAD.Agents gain a
ResumeLauncherinterface, sharedNewForegroundCommand,ResumeLauncherForin the registry, andLaunchResumeCmdfor Claude, Codex, Copilot, Droid, Gemini, OpenCode, and Pi. Restored sessions now carry kind/review prompt metadata, with richer prompt previews (sidecar → review prompt → transcript extraction, skipping injected instructions). Interactive trail flows prefer work sessions over review/investigation when choosing what to continue.Coverage includes unit tests for trail resume UX/validation, an integration test for multi-session checkpoint listing and
--sessionrestore after clearing local state, and minor.gitignoreentries.Reviewed by Cursor Bugbot for commit 894aa84. Configure here.