mirror of
https://github.com/murashit/codex-panel.git
synced 2026-07-22 06:57:10 +00:00
Limit slash command completions to composer start
This commit is contained in:
parent
b30482723d
commit
2065bf3999
2 changed files with 14 additions and 4 deletions
|
|
@ -158,7 +158,7 @@ function compareWikiLinkSuggestionTiebreakers(a: NoteCandidateMatch, b: NoteCand
|
|||
}
|
||||
|
||||
export function activeSlashCommandSuggestions(beforeCursor: string): ComposerSuggestion[] | null {
|
||||
const match = /(?:^|\n)(\/[A-Za-z-]*)$/.exec(beforeCursor);
|
||||
const match = /^(\/[A-Za-z-]*)$/.exec(beforeCursor);
|
||||
if (match?.index === undefined) return null;
|
||||
|
||||
const rawQuery = match[1];
|
||||
|
|
@ -178,7 +178,7 @@ export function activeSlashCommandSuggestions(beforeCursor: string): ComposerSug
|
|||
}
|
||||
|
||||
export function activeThreadCommandSuggestions(beforeCursor: string, threads: readonly Thread[]): ComposerSuggestion[] | null {
|
||||
const match = /(?:^|\n)\/(?:resume|refer|archive)\s+([^\s\n]{0,120})$/.exec(beforeCursor);
|
||||
const match = /^\/(?:resume|refer|archive)\s+([^\s\n]{0,120})$/.exec(beforeCursor);
|
||||
if (match?.index === undefined) return null;
|
||||
|
||||
const rawQuery = match[1];
|
||||
|
|
@ -208,7 +208,7 @@ export function activeThreadCommandSuggestions(beforeCursor: string, threads: re
|
|||
}
|
||||
|
||||
export function activeModelOverrideSuggestions(beforeCursor: string, models: readonly Model[]): ComposerSuggestion[] | null {
|
||||
const match = /(?:^|\n)\/model\s+([^\n]{0,120})$/.exec(beforeCursor);
|
||||
const match = /^\/model\s+([^\n]{0,120})$/.exec(beforeCursor);
|
||||
if (match?.index === undefined) return null;
|
||||
|
||||
const rawQuery = match[1];
|
||||
|
|
@ -255,7 +255,7 @@ export function activeReasoningEffortSuggestions(
|
|||
models: readonly Model[],
|
||||
currentModel: string | null,
|
||||
): ComposerSuggestion[] | null {
|
||||
const match = /(?:^|\n)\/effort\s+([^\n]{0,120})$/.exec(beforeCursor);
|
||||
const match = /^\/effort\s+([^\n]{0,120})$/.exec(beforeCursor);
|
||||
if (match?.index === undefined) return null;
|
||||
|
||||
const rawQuery = match[1];
|
||||
|
|
|
|||
|
|
@ -175,6 +175,16 @@ describe("composer suggestions", () => {
|
|||
expect(activeComposerSuggestions("/help", notes, [])).toEqual([]);
|
||||
});
|
||||
|
||||
it("limits slash command suggestions to the start of the composer", () => {
|
||||
const threads = [thread({ id: "019abcde-0000-7000-8000-000000000001", name: "Codex Panel実装" })];
|
||||
const models = [model("gpt-5.5", ["low", "medium", "high"])];
|
||||
|
||||
expect(activeComposerSuggestions("please\n/sta", notes, [])).toEqual([]);
|
||||
expect(activeComposerSuggestions("please\n/resume codex", notes, [], threads)).toEqual([]);
|
||||
expect(activeComposerSuggestions("please\n/model gpt", notes, [], [], models)).toEqual([]);
|
||||
expect(activeComposerSuggestions("please\n/effort h", notes, [], [], models, "gpt-5.5")).toEqual([]);
|
||||
});
|
||||
|
||||
it("suggests recent threads for /resume, /refer, and /archive arguments", () => {
|
||||
const threads = [
|
||||
thread({ id: "019abcde-0000-7000-8000-000000000001", name: "Codex Panel実装" }),
|
||||
|
|
|
|||
Loading…
Reference in a new issue