Skip to content

refactor(vscode): share context mention parsing and attachments - #13740

Merged
marius-kilocode merged 1 commit into
mainfrom
dedupe-context-mentions
Sep 3, 2026
Merged

refactor(vscode): share context mention parsing and attachments#13740
marius-kilocode merged 1 commit into
mainfrom
dedupe-context-mentions

Conversation

@marius-kilocode

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Git and terminal context mentions duplicate the same standalone-boundary/span parsing and UTF-8 text attachment construction. Maintaining the copies separately risks differences in matching or source metadata.

Why This Change Was Made

Extract only these two algorithms into a browser-safe helper, retaining the feature-specific named wrappers, token constants, filenames, and patterns. Keep the already-shared request lifecycle untouched. This is a small semantic duplicate below the scanner threshold, not a new mention framework.

User Impact

No intended behavior change. Both mentions retain their boundaries, first-match spans, repeated-call behavior, source metadata, and exact encoded content. Git retains its 15-second timeout, repository gate, scope/default context, and disposal reset. Terminal retains its 10-second timeout, embedded-output fallback, empty-content rejection, and distinct disposal behavior.

Evidence

  • Five focused files, +69/-72 lines: net -3 total LOC and -7 production LOC, including the new helper and imports.
  • Duplication reports before and after: 21 pairs, 404 duplicated lines, 2,758 duplicated tokens. No scanner settings, suppression, or allowlist changes.
  • Extension typecheck, lint, knip, compile, bundle, formatting, package guard, and 113 focused tests passed. Typecheck, lint, knip, bundle, and the focused tests were rerun after fast-forwarding to current main.
  • Isolated VS Code submission with both @git-changes and @terminal produced git-changes.txt and terminal-output.txt. Verified exact data URLs against real Git and terminal context responses, source ranges, and fixture text containing non-ASCII characters and reserved URL characters. The disposable profile and fixture were removed.
  • Model generation was intentionally unavailable through a local-only test provider; this checked attachment creation and submission, not a model response.

Manual check: modify a Git file, print terminal output, submit Inspect @git-changes and @terminal, and inspect both attachments.

@kilo-code-bot

kilo-code-bot Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (5 files)
  • packages/kilo-vscode/webview-ui/src/hooks/context-mention-utils.ts
  • packages/kilo-vscode/webview-ui/src/hooks/git-changes-context-utils.ts
  • packages/kilo-vscode/webview-ui/src/hooks/terminal-context-utils.ts
  • packages/kilo-vscode/tests/unit/terminal-context-utils.test.ts
  • packages/kilo-vscode/tests/unit/terminal-architecture.test.ts

Reviewed by grok-4.6 · Input: 98.8K · Output: 7.1K · Cached: 175.4K

Review guidance: REVIEW.md from base branch main

@marius-kilocode
marius-kilocode merged commit c679589 into main Sep 3, 2026
24 checks passed
@marius-kilocode
marius-kilocode deleted the dedupe-context-mentions branch September 3, 2026 10:53
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