Skip to content

Commit 368c967

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 214fb7f commit 368c967

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 { displayCharAt, mentionTriggerIndex, slashTriggerIndex } from "../../prompt/display"
22+
import { displayCharAt, 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

@@ -846,6 +847,8 @@ export function Autocomplete(props: {
846847
skill: "skill",
847848
agent: "agent",
848849
reference: "reference",
850+
custom: "custom",
851+
mcp: "mcp",
849852
}
850853

851854
return (

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,10 @@ export function slashTriggerIndex(value: string, offset = promptOffsetWidth(valu
5959
return promptOffsetWidth(text.slice(0, index))
6060
}
6161
}
62+
63+
/** Source badge for a server-provided slash command. MCP prompts follow the `server:prompt`
64+
* naming convention from mcpCommandName; everything else from the command registry is
65+
* config-defined. Built-in keymap commands never reach this and stay unbadged. */
66+
export function slashCommandKind(name: string): "mcp" | "custom" {
67+
return name.includes(":") ? "mcp" : "custom"
68+
}

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

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

1415
describe("directoryAutocomplete", () => {
1516
test("lists parents and siblings without changing location", async () => {
@@ -221,3 +222,15 @@ describe("directoryRecentValue", () => {
221222
expect(directoryRecentValue("/project/recent", "/home/user")).toBe("/project/recent")
222223
})
223224
})
225+
226+
describe("slashCommandKind", () => {
227+
test("badges MCP prompts by the server:prompt naming convention", () => {
228+
expect(slashCommandKind("github:create_issue")).toBe("mcp")
229+
expect(slashCommandKind("my_server:my_prompt")).toBe("mcp")
230+
})
231+
232+
test("badges config-defined commands as custom", () => {
233+
expect(slashCommandKind("review-changes")).toBe("custom")
234+
expect(slashCommandKind("adapt")).toBe("custom")
235+
})
236+
})

0 commit comments

Comments
 (0)