Skip to content

Commit f5cfe0e

Browse files
committed
fix(tui): badge slash list entries by source kind
The TUI slash list rendered every entry identically — name plus one-line description — so a harness command, a config-defined command, and an MCP prompt were indistinguishable. The desktop popover already badges these (prompt.slash.badge.custom / .mcp); the TUI surfaced no source kind. Server commands now carry a kind in the autocomplete options: MCP prompts are recognized by the server:prompt naming convention from mcpCommandName, everything else from the command registry is config-defined (custom). Built-in keymap commands stay unbadged — they are the harness surface the badges differentiate against. Badge labels reuse the existing kind-pill render already used for skills, agents, and references. Fixes anomalyco#51186
1 parent 681156c commit f5cfe0e

3 files changed

Lines changed: 25 additions & 2 deletions

File tree

‎packages/tui/src/component/prompt/autocomplete.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { Locale } from "../../util/locale"
1919
import type { PromptInfo, PromptPartRef } from "../../prompt/history"
2020
import { useFrecency } from "../../prompt/frecency"
2121
import { Keymap, type KeymapCommand } from "../../context/keymap"
22-
import { mentionTriggerIndex, slashTriggerIndex } from "../../prompt/display"
22+
import { mentionTriggerIndex, slashCommandKind, slashTriggerIndex } from "../../prompt/display"
2323
import type { FileSystemEntry } from "@opencode/client"
2424
import { Skill } from "@opencode/schema/skill"
2525
import { stringWidth } from "../../util/string-width"
@@ -44,7 +44,7 @@ export type AutocompleteOption = {
4444
path?: string
4545
absolute?: string
4646
destructive?: { id: string; confirm: string; run: () => void }
47-
kind?: "skill" | "agent" | "reference"
47+
kind?: "skill" | "agent" | "reference" | "custom" | "mcp"
4848
queueable?: boolean
4949
}
5050

@@ -490,6 +490,7 @@ export function Autocomplete(props: {
490490
description: serverCommand.description,
491491
queueable: true,
492492
onSelect: () => insertSlash(serverCommand.name),
493+
kind: slashCommandKind(serverCommand.name),
493494
})
494495
}
495496

@@ -853,6 +854,8 @@ export function Autocomplete(props: {
853854
skill: "skill",
854855
agent: "agent",
855856
reference: "reference",
857+
custom: "custom",
858+
mcp: "mcp",
856859
}
857860

858861
return (

‎packages/tui/src/prompt/display.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,10 @@ export function slashTriggerIndex(text: string, widthMethod: WidthMethod) {
3939
return measureEditText(text.slice(0, index), { widthMethod })
4040
}
4141
}
42+
43+
/** Source badge for a server-provided slash command. MCP prompts follow the `server:prompt`
44+
* naming convention from mcpCommandName; everything else from the command registry is
45+
* config-defined. Built-in keymap commands never reach this and stay unbadged. */
46+
export function slashCommandKind(name: string): "mcp" | "custom" {
47+
return name.includes(":") ? "mcp" : "custom"
48+
}

‎packages/tui/test/prompt/autocomplete.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
directoryRecentValue,
1212
slashArgumentAutocomplete,
1313
} from "../../src/prompt/directory-completion"
14+
import { slashCommandKind } from "../../src/prompt/display"
1415

1516
describe("directoryAutocomplete", () => {
1617
test("lists parents and siblings without changing location", async () => {
@@ -216,3 +217,15 @@ describe("directoryRecentValue", () => {
216217
expect(directoryRecentValue("/project/recent", "/home/user")).toBe("/project/recent")
217218
})
218219
})
220+
221+
describe("slashCommandKind", () => {
222+
test("badges MCP prompts by the server:prompt naming convention", () => {
223+
expect(slashCommandKind("github:create_issue")).toBe("mcp")
224+
expect(slashCommandKind("my_server:my_prompt")).toBe("mcp")
225+
})
226+
227+
test("badges config-defined commands as custom", () => {
228+
expect(slashCommandKind("review-changes")).toBe("custom")
229+
expect(slashCommandKind("adapt")).toBe("custom")
230+
})
231+
})

0 commit comments

Comments
 (0)