Watch
0
0
Fork
You've already forked hyperhive
0

swarm ui: a lone /word goes without the space completion leaves

This commit is contained in:
iris 2026-11-16 17:39:35 +01:00 • committed by mara
commit 2f3c9253bf
2 changed files with 27 additions and 1 deletions

View file

@ -24,6 +24,7 @@ import {
enterSends,
matchCommands,
menuQuery,
textToSend,
moveSelection,
type AgentCommand,
} from "./command-menu.js";
@ -61,7 +62,7 @@ export function AgentInputForm({ agentName }: { agentName: string }) {
: fetch(`${base}/input`, {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ body }),
body: JSON.stringify({ body: textToSend(body) }),
}),
{ onDone: () => setBody("") },
);

View file

@ -108,3 +108,14 @@ export function controlRoute(
commands.some((c) => c.kind === "command" && c.name === "clear");
return isClear ? "new-session" : null;
}
/**
* The text to send for what the box holds: a lone `/word`, which completion
* leaves with a space after it, goes without that space, so a command such as
* `/compact` reaches the agent exactly as typed by hand. Any other message goes
* as it is.
*/
export function textToSend(text: string): string {
const trimmed = text.trim();
return menuQuery(trimmed) === null ? text : trimmed;
}