Skip to content

feat(webui): rebuild the shell and shared primitives - #3537

Merged
inureyes merged 12 commits into
mainfrom
feature/issue-3520-webui-shell-primitives
Nov 28, 2026
Merged

inureyes merged 12 commits into
mainfrom
feature/issue-3520-webui-shell-primitives

Conversation

@inureyes

@inureyes inureyes commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

Summary

Rebuilds the WebUI shell and the shared primitives on the grammar of docs/webui/design-system.md (#3526). Screens keep their current layout inside the new shell until #3521 to #3524 move them.

  • Shell. A 200 px sidebar that collapses to a 64 px rail through ui-common SideNav collapsible, stored as sidebarCollapsed in the appearance preferences. A 52 px header that receives each route's title and actions from its PageHeader; actions that do not fit fold into one overflow menu. A 28 px status bar replaces the toolbar chips and TOOLBAR_CHIP_LIMIT. Below 1024 px the sidebar is the mobile navigation and the bar shows its one most important item, 44 px tall so it meets the hit-target floor. Chrome is glass in the glass family only.
  • Status bar. Running models, tokens per second and reachability, from the snapshot Activity already reads; no new endpoint. The server publishes no instantaneous rate (decode_rate is always unavailable), so the rate is the growth of its cumulative decode counters between two runtime samples. Without the metrics endpoint (--metrics) or the slots endpoint (on unless --no-slots) the bar shows reachability and running models only and says why on hover and focus. Each non-ready state (partial, empty, loading, stale, offline, error, unauthorized) has a recovery action and a data-testid. A model that starts is one status-bar item ("Preparing") plus one notification entry.
  • Primitives. Button and Field at the control height, neutral secondary pill, no hover lift, a feedback state (useButtonFeedback), one shared confirm hook (useConfirm), the fixed destructive and stop verbs (ActionButton). A sized Dialog with a pill-tab strip and body and footer slots. NoticeBanner, the inline error banner and a bottom-right toast stack (360 px, three at most). CountBadge, StatSummary, StatCardRow, Timestamp, DataTable row padding from the contract. One 64 px icon in the empty state, the 1.25 px icon stroke. Text fields change their border color on focus; every other control keeps the ring.
  • Drawer and Inspector stay exported from primitives.tsx. The gallery shows every primitive in its states. Strings are in English and Korean with the fixture. data-testid values keep their names; every spec that queried a renamed class is updated.

Dialog decision

Dialog stays on the native <dialog> and does not wrap ui-common Modal. Both were built behind the same props and run through the served-CSP check against a real mlxcel-server --webui --api-key ... on loopback (default-src 'self'; script-src 'self'; style-src 'self'; ...).

Check Native <dialog> ui-common Modal
securitypolicyviolation events, inserted <style> none, 0 none, 0
Element dialog, :modal, top layer, no style attribute div[role="dialog"], not in the top layer
expectSafeLayout passes fails: six elements carry library styles outside the allowlist, among them the scroll lock on <html> and <body>
Opened beside the open, still-exported Drawer (390 px run; at 1440 px the Modal case left the Drawer unable to close, which ended that run) paints above it, takes focus, traps Tab, one Escape closes only it does not paint above it, focus stays in the Drawer, Tab never enters it

The policy permits both, since every style either one writes goes through CSSOM. Modal sits below the top layer, and two confirmations render beside the Drawer they open from (the Models library's beside the inspector Drawer, Chat's delete beside the conversation-list Drawer), so those would be hidden and unreachable until #3525 removes Drawer. The decision and this table are in docs/webui/ui-common.md#dialog-decision.

JavaScript growth

Baseline This PR Growth Limit
Initial JS (gzip) 306,208 315,471 +9,263 bytes (9.0 KiB) 393,216
All JS (gzip) 456,569 470,813 +14,244 bytes (13.9 KiB) 716,800

The initial growth is the header, the status bar, the sized Dialog and the Tooltip that carries the status bar's reason. The toast stack is its own chunk, fetched when the first notice is posted.

Real-binary validation

Release mlxcel-server --webui --api-key ... -m <Qwen3 0.6B 4-bit checkpoint> --metrics --slots on loopback, serving this branch's bundle (the served index-*.js and index-*.css names match src/webui/assets/), driven by headless Chromium.

Viewport Cases (family x scheme x locale) Header Sidebar Status bar Page overflow
390 x 844 8: mlxcel and glass, light and dark, English and Korean 52 px mobile navigation 44 px, on the bottom edge 0 px
1024 x 768 8, the same 52 px 200 px 28 px, on the bottom edge 0 px
1440 x 900 8, the same 52 px 200 px 28 px, on the bottom edge 0 px

Sizes are getBoundingClientRect of AppShell's banner, AppShell's side navigation and the status bar. All 24 cases measured the same per viewport.

Step Status bar, as read from the page
Signed in 1 running, qwen3-0.6b-4bit Ready, Server reachable; state partial (no running model selected yet; the information control says so)
Running model opened from the bar adds tokens/s not yet measured; state ready
After one generation in Chat 216 tokens/s; state ready
Same session at 390 px 1 running, qwen3-0.6b-4bit Ready only
Korean, after a generation 1개 실행 중, qwen3-0.6b-4bit 준비됨, 216 tokens/s, 서버 응답 중
Server restarted without --metrics no rate; state partial; the control's tooltip reads "Metrics are off. Restart the server with --metrics."
Server restarted with --metrics --no-slots no rate; state partial; the tooltip reads "Slots are off. Restart the server with --slots."

Computed styles on the same binary: icon stroke-width 1.25 px with vector-effect: non-scaling-stroke; h1 17.5 px at weight 600; buttons and text fields 31.5 px tall (2.25 rem on the 14 px root); field radius 5.25 px; a focused text field changes its border from rgb(220, 220, 228) to rgb(139, 92, 246) with no ring; a focused button draws the 2 px ring in that color.

Screenshots of all 24 cases and of the live steps were captured locally. They are not embedded here because no image upload path is available from the CLI.

Deviations and open items

  • The theme cross-fade and the rise-in stay marked as targets in the contract, although the shell could own them. Every layout case runs axe on the first frame and the theme specs read colors in the frame after a switch, so they need assertion helpers that wait for motion first.
  • Tokens per second appears once a running model is selected, because the provider observes only the selected model and the bar never selects one. A fresh session rests in partial until then, the reason still reads "no running model is selected" until that model's first sample, and the unit reads "tokens/s" in Korean too. feat(webui): restyle Activity as a dashboard feeding the status bar #3523 owns the status bar content.
  • The header fold is all-or-nothing and holds buttons only: at 390 px the screens that have not moved yet keep New conversation and Add model behind More actions. Model pickers (Activity, Chat, Settings) are never folded; each is the first row of its route's content at every width.
  • Lifecycle copy (models.status.*) is unchanged; only the status bar's starting item reads "Preparing".
  • expectSafeLayout gained three entries for styles the newly adopted library components write through CSSOM (a Banner's action row, a toast's progress fill, the CountBadge offset). "No new inline style outside the allowlist" is measured against the list with those entries.

Changes during review

  • Below 1024 px, route actions in the header and its overflow menu (and Activity's model picker trigger) were under the 44 px hit-target floor; a compact rule fixes them and expectCompactToolbarHitTargets now measures them. Toast dismiss buttons get the same 44 px compact target, with a spec for the stack's width, position, count and targets.
  • Tests for the tokens-per-second derivation: counters that fall after a reload, tokens with no elapsed time, no growth, and a server restart clearing the history.
  • The Banner entry in the expectSafeLayout allowlist is narrowed to the Banner's action row.
  • The "Preparing" notice is posted only when its content changes, so a loading model no longer re-renders the toast stack on every catalog update. The header overflow trigger drops aria-haspopup (its panel is a group, not a menu). The gallery's Dialog demo uses the footer slot. The status bar's empty state documents why it offers no action on the Models route.
  • The served-CSP spec was re-run against a fresh release build of the reviewed head: 2 passed, and the served assets matched src/webui/assets/ by SHA-256.
  • The shell runs AppShell in fill mode: the main landmark is the only scroll container, between the header and the fixed status bar, so content never passes under the chrome (this fixed axe target-size failures on Linux at 390 px where a content control sat under a header control). The overflow assertions now measure the document, the shell box and main, and the shell-floor helper measures after two animation frames, because the header fold settles one frame after a route mounts.
  • Activity's model picker moved out of the header into the first row of its content, so it stays directly reachable at compact widths (the installed-artifact Activity performance script drives it at 700 px). Settings help buttons are 44 px below 1024 px.
  • Settings keeps its target selector mounted while signed in when the connection briefly leaves the live phase; only the sections that read the live server are replaced by the unavailable banner. A unit test covers it.

Values chosen where the contract gave none

Dialog widths 28, 40 and 60 rem; field radius md (0.375 rem); the header title as heading 3; the compact status bar at 44 px; six iterations of the lifecycle pulse; 1.6 s of button feedback; 6 s for the "is running" notice. All are written into docs/webui/design-system.md and need the owner's confirmation.

Test plan

  • webui/: typecheck, lint, check:theme-selectors, check:themes, check:agents, unit (811 tests), browser (136), browser:all (21)
  • python3 scripts/webui/build_bundle.py --verify, make verify-webui-contract, make verify-webui-rust, make verify-webui-integration-fake (the router harness)
  • Served-CSP spec (playwright.csp.config.ts) against the release binary above: 2 passed
  • Re-run on the final head: served-CSP spec 2 passed against a fresh release build (served index.html matches src/webui/assets/), make verify-webui-rust, make verify-webui-integration-fake
  • CI green except binary assets, which fails on main too since feat(models): add LiquidAI d1-omni (d1_omni) decision model #3533 (an undeclared audio fixture), independent of this PR

Closes #3520

The shell moves onto the grammar of docs/webui/design-system.md: a 200 px sidebar that collapses to a 64 px rail through ui-common SideNav's collapsible option (stored in the appearance preferences), a 52 px header that receives each route's title and actions from its PageHeader and folds actions that do not fit into one overflow menu, and a 28 px status bar that replaces the toolbar chips. The bar shows the running models, tokens per second and server reachability from the snapshot Activity already reads; the server publishes no instantaneous rate, so the rate is the growth of its cumulative decode counters between two runtime samples. Every non-ready state of the bar has a recovery action and a test id, and a model that starts is one status-bar item plus one notification entry.

The primitives follow: buttons and fields at the control height with the neutral secondary pill, a feedback state and one shared confirm hook, the fixed destructive and stop verbs, a sized Dialog with a tab strip and body and footer slots, notice banners and the toast stack, the count badge, stat summary, stat-card row and timestamps, the 64 px empty-state icon and the 1.25 px icon stroke. Text fields change their border color on focus; every other control keeps the ring. Dialog stays on the native element: under the served CSP both it and ui-common Modal raise no violation, but Modal is not in the top layer, so opened beside the still-exported native Drawer it does not paint above it or take focus, and it needs six more style-carrying elements in the safe-layout allowlist.

Drawer and Inspector stay exported for the screens that have not moved yet. Specs and unit tests are updated for every renamed class; test ids keep their values. Initial JavaScript grows by 9,023 bytes gzip (306,208 to 315,231).

Refs #3520
…g decision

docs/webui/design-system.md now states the shell geometry as built (sidebar and rail, header with the overflow menu, status bar and its compact form), the dialog sizes and slots, button feedback and the shared confirmation, the figure and timestamp primitives, and the notice rules. The Shell and localization section replaces the toolbar-chip text with the status bar: its three items, where their data comes from, how tokens per second is derived, and the recovery action and test id of every async state. The target markers for the icon stroke, the control height binding and the text-field focus are gone; the theme cross-fade and the rise-in stay marked as targets, with the reason.

docs/webui/ui-common.md records why Dialog stays on the native element, with the served-CSP comparison against ui-common Modal, and updates the adapter matrix, the bridges, the CSSOM allowlist and the seam list. The UX contract and both user guides describe the new layout.

Refs #3520
@inureyes inureyes added status:review Under review type:enhancement New features, capabilities, or significant additions priority:medium Medium priority labels Nov 28, 2026
…gaps

The compact override of the status bar height sat in styles.css, which app.css imports before tokens.css, so the base 28 px won and the bar rendered 46 px while everything that subtracts the token used 28. The override now lives in tokens.css after the base value, and the bar draws its hairline inside its box, so it is exactly 44 px below 1024 px. The shell's edge rules now outrank .material-glass, which had been framing the header, the sidebar and the bar on all four sides.

A dialog body that scrolls is now a keyboard stop (a named region when the dialog has no tabs), so it can be scrolled when nothing inside takes focus. A signed-in session whose catalog has not arrived reads as still being reached and keeps Retry, so the bar's loading state always has a recovery action. The document sets scroll-padding for the sticky header and the fixed bar.

The served-CSP spec waits for SideNav's rail motion, which holds an inert copy of the content area while it plays; found by running the spec against a preview build. The settings spec measures from the top of the page, since axe counts a control half under the sticky header as obscured.

Refs #3520
The user guides said tokens per second needs --metrics and --slots. The slots endpoint is on unless the server starts with --no-slots, which a run against the release binary confirmed: without --metrics the status bar's reason names metrics only, and with --no-slots it names slots. The design contract also records two status bar gaps left for #3523: the rate's unit is not localized, and the reason control reads as "no running model selected" until the selected model's first runtime sample arrives.

Refs #3520
Below 1024 px the route's actions live in the header, and at 390 px in its overflow menu, but only the header's icon buttons were raised to 44 px. Add Model, Rescan local roots, Refresh server state, New conversation, Refresh observations and Export sanitized diagnostics measured 31.5 px tall there, and the trigger of Activity's model picker 24 px, against the ux-contract rule that the header's controls are 44 px targets in the compact layout.

The compact rule now covers buttons and Select triggers inside the header actions, and expectCompactToolbarHitTargets measures them too; the fold spec asserts it with the menu open. With the rule reverted that spec fails at 31.5 px.

Also add unit cases for the tokens-per-second derivation: counters that fall (a model reloaded on the same server instance restarts its lifetime totals), tokens with no elapsed time, no growth, and a server restart clearing the history the rate is read from.

Refs #3520
The toast stack is new in this change, and below 1024 px a toast's dismiss button measured 28 by 28 px, under the 44 px compact hit-target floor in ux-contract.md. A compact rule in the toast adapter CSS now raises a toast's buttons to 44 px.

A shell spec now posts five toasts at 1440 and 390 px and asserts the stack is at most 360 px wide, flush right, above the status bar, shows three entries, and keeps its controls at 24 px and 44 px respectively. With the rule reverted it fails at 28 px.

Refs #3520
@inureyes

Copy link
Copy Markdown
Member Author

Implementation Review Summary

Intent

Rebuild the WebUI shell (200/64 px sidebar, 52 px header with overflow fold, 28 px status bar) and the shared primitives on the design-system contract, without migrating feature screens.

Findings Addressed

  • Route actions in the header and its overflow menu were 31.5 px tall below 1024 px (Activity's model picker trigger 24 px), against the 44 px compact floor the contract applies to header controls. Fixed in bd1ddb8; the fold spec now measures them with the menu open (HIGH)
  • A toast's dismiss button was 28 px below 1024 px. Fixed in 23f390a; a new shell spec checks the stack width, position, three-entry cap and target sizes at 1440 and 390 px (HIGH)
  • Tokens per second had no tests for falling counters (a provider reload on the same server instance), zero elapsed time or a server restart. Added in bd1ddb8 (MEDIUM)

Remaining Items

  • useConfirm, ActionButton, useButtonFeedback, NoticeBanner, CountBadge, StatSummary, StatCardRow and Timestamp are used only by the gallery. The issue keeps screen migration in feat(webui): move Models onto the list-page grammar with Run/Stop #3521 to feat(webui): rebuild Settings as one-setting rows with search #3524, so they are adopted there (MEDIUM)
  • The rate shows only for the selected model, so a fresh session rests in partial until a model is opened from the bar, Chat, Activity or Settings. Already listed as a deviation (MEDIUM)
  • empty has no action on the Models route itself, and partial's reason control is hidden below 1024 px, where the bar shows only the running models (LOW)
  • header-more sets aria-haspopup while its panel is a group, not a menu (LOW)
  • The Banner allowlist entry matches any div under .astryx-banner. It accepts custom properties only, so it stays safe, but it is broader than the action row it describes (LOW)
  • The PR body's counts are stale: unit is now 810 tests, browser 136, and gzip JS is 315,432 initial and 470,761 total (growth +9,224 and +14,192 bytes)

Verification

  • All stated requirements implemented (adoption of the new primitives by screens is deferred to feat(webui): move Models onto the list-page grammar with Run/Stop #3521 to feat(webui): rebuild Settings as one-setting rows with search #3524 by the issue)
  • No placeholder/mock code remaining
  • Integrated into project code flow: the shell, status bar, header fold, rail, Dialog, toasts and model-start notices are wired into the app. The eight primitives above are not yet used outside the gallery
  • Project conventions followed
  • Existing modules reused where applicable
  • No unintended structural changes
  • Tests pass: typecheck, lint, check:theme-selectors, check:themes, check:agents, unit (810), browser (136), browser:all (21), build_bundle.py --verify, make verify-webui-contract, make verify-webui-rust, make verify-webui-integration-fake. The served-CSP spec was not re-run: both fixes are stylesheet rules with no new style write, and it needs a release binary

expectSafeLayout admitted custom-property style writes on every div inside an Astryx Banner header in a notice or toast. Only the header's end area (the action row) receives the StyleX edge-compensation margins, so the allowlist now names that element alone: a style write on the title, description or icon wrapper fails the layout check again.

Validated with the shell spec and the served-CSP spec against a real secured server.
@inureyes

Copy link
Copy Markdown
Member Author

Security and performance review

No CRITICAL, HIGH or MEDIUM findings.

  • CSP: no inserted <style>, no innerHTML or dangerouslySetInnerHTML, no inline style in the new code. Against a real secured server the three new library CSSOM writes are custom properties only: the Banner action row (StyleX edge-compensation margins), the toast progress fill (--_progress-bar-*) and CountBadge's overlay (--count-badge-offset-*, px values). No cross-origin request.
  • Polling: the status bar adds no endpoint, timer or listener. It derives from the existing snapshot and the runtime history, which stays capped at 150 samples. Notices are keyed per model and at most three toasts show; auto-closing toasts dismiss through the store. Dialog and header-fold listeners are removed on cleanup.
  • Rendering: model names, reasons and server text reach the status bar, toasts and tooltips as React text children or title attributes, never as HTML.
  • Auth: the new code writes no token to storage, URLs or logs. The only new stored field is sidebarCollapsed in the appearance record.
  • Bundle: 308 KiB initial and 460 KiB total gzip (main is 299 and 446), under the 384/700 budgets. The toast stack is a lazy chunk.

Fixed in bb2cac5 (LOW, test only): the expectSafeLayout allowlist admitted custom-property writes on every div inside a notice or toast Banner header. It now covers only the header's last child, the action row, which a DOM probe confirmed is the one element Banner writes to.

Not fixed (LOW): while a model loads, every catalog update posts its "Preparing" notice again with the same content, so the toast stack re-renders once per catalog change.

Gates on the final head: typecheck, lint, unit (810 tests), theme and agent checks, build_bundle.py --verify, shell spec (21 passed), and the served-CSP spec (2 passed) against a fresh release build. The served index and its 12 assets matched the committed bundle byte for byte.

…ialog

The Preparing notice for a loading model was re-posted on every catalog update, rebuilding the notice array and re-rendering the toast stack each time. useModelStartNotices now remembers the posted title per model and posts only when it changes.

The header overflow trigger no longer sets aria-haspopup, since its panel is a group rather than a menu; aria-expanded, aria-controls and the Escape and focus behavior are unchanged. The gallery Dialog demo uses the Dialog footer slot instead of the old dialog-actions row. The design-system doc now states that the empty status-bar action is omitted on the Models route, which is already the recovery surface.

Validation: typecheck, lint, unit (811), theme and agents checks, build_bundle --verify, verify-webui-contract, and Playwright shell and browser specs (chromium, 50 passed).

Refs #3520
@inureyes inureyes added status:done Completed and removed status:review Under review labels Nov 28, 2026
Bilingual report covering the rebuilt WebUI shell, the status bar's counter-derived rate, the native Dialog decision, the header fold and the remaining gaps.
@inureyes
inureyes marked this pull request as ready for review November 28, 2026 20:24
The page scrolled under a sticky header that now holds route actions, so at some scroll offsets a content control sat half under a header control. axe target-size flagged the Settings request-defaults help button under the header's storage help button at 390 px in the CI engines spec; a scroll-offset sweep found four failing offsets. AppShell now runs in its fill mode: the main landmark is the one scroller between the header and the fixed status bar, so content never passes under chrome. Rules for the old sticky model are removed and Chat fills main. The settings spec's scroll-to-top workaround for the same overlap is removed, and the layout checks (expectSafeLayout, horizontalOverflow, the shell floor and the Activity fit test) now measure main as well as the document, so overflow inside the new scroller still fails them.

At compact widths the header folded Activity's model picker behind More actions, so activity-performance.mjs (700 px window) could not find the combobox. The picker scopes the page, so it is now the first row of the content at every width, like the Chat and Settings pickers; header actions are buttons only, and the dead header-Select rules are removed. Tabbing to the picker showed no focus ring, since the trigger is a button inside the Select box; the box now draws the ring.

Validation in a Linux container with the CI font packages: chromium suite 136 passed (three runs with two workers), engines spec chromium, firefox and webkit 17 passed, scroll sweep clean. typecheck, lint, unit (811), theme, agents, contract and bundle verify pass.

Refs #3520
The scoped Settings spec timed out on CI at 390 px clicking a model option: the option went unstable, a profile input intercepted the click, and the option never became visible again. Forcing one non-live connection phase (a visibilitychange dispatch) with the list open reproduces that signature deterministically: the Model and Server tabs replaced their whole panel with the unavailable banner whenever the connection left ready, streaming or polling, so the selector unmounted, the content moved up under the list, and the selector came back closed. While signed in, both tabs now keep the selector (and the Model tab its next-load profile) mounted and replace only the live sections with the banner. A unit test pins it and fails without the fix.

AppShell's fill mode clips its own box, so a header wider than the viewport never reached the document; a mutation at 195 px went unnoticed. The layout checks now measure the shell box too, and the shell floor reads a settled frame, since a route folds its header actions within its first frame. The Settings help buttons are 44 px targets below 1024 px.

Validation in a Linux container with the CI fonts: chromium suite 136 passed, shell and settings specs 56 passed over two repeats, engines spec 17 passed in chromium, firefox and webkit, scroll sweep clean; typecheck, lint, unit (812), theme, agents, contract and bundle verify pass.

Refs #3520
The report said the 390 px header fold hides Activity's model picker; the picker now stays in the content column with the Chat and Settings selectors, and only buttons fold.

Refs #3520
@inureyes
inureyes merged commit 8caaa3a into main Nov 28, 2026
32 of 33 checks passed
@inureyes
inureyes deleted the feature/issue-3520-webui-shell-primitives branch November 28, 2026 23:18
@inureyes inureyes added this to the 0.9 milestone Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority:medium Medium priority status:done Completed type:enhancement New features, capabilities, or significant additions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(webui): rebuild the shell and shared primitives

1 participant