fix(web): hide invalid slash skill completions (#8904)
This commit is contained in:
1 parent
2921050c69
commit
bba79cc254
3 files changed
+56
-7
No files matched your search
@@ -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,
|
||||
@@ -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") {
|
||||
|
||||
@@ -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");
|
||||
@@ -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",
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -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") {
|
||||
|
||||
Reference in new issue
Block a user