fix(vscode): list past chats across the worktree family - #12692
Conversation
| 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 }, |
There was a problem hiding this comment.
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>} |
There was a problem hiding this comment.
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.
Code Review SummaryStatus: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)SUGGESTION
Notes
Files Reviewed (6 files)
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 |
…-worktree-family fix(vscode): list past chats across the worktree family
In Agent Manager, chats run across many worktree directories of the same repository. The
@"Past chats" picker fetched candidates with the plainsession.listendpoint 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.listwithworktrees: 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.