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(desktop): give icon-only controls an explicit square geometry
ZeroYb2e073455ad5
diff --git a/apps/desktop/src/components/Sidebar.tsx b/apps/desktop/src/components/Sidebar.tsxindex dea5816b8..97c7ad97f 100644--- a/apps/desktop/src/components/Sidebar.tsx+++ b/apps/desktop/src/components/Sidebar.tsx@@ -2023,7 +2023,7 @@ export function Sidebar({<div className="sidebar-header-actions no-drag"><TooltipButtontype="button"- className="icon-btn"+ className="icon-btn icon-btn-square"tooltip={sidebarToggleShortcut? `${t("nav.collapseSidebar")} (${sidebarToggleShortcut})`diff --git a/apps/desktop/src/components/settings/ModelConfigPage.tsx b/apps/desktop/src/components/settings/ModelConfigPage.tsxindex 939c9dcab..30488287c 100644--- a/apps/desktop/src/components/settings/ModelConfigPage.tsx+++ b/apps/desktop/src/components/settings/ModelConfigPage.tsx@@ -518,7 +518,7 @@ export function ModelConfigPage() {{!ownedByPlugin ? (<TooltipButtontype="button"- className="icon-btn model-provider-icon-btn"+ className="icon-btn icon-btn-square model-provider-icon-btn"tooltip={t("settings.copyProvider")}ariaLabel={t("settings.copyProvider")}disabled={rowBusy}@@ -533,7 +533,7 @@ export function ModelConfigPage() {{ownedByPlugin && provider.authKind === "api_key" ? (<TooltipButtontype="button"- className="icon-btn model-provider-icon-btn"+ className="icon-btn icon-btn-square model-provider-icon-btn"tooltip={t("settings.pluginProviderKey")}ariaLabel={t("settings.pluginProviderKey")}disabled={rowBusy}@@ -547,7 +547,7 @@ export function ModelConfigPage() {) : null}<TooltipButtontype="button"- className="icon-btn model-provider-icon-btn"+ className="icon-btn icon-btn-square model-provider-icon-btn"tooltip={ownedByPlugin? t("settings.pluginProviderManaged", { plugin: ownedByPlugin })@@ -562,7 +562,7 @@ export function ModelConfigPage() {<TooltipButtontype="button"className={cx(- "icon-btn model-provider-icon-btn",+ "icon-btn icon-btn-square model-provider-icon-btn",testingId === provider.id && "is-testing",)}tooltip={t("settings.testConnection")}@@ -585,7 +585,7 @@ export function ModelConfigPage() {) : (<TooltipButtontype="button"- className="icon-btn model-provider-icon-btn is-danger"+ className="icon-btn icon-btn-square model-provider-icon-btn is-danger"tooltip={ownedByPlugin? t("settings.pluginProviderManaged", { plugin: ownedByPlugin })diff --git a/apps/desktop/src/components/workpanel/FilesTab.tsx b/apps/desktop/src/components/workpanel/FilesTab.tsxindex 695a99d72..582f34bb4 100644--- a/apps/desktop/src/components/workpanel/FilesTab.tsx+++ b/apps/desktop/src/components/workpanel/FilesTab.tsx@@ -321,7 +321,7 @@ export function FilesTab() {<div className="file-viewer-header"><TooltipButtontype="button"- className="icon-btn"+ className="icon-btn icon-btn-square"tooltip={t("panel.files.back")}ariaLabel={t("panel.files.back")}onClick={() => {@@ -337,7 +337,7 @@ export function FilesTab() {{file && <span className="file-viewer-size">{formatSize(file.size)}</span>}<TooltipButtontype="button"- className="icon-btn"+ className="icon-btn icon-btn-square"tooltip={t("panel.files.reveal")}ariaLabel={t("panel.files.reveal")}onClick={() => void api.fsReveal(selected)}diff --git a/apps/desktop/src/features/chat/composer/ComposerToolbar.tsx b/apps/desktop/src/features/chat/composer/ComposerToolbar.tsxindex a31139b7a..d2c899052 100644--- a/apps/desktop/src/features/chat/composer/ComposerToolbar.tsx+++ b/apps/desktop/src/features/chat/composer/ComposerToolbar.tsx@@ -108,7 +108,7 @@ export function ComposerToolbar({<div className="composer-plus"><TooltipButtontype="button"- className="icon-btn"+ className="icon-btn icon-btn-square"tooltip={t("chat.addFiles")}ariaLabel={t("chat.addFiles")}disabled={controlsBlocked || pasting}@@ -245,7 +245,7 @@ export function ComposerToolbar({/><TooltipButtontype="button"- className={`icon-btn composer-enhance-btn${enhancingPrompt ? " is-loading" : ""}`}+ className={`icon-btn icon-btn-square composer-enhance-btn${enhancingPrompt ? " is-loading" : ""}`}tooltip={t("chat.enhancePrompt")}ariaLabel={enhancingPrompt ? t("chat.enhancingPrompt") : t("chat.enhancePrompt")}aria-busy={enhancingPrompt}@@ -270,7 +270,7 @@ export function ComposerToolbar({{enhancementUndoText !== null ? (<TooltipButtontype="button"- className="icon-btn composer-enhance-undo"+ className="icon-btn icon-btn-square composer-enhance-undo"tooltip={t("chat.undoEnhancement")}ariaLabel={t("chat.undoEnhancement")}disabled={controlsBlocked}diff --git a/apps/desktop/src/pages/PullRequestsPage.tsx b/apps/desktop/src/pages/PullRequestsPage.tsxindex 2d6161cca..ad96c7723 100644--- a/apps/desktop/src/pages/PullRequestsPage.tsx+++ b/apps/desktop/src/pages/PullRequestsPage.tsx@@ -158,7 +158,7 @@ export function PullRequestsPage() {<div className="dest-row-actions"><TooltipButtontype="button"- className="icon-btn"+ className="icon-btn icon-btn-square"tooltip={t("pulls.open")}ariaLabel={t("pulls.open")}onClick={() => void api.browserOpenExternal(pr.url)}diff --git a/apps/desktop/src/styles/composer.css b/apps/desktop/src/styles/composer.cssindex d014fdf5f..50055379c 100644--- a/apps/desktop/src/styles/composer.css+++ b/apps/desktop/src/styles/composer.css@@ -412,7 +412,11 @@min-width: 28px;}-.composer-enhance-btn.is-loading {+/* While enhancing, this control carries a label and leaves the square geometry+ its idle state gets from `.icon-btn-square`. */+.icon-btn.composer-enhance-btn.is-loading {+ width: auto;+ flex: 0 0 auto;cursor: wait;padding-inline: 8px;}diff --git a/apps/desktop/src/styles/theme-overrides.css b/apps/desktop/src/styles/theme-overrides.cssindex afe5a46f1..e3df496ed 100644--- a/apps/desktop/src/styles/theme-overrides.css+++ b/apps/desktop/src/styles/theme-overrides.css@@ -268,9 +268,11 @@color: var(--ds-text-secondary) !important;}+/* Tone and truncation only. The label-driven chip sets its own padding with+ `!important`, so the inline padding that used to sit here only ever widened+ the icon-only controls in this row. */.composer-right .icon-btn {max-width: 220px;- padding: 0 10px;color: var(--ds-text-secondary);font-size: var(--text-sm);}diff --git a/apps/desktop/src/styles/tokens.css b/apps/desktop/src/styles/tokens.cssindex f03f4523d..fa0a47f7d 100644--- a/apps/desktop/src/styles/tokens.css+++ b/apps/desktop/src/styles/tokens.css@@ -156,6 +156,9 @@* surface tone from the window top edge down. */--ds-settings-nav-width: 275px;--ds-toolbar-height: 46px;+ /* Square icon-only control. `.icon-btn` takes its width from its label, so an+ icon-only use pins both axes to this token instead. */+ --ds-control-size: 28px;/* Work-panel controls share these geometry tokens so the header's safe lanecannot drift away from the viewport-fixed toggle. */--ds-work-panel-toggle-size: 28px;diff --git a/apps/desktop/src/styles/ui-kit.css b/apps/desktop/src/styles/ui-kit.cssindex 8685b16cd..ddda1ba73 100644--- a/apps/desktop/src/styles/ui-kit.css+++ b/apps/desktop/src/styles/ui-kit.css@@ -105,6 +105,19 @@color: var(--ds-text-primary);}+/* Icon-only control geometry. `.icon-btn` (styles/composer.css) is shared with+ label-driven pills and takes its width from its content — glyph plus padding+ — so an icon-only use states the square instead: both axes pinned to the same+ token, `flex: 0 0` so a crowded toolbar row cannot shrink it back out of+ square, and no side padding, which under the global `border-box` would+ otherwise leave a 12px content box for a 15px glyph. */+.icon-btn.icon-btn-square {+ width: var(--ds-control-size);+ height: var(--ds-control-size);+ flex: 0 0 var(--ds-control-size);+ padding: 0;+}+.badge {display: inline-flex;align-items: center;diff --git a/apps/desktop/test/icon-button-square.test.mjs b/apps/desktop/test/icon-button-square.test.mjsnew file mode 100644index 000000000..cea27286d--- /dev/null+++ b/apps/desktop/test/icon-button-square.test.mjs@@ -0,0 +1,90 @@+/**+ * Icon-only control geometry.+ *+ * `.icon-btn` is shared with label-driven pills, so its width comes from its+ * content — glyph plus padding — and an icon-only use must state the square+ * explicitly (`.icon-btn-square`). These are source contracts; the layout E2E+ * measures the rendered rectangles.+ */+import assert from "node:assert/strict";+import { readFile } from "node:fs/promises";+import test from "node:test";+import { loadStyles } from "./helpers/styles.mjs";++const styles = await loadStyles();++/**+ * Files that host icon-only `.icon-btn` controls. Every `.icon-btn` line in+ * them is either icon-only (and therefore square) or a label-driven chip. Add a+ * file here when it starts using `.icon-btn` for an icon-only control.+ */+const ICON_BUTTON_FILES = [+ "../src/components/Sidebar.tsx",+ "../src/features/chat/composer/ComposerToolbar.tsx",+ "../src/components/workpanel/FilesTab.tsx",+ "../src/pages/PullRequestsPage.tsx",+ "../src/components/settings/ModelConfigPage.tsx",+];++/** Label-driven controls: their width is their text, not a square target. */+const CHIP_CLASSES = /mode-chip|composer-model-thinking-chip/;++async function readSources() {+ return Promise.all(+ ICON_BUTTON_FILES.map(async (path) => [+ path,+ await readFile(new URL(path, import.meta.url), "utf8"),+ ]),+ );+}++const squareRule = () =>+ styles.match(/\.icon-btn\.icon-btn-square\s*\{[^}]*\}/)?.[0] ?? "";++test("the square variant pins both axes and drops the label padding", () => {+ assert.match(styles, /--ds-control-size:\s*28px/);+ const rule = squareRule();+ assert.ok(rule, ".icon-btn.icon-btn-square rule is missing");+ assert.match(rule, /width:\s*var\(--ds-control-size\);/);+ assert.match(rule, /height:\s*var\(--ds-control-size\);/);+ // A crowded toolbar row must not shrink the control back out of square.+ assert.match(rule, /flex:\s*0 0 var\(--ds-control-size\);/);+ // Under the global `border-box`, keeping the 8px side padding would leave a+ // 12px content box for a 15px glyph.+ assert.match(rule, /padding:\s*0;/);+});++test("composer-right no longer widens its icon-only controls", () => {+ const rule =+ styles.match(/\.composer-right \.icon-btn\s*\{[^}]*\}/)?.[0] ?? "";+ assert.ok(rule, ".composer-right .icon-btn rule is missing");+ assert.doesNotMatch(rule, /padding/);+});++test("the enhancing state leaves the square geometry for its label", () => {+ // It carries the label while enhancing, so it must outrank+ // `.icon-btn.icon-btn-square` — by classes in the selector, not `!important`.+ const rule =+ styles.match(+ /\.icon-btn\.composer-enhance-btn\.is-loading\s*\{[^}]*\}/,+ )?.[0] ?? "";+ assert.ok(rule, "the labelled enhancing state rule is missing");+ assert.match(rule, /flex:\s*0 0 auto;/);+ assert.match(rule, /padding-inline:\s*8px;/);+});++test("every icon-only .icon-btn states the square", async () => {+ for (const [path, source] of await readSources()) {+ const lines = source.split("\n");+ for (let index = 0; index < lines.length; index += 1) {+ const line = lines[index];+ if (!line.includes("icon-btn")) continue;+ if (CHIP_CLASSES.test(line)) continue;+ assert.match(+ line,+ /icon-btn-square/,+ `${path}:${index + 1} is an icon-only control without .icon-btn-square`,+ );+ }+ }+});diff --git a/apps/desktop/test/prompt-enhancement.test.mjs b/apps/desktop/test/prompt-enhancement.test.mjsindex f51b49a98..fc6101c1d 100644--- a/apps/desktop/test/prompt-enhancement.test.mjs+++ b/apps/desktop/test/prompt-enhancement.test.mjs@@ -38,7 +38,7 @@ test("Composer enables enhancement with inline file references and guards staleassert.match(composer, /!modelReady/);assert.match(composer,- /className=\{`icon-btn composer-enhance-btn/,+ /className=\{`icon-btn icon-btn-square composer-enhance-btn/,);assert.match(composer, /aria-busy=\{enhancingPrompt\}/);assert.match(composer, /className="tool-spinner"/);