Skip to content

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

fix(settings): size segmented controls to their content

vastsa45a73f276e1f
diff --git a/apps/desktop/src/styles/settings.css b/apps/desktop/src/styles/settings.css
index 0787181d1..1586edf72 100644
--- a/apps/desktop/src/styles/settings.css
+++ b/apps/desktop/src/styles/settings.css
@@ -1162,6 +1162,32 @@
justify-content: flex-end;
}
+/* Segmented choices size to their labels, not the field-column cap. Wrap the
+ control below the title, then wrap whole options if the pane is narrower. */
+.settings-row:has(> .settings-row-control > .settings-segment) {
+ flex-wrap: wrap;
+ gap: 8px 24px;
+}
+
+.settings-row:has(> .settings-row-control > .settings-segment) > .settings-row-copy {
+ flex-basis: max-content;
+}
+
+.settings-row-control:has(> .settings-segment) {
+ max-width: 100%;
+}
+
+.settings-row-control > .settings-segment {
+ width: max-content;
+ max-width: 100%;
+ flex-wrap: wrap;
+}
+
+.settings-row-control > .settings-segment > .settings-segment-item {
+ flex: 0 0 auto;
+ white-space: nowrap;
+}
+
/*
A toggle is 20 px tall, while the field metric (select triggers, text inputs)
resolves to ~38 px. Give the control column a matching minimum so toggle rows
diff --git a/apps/desktop/test/settings-responsive-layout.test.mjs b/apps/desktop/test/settings-responsive-layout.test.mjs
index ad7227c40..9242e001d 100644
--- a/apps/desktop/test/settings-responsive-layout.test.mjs
+++ b/apps/desktop/test/settings-responsive-layout.test.mjs
@@ -19,3 +19,26 @@ test("settings content follows the available window width", () => {
/\.settings-content-inner\s*\{[^}]*width:\s*min\(\s*100%\s*,\s*720px\s*\);/s,
);
});
+
+test("settings row segments size to content and wrap whole options instead of labels", () => {
+ assert.match(
+ globalStyles,
+ /\.settings-row:has\(> \.settings-row-control > \.settings-segment\)\s*\{[^}]*flex-wrap:\s*wrap;/s,
+ );
+ assert.match(
+ globalStyles,
+ /\.settings-row:has\(> \.settings-row-control > \.settings-segment\) > \.settings-row-copy\s*\{[^}]*flex-basis:\s*max-content;/s,
+ );
+ assert.match(
+ globalStyles,
+ /\.settings-row-control:has\(> \.settings-segment\)\s*\{[^}]*max-width:\s*100%;/s,
+ );
+ assert.match(
+ globalStyles,
+ /\.settings-row-control > \.settings-segment\s*\{[^}]*width:\s*max-content;[^}]*max-width:\s*100%;[^}]*flex-wrap:\s*wrap;/s,
+ );
+ assert.match(
+ globalStyles,
+ /\.settings-row-control > \.settings-segment > \.settings-segment-item\s*\{[^}]*flex:\s*0 0 auto;[^}]*white-space:\s*nowrap;/s,
+ );
+});
diff --git a/docs/spec/04-ux/06-settings-ia.md b/docs/spec/04-ux/06-settings-ia.md
index c07857e79..6fc5ff6bd 100644
--- a/docs/spec/04-ux/06-settings-ia.md
+++ b/docs/spec/04-ux/06-settings-ia.md
@@ -335,6 +335,10 @@ Settings is a **full-window page** that replaces the app sidebar + main chrome (
only, and are read at render time, so switching repaints the transcript
immediately. The deprecated `keepCommandsExpanded` boolean is no longer
exposed and is not read for rendering. Settings search indexes the row.
+ Settings-row segmented controls use content-sized options rather than the
+ standard 240px field-column cap. Labels stay on one line; when space is
+ insufficient, the control moves below the title and whole options wrap
+ within the available pane width without horizontal overflow.
- The **Command shell** row in Defaults uses the host-discovered catalog of native
PowerShell 5.1, PowerShell 7, cmd, Git Bash, and Bash with IDs
`windows-powershell`, `windows-pwsh`, `cmd`, `git-bash`, and
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index ced0b4975..433e758e5 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -17249,6 +17249,9 @@ plugin-form fixtures in an isolated temporary directory at runtime.
singleton segment, literal-final-item leaf selection, failure/denial/recovery,
retained-pane remounts, run rows keeping their details closed until opened, and
a legacy search reveal.
+ In AI settings, check the display selector in English and Simplified Chinese
+ at 800px, 1000px, and 1440px window widths with 100% and 150% font scales.
+ Select all three values and verify each remains visibly selected and saved.
- **Expected:** A turn renders exactly one process disclosure containing every
pre-answer row, leaving the final answer, assistant errors, stopped trailing
text and pending actions outside it; when no final answer text exists, the
@@ -17286,6 +17289,10 @@ plugin-form fixtures in an isolated temporary directory at runtime.
restart and an absent or unknown value resolves to Fully folded; saved
`showThinking` survives restart, and an absent value falls back to the legacy
`thinkingDisplayMode` (`compact` hides, `detailed`/unknown/absent shows).
+ The Settings selector grows to its labels beyond the standard 240px field
+ cap. Option labels remain single-line and unclipped; the control and whole
+ options wrap only as needed, preserving the title/help space and preventing
+ horizontal row overflow. Wide windows keep the title and control inline.
- **Validation scope for the 2026-09-20 change:** Nested disclosure and activity
group presentation only; precise item-level transcript search targeting is out
of scope and keeps the existing message-level search behavior.
@@ -17299,6 +17306,9 @@ plugin-form fixtures in an isolated temporary directory at runtime.
Settings row and search indexing, and
`apps/desktop/test/settings-roundtrip.test.mjs` covers normalization, write
validation and the fully-folded default.
+ `node scripts/e2e-settings-scroll.mjs` additionally exercises the mounted
+ Settings page's selector layout and settings-save path across both locales,
+ three window widths, and both font scales with isolated Electron state.
- **Specs:** 04-ux/06-settings-ia, 04-ux/08-component-spec,
04-ux/09-interaction-patterns; ADR turn-process-and-thinking-display.
diff --git a/scripts/e2e-settings-scroll.mjs b/scripts/e2e-settings-scroll.mjs
index f3cf78a98..38cf1219e 100644
--- a/scripts/e2e-settings-scroll.mjs
+++ b/scripts/e2e-settings-scroll.mjs
@@ -52,6 +52,17 @@ app.whenReady().then(async () => {
await win.loadFile(path.join(__dirname, "index.html"));
const result = await win.webContents.executeJavaScript("window.settingsScrollProbe()");
console.log("SETTINGS_SCROLL " + JSON.stringify(result));
+ const segments = [];
+ for (const width of [800, 1000, 1440]) {
+ win.setContentSize(width, 720);
+ for (const language of ["en", "zh-CN"]) {
+ for (const scale of [1, 1.5]) {
+ segments.push(await win.webContents.executeJavaScript(
+ "window.settingsSegmentProbe(" + JSON.stringify(language) + "," + scale + ")"));
+ }
+ }
+ }
+ console.log("SETTINGS_SEGMENTS " + JSON.stringify(segments));
app.exit(0);
} catch (error) { console.error(error); app.exit(1); }
});
@@ -68,4 +79,7 @@ app.whenReady().then(async () => {
const result = output.split(/\r?\n/).find((line) => line.startsWith("SETTINGS_SCROLL "));
assert(result, output);
console.log(result);
+ const segments = output.split(/\r?\n/).find((line) => line.startsWith("SETTINGS_SEGMENTS "));
+ assert(segments, output);
+ console.log(segments);
} finally { await rm(temp, { recursive: true, force: true }); }
diff --git a/scripts/e2e/settings-scroll.jsx b/scripts/e2e/settings-scroll.jsx
index ef55d6ca1..ced005878 100644
--- a/scripts/e2e/settings-scroll.jsx
+++ b/scripts/e2e/settings-scroll.jsx
@@ -92,6 +92,7 @@ await i18n.use(initReactI18next).init({
resources: {
en: { translation: flattenCatalog(catalogs.en) },
"pt-BR": { translation: flattenCatalog(catalogs["pt-BR"]) },
+ "zh-CN": { translation: flattenCatalog(catalogs["zh-CN"]) },
},
interpolation: { escapeValue: false },
});
@@ -377,3 +378,46 @@ window.settingsScrollProbe = async () => {
checks.push(await exerciseBrazilianPortuguese());
return { ok: true, checks };
};
+
+window.settingsSegmentProbe = async (language, fontScale) => {
+ settings = { ...settings, language };
+ flushSync(() => useAppStore.setState({ settings, settingsTab: "ai" }));
+ await i18n.changeLanguage(language);
+ document.documentElement.style.setProperty("--font-scale", String(fontScale));
+ await settle();
+
+ const group = [...document.querySelectorAll('[role="radiogroup"]')]
+ .find((node) => node.getAttribute("aria-label") === i18n.t("settings.transcriptDisplayMode"));
+ assert(group, "Transcript display selector must render in AI settings");
+ const row = group.closest(".settings-row");
+ const copy = row.querySelector(".settings-row-copy");
+ const buttons = [...group.querySelectorAll('[role="radio"]')];
+ assert(buttons.length === 3, "All transcript display choices must be visible");
+ for (const button of buttons) {
+ const text = document.createRange();
+ text.selectNodeContents(button);
+ const lines = new Set([...text.getClientRects()].map((rect) => Math.round(rect.top)));
+ assert(lines.size === 1, `${language}/${innerWidth}/${fontScale}: ${button.textContent} must stay on one line`);
+ assert(button.scrollWidth <= button.clientWidth + 1, "Option text must not be clipped");
+ }
+ const bounds = group.getBoundingClientRect();
+ const rowBounds = row.getBoundingClientRect();
+ assert(bounds.left >= rowBounds.left && bounds.right <= rowBounds.right + 1,
+ "Transcript display control must stay inside its row");
+ assert(row.scrollWidth <= row.clientWidth + 1, "The row must not overflow horizontally");
+ assert(copy.clientWidth > 0 && copy.scrollWidth <= copy.clientWidth + 1,
+ "The setting title and help control must retain their space");
+ if (innerWidth >= 1440) {
+ assert(bounds.width > 240, "Long labels must grow beyond the old 240px control cap");
+ assert(bounds.top < copy.getBoundingClientRect().bottom, "Wide rows must retain the inline title/control layout");
+ }
+
+ for (const [index, value] of ["flat", "command-first", "fully-folded"].entries()) {
+ flushSync(() => buttons[index].click());
+ await settle();
+ assert(settings.transcriptDisplayMode === value, "The selected display mode must persist through settings IPC");
+ assert(buttons[index].getAttribute("aria-checked") === "true", "The saved display mode must be visibly selected");
+ }
+ return { language, fontScale, width: innerWidth, controlWidth: bounds.width,
+ optionRows: new Set(buttons.map((button) => Math.round(button.getBoundingClientRect().top))).size };
+};