fix(strategy): don't purge imported sessions in shadow-branch orphan cleanup · Entire
fix(strategy): don't purge imported sessions in shadow-branch orphan cleanup
96ed4e1→main·
computermode·1w ago·2 files·+57 added/-0 removed
Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com
Sessions
01KX49T0BNT7NAW9TJXFE7DSYBView transcript
[?
Fix Imported Sessions Handling in CLIClaude Code·Opus 4.8·34 steps](/content/gh/entireio/cli/session/91fa7c44-6634-48ab-ae5f-d394502f50d5#timeline-01KX49T0BNT7NAW9TJXFE7DSYB/index.html)
Changes
2
cmd/entire/cli/strategy
Mmanual_commit_session.go+9
Amanual_commit_session_test.go+48
88 unmodified lines
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
88 unmodified lines
continue
}
// Imported sessions are read-only historical records: no shadow branch
// and (by design) no BaseCommit. Keep them regardless of the
// shadow-branch orphan check below. Gate on Kind, not on commit
// presence, so this stays correct once imports are linked to a commit.
if state.Kind == session.KindImported {
states = append(states, state)
continue
}
// Skip and cleanup orphaned sessions whose shadow branch no longer exists.
// Keep active sessions (shadow branch may not be created yet) and sessions
// with LastCheckpointID (needed for checkpoint ID reuse on subsequent commits).
Mcmd/entire/cli/strategy/manual_commit_session.go+9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package strategy
import (
"context"
"testing"
"time"
"github.com/entireio/cli/cmd/entire/cli/session"
"github.com/entireio/cli/cmd/entire/cli/testutil"
)
func TestListAllSessionStates_KeepsImported(t *testing.T) {
// Not parallel: t.Chdir.
dir := t.TempDir()
testutil.InitRepo(t, dir)
testutil.WriteFile(t, dir, "f.txt", "x")
testutil.GitAdd(t, dir, "f.txt")
testutil.GitCommit(t, dir, "init")
t.Chdir(dir)
ctx := context.Background()
store, err := session.NewStateStore(ctx)
if err != nil {
t.Fatalf("NewStateStore: %v", err)
}
old := time.Now().Add(-24 * time.Hour)
imported := &session.State{
SessionID: "imported-keep", Kind: session.KindImported,
Phase: session.PhaseEnded, StartedAt: old, EndedAt: &old,
}
if err := store.Save(ctx, imported); err != nil {
t.Fatalf("save imported: %v", err)
}
states, err := NewManualCommitStrategy().listAllSessionStates(ctx)
if err != nil {
t.Fatalf("listAllSessionStates: %v", err)
}
found := false
for _, s := range states {
if s.SessionID == "imported-keep" {
found = true
}
}
if !found {
t.Fatal("imported session was purged by listAllSessionStates orphan cleanup")
}
}
Acmd/entire/cli/strategy/manual_commit_session_test.go+48