Skip to content

feat: reference past chats with @-mentions - #12456

Merged
marius-kilocode merged 2 commits into
mainfrom
correct-session-scoping
Jul 23, 2026
Merged

feat: reference past chats with @-mentions#12456
marius-kilocode merged 2 commits into
mainfrom
correct-session-scoping

Conversation

@marius-kilocode

Copy link
Copy Markdown
Collaborator

Closes #12420.

Problem

There was no way to point the agent at a previous conversation. When a follow-up task depends on what was discussed or built in an earlier session, the only option was to re-explain everything manually, even though the transcript already exists locally. Agent Manager already has fast session search, but neither the CLI TUI nor the VS Code extension prompt could reach it.

What changed

Typing @ in the prompt now surfaces a Past chats entry. Choosing it opens an inline picker with fuzzy search over previous sessions (same fuzzysort-based mechanism as Agent Manager session search, recency-ordered when the query is empty, scoped to the current workspace/worktree). Selecting a session inserts a highlighted @title mention token into the prompt; clicking the token later opens that session.

The mention is sent as a file part with a session:<id> URL and resolved server-side at prompt time: the server renders the referenced session's transcript as markdown (# Session / ## User / ## Assistant) and injects it as context. Resolving at prompt time means the model always gets the current transcript rather than a stale snapshot, and no core schema or SDK change was needed. Synthetic parts (snapshots, patches, etc.) are excluded by default. Resolution enforces scoping: a mention can only resolve sessions that belong to the current project or worktree family, so a mention cannot leak transcripts across projects.

Transcripts are capped at ~100k characters, keeping the first third and last two thirds with an explicit omission marker, so attaching a very long chat cannot by itself blow up the context window.

The TUI implements the same flow with a dedicated dialog (DialogSessionMention), reusing the shared transcript formatter that recall now also uses.

Available in the CLI TUI and the VS Code extension.

@-mention dropdown showing the Past chats entry

Session picker with fuzzy search over previous sessions

Inserted session mention token in the prompt input

Comment thread packages/opencode/src/kilocode/session/transcript.ts
Comment thread packages/kilo-vscode/src/kilo-provider/session-search.ts
Comment thread packages/kilo-vscode/webview-ui/src/hooks/useFileMention.ts
Comment thread packages/kilo-ui/src/components/message-part.tsx
Comment thread packages/tui/src/kilocode/dialog-session-mention.tsx
@kilo-code-bot

kilo-code-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 2 Issues Found | Recommendation: Address before merge

Overview

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

WARNING

File Line Issue
packages/opencode/src/kilocode/session/transcript.ts 93 New scoped() check reimplements worktree-family resolution instead of reusing WorktreeFamily.list()/family(), which also do a live git worktree list lookup — inconsistent scoping vs. recall.ts
packages/kilo-vscode/src/kilo-provider/session-search.ts 42 No guard against an empty/falsy dir before calling session.list, unlike file-search.ts's pattern; a falsy directory silently widens the search
Resolved since previous review
  • packages/kilo-vscode/webview-ui/src/hooks/useFileMention.ts — session mentions are now keyed by a collision-safe token (sessionMentionToken) instead of raw title, so colliding titles no longer overwrite each other.
  • packages/kilo-ui/src/components/message-part.tsxdata-clickable now shares the same session-lookup helper used for click handling, so styling matches actual clickability for session mentions.
  • packages/tui/src/kilocode/dialog-session-mention.tsx — the past-chats picker now accepts an exclude prop and filters out the currently active session, matching the VS Code picker.
Files Reviewed (6 files in this incremental diff)
  • packages/kilo-ui/src/components/message-part.tsx
  • packages/kilo-vscode/tests/unit/file-mention-utils.test.ts
  • packages/kilo-vscode/webview-ui/src/hooks/file-mention-utils.ts
  • packages/kilo-vscode/webview-ui/src/hooks/useFileMention.ts
  • packages/tui/src/component/prompt/autocomplete.tsx
  • packages/tui/src/kilocode/dialog-session-mention.tsx

Fix these issues in Kilo Cloud

Previous Review Summary (commit 3d648d7)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 3d648d7)

Status: 5 Issues Found | Recommendation: Address before merge

Overview

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

WARNING

File Line Issue
packages/opencode/src/kilocode/session/transcript.ts 93 New scoped() check reimplements worktree-family resolution instead of reusing WorktreeFamily.list()/family(), which also do a live git worktree list lookup — inconsistent scoping vs. recall.ts
packages/kilo-vscode/src/kilo-provider/session-search.ts 42 No guard against an empty/falsy dir before calling session.list, unlike file-search.ts's pattern; a falsy directory silently widens the search
packages/kilo-vscode/webview-ui/src/hooks/useFileMention.ts 244 knownSessions map is keyed by session title, not id — colliding titles can silently attach the wrong session's transcript
packages/kilo-ui/src/components/message-part.tsx 954 data-clickable attribute doesn't account for the new session-mention navigation path, so styling can be out of sync with actual clickability
packages/tui/src/kilocode/dialog-session-mention.tsx 21 TUI past-chats picker doesn't exclude the currently active session, unlike the VS Code counterpart's exclude filter
Files Reviewed (24 files)
  • .changeset/session-mentions.md
  • packages/kilo-ui/src/components/message-part.tsx - 1 issue
  • packages/kilo-vscode/src/KiloProvider.ts
  • packages/kilo-vscode/src/kilo-provider/message-files.ts
  • packages/kilo-vscode/src/kilo-provider/session-search.ts - 1 issue
  • packages/kilo-vscode/tests/unit/file-mention-utils.test.ts
  • packages/kilo-vscode/tests/unit/message-files.test.ts
  • packages/kilo-vscode/webview-ui/src/App.tsx
  • packages/kilo-vscode/webview-ui/src/components/chat/PromptInput.tsx
  • packages/kilo-vscode/webview-ui/src/components/chat/SessionMentionPicker.tsx
  • packages/kilo-vscode/webview-ui/src/context/session.tsx
  • packages/kilo-vscode/webview-ui/src/hooks/file-mention-utils.ts
  • packages/kilo-vscode/webview-ui/src/hooks/useFileMention.ts - 1 issue
  • packages/kilo-vscode/webview-ui/src/styles/prompt-dropdowns.css
  • packages/kilo-vscode/webview-ui/src/types/messages/extension-messages.ts
  • packages/kilo-vscode/webview-ui/src/types/messages/webview-messages.ts
  • packages/opencode/src/kilocode/session/transcript.ts - 1 issue
  • packages/opencode/src/session/prompt.ts
  • packages/opencode/src/tool/recall.ts
  • packages/opencode/test/kilocode/session/transcript.test.ts
  • packages/tui/src/component/prompt/autocomplete.tsx
  • packages/tui/src/kilocode/dialog-session-mention.tsx - 1 issue
  • packages/tui/src/kilocode/session-mentions.ts

Fix these issues in Kilo Cloud


Reviewed by claude-sonnet-5 · Input: 36 · Output: 6.8K · Cached: 909.8K

Review guidance: REVIEW.md from base branch main

@marius-kilocode
marius-kilocode merged commit bf2cf93 into main Jul 23, 2026
31 checks passed
@marius-kilocode
marius-kilocode deleted the correct-session-scoping branch July 23, 2026 12:15
t7tran pushed a commit to t7tran/kilocode that referenced this pull request Aug 14, 2026
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.

[FEATURE]: Ability to @-mention past chats/sessions as inline file context for a session

2 participants