Skip to content

fix(session): clear activeSession pointer on discard to prevent MCP server lockup#201

Merged
blak0p merged 1 commit into
mainfrom
fix/session-discard-active-session
Jun 30, 2026
Merged

fix(session): clear activeSession pointer on discard to prevent MCP server lockup#201
blak0p merged 1 commit into
mainfrom
fix/session-discard-active-session

Conversation

@blak0p

@blak0p blak0p commented Jun 30, 2026

Copy link
Copy Markdown
Owner

Closes #197

Summary

  • handleDiscard() now calls clearActiveSessionIfMatch() after removing the worktree, matching the same pattern already used in handleFinish()
  • Without this fix, discarding the active session leaves a dangling pointer to a non-existent worktree, causing every subsequent MCP tool call to fail with chdir: no such file or directory
  • Test updated to verify activeSession is nil after discard

Changes

File Change
internal/delivery/mcp/session/session.go Added h.clearActiveSessionIfMatch(sess.ID) in handleDiscard() after store.Delete
internal/delivery/mcp/session/session_test.go Updated TestHandleDiscard_RemovesWorktreeBranchMetadata to pre-select session and assert active pointer is cleared

Test Plan

  • go test ./internal/delivery/mcp/session/... — 27/27 tests pass
  • go build ./... — passes

…erver lockup

Bug #197: session discard leaves MCP server in unusable state because
handleDiscard() removes the worktree but never calls
clearActiveSessionIfMatch(). After discard, any tool call fails with
'chdir ../git-courer-worktrees/<id>: no such file or directory'.

Fix: add h.clearActiveSessionIfMatch(sess.ID) in handleDiscard() after
store.Delete, matching the same pattern already used in handleFinish().

Closes #197
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@blak0p blak0p added the bug Something isn't working label Jun 30, 2026
@blak0p blak0p merged commit 35291fe into main Jun 30, 2026
5 of 9 checks passed
@blak0p blak0p deleted the fix/session-discard-active-session branch June 30, 2026 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: session discard leaves MCP server in unusable state (chdir to non-existent worktree)

1 participant