Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@marius-kilocode
Copy link
Collaborator

Problem

When pressing the terminal button on resumed sessions in the Agent Manager, users always see "Session not found" error.

Root Cause

The SessionTerminalManager.showTerminal() method was checking if the session exists in AgentRegistry, but remote sessions (from cloud history) are only stored in the webview's Jotai state, not in the backend registry.

Solution

Modified showTerminal() to handle remote-only sessions gracefully:

  • When a session is not in the registry, it now creates a terminal using the workspace folder as the working directory
  • Extracted terminal creation logic into a new showOrCreateTerminal() helper method for code reuse

Changes

  • src/core/kilocode/agent-manager/SessionTerminalManager.ts - Handle remote-only sessions
  • src/core/kilocode/agent-manager/__tests__/SessionTerminalManager.spec.ts - Updated tests

Notes

For remote worktree sessions, the terminal will open in the workspace folder (not the worktree) because the worktree path info is only available in the registry after the session is resumed. This is a reasonable fallback that can be improved later when worktree resumption is fixed.

@changeset-bot
Copy link

changeset-bot bot commented Jan 19, 2026

🦋 Changeset detected

Latest commit: 4131a42

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

@marius-kilocode marius-kilocode enabled auto-merge (squash) January 19, 2026 17:28
@marius-kilocode marius-kilocode requested a review from a team January 19, 2026 17:28
@kiloconnect
Copy link
Contributor

kiloconnect bot commented Jan 19, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

The PR correctly fixes the "Session not found" error for remote sessions by:

  1. Handling sessions that exist in the webview's Jotai state but not in the backend registry
  2. Creating a terminal with the workspace folder for these remote-only sessions
  3. Extracting terminal creation logic into a reusable showOrCreateTerminal() method

The refactoring is clean, the logic is correct, and the test has been properly updated.

Files Reviewed (3 files)
  • .changeset/fix-terminal-remote-sessions.md - Appropriate patch changeset
  • src/core/kilocode/agent-manager/SessionTerminalManager.ts - Main fix with good refactoring
  • src/core/kilocode/agent-manager/__tests__/SessionTerminalManager.spec.ts - Test updated correctly

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