Skip to content

fix(vscode): list past chats across the worktree family - #12692

Merged
marius-kilocode merged 1 commit into
mainfrom
fix/vscode-past-chats-worktree-family
Jul 30, 2026
Merged

fix(vscode): list past chats across the worktree family#12692
marius-kilocode merged 1 commit into
mainfrom
fix/vscode-past-chats-worktree-family

Conversation

@marius-kilocode

Copy link
Copy Markdown
Collaborator

In Agent Manager, chats run across many worktree directories of the same repository. The @ "Past chats" picker fetched candidates with the plain session.list endpoint filtered to the chat's exact directory, so a worktree chat's picker showed only that worktree's handful of sessions and looked empty next to the Agent Manager's own session search, which spans all worktrees. The changelog for past chats already promised "searched like the Agent Manager session search", but the implementation scoped to a single directory instead.

The picker now fetches from the same family-wide endpoint the CLI past-chats picker uses: experimental.session.list with worktrees: true. For git repositories this lists root sessions across the repo's whole worktree family (local workspace plus every linked worktree); for non-git directories the family collapses to the directory itself, so sidebar behavior outside git is unchanged. Every session in the family shares the repository's project server-side, so attaching any of them passes the existing cross-scope validation regardless of which worktree the current chat runs in.

Each picker row is now labeled with the session's worktree name, and the picker's fuzzy search matches on it, mirroring how the Agent Manager sidebar search lets users narrow by worktree.

@marius-kilocode
marius-kilocode merged commit 22ca041 into main Jul 30, 2026
24 checks passed
@marius-kilocode
marius-kilocode deleted the fix/vscode-past-chats-worktree-family branch July 30, 2026 12:01
try {
const res = await client.session.list({ directory: dir, roots: true, limit: 50 }, { throwOnError: true })
const res = await client.experimental.session.list(
{ worktrees: true, roots: true, directory: dir, limit: 50 },

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.

SUGGESTION: worktrees: true moves this onto a noticeably more expensive server path than the old directory-scoped session.list

With worktrees set, the handler runs WorktreeFamily.list() (a git worktree list --porcelain subprocess) and then KiloSession.listGlobal skips the SQL LIMIT entirely because directories is non-empty (packages/opencode/src/kilocode/session/index.ts:400), loading every non-archived root session in the project family and filtering in JS — with a existsSync(.git) parent walk per row via nested(). Since the webview refetches candidates on every picker open (useFileMention.ts openSessionPicker), that cost is paid each time @ past-chats is opened, and it scales with the project's total session count rather than with limit: 50.

Probably fine in practice, but if it shows up on large histories, consider caching the candidate list for the lifetime of the composer instead of refetching per open.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

<span class="session-mention-item">
<Icon name="history" class="file-mention-icon" />
<span class="session-mention-title">{item.title}</span>
{item.worktreeName && <span class="session-mention-worktree">{item.worktreeName}</span>}

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.

SUGGESTION: the worktree label is rendered even when it carries no information

The server sets worktreeName for every session whenever the family listing is used — path.basename(root ?? session.directory) in handlers/experimental.ts:245 — so in the plain sidebar of a repo with no Agent Manager worktrees, every row now gets an identical badge with the repo folder name (and for non-git directories, the basename of the directory itself). That eats up to 40% of the row width without disambiguating anything.

Consider only rendering the badge when the candidates actually span more than one worktree, e.g. compute new Set(props.sessions.map((s) => s.worktreeName)).size > 1 in a memo and gate the span on it. Fuzzy matching on worktreeName can stay unconditional.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

@kilo-code-bot

kilo-code-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 2
Issue Details (click to expand)

SUGGESTION

File Line Issue
packages/kilo-vscode/src/kilo-provider/session-search.ts 47 worktrees: true bypasses the SQL LIMIT server-side (kilocode/session/index.ts:400) and adds a git worktree list subprocess plus a per-row existsSync walk, so each picker open scales with total project sessions rather than limit: 50
packages/kilo-vscode/webview-ui/src/components/chat/SessionMentionPicker.tsx 55 The worktree badge is set for every session, so plain-sidebar rows all show an identical repo-folder label that consumes up to 40% of the row width without disambiguating anything
Notes
  • Verified the cross-worktree attach claim: SessionTranscript.scoped() accepts sessions whose projectID matches the instance project, and Project.resolve derives the id from the git remote / repo store, which is shared across linked worktrees — so attaching a session from another worktree of the same repo passes validation.
  • Behavior difference worth being aware of: experimental.session.list excludes archived sessions (isNull(time_archived)) while the previous session.list did not, so archived past chats no longer appear in the picker. Likely an improvement, not flagged.
  • The doc comments in SessionMentionPicker.tsx ("directory-scoped session list") and useFileMention.ts:198/:34 still describe the old directory scoping; those lines are outside this PR's diff hunks, so they were not commented inline.
Files Reviewed (6 files)
  • .changeset/past-chats-worktree-family.md - 0 issues
  • packages/kilo-vscode/src/kilo-provider/session-search.ts - 1 issue
  • packages/kilo-vscode/tests/unit/session-search.test.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/components/chat/SessionMentionPicker.tsx - 1 issue
  • packages/kilo-vscode/webview-ui/src/styles/prompt-dropdowns.css - 0 issues
  • packages/kilo-vscode/webview-ui/src/types/messages/extension-messages.ts - 0 issues

Fix these issues in Kilo Cloud


Reviewed by claude-opus-5 · Input: 116 · Output: 22.7K · Cached: 4.4M

Review guidance: REVIEW.md from base branch main

t7tran pushed a commit to t7tran/kilocode that referenced this pull request Aug 14, 2026
…-worktree-family

fix(vscode): list past chats across the worktree family
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.

2 participants