Skip to content

feat: Add Agent Manager terminal switching - #4615

Merged
marius-kilocode merged 14 commits into
mainfrom
am-terminal-integration
Dec 22, 2025
Merged

feat: Add Agent Manager terminal switching#4615
marius-kilocode merged 14 commits into
mainfrom
am-terminal-integration

Conversation

@marius-kilocode

Copy link
Copy Markdown
Collaborator

Summary

  • This change introduces a button in the agent manager, that allows to open a VsCode terminal directly in the worktree
  • Add automatic terminal switching when selecting different agent sessions in the Agent Manager
  • Improve CLI output parsing to handle concatenated JSON objects and derive worktree paths from branch names

Manual testing:

  • Select a parallel mode session and verify terminal opens in the worktree directory
  • Switch between sessions and verify the correct terminal is revealed
  • Click the terminal button in session header to manually open terminal
  • Verify provisional sessions don't show the terminal button
  • Run cd src && pnpm vitest run to verify all tests pass

@changeset-bot

changeset-bot Bot commented Dec 22, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2ddd25b

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

This PR includes changesets to release 1 package
Name Type
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

@kilo-code-bot kilo-code-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ 3 Issues Found

Severity Issue Location
WARNING Inconsistent indentation in pending process block CliProcessHandler.ts:207-220
WARNING Inconsistent indentation in handleProcessError method CliProcessHandler.ts:732-757
SUGGESTION Missing blank line between methods CliProcessHandler.ts:523

Recommendation: Address the indentation issues before merge to maintain code consistency.

Review Details (42 files)

Files Reviewed:

  • SessionTerminalManager.ts (new) - Well-structured terminal management class with proper cleanup
  • CliProcessHandler.ts - Core changes for worktree path handling, has formatting issues
  • CliOutputParser.ts - Good addition of extractJsonObjects for concatenated JSON handling
  • AgentRegistry.ts - Improved renameSession and updateParallelModeInfo logic
  • AgentManagerProvider.ts - Clean integration of terminal manager
  • SessionDetail.tsx - Terminal button UI addition
  • parallelModeParser.ts - New buildParallelModeWorktreePath utility
  • Various i18n files - Proper localization for "openTerminal"
  • Test files - Good coverage for new functionality

Checked: Security, bugs, performance, error handling

Notes:

  • The .husky/_/ files (post-checkout, post-commit, post-merge, pre-push) appear to be unrelated git-lfs hooks that were accidentally included. Consider removing them to keep the PR focused.
  • The core terminal switching logic is well-implemented with proper cleanup on terminal close
  • Good test coverage for the new SessionTerminalManager class

Fix these issues in Kilo Cloud

Comment thread src/core/kilocode/agent-manager/CliProcessHandler.ts Outdated
Comment thread src/core/kilocode/agent-manager/CliProcessHandler.ts Outdated
Comment thread src/core/kilocode/agent-manager/CliProcessHandler.ts

@kilo-code-bot kilo-code-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No New Issues in Latest Changes

The latest commits (removing .husky/_/ files and merging main) are cleanup only and don't introduce new code.

Previous issues still pending:
The 3 formatting issues flagged in the previous review on CliProcessHandler.ts (inconsistent indentation at lines 207-220 and 732-757, missing blank line at line 523) are still present and should be addressed before merge.

Review Details (38 files)

Files: Reviewed diff since last review - only cleanup commits (husky file deletions) and merge from main.

Checked: Security, bugs, performance, error handling

@kilo-code-bot kilo-code-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No New Issues

Reviewed the latest changes (38 files, +1073/-101 lines). The previous review's comments on indentation issues in CliProcessHandler.ts remain valid and should be addressed.

Core Implementation Quality:

  • SessionTerminalManager is well-structured with proper cleanup via onDidCloseTerminal listener
  • extractJsonObjects correctly handles string escaping and nested braces
  • buildParallelModeWorktreePath provides consistent worktree path derivation
  • Good test coverage for new functionality (344 lines of tests for SessionTerminalManager alone)
Review Details (38 files)

