summaryrefslogtreecommitdiffhomepage
path: root/packages/cli/src/args.test.ts
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-06-28 21:56:23 +0900
committerAdam Malczewski <[email protected]>2026-06-28 21:56:23 +0900
commit8175a3df065155c5a164e29bd1c47aad392ae555 (patch)
tree2c5d02672d14c9fe51b785196c28d6d9f72229fd /packages/cli/src/args.test.ts
parent6dd9ea9b935e5011c16faed6c869c976cf5ff172 (diff)
downloaddispatch-8175a3df065155c5a164e29bd1c47aad392ae555.tar.gz
dispatch-8175a3df065155c5a164e29bd1c47aad392ae555.zip
feat(cli): add --title flag to set tab title when summoning
Add a --title <title> flag to the dispatch CLI so a summoned agent's conversation/tab gets a human-readable title at creation time instead of the auto-derived default (Untitled until the first message append). The title is carried as an additive optional ChatRequest.title field (the HTTP client-server contract), parsed + trimmed server-side in parseChatBody, and persisted via the conversation store's setConversationTitle in the POST /chat route BEFORE the turn starts — so the title is set atomically with creation and before --open signals the frontend to open the tab. No second HTTP round-trip is needed. A whitespace-only title is treated as absent (auto-derive); a non-string title yields HTTP 400. A title-set failure is logged but never blocks the turn (the title is a nicety, the answer is not). The change is purely additive — no existing behavior or assertion changes. Verification: typecheck EXIT 0; test 2021 passed | 6 skipped | 0 failed; check EXIT 0 (12 pre-existing warnings in untouched files).
Diffstat (limited to 'packages/cli/src/args.test.ts')
-rw-r--r--packages/cli/src/args.test.ts43
1 files changed, 43 insertions, 0 deletions
diff --git a/packages/cli/src/args.test.ts b/packages/cli/src/args.test.ts
index e6b43cf..14c4ffc 100644
--- a/packages/cli/src/args.test.ts
+++ b/packages/cli/src/args.test.ts
@@ -216,6 +216,49 @@ describe("parseArgs", () => {
expect(result.kind).toBe("error");
if (result.kind === "error") expect(result.message).toContain("--workspace requires a value");
});
+
+ it("parses --title flag", () => {
+ const result = parseArgs(["m", "--text", "x", "--title", "My Task"], { defaultServer });
+ expect(result).toEqual({
+ kind: "chat",
+ server: "http://localhost:24203",
+ modelName: "m",
+ text: "x",
+ file: undefined,
+ cwd: undefined,
+ conversationId: undefined,
+ reasoningEffort: undefined,
+ showReasoning: false,
+ open: false,
+ title: "My Task",
+ });
+ });
+
+ it("parses --title with --workspace together", () => {
+ const result = parseArgs(["m", "--text", "x", "--workspace", "ws", "--title", "T"], {
+ defaultServer,
+ });
+ expect(result.kind).toBe("chat");
+ if (result.kind === "chat") {
+ expect(result.workspaceId).toBe("ws");
+ expect(result.title).toBe("T");
+ }
+ });
+
+ it("omits title when --title is not given", () => {
+ const result = parseArgs(["m", "--text", "x"], { defaultServer });
+ expect(result.kind).toBe("chat");
+ if (result.kind === "chat") {
+ expect(result.title).toBeUndefined();
+ expect(result).not.toHaveProperty("title");
+ }
+ });
+
+ it("errors when --title has no value", () => {
+ const result = parseArgs(["m", "--text", "x", "--title"], { defaultServer });
+ expect(result.kind).toBe("error");
+ if (result.kind === "error") expect(result.message).toContain("--title requires a value");
+ });
});
describe("list", () => {