Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
fix(web): show a task send message passed through a heredoc
LeoXingff57cfa9240c
diff --git a/apps/web/src/features/rooms/runtime-status/task-command.test.ts b/apps/web/src/features/rooms/runtime-status/task-command.test.tsnew file mode 100644index 00000000..5bba5bea--- /dev/null+++ b/apps/web/src/features/rooms/runtime-status/task-command.test.ts@@ -0,0 +1,36 @@+import { describe, expect, it } from "vitest";+import { parseTaskCommand } from "./task-command";++describe("parseTaskCommand", () => {+ it("reads the message of task send from --message", () => {+ expect(+ parseTaskCommand(+ 'teamhub task send --task-id workitem_1 --message "Add pricing"',+ ),+ ).toEqual({+ message: "Add pricing",+ operation: "send",+ taskId: "workitem_1",+ });+ });++ it("reads a --message-file - message from its quoted heredoc, literally", () => {+ expect(+ parseTaskCommand(+ "teamhub task send --task-id workitem_1 --message-file - --steer <<'EOF'\nKeep $180/store as typed.\n--json is text here.\nEOF",+ ),+ ).toEqual({+ message: "Keep $180/store as typed.\n--json is text here.",+ operation: "send",+ taskId: "workitem_1",+ });+ });++ it("names a Task created from a heredoc requirement", () => {+ expect(+ parseTaskCommand(+ 'teamhub task create --name "Rivals" --requirement-file - <<\'EOF\'\nCompare --name "Other"\nEOF',+ ),+ ).toEqual({ name: "Rivals", operation: "create" });+ });+});diff --git a/apps/web/src/features/rooms/runtime-status/task-command.ts b/apps/web/src/features/rooms/runtime-status/task-command.tsindex 2bc0d50d..aa2eaa5c 100644--- a/apps/web/src/features/rooms/runtime-status/task-command.ts+++ b/apps/web/src/features/rooms/runtime-status/task-command.ts@@ -20,7 +20,8 @@ const OPERATIONS = new Set<TaskCommand["operation"]>([]);export function parseTaskCommand(command: string): TaskCommand | undefined {- const words = shellWords(command);+ const { line, body } = splitQuotedHeredoc(command);+ const words = shellWords(line);const start = words.findIndex((word, index) =>(word === "teamhub" || word.endsWith("/teamhub")) &&@@ -46,10 +47,13 @@ export function parseTaskCommand(command: string): TaskCommand | undefined {index += 1;}}+ const message =+ flags.get("--message") ??+ (flags.get("--message-file") === "-" ? body : undefined);return {operation,...(flags.has("--name") ? { name: flags.get("--name") } : {}),- ...(flags.has("--message") ? { message: flags.get("--message") } : {}),+ ...(message === undefined ? {} : { message }),...(flags.has("--task-id") ? { taskId: flags.get("--task-id") } : {}),};}@@ -62,6 +66,24 @@ export function createdTaskId(output: string | undefined) {return output?.match(/\bworkitem_[0-9a-f]{32}\b/)?.[0];}+/**+ * Separates a command from the body of its quoted heredoc (`<<'EOF'`), the+ * stdin a `--message-file -` reads. A quoted heredoc's body is literal, so it+ * is exactly the text the command received.+ */+function splitQuotedHeredoc(command: string): { line: string; body?: string } {+ const operator = /<<[ \t]*(['"])([A-Za-z_][A-Za-z0-9_]*)\1/u.exec(command);+ const start = operator ? command.indexOf("\n", operator.index) : -1;+ if (!operator || start < 0) return { line: command };+ const lines = command.slice(start + 1).split("\n");+ const end = lines.indexOf(operator[2]!);+ if (end < 0) return { line: command };+ return {+ line: command.slice(0, start),+ body: lines.slice(0, end).join("\n"),+ };+}+/** Splits a command line into words, honoring single and double quotes. */function shellWords(command: string) {const words: string[] = [];