Skip to content

don't update LastInteraction when only git hooks were triggered#550

Open
Soph wants to merge 1 commit intomainfrom
soph/stale-session-fixes
Open

don't update LastInteraction when only git hooks were triggered#550
Soph wants to merge 1 commit intomainfrom
soph/stale-session-fixes

Conversation

@Soph
Copy link
Collaborator

@Soph Soph commented Feb 27, 2026

I noticed a lot of sessions still sitting around locally. And what jumped out was that all of them were constantly updated. Turns out that the commit hooks kept looking at older sessions - which is fine - but also kept bumping LastInteractionTime which made them never going to be cleaned up. Now a commit isn't really an interaction in a session, so let's not do this in this case.

Copilot AI review requested due to automatic review settings February 27, 2026 20:30
@Soph Soph requested a review from a team as a code owner February 27, 2026 20:30
@cursor
Copy link

cursor bot commented Feb 27, 2026

PR Summary

Low Risk
Low risk: restricts LastInteractionTime updates to explicit session lifecycle/turn events, but could affect any logic that relied on commits keeping sessions “active” for cleanup or UX purposes.

Overview
Git commit (EventGitCommit) transitions no longer include the ActionUpdateLastInteraction side effect in PhaseIdle, PhaseActive, or PhaseEnded, so post-commit hooks won’t bump LastInteractionTime.

Tests are updated accordingly, including ApplyTransition coverage (condense/discard actions no longer imply a last-interaction update, and the handler-error test now only asserts the phase is still applied).

Written by Cursor Bugbot for commit ba20a2f. Configure here.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts the session phase state machine so that git commit hooks no longer count as “user interaction” and therefore do not keep sessions alive by updating LastInteractionTime, enabling stale-session cleanup to work as intended.

Changes:

  • Remove ActionUpdateLastInteraction from EventGitCommit transitions across IDLE/ACTIVE/ENDED phases.
  • Update unit tests to reflect the new transition action sets and updated expectations around LastInteractionTime.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
cmd/entire/cli/session/phase.go Removes ActionUpdateLastInteraction from EventGitCommit transition results so commits don’t refresh session “activity”.
cmd/entire/cli/session/phase_test.go Updates transition/apply-transition tests to match the new GitCommit behavior and expectations.

Comment on lines +519 to 535
func TestApplyTransition_ReturnsHandlerError_ButSetsPhase(t *testing.T) {
t.Parallel()

state := &State{Phase: PhaseActive}
handler := &mockActionHandler{returnErr: errors.New("condense failed")}
// Synthetic transition with [Condense, UpdateLastInteraction] actions.
result := TransitionResult{
NewPhase: PhaseIdle,
Actions: []Action{ActionCondense, ActionUpdateLastInteraction},
Actions: []Action{ActionCondense},
}

err := ApplyTransition(context.Background(), state, result, handler)

require.Error(t, err)
assert.Contains(t, err.Error(), "condense failed")
// Phase must still be set even though handler failed.
assert.Equal(t, PhaseIdle, state.Phase)
// Common action must still run even though handler failed.
require.NotNil(t, state.LastInteractionTime,
"UpdateLastInteraction must run despite earlier handler error")
}
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TestApplyTransition_ReturnsHandlerError_ButSetsPhase used to also assert that a common action (ActionUpdateLastInteraction) still runs even when a handler action errors (matching ApplyTransition's contract that common actions always apply). After this change, that behavior is no longer exercised by any test in this file. Add a focused test case where a handler action fails but ActionUpdateLastInteraction is still present later in the Actions list (e.g., []Action{ActionCondenseIfFilesTouched, ActionUpdateLastInteraction}), and assert LastInteractionTime was set despite the handler error.

Copilot generated this review using guidance from repository custom instructions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants