fix(app): accept inline skill autocomplete (#1464)
This commit is contained in:
@@ -450,9 +450,7 @@ export function useAgentAutocomplete(input: UseAgentAutocompleteInput): AgentAut
|
||||
command: activeSlashCommand,
|
||||
commandName: selected.id,
|
||||
});
|
||||
const shouldAppendSpace =
|
||||
activeSlashCommand.position === "start" && activeSlashCommand.end === userInput.length;
|
||||
setUserInput(shouldAppendSpace ? `${nextInput} ` : nextInput);
|
||||
setUserInput(nextInput);
|
||||
onAutocompleteApplied?.();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -95,6 +95,30 @@ describe("applySlashCommandReplacement", () => {
|
||||
}),
|
||||
).toBe("use /taste before implementation");
|
||||
});
|
||||
|
||||
it("commits an inline slash token at the prompt tail", () => {
|
||||
const text = "use /tas";
|
||||
|
||||
expect(
|
||||
applySlashCommandReplacement({
|
||||
text,
|
||||
command: { start: 4, end: text.length, query: "tas", position: "inline" },
|
||||
commandName: "taste",
|
||||
}),
|
||||
).toBe("use /taste ");
|
||||
});
|
||||
|
||||
it("commits a start slash token at the prompt tail", () => {
|
||||
const text = "/tas";
|
||||
|
||||
expect(
|
||||
applySlashCommandReplacement({
|
||||
text,
|
||||
command: { start: 0, end: text.length, query: "tas", position: "start" },
|
||||
commandName: "taste",
|
||||
}),
|
||||
).toBe("/taste ");
|
||||
});
|
||||
});
|
||||
|
||||
describe("filterInlineSkillCommandEntries", () => {
|
||||
|
||||
@@ -115,5 +115,6 @@ export function findActiveSlashCommand(
|
||||
export function applySlashCommandReplacement(input: ApplySlashCommandReplacementInput): string {
|
||||
const before = input.text.slice(0, input.command.start);
|
||||
const after = input.text.slice(input.command.end);
|
||||
return `${before}/${input.commandName}${after}`;
|
||||
const replacement = `${before}/${input.commandName}${after}`;
|
||||
return input.command.end === input.text.length ? `${replacement} ` : replacement;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user