-
Notifications
You must be signed in to change notification settings - Fork 1.5k
add parent session id when creating a session #4428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: improve-session-manager-maintainability
Are you sure you want to change the base?
add parent session id when creating a session #4428
Conversation
🦋 Changeset detectedLatest commit: 39a0af3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
There was a problem hiding this 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- AddedgetParentTaskIddependency with proper async request/response patternsrc/shared/kilocode/cli-sessions/core/SessionClient.ts- Addedparent_session_idto Session interface and CreateSessionInputsrc/shared/kilocode/cli-sessions/core/SessionManager.ts- AddedgetParentTaskIdto dependencies, bumped VERSION to 3src/shared/kilocode/cli-sessions/core/SessionSyncService.ts- Implemented parent session ID lookup and passing to session creationsrc/shared/kilocode/cli-sessions/core/__tests__/SessionManager.spec.ts- Added mock forgetParentTaskIdsrc/shared/kilocode/cli-sessions/core/__tests__/SessionSyncService.spec.ts- Added test coverage for parent session ID featuresrc/shared/kilocode/cli-sessions/extension/session-manager-utils.ts- AddedgetParentTaskIdimplementation 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:
- Interface changes are properly typed with
parent_session_id: string | nullin the Session interface and optional in CreateSessionInput - Version bump from 2 to 3 is appropriate for this schema change
- CLI implementation uses a promise-based request/response pattern with proper timeout handling (5 seconds)
- Extension implementation follows the same pattern as existing
getMode,getModel, andgetOrganizationIdcallbacks - Test coverage includes a new test case specifically for parent session ID propagation
- Null safety is handled correctly -
parentSessionIdis only set when bothparentTaskIdexists AND a session exists for that parent task
There was a problem hiding this 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- AddedgetParentTaskIddependency implementationsrc/shared/kilocode/cli-sessions/core/SessionClient.ts- Addedparent_session_idto interfacessrc/shared/kilocode/cli-sessions/core/SessionManager.ts- Added dependency and version bumpsrc/shared/kilocode/cli-sessions/core/SessionSyncService.ts- Core logic for parent session resolutionsrc/shared/kilocode/cli-sessions/core/__tests__/SessionManager.spec.ts- Test updatessrc/shared/kilocode/cli-sessions/core/__tests__/SessionSyncService.spec.ts- New test for parent session IDsrc/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:
- Type Safety: Properly typed interfaces with
parent_session_id: string | nullinSessionand optional inCreateSessionInput - Consistent Pattern: The
getParentTaskIddependency follows the same pattern as existinggetOrganizationId,getMode, andgetModeldependencies - Proper Null Handling: Parent session ID is only set when both parent task ID exists AND a session exists for that parent task
- Version Bump: Correctly incremented
SessionManager.VERSIONfrom 2 to 3 - Test Coverage: Added test case "creates new session with parent session ID when parent task exists" that verifies the parent session lookup logic
- CLI Implementation: Uses promise-based request/response pattern with proper timeout handling (5 second fallback)
- Extension Implementation: Cleanly retrieves parent task ID from current task or task history
There was a problem hiding this 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
getParentTaskIddependency 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 |
Context
Adds parent session id when creating a session.