Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
fix(composer): show full background task commands on expansion
Linuxdazhao9d1b09d1dc3d
diff --git a/apps/desktop/src/components/TaskDock.tsx b/apps/desktop/src/components/TaskDock.tsxindex 91b70108b..c13bcdb79 100644--- a/apps/desktop/src/components/TaskDock.tsx+++ b/apps/desktop/src/components/TaskDock.tsx@@ -227,11 +227,7 @@ function TaskDockPanel({ sessionId }: { sessionId: string }) {);}-/**- * Task rows. `Output` and `Stop`/`Remove` sit outside the row body so the- * clickable band never swallows a control, and the whole row stays one line:- * a long command ellipsizes with its full text in `title`.- */+/** The command preview and its actions share one line above the expanded details. */function TaskPanel({listId,tasks,@@ -322,7 +318,10 @@ function TaskPanel({) : null}</div>{expanded ? (- <pre className="task-output">{formatOutput(output, task.id)}</pre>+ <>+ <code className="task-command-detail">{task.command}</code>+ <pre className="task-output">{formatOutput(output, task.id)}</pre>+ </>) : null}</div>);diff --git a/apps/desktop/src/styles/composer.css b/apps/desktop/src/styles/composer.cssindex 4a6b0f388..953af0150 100644--- a/apps/desktop/src/styles/composer.css+++ b/apps/desktop/src/styles/composer.css@@ -1385,14 +1385,12 @@color: var(--ds-warning);}+.task-command-detail,.task-output {- max-height: 180px;margin: 0;padding: 8px 10px;- overflow: auto;border-top: 1px solid var(--ds-border-subtle);background: var(--ds-bg-inset);- color: var(--ds-text-secondary);font-family: var(--font-mono);font-size: var(--text-xs);line-height: var(--leading-body);@@ -1400,6 +1398,17 @@word-break: break-word;}+.task-command-detail {+ display: block;+ color: var(--ds-text-primary);+}++.task-output {+ max-height: 180px;+ overflow: auto;+ color: var(--ds-text-secondary);+}+/* Narrow composer panes: the header cannot hold progress text, the currentstep, a live count and the tablist at once. Drop the lowest-value copy ratherthan crushing the tabs. */diff --git a/apps/desktop/test/background-tasks-dock-render.test.mjs b/apps/desktop/test/background-tasks-dock-render.test.mjsindex 3cba37ae0..aaf23f0ca 100644--- a/apps/desktop/test/background-tasks-dock-render.test.mjs+++ b/apps/desktop/test/background-tasks-dock-render.test.mjs@@ -127,6 +127,25 @@ test("the container counts the rows it can render", async () => {});});+test("an expanded task shows the complete multiline command above its output", async () => {+ await withDockRender(({ render }) => {+ const command = `# ${"long-argument-".repeat(100)}\n sleep 60 # end of command`;+ const running = { ...task("t-running", "running"), command };+ const fixture = { tasks: [running], sessionTasks: [running], collapsed: false };+ assert.doesNotMatch(render(fixture), /class="task-command-detail"/);++ const html = render({+ ...fixture,+ expandedId: running.id,+ output: { id: running.id, stdout: "", stderr: "", truncated: false },+ });+ const detail = html.match(/<code class="task-command-detail">([\s\S]*?)<\/code>/);+ assert.equal(detail?.[1], command);+ const output = html.indexOf('<pre class="task-output">—</pre>');+ assert.ok(output > html.indexOf(detail[0]), "the command appears above its empty output");+ });+});+test("a finished row inside its grace window still counts", async () => {await withDockRender(({ render }) => {const finished = task("t-grace", "exited", 0);diff --git a/apps/desktop/test/helpers/background-tasks-hook.stub.ts b/apps/desktop/test/helpers/background-tasks-hook.stub.tsindex 16d749009..60c7f6480 100644--- a/apps/desktop/test/helpers/background-tasks-hook.stub.ts+++ b/apps/desktop/test/helpers/background-tasks-hook.stub.ts@@ -1,4 +1,4 @@-import type { BackgroundTaskSummary } from "../../src/lib/api";+import type { BackgroundTaskOutput, BackgroundTaskSummary } from "../../src/lib/api";/*** Stand-in for `useBackgroundTasks` in the container's render tests.@@ -16,6 +16,8 @@ export type DockFixture = {sessionTasks: BackgroundTaskSummary[];collapsed?: boolean;activeTab?: "todo" | "tasks";+ expandedId?: string;+ output?: BackgroundTaskOutput;};declare global {@@ -35,8 +37,8 @@ export function useBackgroundTasks() {setCollapsed() {},badge: 0,badgeText: "0",- expandedId: null,- output: null,+ expandedId: fixture.expandedId ?? null,+ output: fixture.output ?? null,toggleOutput() {},stop() {},remove() {diff --git a/docs/spec/04-ux/09-interaction-patterns.md b/docs/spec/04-ux/09-interaction-patterns.mdindex 0c8ba2310..54a21597e 100644--- a/docs/spec/04-ux/09-interaction-patterns.md+++ b/docs/spec/04-ux/09-interaction-patterns.md@@ -2032,6 +2032,13 @@ This does not prevent state changes — it makes them instant.window already placed in a narrower tile. Normal bounds persistence and theinternal work-panel/chat-width IPC contracts are unchanged.+## Background task details++The task header keeps the command on a single line with an ellipsis when it+overflows. Expanding the row shows the full, selectable command above the+output, preserving whitespace and wrapping long lines within the dock. The+command is visible as soon as the row expands, even when output is empty.+## Background completion continuationAgent behavior → Execution offers a default-off “Continue after background jobs” switch. Enabling it permits the assistant to arrange follow-up using the current permission mode, without separate per-job approval. The task dock labels running intents “Continue when finished” and finished intents “Waiting to resume”. Pending rows survive expiry and reload and expose “Cancel continuation”; they cannot be dismissed while still pending. Cancellation withdraws only continuation, leaving the process and log accessible. Other states distinguish started, received, cancelled and failed. Completion never switches the active conversation or steals focus.diff --git a/docs/spec/06-delivery/e2e/tools-and-workspace.md b/docs/spec/06-delivery/e2e/tools-and-workspace.mdindex 690ac46be..0887e7e04 100644--- a/docs/spec/06-delivery/e2e/tools-and-workspace.md+++ b/docs/spec/06-delivery/e2e/tools-and-workspace.md@@ -1212,6 +1212,8 @@ journeys cover successful reads, saves and directory browsing.at wide and narrow widths, scroll to the tenth task, and switch output previewswhile an earlier read is pending. 7) Fail a Stop request and retry it.8) Start two more tasks and quit the app during output capture.+ 9) Start a quiet task with a long, multiline command. Expand its row at+ a narrow width and select the command through its final line.- **Expected**: The tool result carries `backgroundTaskId` and resolves withoutwaiting for the command; the bar lists the task as running with a growingelapsed time and shows its streamed output; the process stays alive across the@@ -1222,6 +1224,9 @@ journeys cover successful reads, saves and directory browsing.fetched and refreshed; old responses cannot erase it. Each stream remainsbounded to 256KiB and retains its final marker after exit. A Stop failure isvisible without an unhandled rejection and the control remains retryable.+ The task header stays on one line. The expanded row shows the complete+ command above the output, preserving whitespace and wrapping to fit even+ before the task produces any output.An ended task keeps its row only for a short grace window and can be closedfrom the bar, so finished commands do not accumulate above the composer.- **Specs linked**: `03-runtime/03-tools-and-permissions.md` (§5),diff --git a/scripts/e2e-task-dock-tabs.mjs b/scripts/e2e-task-dock-tabs.mjsindex 07b2b86b6..fef8f715c 100644--- a/scripts/e2e-task-dock-tabs.mjs+++ b/scripts/e2e-task-dock-tabs.mjs@@ -20,7 +20,7 @@ try {"react-dom": join(root, "apps/desktop/node_modules/react-dom") },nodePaths: [join(root, "apps/desktop/node_modules")],});- const styles = await Promise.all(["tokens.css", "composer.css"].map((name) =>+ const styles = await Promise.all(["tokens.css", "base.css", "composer.css"].map((name) =>readFile(join(root, "apps/desktop/src/styles", name), "utf8")));await writeFile(join(temp, "styles.css"), styles.join("\n"));await writeFile(join(temp, "index.html"), `<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="default-src 'self'; style-src 'self' 'unsafe-inline'"><link rel="stylesheet" href="styles.css"></head><body><div id="root"></div><script src="renderer.js"></script></body></html>`);@@ -30,7 +30,7 @@ const { join } = require("node:path");app.setPath("userData", join(__dirname, "profile"));app.disableHardwareAcceleration();app.whenReady().then(async () => {- const win = new BrowserWindow({ show: false, webPreferences: {+ const win = new BrowserWindow({ show: false, width: 440, webPreferences: {sandbox: true, contextIsolation: true, nodeIntegration: false, backgroundThrottling: false } });try {await win.loadFile(join(__dirname, "index.html"));diff --git a/scripts/e2e/task-dock-tabs.tsx b/scripts/e2e/task-dock-tabs.tsxindex 9153bfb25..745f35129 100644--- a/scripts/e2e/task-dock-tabs.tsx+++ b/scripts/e2e/task-dock-tabs.tsx@@ -17,12 +17,13 @@ async function until(predicate: () => boolean, message: string) {await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()));}}+const command = `# ${"long-argument-".repeat(30)}\n sleep 60 # end of command`;let stops = 0;Object.defineProperty(window, "piDesktop", { value: {invoke: async (channel: string) => {let data: unknown;if (channel === IPC.invoke.backgroundTasksList) {- data = { tasks: [{ id: "task-1", sessionId: "fixture", command: "fixture-dev-server",+ data = { tasks: [{ id: "task-1", sessionId: "fixture", command,commandShellId: "bash", state: "running", elapsedMs: 1000 }], version: 1 };} else if (channel === IPC.invoke.backgroundTasksOutput) {data = { id: "task-1", state: "running", stdout: "fixture log output", stderr: "", truncated: false };@@ -68,10 +69,15 @@ async function probe() {const row = document.querySelector<HTMLElement>(".task-main");assert(row, "Task row missing");if (row.getAttribute("aria-expanded") !== "true") flushSync(() => row.click());+ const detail = document.querySelector<HTMLElement>(".task-command-detail");+ assert(detail?.textContent === command, "Expanded task must show its complete command");+ assert(detail.scrollWidth <= detail.clientWidth, "Long command must wrap within the panel");+ assert(getComputedStyle(detail).userSelect === "text", "Complete command must be selectable");await until(() => !!document.querySelector("pre")?.textContent?.includes("fixture log output"), "Log must load");select("Todo");assertPanel(true);assert(!document.querySelector("pre"), "Task log must not leak into Todo");+ assert(!document.querySelector(".task-command-detail"), "Command details must not leak into Todo");select("Background tasks");assertPanel(false);assert(document.querySelector("pre")?.textContent?.includes("fixture log output"), "Open log must survive switching");