Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

feat(composer): toggle background task output from the whole row

vastsad008073814aa
diff --git a/apps/desktop/src/components/BackgroundTasksBar.tsx b/apps/desktop/src/components/BackgroundTasksBar.tsx
index 16d838121..ace12f696 100644
--- a/apps/desktop/src/components/BackgroundTasksBar.tsx
+++ b/apps/desktop/src/components/BackgroundTasksBar.tsx
@@ -43,32 +43,52 @@ export function BackgroundTasksBar(): React.JSX.Element | null {
{tasks.map((task) => {
const isRunning = task.state === "running";
const stopping = stoppingIds.has(task.id);
+ const isExpanded = expandedId === task.id;
return (
<div
key={task.id}
className="background-task"
data-state={task.state}
+ data-expanded={isExpanded ? "true" : undefined}
>
- <span
- className="background-task-state"
- data-state={task.state}
- title={t(`backgroundTasks.${task.state}`)}
- />
- <span className="background-task-command" title={task.command}>
- {task.command}
- </span>
- <span className="background-task-meta">
- {t(`backgroundTasks.${task.state}`)}
- {isRunning ? ` · ${formatElapsed(task.elapsedMs)}` : ""}
- {task.exitCode !== undefined ? ` · ${task.exitCode}` : ""}
- </span>
+ {/* The row body toggles the log; the explicit action buttons keep
+ their own behavior and stay out of it. Kept as a div with a
+ button role so Enter / Space match the projection button. */}
+ <div
+ className="background-task-main"
+ role="button"
+ tabIndex={0}
+ aria-expanded={isExpanded}
+ onClick={() => void toggleOutput(task.id)}
+ onKeyDown={(event) => {
+ if (event.target !== event.currentTarget) return;
+ if (event.key === "Enter" || event.key === " ") {
+ event.preventDefault();
+ void toggleOutput(task.id);
+ }
+ }}
+ >
+ <span
+ className="background-task-state"
+ data-state={task.state}
+ title={t(`backgroundTasks.${task.state}`)}
+ />
+ <span className="background-task-command" title={task.command}>
+ {task.command}
+ </span>
+ <span className="background-task-meta">
+ {t(`backgroundTasks.${task.state}`)}
+ {isRunning ? ` · ${formatElapsed(task.elapsedMs)}` : ""}
+ {task.exitCode !== undefined ? ` · ${task.exitCode}` : ""}
+ </span>
+ </div>
<Button
type="button"
variant="ghost"
size="sm"
className="background-task-action"
onClick={() => void toggleOutput(task.id)}
- aria-expanded={expandedId === task.id}
+ aria-expanded={isExpanded}
>
{t("backgroundTasks.output")}
</Button>
@@ -94,7 +114,7 @@ export function BackgroundTasksBar(): React.JSX.Element | null {
{t("backgroundTasks.dismiss")}
</Button>
)}
- {expandedId === task.id ? (
+ {isExpanded ? (
<pre className="background-task-output">
{outputText || NO_OUTPUT}
</pre>
diff --git a/apps/desktop/src/styles/composer.css b/apps/desktop/src/styles/composer.css
index 04cd62fbd..e80887af4 100644
--- a/apps/desktop/src/styles/composer.css
+++ b/apps/desktop/src/styles/composer.css
@@ -1018,11 +1018,34 @@
align-items: center;
gap: 8px;
min-width: 0;
- padding: 6px 10px;
+ padding: 0;
color: var(--ds-text-secondary);
font-size: var(--text-sm);
}
+/* The row body opens the log; the action buttons sit outside it in the same
+ flex line, so the clickable area is everything except the controls. */
+.background-task-main {
+ display: flex;
+ flex: 1 1 auto;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: 8px;
+ min-width: 0;
+ padding: 6px 10px;
+ border-radius: var(--radius-sm);
+ cursor: pointer;
+}
+
+.background-task-main:focus-visible {
+ outline: 2px solid var(--ds-focus);
+ outline-offset: -2px;
+}
+
+.background-task[data-expanded="true"] .background-task-main {
+ color: var(--ds-text-primary);
+}
+
.background-task-error {
margin: 0;
padding: 6px 10px;
diff --git a/apps/desktop/test/background-tasks-bar-row-toggle.test.mjs b/apps/desktop/test/background-tasks-bar-row-toggle.test.mjs
new file mode 100644
index 000000000..e119fe494
--- /dev/null
+++ b/apps/desktop/test/background-tasks-bar-row-toggle.test.mjs
@@ -0,0 +1,58 @@
+import assert from "node:assert/strict";
+import { readFile } from "node:fs/promises";
+import test from "node:test";
+
+/*
+ * The row body of the background-tasks bar toggles the log, not only the
+ * "output" button: the clickable surface is the whole row lead (state dot,
+ * command, meta), while stop / dismiss keep their own behavior.
+ */
+
+const [bar, composerStyles] = await Promise.all([
+ readFile(new URL("../src/components/BackgroundTasksBar.tsx", import.meta.url), "utf8"),
+ readFile(new URL("../src/styles/composer.css", import.meta.url), "utf8"),
+]);
+
+test("the row body is an interactive element that toggles the log", () => {
+ const main = bar.match(
+ /<div\s+className="background-task-main"[\s\S]*?<\/div>/,
+ );
+ assert.ok(main, "row body element missing");
+ assert.match(main[0], /role="button"/);
+ assert.match(main[0], /tabIndex=\{0\}/);
+ assert.match(main[0], /aria-expanded=\{isExpanded\}/);
+ assert.match(main[0], /onClick=\{\(\) => void toggleOutput\(task\.id\)\}/);
+ // Keyboard parity with a real button.
+ assert.match(main[0], /event\.key === "Enter" \|\| event\.key === " "/);
+ assert.match(main[0], /if \(event\.target !== event\.currentTarget\) return;/);
+});
+
+test("the toggle surface covers the state dot, command and meta rows", () => {
+ const main = bar.match(
+ /<div\s+className="background-task-main"[\s\S]*?<\/div>/,
+ )[0];
+ for (const className of ["background-task-state", "background-task-command", "background-task-meta"]) {
+ assert.match(main, new RegExp(`className="${className}"`));
+ }
+});
+
+test("stop and dismiss stay outside the toggle surface", () => {
+ const toggleEnd = bar.indexOf('className="background-task-main"');
+ const stopAt = bar.indexOf('background-task-action is-stop"');
+ const dismissAt = bar.indexOf('onClick={() => dismiss(task.id)}');
+ assert.ok(stopAt > toggleEnd && dismissAt > toggleEnd);
+ // Exactly one projection button remains.
+ assert.equal(bar.match(/t\("backgroundTasks\.output"\)/g)?.length, 1);
+});
+
+test("the row styles keep the body clickable and focus-visible", () => {
+ assert.match(
+ composerStyles,
+ /\.background-task-main\s*\{[^{}]*flex: 1 1 auto/,
+ );
+ assert.match(composerStyles, /\.background-task-main\s*\{[^{}]*cursor: pointer/);
+ assert.match(
+ composerStyles,
+ /\.background-task-main:focus-visible\s*\{[^{}]*outline: 2px solid var\(--ds-focus\)/,
+ );
+});