Repository navigation
fix(vscode): match chat search against message text only #14210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
8437096
fix(vscode): match chat search against message text only
marius-kilocode b7ebdc5
Merge remote-tracking branch 'origin/main' into refactor-search-scope…
marius-kilocode a955c15
chore(vscode): drop leftover question dock id and pin search range as…
marius-kilocode File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "kilo-code": patch | ||
| --- | ||
|
|
||
| Restrict chat search to user and assistant messages, so reasoning blocks, tool calls, and tool output no longer produce matches |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
packages/kilo-vscode/tests/unit/transcript-search-text.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| import { describe, expect, it } from "bun:test" | ||
| import { rowSearchText } from "../../webview-ui/src/components/chat/transcript-search-text" | ||
| import type { TranscriptRow } from "../../webview-ui/src/context/transcript-rows" | ||
| import type { Part } from "../../webview-ui/src/types/messages" | ||
|
|
||
| const part = (value: Record<string, unknown>) => value as unknown as Part | ||
|
|
||
| const row = (type: "user" | "assistant", parts: Part[]) => | ||
| ({ | ||
| type, | ||
| key: "row-1", | ||
| turn: "turn-1", | ||
| partial: false, | ||
| queued: false, | ||
| live: false, | ||
| message: {}, | ||
| parts, | ||
| }) as unknown as TranscriptRow | ||
|
|
||
| const reasoning = part({ id: "reasoning-1", type: "reasoning", text: "penguin reasoning" }) | ||
| const tool = part({ | ||
| id: "tool-1", | ||
| type: "tool", | ||
| tool: "bash", | ||
| state: { status: "completed", input: { command: "walrus" }, output: "walrus output", title: "Run" }, | ||
| }) | ||
| const file = part({ id: "file-1", type: "file", mime: "text/plain", filename: "narwhal.ts", url: "file:///narwhal.ts" }) | ||
| const text = (id: string, value: string) => part({ id, type: "text", text: value }) | ||
|
|
||
| describe("rowSearchText", () => { | ||
| it("searches message text only and skips every non-message part", () => { | ||
| const result = rowSearchText(row("assistant", [reasoning, text("text-1", "swallow helper"), tool, file])) | ||
| expect(result.text).toBe("swallow helper") | ||
| expect(result.ranges).toEqual([{ start: 0, end: 14, partId: "text-1" }]) | ||
| }) | ||
|
|
||
| it("joins multiple text parts and attributes a range to each", () => { | ||
| const result = rowSearchText(row("assistant", [text("text-1", "alpha"), reasoning, text("text-2", "beta")])) | ||
| expect(result.text).toBe("alpha\nbeta") | ||
| expect(result.ranges).toEqual([ | ||
| { start: 0, end: 5, partId: "text-1" }, | ||
| { start: 6, end: 10, partId: "text-2" }, | ||
| ]) | ||
| }) | ||
|
|
||
| it("skips synthetic text parts", () => { | ||
| const result = rowSearchText( | ||
| row("assistant", [part({ id: "synthetic-1", type: "text", text: "hidden", synthetic: true })]), | ||
| ) | ||
| expect(result.text).toBe("") | ||
| expect(result.ranges).toEqual([]) | ||
| }) | ||
|
|
||
| it("strips hidden markdown link URLs from assistant text", () => { | ||
| const result = rowSearchText(row("assistant", [text("text-1", "see [marked.tsx](src/marked.tsx) now")])) | ||
| expect(result.text).toBe("see marked.tsx now") | ||
| // Ranges must be measured against the stripped text, not the raw source. | ||
| expect(result.ranges).toEqual([{ start: 0, end: 18, partId: "text-1" }]) | ||
| }) | ||
|
|
||
| it("keeps brackets in user text, which renders literally", () => { | ||
| const result = rowSearchText(row("user", [text("text-1", "see [marked.tsx](src/marked.tsx) now")])) | ||
| expect(result.text).toBe("see [marked.tsx](src/marked.tsx) now") | ||
| }) | ||
|
|
||
| it("returns nothing for diff and error rows", () => { | ||
| const diff = { | ||
| type: "diff", | ||
| key: "row-1", | ||
| turn: "turn-1", | ||
| partial: false, | ||
| queued: false, | ||
| live: false, | ||
| message: {}, | ||
| diffs: [], | ||
| } | ||
| const error = { | ||
| type: "error", | ||
| key: "row-2", | ||
| turn: "turn-1", | ||
| partial: false, | ||
| queued: false, | ||
| live: false, | ||
| message: {}, | ||
| error: {}, | ||
| } | ||
| expect(rowSearchText(diff as unknown as TranscriptRow)).toEqual({ text: "", ranges: [] }) | ||
| expect(rowSearchText(error as unknown as TranscriptRow)).toEqual({ text: "", ranges: [] }) | ||
| }) | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.