Skip to content

Conversation

@iscekic
Copy link
Collaborator

@iscekic iscekic commented Dec 4, 2025

Fixes a couple race conditions:

  • renaming could rename the wrong session due this.sessionId changing
  • session data clobbered due to taskId not being reset

@iscekic iscekic requested a review from Copilot December 4, 2025 14:08
@iscekic iscekic self-assigned this Dec 4, 2025
@changeset-bot
Copy link

changeset-bot bot commented Dec 4, 2025

🦋 Changeset detected

Latest commit: 92563eb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@kilocode/cli Patch
kilo-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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 fixes critical race conditions in session management that could lead to incorrect session operations and data corruption.

Key Changes:

  • Modified renameSession to accept an explicit sessionId parameter to prevent renaming the wrong session when this.sessionId changes during async operations
  • Enhanced destroy() method to clear currentTaskId and sessionGitUrl to prevent session data clobbering across tasks
  • Updated syncSession() to capture and use a stable sessionId value throughout its execution

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/shared/kilocode/cli-sessions/core/SessionManager.ts Added explicit sessionId parameter to renameSession, captured local sessionId in syncSession for race-free operations, and cleared currentTaskId/sessionGitUrl in destroy
src/shared/kilocode/cli-sessions/core/__tests__/SessionManager.test.ts Updated test expectations for new renameSession signature and added comprehensive test case validating currentTaskId clearing prevents session clobbering
cli/src/commands/session.ts Updated renameSession call to pass explicit sessionId parameter and added early validation for active session

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants