From 5b251e1f114e51559428d848ef9d39632dda2d0b Mon Sep 17 00:00:00 2001 From: Zach Kelling Date: Fri, 20 Nov 2026 19:15:04 -0800 Subject: [PATCH 1/2] ui 8.33.8: a word on Auto draws its title alone, so the composer's row never reads Auto Auto (hanzo-inc/app#460) Model, Effort and Mode read as their titles while on Auto; Auto is a checked option inside each list. A word chosen away from Auto reads its title and value. Claude-Session: https://claude.ai/code/session_015XYKLn69gF4x75RWePpDBV --- pkg/ui/package.json | 2 +- pkg/ui/src/chat/Tune.test.tsx | 42 +++++++++++++++++++++----- pkg/ui/src/chat/Tune.tsx | 25 ++++++++++++--- pkg/ui/src/models/ModelPicker.test.tsx | 7 +++++ pkg/ui/src/models/ModelPicker.tsx | 9 +++++- 5 files changed, 71 insertions(+), 14 deletions(-) diff --git a/pkg/ui/package.json b/pkg/ui/package.json index 74a7d0c9b..4e6131d80 100644 --- a/pkg/ui/package.json +++ b/pkg/ui/package.json @@ -1,6 +1,6 @@ { "name": "@hanzo/ui", - "version": "8.33.7", + "version": "8.33.8", "type": "module", "description": "Hanzo UI — the one canonical Hanzo component library, on @hanzo/gui + @hanzo/design. ONE substrate: every component renders through @hanzo/gui primitives, so the same import works on web, native (expo) and desktop (Tauri). Self-contained (theme.css), presentational, host-agnostic, clean-room.", "exports": { diff --git a/pkg/ui/src/chat/Tune.test.tsx b/pkg/ui/src/chat/Tune.test.tsx index abe12a6c7..e5dbd7474 100644 --- a/pkg/ui/src/chat/Tune.test.tsx +++ b/pkg/ui/src/chat/Tune.test.tsx @@ -115,13 +115,41 @@ describe('Tune', () => { expect(set).toHaveBeenCalledWith('auto') }) - it('titles each closed word with what it chooses, so two Autos never stand alone (hanzo-inc/app#313)', () => { + it('draws a word on Auto as its title alone, so two Autos never stand beside each other (hanzo-inc/app#460)', () => { const auto = [{ id: 'auto', label: 'Auto', note: 'Adaptive' }] mount( {}, items: auto }} mode={{ value: 'auto', set: () => {}, items: auto }} />) const text = (slot: string) => host.querySelector(`[data-slot="${slot}"]`)!.textContent - expect(text('model-picker')).toBe('ModelEnso') - expect(text('effort')).toBe('EffortAuto') - expect(text('mode')).toBe('ModeAuto') + expect(text('model-picker')).toBe('Model') + expect(text('effort')).toBe('Effort') + expect(text('mode')).toBe('Mode') + expect(host.textContent).not.toContain('Auto') + // The accessible name still says what is in force. + expect(label('Model')!.getAttribute('aria-label')).toBe('Model: Enso') + expect(host.querySelector('[data-slot="effort"]')!.getAttribute('aria-label')).toBe('Effort: Auto') + expect(host.querySelector('[data-slot="mode"]')!.getAttribute('aria-label')).toBe('Mode: Auto') + }) + + it('draws a word chosen away from Auto as its title and its value', () => { + const items = [ + { id: 'auto', label: 'Auto', note: 'Adaptive' }, + { id: 'high', label: 'High', note: 'Thinks longer' }, + ] + mount( {}, items }} mode={{ value: 'high', set: () => {}, items }} />) + const text = (slot: string) => host.querySelector(`[data-slot="${slot}"]`)!.textContent + expect(text('model-picker')).toBe('ModelThinker') + expect(text('effort')).toBe('EffortHigh') + expect(text('mode')).toBe('ModeHigh') + }) + + it('lists Auto as a checked option inside the Effort list', () => { + const items = [ + { id: 'auto', label: 'Auto', note: 'Adaptive' }, + { id: 'high', label: 'High', note: 'Thinks longer' }, + ] + mount( {}, items }} />) + act(() => host.querySelector('[data-slot="effort"]')!.click()) + const auto = [...document.querySelectorAll('[role="option"]')].find((o) => o.textContent?.startsWith('Auto'))! + expect(auto.getAttribute('aria-selected')).toBe('true') }) it('draws nothing where the surface has no model, no effort and no mode', () => { @@ -159,9 +187,9 @@ describe('Tune, effort and mode lists', () => { }) it('names the model from the catalog, with the catalog\'s own description in its tip', () => { - mount() - expect(label('Model')!.getAttribute('aria-label')).toBe('Model: Enso') - expect(host.textContent).toContain('Enso') + mount() + expect(label('Model')!.getAttribute('aria-label')).toBe('Model: Thinker') + expect(host.textContent).toContain('Thinker') }) it('leaves the mode list in the order it was given', () => { mount( {}, items }} />) diff --git a/pkg/ui/src/chat/Tune.tsx b/pkg/ui/src/chat/Tune.tsx index efe4562ef..f31a36025 100644 --- a/pkg/ui/src/chat/Tune.tsx +++ b/pkg/ui/src/chat/Tune.tsx @@ -12,6 +12,11 @@ * and add Plan. The chips are the surface's own: Chat's are the model families * the catalog lists, Dev's are the places a run reaches. * + * A word that is on Auto (the house router, the adaptive effort, the automatic + * mode) is drawn as its title alone, "Model", "Effort", "Mode": Auto is an option + * inside each list, checked there, and never a second "Auto" beside the first + * (hanzo-inc/app#460). One chosen away from Auto reads its title and its value. + * * Its words are the reader's language (@hanzo/i18n `t`): efforts and modes are * marked English (`phrase`), drawn through `t`; model names are the catalog's. */ @@ -22,13 +27,16 @@ import { forwardRef, useCallback, useRef, useState, type CSSProperties, type Rea import { Popover, PopoverContent, PopoverTrigger, Sheet, SheetContent, SheetTitle, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../backends/gui' import { slot } from '../backends/gui/slot' -import { grants, modelName, type ModelCatalogEntry, type PauseSource } from '../models/catalog' +import { ENSO, grants, modelName, type ModelCatalogEntry, type PauseSource } from '../models/catalog' import { ModelPicker } from '../models/ModelPicker' import { RING } from './look' import type { Way } from './ways' const STRONG = 'var(--border-strong)' as const +/** The id every short list gives its automatic way (ways.ts EFFORTS, a surface's modes). */ +const AUTO = 'auto' + // The composer lowers `--tap-target` to 24px (Composer.tsx `FLOOR`); the words under the frame are thumbs' targets, so on a phone they take it back to 44. // inline-style: a custom property, which no gui prop carries. const PHONE_FLOOR = { '--tap-target': '44px' } as CSSProperties @@ -82,7 +90,8 @@ const Word = forwardRef< HTMLElement, { category: string - children: ReactNode + /** The value in force; absent where the word is on Auto and the title stands alone. */ + children?: ReactNode label: string slotName: string open: boolean @@ -128,7 +137,11 @@ const Word = forwardRef< focusVisibleStyle={RING} $max-sm={{ minH: 44 }} > - {compact ? ( + {children == null ? ( + + {category} + + ) : compact ? ( {category} @@ -232,7 +245,8 @@ function Opens({ category: string hint: string label: string - word: ReactNode + /** The value in force, or null where the word is on Auto and only its title is drawn. */ + word: ReactNode | null slotName: string disabled?: boolean children: (close: () => void, compact: boolean) => ReactNode @@ -415,7 +429,7 @@ function Pick({ const now = modes.items.find((m) => m.id === modes.value) ?? modes.items[0] if (!now) return null return ( - + {(close, compact) => ( { expect(trigger.textContent).toBe('ModelEnso') }) + it('draws its title alone where it is bare, the model being the checked row of its list', async () => { + await mount( {}} />) + const trigger = host.querySelector('[data-slot="model-picker"]')! + expect(trigger.textContent).toBe('Model') + expect(trigger.getAttribute('aria-label')).toBe('Model: Enso') + }) + it('holds a model the catalog lacks by its id, read as words', async () => { await mount( {}} />) expect(host.querySelector('[data-slot="model-picker"]')!.textContent).toContain('Vendor Odd One') diff --git a/pkg/ui/src/models/ModelPicker.tsx b/pkg/ui/src/models/ModelPicker.tsx index fb590bba1..f97dafb0d 100644 --- a/pkg/ui/src/models/ModelPicker.tsx +++ b/pkg/ui/src/models/ModelPicker.tsx @@ -62,6 +62,8 @@ export interface ModelPickerProps { quiet?: boolean /** Stack the micro-label (`name`) cleanly above (or beside on narrow screens) the active model value. */ stacked?: boolean + /** With `stacked`: the model is the house default, so only the micro-label (`name`) is drawn; the model is the checked row in the list. */ + bare?: boolean size?: 'sm' | 'md' /** Absent, "Choose a model" in the reader's language. */ placeholder?: string @@ -98,6 +100,7 @@ export function ModelPicker({ disabled = false, quiet = false, stacked = false, + bare = false, size = 'md', placeholder, name: named, @@ -229,7 +232,11 @@ export function ModelPicker({ } }} > - {stacked ? ( + {stacked && bare ? ( + + {name} + + ) : stacked ? ( {name} From 3f7e531b17c21759cbcb8d9ecd774e996c502ade Mon Sep 17 00:00:00 2001 From: Zach Kelling Date: Fri, 20 Nov 2026 19:25:34 -0800 Subject: [PATCH 2/2] ui: the composer script holds a word on Auto to its title alone Claude-Session: https://claude.ai/code/session_015XYKLn69gF4x75RWePpDBV --- pkg/ui/scripts/composer.mjs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/ui/scripts/composer.mjs b/pkg/ui/scripts/composer.mjs index f0fd53268..8c27a5d12 100644 --- a/pkg/ui/scripts/composer.mjs +++ b/pkg/ui/scripts/composer.mjs @@ -237,10 +237,12 @@ for (const [width, height, ratio] of [ // Under the frame: labelled controls at least a word tall, a transparent edge and no fill at rest, at the text edge. check(m.words.some((w) => /^Effort: /.test(w.name)) && m.words.some((w) => /^Model: /.test(w.name)), `${name}: the model and the effort are words under the frame (${m.words.map((w) => w.name).join(', ')})`) if (kind === 'dev') check(m.words.filter((w) => /Where the run runs|Repository|Branch/.test(w.name)).length === 3, `${name}: the pills are words under the frame`) - // Closed, each one reads as what it chooses, its title before its value: never two bare "Auto"s side by side (hanzo-inc/app#313). + // Closed, each one reads as what it chooses: its title alone while it is on Auto, its title before its value once chosen away from it. + // Never two bare "Auto"s side by side (hanzo-inc/app#313), nor "Effort Auto" beside "Model Enso Auto" (#460). for (const w of m.words.filter((w) => /^(Model|Effort|Mode): /.test(w.name))) { const [title, value] = w.name.split(': ') - check(w.text.startsWith(title) && w.text.endsWith(value) && w.text !== value, `${name}: ${title} is titled on the row, not only its value ("${w.text}")`) + if (/\bAuto$/.test(value)) check(w.text === title, `${name}: ${title} on Auto is its title alone ("${w.text}")`) + else check(w.text.startsWith(title) && w.text.endsWith(value) && w.text !== value, `${name}: ${title} is titled on the row, not only its value ("${w.text}")`) } for (const w of m.words) { // Model, Effort and Mode are labelled controls (the label over the value); the pills and chips stay words.