Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions apps/web/src/components/chat/ChatComposer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ import { ComposerPendingUserInputPanel } from "./ComposerPendingUserInputPanel";
import { ComposerPlanFollowUpBanner } from "./ComposerPlanFollowUpBanner";
import { ComposerControl, ComposerControlIcon, ComposerSelectControl } from "./ComposerControl";
import { resolveComposerMenuActiveItemId } from "./composerMenuHighlight";
import { searchSlashCommandItems } from "./composerSlashCommandSearch";
import {
searchSlashCommandItems,
slashCommandItemsForPromptPosition,
} from "./composerSlashCommandSearch";
import {
getComposerPromptInjectionState,
getComposerProviderState,
Expand Down Expand Up @@ -1360,11 +1363,10 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
skill.description ??
(skill.scope ? `${skill.scope} skill` : ""),
}));
const slashCommandItems = [
...builtInSlashCommandItems,
...providerSlashCommandItems,
...skillItems,
];
const slashCommandItems = slashCommandItemsForPromptPosition(
[...builtInSlashCommandItems, ...providerSlashCommandItems, ...skillItems],
composerTrigger.rangeStart === 0,
);
return searchSlashCommandItems(slashCommandItems, query);
}
if (composerTrigger.kind === "skill") {
Expand Down
39 changes: 38 additions & 1 deletion apps/web/src/components/chat/composerSlashCommandSearch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { describe, expect, it } from "vite-plus/test";
import { ProviderDriverKind } from "@t3tools/contracts";

import type { ComposerCommandItem } from "./ComposerCommandMenu";
import { searchSlashCommandItems } from "./composerSlashCommandSearch";
import {
searchSlashCommandItems,
slashCommandItemsForPromptPosition,
} from "./composerSlashCommandSearch";

describe("searchSlashCommandItems", () => {
const claudeDriver = ProviderDriverKind.make("claudeAgent");
Expand Down Expand Up @@ -173,4 +176,38 @@ describe("searchSlashCommandItems", () => {
"skill:claudeAgent:unslop",
]);
});

it("hides skills from slash completion after the first message line", () => {
const items = [
{
id: "slash:model",
type: "slash-command",
command: "model",
label: "/model",
description: "Switch model",
},
{
id: "skill:claudeAgent:unslop",
type: "skill",
provider: claudeDriver,
skill: {
name: "unslop",
path: "/skills/unslop/SKILL.md",
enabled: true,
},
label: "/skill:unslop",
description: "Cut AI tells from writing",
},
] satisfies Array<
Extract<ComposerCommandItem, { type: "slash-command" | "provider-slash-command" | "skill" }>
>;

expect(slashCommandItemsForPromptPosition(items, false).map((item) => item.id)).toEqual([
"slash:model",
]);
expect(slashCommandItemsForPromptPosition(items, true).map((item) => item.id)).toEqual([
"slash:model",
"skill:claudeAgent:unslop",
]);
});
});
10 changes: 10 additions & 0 deletions apps/web/src/components/chat/composerSlashCommandSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ type SlashSearchItem = Extract<
{ type: "slash-command" | "provider-slash-command" | "skill" }
>;

export function slashCommandItemsForPromptPosition(
items: ReadonlyArray<SlashSearchItem>,
isAtPromptStart: boolean,
): SlashSearchItem[] {
if (isAtPromptStart) {
return [...items];
}
return items.filter((item) => item.type !== "skill");
}

function scoreSlashCommandItem(item: SlashSearchItem, query: string): number | null {
if (item.type === "skill") {
if (query === "skill") {
Expand Down
Loading