Files Reviewed:

  • SessionTerminalManager.ts (new) - Terminal lifecycle management ✓
  • CliOutputParser.ts - Concatenated JSON handling ✓
  • CliProcessHandler.ts - Worktree path propagation (has formatting issues from prior review)
  • AgentRegistry.ts - Session rename and parallel mode updates ✓
  • AgentManagerProvider.ts - Terminal manager integration ✓
  • SessionDetail.tsx - Terminal button UI ✓
  • parallelModeParser.ts - Path derivation utility ✓
  • 20+ i18n files - Localization for "openTerminal" ✓
  • Test files - Comprehensive coverage ✓

Checked: Security, bugs, performance, error handling

@kilo-code-bot kilo-code-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ 3 Issues Found

Severity Issue Location
WARNING Inconsistent indentation in pendingProcess block CliProcessHandler.ts:207-220
WARNING Inconsistent indentation in handleProcessError method CliProcessHandler.ts:732-757
SUGGESTION Missing blank line between methods CliProcessHandler.ts:523

Recommendation: Address the formatting issues before merge. These are style inconsistencies that should be fixed for code consistency.

Review Details (38 files)

Files Reviewed:

  • SessionTerminalManager.ts (new) - Well-structured terminal management with proper cleanup
  • CliOutputParser.ts - Good JSON extraction for concatenated objects
  • AgentRegistry.ts - Improved session renaming and parallel mode handling
  • CliProcessHandler.ts - Worktree path tracking (has formatting issues)
  • parallelModeParser.ts - Simple utility addition
  • AgentManagerProvider.ts - Clean integration of terminal manager
  • SessionDetail.tsx - UI button for terminal access
  • 20+ locale files - Translations added
  • Test files - Comprehensive coverage

Checked: Security, bugs, performance, error handling, resource cleanup

Positive Observations:

  • Proper disposal pattern in SessionTerminalManager
  • Good null/undefined handling throughout
  • Comprehensive test coverage for new functionality
  • Clean integration with existing codebase patterns

Fix these issues in Kilo Cloud

@kilo-code-bot kilo-code-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ 3 Issues Found

Severity Issue Location
WARNING Inconsistent indentation CliProcessHandler.ts:220
WARNING Inconsistent indentation in handleProcessError CliProcessHandler.ts:757
SUGGESTION Missing blank line after method CliProcessHandler.ts:523

Recommendation: Address formatting issues before merge

Review Details (38 files)

Source Files Reviewed:

  • SessionTerminalManager.ts (new) - Well-structured terminal management
  • CliProcessHandler.ts - Major changes for worktree path handling
  • AgentManagerProvider.ts - Terminal manager integration
  • AgentRegistry.ts - Modified parallel mode and session rename logic
  • CliOutputParser.ts - Added concatenated JSON parsing
  • parallelModeParser.ts - Added worktree path builder

Test Files: Comprehensive coverage added for new functionality

Localization: 20+ language files updated with openTerminal key

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

Notes:

  • Code is well-structured with proper null checks
  • New SessionTerminalManager class follows good patterns
  • Test coverage is comprehensive
  • The 3 formatting issues flagged are minor style inconsistencies

Fix these issues in Kilo Cloud

@RSO

RSO commented Dec 22, 2025

Copy link
Copy Markdown
Contributor

Can you add a short video highlighting the feature?

@eshurakov eshurakov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I approved, but instead I wanted to add a comment that I looked through the code but didn't test it.

@kilo-code-bot kilo-code-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Previous Issues Addressed

The formatting issues flagged in previous reviews have been resolved in commit 6d82aded ("Fix intendation comments"):

  • Inconsistent indentation in pending process block (lines 207-220)
  • Inconsistent indentation in handleProcessError method (lines 732-757)
  • Missing blank line between methods (line 523)

No new issues found in the latest changes.

Review Details (38 files)

Files Reviewed:

  • SessionTerminalManager.ts (new) - Well-structured terminal management with proper cleanup via onDidCloseTerminal
  • CliProcessHandler.ts - Worktree path tracking and propagation, formatting now consistent
  • CliOutputParser.ts - extractJsonObjects correctly handles string escaping and nested braces
  • AgentRegistry.ts - Improved renameSession merges logs when target exists, updateParallelModeInfo now enables parallelMode if not set
  • AgentManagerProvider.ts - Clean terminal manager integration
  • SessionDetail.tsx - Terminal button hidden for provisional sessions (correct behavior)
  • parallelModeParser.ts - buildParallelModeWorktreePath utility added
  • 20+ i18n files - Proper localization for "openTerminal"
  • Test files - Comprehensive coverage (344+ lines for SessionTerminalManager alone)

