graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
Compact the reasoning effort popover (#1164)
Rach Pradhanf63fbc56c7ba
diff --git a/.github/workflows/desktop.yml b/.github/workflows/desktop.ymlindex bd21afc3..f22e5e55 100644--- a/.github/workflows/desktop.yml+++ b/.github/workflows/desktop.yml@@ -37,6 +37,8 @@ jobs:bun run test:webauthn- run: bun run build- run: bunx playwright install chromium+ - name: Compact reasoning effort control+ run: node scripts/test-motion.mjs "$PWD" ../../zig-out/motion/effort-picker --effort-only- run: bun run test:queue- run: bun run test:turns- run: bun run test:tab-dragdiff --git a/apps/native/components/primitives/EffortPicker.module.css b/apps/native/components/primitives/EffortPicker.module.cssindex 81e2963a..cbba3254 100644--- a/apps/native/components/primitives/EffortPicker.module.css+++ b/apps/native/components/primitives/EffortPicker.module.css@@ -1,11 +1,11 @@.slider {position: relative;- height: 40px;- margin-top: 20px;+ height: 20px;+ margin-top: 6px;}.track {position: absolute;- inset: 4px 0;+ inset: 2px 0;overflow: hidden;border-radius: 999px;background: color-mix(in srgb, var(--ink) 10%, var(--page));@@ -18,13 +18,13 @@}.stops {position: absolute;- inset: 0 20px;+ inset: 0 10px;}.stop {position: absolute;top: 50%;- width: 5px;- height: 5px;+ width: 3px;+ height: 3px;border-radius: 50%;background: color-mix(in srgb, var(--ink) 24%, transparent);transform: translate(-50%, -50%);@@ -37,19 +37,19 @@inset: 0;margin: 0;width: 100%;- height: 40px;+ height: 20px;background: transparent;cursor: pointer;outline: none;border-radius: 999px;}-.range::-webkit-slider-runnable-track { height: 40px; background: transparent; }-.range::-moz-range-track { height: 40px; background: transparent; }+.range::-webkit-slider-runnable-track { height: 20px; background: transparent; }+.range::-moz-range-track { height: 20px; background: transparent; }.range::-webkit-slider-thumb {appearance: none;-webkit-appearance: none;- width: 40px;- height: 40px;+ width: 20px;+ height: 20px;border-radius: 50%;background: #fff;border: 1px solid rgb(0 0 0 / 10%);@@ -57,8 +57,8 @@}.range::-moz-range-thumb {box-sizing: border-box;- width: 40px;- height: 40px;+ width: 20px;+ height: 20px;border-radius: 50%;background: #fff;border: 1px solid rgb(0 0 0 / 10%);diff --git a/apps/native/components/primitives/ModelEffortButtons.tsx b/apps/native/components/primitives/ModelEffortButtons.tsxindex 095292cc..b2dc2a76 100644--- a/apps/native/components/primitives/ModelEffortButtons.tsx+++ b/apps/native/components/primitives/ModelEffortButtons.tsx@@ -5,6 +5,8 @@ import type { ModelChoice } from "@/lib/acp-client";import styles from "./EffortPicker.module.css";import ContextMeter from "./ContextMeter";const labels: Record<string, string> = { low: "Light", medium: "Medium", high: "High", xhigh: "Extra high", max: "Max", ultra: "Ultra" };+const effortPanelWidth = 200;+const effortPanelMargin = 12;function Bolt({ filled = false }: { filled?: boolean }) {return <svg aria-hidden="true" width="20" height="20" viewBox="0 0 24 24" fill={filled ? "currentColor" : "none"} stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round"><path d="m13.3 2-9 12h7L10.7 22l9-12h-7L13.3 2Z" /></svg>;}@@ -29,7 +31,7 @@ export default function ModelEffortButtons({ model, buttonRef, modelOpen, openMoconst index = Math.max(0, levels.indexOf(model.effort ?? "medium"));const show = () => {const rect = effortButton.current?.getBoundingClientRect();- if (rect) setPosition({ left: Math.max(12, Math.min(window.innerWidth - 332, rect.right - 320)), bottom: window.innerHeight - rect.top + 10 });+ if (rect) setPosition({ left: Math.max(effortPanelMargin, Math.min(window.innerWidth - effortPanelWidth - effortPanelMargin, rect.right - effortPanelWidth)), bottom: window.innerHeight - rect.top + 10 });if (modelOpen) openModel();setDraft(index); setOpen(true);};@@ -65,18 +67,18 @@ export default function ModelEffortButtons({ model, buttonRef, modelOpen, openMo{levels.length > 0 && <button ref={effortButton} type="button" aria-label="Select effort" aria-expanded={open} onClick={show}className="flex h-7 shrink-0 items-center gap-1.5 rounded-full px-2 text-xs text-ink-3 hover:bg-hover">{labels[model.effort ?? ""] ?? "Effort"}<Chevron /></button>}{showContextMeter && <ContextMeter reading={contextMeter} />}- {open && createPortal(<div ref={panel} role="dialog" aria-label="Reasoning effort" style={position}- className="motion-surface fixed z-[100] w-80 max-w-[calc(100vw-24px)] rounded-[22px] border border-line bg-page px-4 pb-4 pt-3 text-ink shadow-[0_8px_24px_-8px_rgb(0_0_0/18%)]">- <div className="flex items-center justify-between gap-3">+ {open && createPortal(<div ref={panel} role="dialog" aria-label="Reasoning effort" style={{ ...position, width: effortPanelWidth }}+ className="motion-surface fixed z-[100] max-w-[calc(100vw-24px)] rounded-window border border-line bg-page px-2 pb-[7px] pt-1.5 text-ink shadow-[0_8px_24px_-8px_rgb(0_0_0/18%)]">+ <div className="flex h-[25px] items-center justify-between gap-1.5"><button type="button" aria-label="Fast mode" aria-pressed={!!model.fast} disabled={blocked || !model.fastSupported}title={model.fastSupported ? "Priority service for lower latency; may use more of your allowance" : "Fast mode is available for Codex models"}onClick={() => void change(`/fast ${model.fast ? "off" : "on"}`)}- className={`flex size-8 shrink-0 items-center justify-center rounded-[10px] transition-colors disabled:opacity-30 ${model.fast ? "bg-accent-tint text-accent" : "text-ink-3 hover:bg-hover"}`}><Bolt filled={!!model.fast} /></button>- <div className="min-w-0 text-center"><div className="text-[17px] font-medium leading-6 text-accent">{labels[levels[draft]] ?? levels[draft]}</div><div className="mt-0.5 truncate text-[13px] leading-5 text-ink-3">{saving ? <span role="status">Saving…</span> : displayName}</div></div>- <button type="button" aria-label="Reset effort to medium" title="Reset effort to medium" disabled={blocked || !levels.includes("medium")} onClick={() => { setDraft(levels.indexOf("medium")); void change("/effort medium"); }} className="flex size-8 shrink-0 items-center justify-center rounded-lg text-ink-3 hover:bg-hover disabled:opacity-30"><svg aria-hidden="true" width="19" height="19" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round"><path d="M4 10a8 8 0 1 1 0 5M4 4v6h6" /></svg></button>+ className={`flex size-5 shrink-0 items-center justify-center rounded-full transition-colors disabled:opacity-30 [&_svg]:size-3.5 ${model.fast ? "bg-accent-tint text-accent" : "text-ink-3 hover:bg-hover"}`}><Bolt filled={!!model.fast} /></button>+ <div className="min-w-0 text-center"><div className="text-xs font-medium leading-3 text-accent">{labels[levels[draft]] ?? levels[draft]}</div><div className="mt-px truncate text-[9px] leading-2.5 text-ink-3">{saving ? <span role="status">Saving…</span> : displayName}</div></div>+ <button type="button" aria-label="Reset effort to medium" title="Reset effort to medium" disabled={blocked || !levels.includes("medium")} onClick={() => { setDraft(levels.indexOf("medium")); void change("/effort medium"); }} className="flex size-5 shrink-0 items-center justify-center rounded-full text-ink-3 hover:bg-hover disabled:opacity-30 [&_svg]:size-3.5"><svg aria-hidden="true" width="19" height="19" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round"><path d="M4 10a8 8 0 1 1 0 5M4 4v6h6" /></svg></button></div><div className={styles.slider}>- <div aria-hidden="true" className={styles.track}><div className={styles.fill} style={{ width: draft === 0 ? 0 : `calc(20px + (100% - 40px) * ${progress})` }} /></div>+ <div aria-hidden="true" className={styles.track}><div className={styles.fill} style={{ width: draft === 0 ? 0 : `calc(10px + (100% - 20px) * ${progress})` }} /></div><div aria-hidden="true" className={styles.stops}>{levels.map((level, i) => <span key={level} className={`${styles.stop} ${i < draft ? styles.passed : ""}`} style={{ left: `${i / Math.max(1, levels.length - 1) * 100}%` }} />)}</div><input type="range" aria-label="Reasoning effort level" aria-valuetext={labels[levels[draft]] ?? levels[draft]} min={0} max={Math.max(0, levels.length - 1)} step={1} value={draft} disabled={blocked}onChange={event => setDraft(Number(event.target.value))} onPointerUp={apply} onKeyUp={apply}diff --git a/apps/native/lib/effort-picker-size.test.ts b/apps/native/lib/effort-picker-size.test.tsnew file mode 100644index 00000000..a51b4761--- /dev/null+++ b/apps/native/lib/effort-picker-size.test.ts@@ -0,0 +1,15 @@+import { readFileSync } from "node:fs";+import { join } from "node:path";+import { expect, test } from "bun:test";++const component = readFileSync(join(import.meta.dir, "../components/primitives/ModelEffortButtons.tsx"), "utf8");+const styles = readFileSync(join(import.meta.dir, "../components/primitives/EffortPicker.module.css"), "utf8");++test("reasoning effort popover keeps the selected compact dimensions", () => {+ expect(component).toContain("const effortPanelWidth = 200;");+ expect(component).toContain("width: effortPanelWidth");+ expect(component).toContain("calc(10px + (100% - 20px)");+ expect(styles).toMatch(/\.slider\s*\{[^}]*height: 20px;[^}]*margin-top: 6px;/s);+ expect(styles).toMatch(/\.range::-webkit-slider-thumb\s*\{[^}]*width: 20px;[^}]*height: 20px;/s);+ expect(styles).toMatch(/\.range::-moz-range-thumb\s*\{[^}]*width: 20px;[^}]*height: 20px;/s);+});diff --git a/apps/native/scripts/test-motion.mjs b/apps/native/scripts/test-motion.mjsindex 1d6ac8c7..ce3f102a 100644--- a/apps/native/scripts/test-motion.mjs+++ b/apps/native/scripts/test-motion.mjs@@ -1,5 +1,5 @@// Headless production motion checks. Never opens or focuses a native window.-// Usage: node scripts/test-motion.mjs /absolute/app/root /absolute/output+// Usage: node scripts/test-motion.mjs /absolute/app/root /absolute/output [--effort-only]import { spawn } from 'node:child_process';import fs from 'node:fs';import path from 'node:path';@@ -14,6 +14,7 @@ const { installGalleryFixture } = require('../electron/gallery-fixture.cjs');const { installMotionFixture } = require('../electron/motion-fixture.cjs');const root = path.resolve(process.argv[2] || path.join(path.dirname(fileURLToPath(import.meta.url)), '..'));const output = path.resolve(process.argv[3] || path.join(root, '../../zig-out/motion/current'));+const effortOnly = process.argv.includes('--effort-only');const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));let server, browser, context, page, video, complete = false, finishing = false;assert.ok(fs.existsSync(chromium.executablePath()), 'Install the Playwright Chromium runtime before running headless checks');@@ -77,6 +78,7 @@ try {runtime: { chromium: browser.version(), headless: true }, checks: [],note: 'Headless Chromium, production build, fresh context, synthetic API responses and blocked API/network escape. Visibility checks dispatch synthetic document events; they do not verify native window throttling. Layout counters are observations, not a tight timing threshold.' };const passed = name => { report.checks.push(name); console.log('Motion:', name); };+ checks: {await page.goto(origin);await wait(`!!document.querySelector('textarea[aria-label="Prompt"]') && document.querySelector('[aria-label="Choose model"]')?.textContent.includes('Graff')`);await js(`window.motionEvents=[];for(const type of ['keydown','mouseover','focusin'])document.addEventListener(type,event=>{window.motionEvents.push({type,key:event.key,row:event.target.closest?.('[data-motion-row]')?.dataset.motionRow,label:event.target.getAttribute?.('aria-label')});if(window.motionEvents.length>30)window.motionEvents.shift()},true)`);@@ -151,11 +153,17 @@ try {for (let repeat = 0; repeat < 2; repeat++) {await click('[aria-label="Select effort"]');await wait(`!!document.querySelector('[aria-label="Reasoning effort"]')`);+ await page.locator('[aria-label="Reasoning effort"]').evaluate(async element => { await Promise.all(element.getAnimations().map(animation => animation.finished)); });+ if (repeat === 0) {+ const renderedSize = await js(`(()=>{const dialog=document.querySelector('[aria-label=\"Reasoning effort\"]');const range=document.querySelector('[aria-label=\"Reasoning effort level\"]');return {dialogWidth:Math.round(dialog.getBoundingClientRect().width),rangeHeight:Math.round(range.getBoundingClientRect().height)}})()`);+ assert.deepEqual(renderedSize, { dialogWidth: 200, rangeHeight: 20 }, 'The rendered effort control must keep the selected compact dimensions');+ }await key('Escape');await wait(`!document.querySelector('[aria-label="Reasoning effort"]')`);assert.equal(await js('document.activeElement.getAttribute("aria-label")'), 'Choose model');}- passed('effort menu Escape, focus restoration and reopening');+ passed('effort menu Escape, focus restoration, reopening and compact dimensions');+ if (effortOnly) break checks;// Extend a production entrance to test the visibility listener and CSS gate.// Headless documents cannot reproduce native minimize/occlusion behavior.@@ -247,6 +255,7 @@ try {await js("window.dispatchEvent(new CustomEvent('graff-desktop-action',{detail:'close'}))");await wait(`!document.querySelector('article') && !!document.querySelector('textarea[aria-label="Prompt"]')`);await sleep(700);+ }assert.deepEqual(unexpected, [], 'Motion checks must not call real APIs or external services');report.unexpectedRequests = unexpected;fs.writeFileSync(path.join(output, 'motion-headless-report.json'), JSON.stringify(report, null, 2));