feat(session): exempt imported sessions from staleness auto-purge · Entire
feat(session): exempt imported sessions from staleness auto-purge
9963361→main·
computermode·1w ago·2 files·+21 added/-0 removed
Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com
Sessions
01KX49J5WC1AG5KBYG7D9SZ8G6View transcript
[?
Fix Imported Sessions Handling in CLIClaude Code·Opus 4.8·34 steps](/content/gh/entireio/cli/session/91fa7c44-6634-48ab-ae5f-d394502f50d5#timeline-01KX49J5WC1AG5KBYG7D9SZ8G6/index.html)
Changes
2
cmd/entire/cli/session
Mstate.go+7
Mstate_test.go+14
472 unmodified lines
473
474
475
476
477
478
479
480
481
482
483
484
485
472 unmodified lines
}
func (s *State) IsStale() bool {
// Imported sessions are historical, read-only records reconstructed from
// pre-existing transcripts; their timestamps are always old by nature.
// Never auto-purge them or they'd vanish from `entire session list` on the
// first read after import.
if s.Kind == KindImported {
return false
}
var since time.Duration
if s.LastInteractionTime != nil {
since = time.Since(*s.LastInteractionTime)
Mcmd/entire/cli/session/state.go+7
233 unmodified lines
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
233 unmodified lines
}
assert.False(t, state.IsStale())
})
t.Run("imported_is_never_stale", func(t *testing.T) {
t.Parallel()
// Imported sessions carry historical timestamps (always old) but must
// never be auto-purged, or they'd vanish from `session list` on read.
old := time.Now().Add(-30 * 24 * time.Hour)
imported := &State{Kind: KindImported, StartedAt: old, LastInteractionTime: &old}
assert.False(t, imported.IsStale(), "imported session should never be stale")
// Control: a non-imported session of the same age IS stale (guards
// against an over-broad exemption).
normal := &State{StartedAt: old, LastInteractionTime: &old}
assert.True(t, normal.IsStale())
})
}
func TestStateStore_Load_DeletesStaleSession(t *testing.T) {