Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions container/internal/git/checkpoint_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ func GetCheckpointTimeout() time.Duration {
return DefaultCheckpointTimeoutSeconds * time.Second
}

// IsCheckpointEnabled returns whether automatic checkpoint creation is enabled
// Disabled by default, can be enabled by setting CATNIP_ENABLE_CHECKPOINTS=true
func IsCheckpointEnabled() bool {
value := os.Getenv("CATNIP_ENABLE_CHECKPOINTS")
return value == "true" || value == "1"
}

// CheckpointManager handles checkpoint functionality for sessions
type CheckpointManager interface {
ShouldCreateCheckpoint() bool
Expand Down
31 changes: 31 additions & 0 deletions container/internal/git/checkpoint_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,37 @@ func TestGetCheckpointTimeout(t *testing.T) {
assert.Equal(t, DefaultCheckpointTimeoutSeconds*time.Second, timeout)
}

func TestIsCheckpointEnabled(t *testing.T) {
// Test disabled by default
_ = os.Unsetenv("CATNIP_ENABLE_CHECKPOINTS")
enabled := IsCheckpointEnabled()
assert.False(t, enabled)

// Test enabled with "true"
_ = os.Setenv("CATNIP_ENABLE_CHECKPOINTS", "true")
defer func() { _ = os.Unsetenv("CATNIP_ENABLE_CHECKPOINTS") }()
enabled = IsCheckpointEnabled()
assert.True(t, enabled)

// Test enabled with "1"
_ = os.Setenv("CATNIP_ENABLE_CHECKPOINTS", "1")
enabled = IsCheckpointEnabled()
assert.True(t, enabled)

// Test disabled with other values
_ = os.Setenv("CATNIP_ENABLE_CHECKPOINTS", "false")
enabled = IsCheckpointEnabled()
assert.False(t, enabled)

_ = os.Setenv("CATNIP_ENABLE_CHECKPOINTS", "0")
enabled = IsCheckpointEnabled()
assert.False(t, enabled)

_ = os.Setenv("CATNIP_ENABLE_CHECKPOINTS", "yes")
enabled = IsCheckpointEnabled()
assert.False(t, enabled)
}

func TestShouldCreateCheckpoint(t *testing.T) {
cm := &SessionCheckpointManager{
lastCommitTime: time.Now(),
Expand Down
5 changes: 5 additions & 0 deletions container/internal/services/claude_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,11 @@ func (m *WorktreeCheckpointManager) HandleTitleChange(newTitle string) {

// startCheckpointTimer starts or restarts the checkpoint timer
func (m *WorktreeCheckpointManager) startCheckpointTimer() {
// Check if checkpoints are enabled via environment variable
if !git.IsCheckpointEnabled() {
return
}

timeout := git.GetCheckpointTimeout()
// Start timer silently
m.checkpointTimer = time.AfterFunc(timeout, func() {
Expand Down