Checked: Security, bugs, performance, error handling, resource cleanup

Positive Observations:

  • Proper disposal pattern in SessionTerminalManager.dispose()
  • Terminal cwd change detection recreates terminal correctly
  • extractJsonObjects handles edge cases (escaped quotes, nested objects)
  • Test coverage is comprehensive

@kilo-code-bot kilo-code-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No New Issues

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

The latest commit (c080470) is a merge from main with no new code changes. Previous formatting issues flagged in earlier reviews have been addressed in commit 6d82aded.

Review Details

Key Files Reviewed:

  • SessionTerminalManager.ts (new) - Well-structured terminal lifecycle management with proper cleanup via onDidCloseTerminal
  • CliOutputParser.ts - extractJsonObjects correctly handles string escaping and nested braces
  • CliProcessHandler.ts - Proper worktree path propagation and provisional session handling
  • AgentRegistry.ts - renameSession properly handles edge cases (same ID, target exists, log merging)
  • parallelModeParser.ts - buildParallelModeWorktreePath utility added
  • SessionDetail.tsx - Terminal button correctly hidden for provisional sessions
  • 20+ i18n files - Proper localization for "openTerminal"
  • Test files - Comprehensive coverage (344+ lines for SessionTerminalManager)

Checked: Security, bugs, performance, error handling, resource cleanup

Positive Observations:

  • Proper disposal pattern in SessionTerminalManager.dispose()
  • Terminal cwd change detection recreates terminal correctly
  • Good null/undefined handling throughout
  • Comprehensive test coverage for new functionality

@kilo-code-bot kilo-code-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No New Issues

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

Latest commits since previous review (c080470):

  • 96922ac - Test fix: added missing vscode terminal mocks to IPC tests
  • 836a8a8, c10c0b2 - Merge commits from main

The test fix correctly adds onDidCloseTerminal and createTerminal mocks to the IPC test file, matching the pattern established in other test files.

Review Details

Key Files Verified:

  • SessionTerminalManager.ts - Well-structured terminal lifecycle management with proper cleanup via onDidCloseTerminal
  • CliOutputParser.ts - extractJsonObjects correctly handles string escaping and nested braces
  • AgentRegistry.ts - renameSession properly handles edge cases (same ID, target exists, log merging)
  • parallelModeParser.ts - buildParallelModeWorktreePath utility added
  • SessionDetail.tsx - Terminal button correctly hidden for provisional sessions
  • 20+ i18n files - Proper localization for "openTerminal"
  • Test files - Comprehensive coverage (344+ lines for SessionTerminalManager)

Checked: Security, bugs, performance, error handling, resource cleanup

Previous Issues Status: All 3 formatting issues from earlier reviews were resolved in commit 6d82aded and are now marked as outdated.

@kilo-code-bot

kilo-code-bot Bot commented Dec 22, 2025

Copy link
Copy Markdown
Contributor

✅ Previous Issues Addressed

The indentation issues from my previous review have been resolved:

  • Fixed inconsistent indentation in CliProcessHandler.ts
  • Fixed indentation in handleProcessError method
  • Added missing blank line between methods

No new issues found in the latest changes.


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

Review Details

Key Changes Reviewed:

  • SessionTerminalManager.ts - New terminal management class with proper lifecycle handling
  • CliOutputParser.ts - Added worktreePath support and extractJsonObjects for concatenated JSON
  • AgentRegistry.ts - Improved updateParallelModeInfo and renameSession methods
  • CliProcessHandler.ts - Integrated worktree path handling
  • SessionDetail.tsx - Added terminal button UI
  • Comprehensive test coverage for all new functionality

Checked: Security, bugs, performance, error handling, test coverage

@marius-kilocode
marius-kilocode enabled auto-merge (squash) December 22, 2025 17:42
@marius-kilocode
marius-kilocode merged commit 6909640 into main Dec 22, 2025
12 checks passed
@marius-kilocode
marius-kilocode deleted the am-terminal-integration branch December 22, 2025 17:51
@github-actions github-actions Bot mentioned this pull request Dec 22, 2025
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