Skip to content

armgit / qm

Public Imported from GitHub
0

Multiplayer agent harness for work.

Fix compact Fast mode toggle layout (#1045)

Joshua France87b0d7fc0648
diff --git a/plugins/web-ui/src/composer.ts b/plugins/web-ui/src/composer.ts
index 8619de53f..9a346637b 100644
--- a/plugins/web-ui/src/composer.ts
+++ b/plugins/web-ui/src/composer.ts
@@ -958,18 +958,18 @@ export function createComposerSurface(ctx: ConvCtx): ComposerSurface {
${
fastAvailable
? html`
- <button
- class="menu-option ${fastOn ? "active" : ""}"
- type="button"
- role="menuitemcheckbox"
- aria-checked=${fastOn ? "true" : "false"}
- @click=${() => toggleFastMode(agent)}
- >
- <span class="menu-option-copy">
- <span class="menu-option-label">${icon(Zap, 13)} Fast mode</span>
- </span>
- ${fastOn ? icon(Check, 15) : nothing}
- </button>
+ <div class="settings-seg">
+ <button
+ class="settings-chip settings-fast-toggle ${fastOn ? "active" : ""}"
+ type="button"
+ role="menuitemcheckbox"
+ aria-checked=${fastOn ? "true" : "false"}
+ @click=${() => toggleFastMode(agent)}
+ >
+ ${icon(Zap, 15)}
+ <span>Fast mode</span>
+ </button>
+ </div>
`
: nothing
}
diff --git a/plugins/web-ui/src/shell.css b/plugins/web-ui/src/shell.css
index 67e40a23d..ddc4546db 100644
--- a/plugins/web-ui/src/shell.css
+++ b/plugins/web-ui/src/shell.css
@@ -7512,6 +7512,16 @@ h3.ambient-field-label {
background: color-mix(in srgb, var(--primary, #6366f1) 8%, var(--background));
}
+.settings-fast-toggle {
+ display: inline-flex;
+ align-items: center;
+ gap: 5px;
+ white-space: nowrap;
+}
+.settings-fast-toggle.active .icon {
+ fill: currentColor;
+}
+
[data-qm-tooltip-anchor] {
anchor-name: --qm-tooltip-anchor;
}
diff --git a/plugins/web-ui/test/composer-fast-mode.test.ts b/plugins/web-ui/test/composer-fast-mode.test.ts
new file mode 100644
index 000000000..7edd79d91
--- /dev/null
+++ b/plugins/web-ui/test/composer-fast-mode.test.ts
@@ -0,0 +1,30 @@
+import assert from "node:assert/strict";
+import { readFileSync } from "node:fs";
+import test from "node:test";
+
+const composer = readFileSync(new URL("../src/composer.ts", import.meta.url), "utf8");
+const css = readFileSync(new URL("../src/shell.css", import.meta.url), "utf8");
+const settings = composer.slice(
+ composer.indexOf("function settingsControl("),
+ composer.indexOf("function menuControl("),
+);
+const fast = settings.slice(settings.indexOf("fastAvailable\n"));
+
+test("compact Fast mode uses a stateful icon-and-label chip without a trailing checkmark", () => {
+ assert.match(fast, /class="settings-chip settings-fast-toggle \$\{fastOn \? "active" : ""\}"/);
+ assert.match(fast, /role="menuitemcheckbox"/);
+ assert.match(fast, /aria-checked=\$\{fastOn \? "true" : "false"\}/);
+ assert.match(fast, /@click=\$\{\(\) => toggleFastMode\(agent\)\}/);
+ assert.match(fast, /icon\(Zap, 15\)/);
+ assert.match(fast, /<span>Fast mode<\/span>/);
+ assert.doesNotMatch(fast, /icon\(Check/);
+ assert.doesNotMatch(fast, /menu-option-copy|menu-option-label/);
+});
+
+test("the Fast mode icon and label stay aligned and the active icon is filled", () => {
+ const toggle = css.match(/\.settings-fast-toggle \{[^}]*\}/)?.[0] ?? "";
+ assert.match(toggle, /display: inline-flex;/);
+ assert.match(toggle, /align-items: center;/);
+ assert.match(toggle, /white-space: nowrap;/);
+ assert.match(css, /\.settings-fast-toggle\.active \.icon \{\s*fill: currentColor;\s*\}/);
+});