Skip to content

fix(vscode): keep file mentions fresh - #13158

Merged
marius-kilocode merged 4 commits into
mainfrom
profile-vscode-extension-context-loading-latency
Aug 17, 2026
Merged

fix(vscode): keep file mentions fresh#13158
marius-kilocode merged 4 commits into
mainfrom
profile-vscode-extension-context-loading-latency

Conversation

@marius-kilocode

@marius-kilocode marius-kilocode commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

Opening an @ file mention in the VS Code sidebar performs a backend search and renders the full suggestion update before the user can efficiently browse the results. The previous flow also issued duplicate updates for the same request and rebuilt more webview state than necessary, making the interaction heavier than it needs to be.

This change makes the zero-query file list available immediately from a short-lived webview snapshot while still refreshing it from the backend. It removes the redundant extension-side prewarm cache and duplicate response path, limits retained directory state, ignores superseded responses, and preserves the highlighted item when fresh results arrive. The result is a lighter file-mention interaction without sacrificing current search results or cross-worktree isolation.

Performance

Comparison of the same @file-search interaction in isolated VS Code, with one controlled profile per side:

Metric Before After Difference
Result latency 1022.0 ms 1009.2 ms -12.8 ms (-1.3%)
Script time 68.24 ms 55.48 ms -12.76 ms (-18.7%)
Layout time 11.40 ms 5.96 ms -5.44 ms (-47.7%)
Paint time 3.37 ms 3.05 ms -0.32 ms (-9.5%)
Longest task 69.62 ms 59.43 ms -10.19 ms (-14.6%)
Created nodes 2585 581 -2004 (-77.5%)
Layout objects 3717 1696 -2021 (-54.4%)
Event listeners 324 77 -247 (-76.2%)

The comparison used separate disposable worktrees with the same prompt, selector, wait condition, isolated VS Code executable, and profiling harness. End-to-end latency is network and backend dominated, so the renderer metrics show the clearer improvement.

The implementation also covers the associated lifecycle cases: empty refreshes remove deleted files, session and worktree results remain isolated, superseded responses are ignored, and remembered session-directory mappings are bounded.

Comment thread packages/kilo-vscode/webview-ui/src/hooks/useFileMention.ts
@kilo-code-bot

kilo-code-bot Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • packages/kilo-vscode/tests/unit/use-file-mention.test.ts
  • packages/kilo-vscode/webview-ui/src/hooks/useFileMention.ts
Previous Review Summary (commit c4dcb3d)

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

Previous review (commit c4dcb3d)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

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

SUGGESTION

File Line Issue
packages/kilo-vscode/webview-ui/src/hooks/useFileMention.ts 137 dirs map grows unbounded (one entry per session ID, never pruned) while cache is capped at 8 — minor memory accumulation in long-lived webviews

The revision/scope/request handling in useFileMention.ts is solid: stale responses are discarded by id + revision, scope switches clear pending state, empty-query responses replace the snapshot even when empty, and selection is preserved by identity across refreshes. The extension-side handler now posts exactly one fresh response per request. Tests exercise the real implementation and cover the regression scenarios from the PR description. The single finding is a minor consistency concern, not a blocker.

Fix these issues in Kilo Cloud

Files Reviewed (5 files)
  • .changeset/fresh-file-mentions.md
  • packages/kilo-vscode/src/kilo-provider/file-search.ts
  • packages/kilo-vscode/tests/unit/file-search.test.ts
  • packages/kilo-vscode/tests/unit/use-file-mention.test.ts
  • packages/kilo-vscode/webview-ui/src/hooks/useFileMention.ts - 1 issue

Reviewed by kimi-k3 · Input: 45.2K · Output: 3.9K · Cached: 270.3K

Review guidance: REVIEW.md from base branch main

@marius-kilocode
marius-kilocode merged commit 1e66d27 into main Aug 17, 2026
24 checks passed
@marius-kilocode
marius-kilocode deleted the profile-vscode-extension-context-loading-latency branch August 17, 2026 13:18
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