fix(snapshot): address final review findings
Signed-off-by: brice <b@bnema.dev>
- commit
- caf28f0ce690ba4f2fc924bc9410d617ade31b23
- author
- brice · · 2026-07-06 08:09 UTC
- parent
- 07ec9d9
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
3 files · +5 -4
M internal/usecase/daemon/process_restore.go +2 -2
| @@ -56,7 +56,7 @@ func extractAgentSessionID(strategy string, argv []string) string { | |||
| 56 | 56 | func agentSessionFlag(strategy, arg string) bool { | |
| 57 | 57 | switch strategy { | |
| 58 | 58 | case processStrategyClaude: | |
| 59 | - | return arg == "--session-id" || arg == "--resume" | |
| 59 | + | return arg == "--session-id" || arg == "--resume" || arg == "-r" | |
| 60 | 60 | case processStrategyOpenCode: | |
| 61 | 61 | return arg == "-s" || arg == "--session" | |
| 62 | 62 | case processStrategyCodex: | |
| @@ -81,7 +81,7 @@ func planProcessRestore(proc *snapcodec.Process, allow map[string]struct{}) proc | |||
| 81 | 81 | switch strategy { | |
| 82 | 82 | case processStrategyPi: | |
| 83 | 83 | if id != "" { | |
| 84 | - | return processRestoreDecision{Command: shellQuoteArgvMust([]string{"pi", "--session-id", id}), Restore: true} | |
| 84 | + | return processRestoreDecision{Command: shellQuoteArgvMust([]string{"pi", "--resume", id}), Restore: true} | |
| 85 | 85 | } | |
| 86 | 86 | return processRestoreDecision{Command: "pi --continue", Restore: true} | |
| 87 | 87 | case processStrategyClaude: | |
| @@ -56,7 +56,7 @@ func extractAgentSessionID(strategy string, argv []string) string { | |||||
| 56 | func agentSessionFlag(strategy, arg string) bool { | 56 | func agentSessionFlag(strategy, arg string) bool { | ||
| 57 | switch strategy { | 57 | switch strategy { | ||
| 58 | case processStrategyClaude: | 58 | case processStrategyClaude: | ||
| 59 | - | return arg == "--session-id" || arg == "--resume" | 59 | + | return arg == "--session-id" || arg == "--resume" || arg == "-r" |
| 60 | case processStrategyOpenCode: | 60 | case processStrategyOpenCode: | ||
| 61 | return arg == "-s" || arg == "--session" | 61 | return arg == "-s" || arg == "--session" | ||
| 62 | case processStrategyCodex: | 62 | case processStrategyCodex: | ||
| @@ -81,7 +81,7 @@ func planProcessRestore(proc *snapcodec.Process, allow map[string]struct{}) proc | |||||
| 81 | switch strategy { | 81 | switch strategy { | ||
| 82 | case processStrategyPi: | 82 | case processStrategyPi: | ||
| 83 | if id != "" { | 83 | if id != "" { | ||
| 84 | - | return processRestoreDecision{Command: shellQuoteArgvMust([]string{"pi", "--session-id", id}), Restore: true} | 84 | + | return processRestoreDecision{Command: shellQuoteArgvMust([]string{"pi", "--resume", id}), Restore: true} |
| 85 | } | 85 | } | ||
| 86 | return processRestoreDecision{Command: "pi --continue", Restore: true} | 86 | return processRestoreDecision{Command: "pi --continue", Restore: true} | ||
| 87 | case processStrategyClaude: | 87 | case processStrategyClaude: | ||
M internal/usecase/daemon/process_restore_test.go +2 -1
| @@ -37,7 +37,7 @@ func TestProcessRestorePlan(t *testing.T) { | |||
| 37 | 37 | name: "pi with ID resumes", | |
| 38 | 38 | proc: &snapcodec.Process{Argv: []string{"pi", "cli"}, Strategy: processStrategyPi, Opts: snapcodec.ProcessOpts{AgentSessionID: "session-123"}}, | |
| 39 | 39 | restore: true, | |
| 40 | - | command: "pi --session-id session-123", | |
| 40 | + | command: "pi --resume session-123", | |
| 41 | 41 | }, | |
| 42 | 42 | { | |
| 43 | 43 | name: "pi no ID continues", | |
| @@ -110,6 +110,7 @@ func TestExtractAgentSessionID(t *testing.T) { | |||
| 110 | 110 | want string | |
| 111 | 111 | }{ | |
| 112 | 112 | {name: "claude session flag extraction", strategy: processStrategyClaude, argv: []string{"claude", "--session-id", "uuid-123"}, want: "uuid-123"}, | |
| 113 | + | {name: "claude short resume extraction", strategy: processStrategyClaude, argv: []string{"claude", "-r", "uuid-456"}, want: "uuid-456"}, | |
| 113 | 114 | {name: "opencode short session flag extraction", strategy: processStrategyOpenCode, argv: []string{"opencode", "-s", "abc"}, want: "abc"}, | |
| 114 | 115 | {name: "codex resume extraction", strategy: processStrategyCodex, argv: []string{"codex", "resume", "abc"}, want: "abc"}, | |
| 115 | 116 | {name: "claude flag-looking ID rejected", strategy: processStrategyClaude, argv: []string{"claude", "--resume", "--continue"}}, | |
| @@ -37,7 +37,7 @@ func TestProcessRestorePlan(t *testing.T) { | |||||
| 37 | name: "pi with ID resumes", | 37 | name: "pi with ID resumes", | ||
| 38 | proc: &snapcodec.Process{Argv: []string{"pi", "cli"}, Strategy: processStrategyPi, Opts: snapcodec.ProcessOpts{AgentSessionID: "session-123"}}, | 38 | proc: &snapcodec.Process{Argv: []string{"pi", "cli"}, Strategy: processStrategyPi, Opts: snapcodec.ProcessOpts{AgentSessionID: "session-123"}}, | ||
| 39 | restore: true, | 39 | restore: true, | ||
| 40 | - | command: "pi --session-id session-123", | 40 | + | command: "pi --resume session-123", |
| 41 | }, | 41 | }, | ||
| 42 | { | 42 | { | ||
| 43 | name: "pi no ID continues", | 43 | name: "pi no ID continues", | ||
| @@ -110,6 +110,7 @@ func TestExtractAgentSessionID(t *testing.T) { | |||||
| 110 | want string | 110 | want string | ||
| 111 | }{ | 111 | }{ | ||
| 112 | {name: "claude session flag extraction", strategy: processStrategyClaude, argv: []string{"claude", "--session-id", "uuid-123"}, want: "uuid-123"}, | 112 | {name: "claude session flag extraction", strategy: processStrategyClaude, argv: []string{"claude", "--session-id", "uuid-123"}, want: "uuid-123"}, | ||
| 113 | + | {name: "claude short resume extraction", strategy: processStrategyClaude, argv: []string{"claude", "-r", "uuid-456"}, want: "uuid-456"}, | |||
| 113 | {name: "opencode short session flag extraction", strategy: processStrategyOpenCode, argv: []string{"opencode", "-s", "abc"}, want: "abc"}, | 114 | {name: "opencode short session flag extraction", strategy: processStrategyOpenCode, argv: []string{"opencode", "-s", "abc"}, want: "abc"}, | ||
| 114 | {name: "codex resume extraction", strategy: processStrategyCodex, argv: []string{"codex", "resume", "abc"}, want: "abc"}, | 115 | {name: "codex resume extraction", strategy: processStrategyCodex, argv: []string{"codex", "resume", "abc"}, want: "abc"}, | ||
| 115 | {name: "claude flag-looking ID rejected", strategy: processStrategyClaude, argv: []string{"claude", "--resume", "--continue"}}, | 116 | {name: "claude flag-looking ID rejected", strategy: processStrategyClaude, argv: []string{"claude", "--resume", "--continue"}}, | ||
M internal/usecase/daemon/snapshot_restore_test.go +1 -1
| @@ -148,7 +148,7 @@ func TestRestoreSnapshotsWritesAgentIDCommandAndWriteFailureIsNonFatal(t *testin | |||
| 148 | 148 | d.restoreSnapshots(context.Background()) | |
| 149 | 149 | ||
| 150 | 150 | require.Len(t, factory.opens, 1) | |
| 151 | - | require.Equal(t, []string{"pi --session-id abc123\n"}, factory.opens[0].pty.writes) | |
| 151 | + | require.Equal(t, []string{"pi --resume abc123\n"}, factory.opens[0].pty.writes) | |
| 152 | 152 | factory.writeErr = errors.New("boom") | |
| 153 | 153 | require.NoError(t, d.restoreSession(context.Background(), snapcodec.Session{Name: "agent2", Tabs: []snapcodec.Tab{{Cols: 80, Rows: 24, Tree: layout.NewTree("pane-1"), Panes: []snapcodec.Pane{{ID: "pane-1", Cwd: "/tmp", Process: proc}}}}})) | |
| 154 | 154 | } | |
| @@ -148,7 +148,7 @@ func TestRestoreSnapshotsWritesAgentIDCommandAndWriteFailureIsNonFatal(t *testin | |||||
| 148 | d.restoreSnapshots(context.Background()) | 148 | d.restoreSnapshots(context.Background()) | ||
| 149 | 149 | ||||
| 150 | require.Len(t, factory.opens, 1) | 150 | require.Len(t, factory.opens, 1) | ||
| 151 | - | require.Equal(t, []string{"pi --session-id abc123\n"}, factory.opens[0].pty.writes) | 151 | + | require.Equal(t, []string{"pi --resume abc123\n"}, factory.opens[0].pty.writes) |
| 152 | factory.writeErr = errors.New("boom") | 152 | factory.writeErr = errors.New("boom") | ||
| 153 | require.NoError(t, d.restoreSession(context.Background(), snapcodec.Session{Name: "agent2", Tabs: []snapcodec.Tab{{Cols: 80, Rows: 24, Tree: layout.NewTree("pane-1"), Panes: []snapcodec.Pane{{ID: "pane-1", Cwd: "/tmp", Process: proc}}}}})) | 153 | require.NoError(t, d.restoreSession(context.Background(), snapcodec.Session{Name: "agent2", Tabs: []snapcodec.Tab{{Cols: 80, Rows: 24, Tree: layout.NewTree("pane-1"), Panes: []snapcodec.Pane{{ID: "pane-1", Cwd: "/tmp", Process: proc}}}}})) | ||
| 154 | } | 154 | } | ||