Skip to content

Conversation

@iscekic
Copy link
Collaborator

@iscekic iscekic commented Dec 12, 2025

Context

Adds parent session id when creating a session.

@iscekic iscekic requested a review from Copilot December 12, 2025 17:57
@iscekic iscekic self-assigned this Dec 12, 2025
@changeset-bot
Copy link

changeset-bot bot commented Dec 12, 2025

🦋 Changeset detected

Latest commit: 39a0af3

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 Minor
kilo-code Minor

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

@kiloconnect kiloconnect bot left a comment

Choose a reason for hiding this comment

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

✅ No Issues Found

7 files reviewed | Confidence: 90% | Recommendation: Merge

Review Details

Files:

  • cli/src/cli.ts - Added getParentTaskId dependency with proper async request/response pattern
  • src/shared/kilocode/cli-sessions/core/SessionClient.ts - Added parent_session_id to Session interface and CreateSessionInput
  • src/shared/kilocode/cli-sessions/core/SessionManager.ts - Added getParentTaskId to dependencies, bumped VERSION to 3
  • src/shared/kilocode/cli-sessions/core/SessionSyncService.ts - Implemented parent session ID lookup and passing to session creation
  • src/shared/kilocode/cli-sessions/core/__tests__/SessionManager.spec.ts - Added mock for getParentTaskId
  • src/shared/kilocode/cli-sessions/core/__tests__/SessionSyncService.spec.ts - Added test coverage for parent session ID feature
  • src/shared/kilocode/cli-sessions/extension/session-manager-utils.ts - Added getParentTaskId implementation for VSCode extension

Checked: Security, bugs, performance, error handling

Summary:
This PR adds parent session ID tracking when creating sessions, enabling session hierarchy/lineage tracking. The implementation is clean and consistent:

  1. Interface changes are properly typed with parent_session_id: string | null in the Session interface and optional in CreateSessionInput
  2. Version bump from 2 to 3 is appropriate for this schema change
  3. CLI implementation uses a promise-based request/response pattern with proper timeout handling (5 seconds)
  4. Extension implementation follows the same pattern as existing getMode, getModel, and getOrganizationId callbacks
  5. Test coverage includes a new test case specifically for parent session ID propagation
  6. Null safety is handled correctly - parentSessionId is only set when both parentTaskId exists AND a session exists for that parent task

Copy link
Contributor

@kiloconnect kiloconnect bot left a comment

Choose a reason for hiding this comment

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

✅ No Issues Found

8 files reviewed | Confidence: 95% | Recommendation: Merge

Review Details

Files Reviewed:

  • .changeset/many-guests-crash.md - Changeset file (trivial)
  • cli/src/cli.ts - Added getParentTaskId dependency implementation
  • src/shared/kilocode/cli-sessions/core/SessionClient.ts - Added parent_session_id to interfaces
  • src/shared/kilocode/cli-sessions/core/SessionManager.ts - Added dependency and version bump
  • src/shared/kilocode/cli-sessions/core/SessionSyncService.ts - Core logic for parent session resolution
  • src/shared/kilocode/cli-sessions/core/__tests__/SessionManager.spec.ts - Test updates
  • src/shared/kilocode/cli-sessions/core/__tests__/SessionSyncService.spec.ts - New test for parent session ID
  • src/shared/kilocode/cli-sessions/extension/session-manager-utils.ts - Extension implementation

Checked: Security, bugs, performance, error handling, type safety

Summary:
This PR adds parent session ID tracking when creating sessions, enabling session hierarchy/lineage tracking. The implementation is clean and well-structured:

  1. Type Safety: Properly typed interfaces with parent_session_id: string | null in Session and optional in CreateSessionInput
  2. Consistent Pattern: The getParentTaskId dependency follows the same pattern as existing getOrganizationId, getMode, and getModel dependencies
  3. Proper Null Handling: Parent session ID is only set when both parent task ID exists AND a session exists for that parent task
  4. Version Bump: Correctly incremented SessionManager.VERSION from 2 to 3
  5. Test Coverage: Added test case "creates new session with parent session ID when parent task exists" that verifies the parent session lookup logic
  6. CLI Implementation: Uses promise-based request/response pattern with proper timeout handling (5 second fallback)
  7. Extension Implementation: Cleanly retrieves parent task ID from current task or task history

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 adds support for tracking parent session IDs when creating new sessions, enabling hierarchical relationships between sessions based on their parent task relationships.

Key Changes:

  • Added getParentTaskId dependency to SessionManager and SessionSyncService
  • Incremented session VERSION from 2 to 3 to reflect the schema change
  • Implemented parent task ID resolution in both extension and CLI environments

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/shared/kilocode/cli-sessions/extension/session-manager-utils.ts Added getParentTaskId function that retrieves parent task ID from current task or task history
cli/src/cli.ts Implemented getParentTaskId using task history request/response pattern with promise-based async resolution
src/shared/kilocode/cli-sessions/core/SessionSyncService.ts Added logic to resolve parent session ID from parent task ID and pass it when creating new sessions
src/shared/kilocode/cli-sessions/core/SessionManager.ts Incremented VERSION to 3 and added getParentTaskId to dependencies interface
src/shared/kilocode/cli-sessions/core/SessionClient.ts Added parent_session_id field to Session and CreateSessionInput interfaces
src/shared/kilocode/cli-sessions/core/__tests__/SessionSyncService.spec.ts Added test coverage for session creation with parent session ID
src/shared/kilocode/cli-sessions/core/__tests__/SessionManager.spec.ts Updated all test cases to include mockGetParentTaskId dependency

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