Files
loki/scripts/test/ux-round-two.ts
CatoandClaude 5d057688a1 fix(ux): what the signed-in audit found first: a short message wraps, a field vanishes, pages slide on load (#1688)
* feat(fields): sixteen text boxes get the microphone; chatkit 0.25

Fleet experience standard, step 9. The experience audit counted 34 hand-made
text areas with no microphone; it now counts 17, and package-plan.json sets
the ceiling at today's counts so the number can only fall.

- @bitbaum/chatkit 0.22.1 -> 0.25.0. Composer behaviour and the class names
  Loki overrides are unchanged; LOKI_VOICE keeps the transcribe route's own
  sentence (showServerDetail), which names the fix.
- <TextArea> (components/ui/text-area.tsx): Loki's one adapter over chatkit's
  DictationField, drawn to match ui-input. Sixteen files use it. One file is
  exempt with its reason on its first line (URL paths, one per line).
- Field takes htmlFor, so its label names the control and a press on it
  focuses the field.
- A signed-out visitor's microphone is the browser's own recogniser
  (VISITOR_VOICE): the server leg answers 401 without a session, so on
  /change the mic recorded a whole take and then failed.
- The widget chat bundle budget goes 40 -> 41 KB: 41,414 -> 41,614 bytes
  gzipped, the two new dictation problems a person can act on.

The other seventeen wait for props the shared field gains in
bitbaum/chatkit#85 (autoFocus, onKeyDown, onBlur/onFocus, name, inputProps).

The stylesheet in this commit also carries the public-site rules of the
next one.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmsyW2aAn78GgfRxyn5

* feat(public): say it on the first screen; a shorter homepage; a header that stays

The way in
- The homepage's one action is the shared composer. What a signed-out
  visitor says is kept in the tab (lib/first-words), shown back on sign-up
  and handed to the new-project form at the end of onboarding or sign-in.
  With a sentence carried, onboarding does not ask for a project name, a
  folder and a GitHub address first.

The homepage
- 10.66 -> 7.48 phone screens at 390x844, 6.6 -> 5.11 at 1440x900.
- Three figures for the three steps, drawn in tokens (LoopFigure).
- Three problems on the homepage, all twelve on /why. Where it runs is one
  sentence and two links. The closing block is the shared FinalCta.
- One label for sign-up everywhere: Start a project.

Header, menu, footer
- The header was sticky in name only: .ui-public-surface was overflow:
  hidden, which made it the sticky container. overflow-x: clip.
- The phone menu takes focus, keeps Tab inside and hands focus back.
- The Product menu opens on a press, not on hover.
- Navigation and Sign in show from 1120px (was 1280px).
- A 2px focus ring, on the public surface and as the app-wide fallback.
- A skip link. Four footer groups instead of five.

Corners
- An unknown address outside the app drew the framework's bare 404 with no
  way back; the in-app one said Back to Today and went to Loki; the error
  page printed the raw error; the loading placeholder drew cards on pages
  that are rows. The share image leads with the headline.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmsyW2aAn78GgfRxyn5

* fix(ux): dates render once; rows say the part that matters; a person's words

- APP_LOCALE is a server variable, so a client component formatted dates in
  the default locale while the server used the configured one: a hydration
  error on /approvals with APP_LOCALE=de-CH. next.config.ts hands the same
  value to the browser as NEXT_PUBLIC_APP_LOCALE.
- Home's running rows lead with the live step. A phone row holds about
  thirty characters and every row read 'Next best step · Editing src/app/pa…'.
- The workbench's three rows on a phone were each cut before the words that
  say what the row is for.
- Terminal without cloud access, Home's first-run row and the widget row use
  the person's words (computer, Loki button), not ours (runner, widget).

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmsyW2aAn78GgfRxyn5

* docs(ux): the November UX pass, the public surface map, the changelog

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmsyW2aAn78GgfRxyn5

* feat(fields): the remaining text boxes get the microphone; chatkit 0.27

The second step of the fleet's experience standard for Loki. The shared
field gained what a form's text area needs in bitbaum/chatkit#85 (0.27.0):
autoFocus, onKeyDown, a submit key, a field-level blur, name, inputProps.
Sixteen more files move onto <TextArea>; the experience audit goes
bareTextareas 17 -> 1 and the ceiling in package-plan.json follows.

Kept, file by file: Cmd/Ctrl+Enter saves where Cmd+Enter did (goal and
person notes, project description, the idea step), Escape still cancels,
Enter still sends an interview answer and confirms a queued prompt, notes
still save when focus leaves the field, and an inline editor no longer
closes when its microphone is pressed. The studio's forms still read their
text by name from the native form. The scheduled job's prompt keeps the
mono face and spell-check off. ProjectBriefFill's separate Speak button is
the field's own microphone now (the same transcribe route).

Left: control/prompt-input.tsx, a prompt box with its own attachments and
paste-to-attach. It is a composer, not a form field.

Checked: tsc, lint, the design gate, file inputs, 599 unit-test files; in a
browser, autofocus, both submit keys, Escape, save on blur and not on the
microphone, 44px microphone and 16px text at 390, and the chat and Home
composers after the bump.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmsyW2aAn78GgfRxyn5

* test: a git fixture cannot reach the real repository from a hook in a linked worktree

A hook run from a linked worktree exports an absolute GIT_DIR, which
overrides git -C <sandbox>. dispatch-launch-dir.ts ran its fixture commands
with that environment, so a pre-push from a second worktree wrote a
test@test init commit onto the branch being pushed and set core.bare = true,
a test identity and a hooks path of /dev/null in the real config. Nothing
reached the remote; the repository was repaired by hand.

worktree-workspace.ts already clears those variables for itself. The unit
runner now clears them once for every test, and dispatch-launch-dir.ts does
so for a direct run. Checked: with a bogus GIT_DIR inherited, the test
passes and the real repository is untouched.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmsyW2aAn78GgfRxyn5

* docs(ux): the text boxes' second step, and what is left

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmsyW2aAn78GgfRxyn5

* chore(deps): chatkit 0.28.1, where a dictated take respects a field's maxLength

bitbaum/chatkit#87, found while reviewing this branch's converted fields.
0.28 also draws a visible border on the composer while it has keyboard
focus and stops thread-following from scrolling the page up.

Checked on 0.28.1: the chat, Home and homepage boxes at 390px in both
themes (text goes in, send enables, no sideways scroll, no console
errors), tsc, lint, the design gate and the widget size test (41 KB
budget holds).

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmsyW2aAn78GgfRxyn5

* Revert "feat(fields): thirty-two text boxes get the microphone; chatkit 0.28.1"

This reverts commit 2f2f3756a2, reversing
changes made to 7f8e731b08.

* fix(ux): what the signed-in audit found first: a short message wraps, a field vanishes, pages slide on load

Seven groups of signed-in screens were audited in a browser on 2026-11-12
(docs/development/ux-audit-signed-in-2026-11.md): 84 findings, each with a
measurement. These are the blockers and the shell-wide ones, each reproduced
on main first and measured again after.

- A sent message was capped at 75-90% of a stack that shrinks to fit it, so
  it always wrapped: "What's going on?" was 106px on two lines where one
  line needs 141px. The cap is on the stack now.
- Onboarding: the "Project name" field was replaced by a read-only row as
  soon as the name was not empty, that is after one keystroke. The row is
  for a repository that was picked.
- A wrong password said nothing: Auth.js answers a refused sign-in with 200
  and the reason in `error`, and the forms tested `ok`. One helper,
  lib/auth/sign-in-result.
- A sentence carried from the homepage over 300 characters ended in
  "Invalid body": 2000 kept by the homepage, 300 in the form and the route.
  One number (config/project-brief); only the GitHub repository description
  is cut, at a word. The refusal is drawn beside the button.
- Revoking a computer's token took one tap and removed the row even when
  the server refused. It asks in a sheet and reads the answer.
- Every desktop load slid the page: the server drew the sidebar open and
  the browser folded it. The choice is in a cookie the layout reads; layout
  shift 0.19 -> 0.000 on Home, Projects and Approvals. The chat's "Recent"
  list is hidden by CSS, not by a viewport test after load: 0.5 -> 0.03.
- The app has a skip link ("Skip to content" is the first Tab stop; the
  page's first control was the 22nd). The sidebar's navigation is named,
  the logo link is named, and a folded rail item shows its name on focus.
- The desktop notifications panel is a dialog on <body>: its click-away
  layer was trapped in the top bar by the bar's blur, so a click on the
  page went through, and Escape did nothing.
- The More sheet, the Sessions drawer and the command palette take the
  keyboard when they open, keep Tab inside and give focus back.
- The account button and the page action in the phone top bar are 44px
  (40px circle inside), not 40.

Pins: scripts/test/ux-round-two.ts, scripts/test/project-brief.ts.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmsyW2aAn78GgfRxyn5

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 16:51:49 +01:00

66 lines
3.2 KiB
TypeScript

/**
* Pins for defects found by the signed-in audit of 2026-11-12, each of which
* passed the type checker, lint and every test while a person could not use
* the screen. Source pins where the fact is one line; behaviour where it is a
* function. The browser measurements are in docs/development/ux-pass-2026-11.md.
*
* npx tsx scripts/test/ux-round-two.ts
*/
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { resolve } from "node:path";
import { signInSucceeded } from "../../src/lib/auth/sign-in-result";
const read = (p: string) => readFileSync(resolve(process.cwd(), p), "utf8");
// 1. A refused sign-in is refused. Auth.js answers 200 with the reason in `error`.
assert.equal(signInSucceeded({ ok: true, error: null }), true);
assert.equal(signInSucceeded({ ok: true }), true);
assert.equal(signInSucceeded({ ok: true, error: "CredentialsSignin" }), false);
assert.equal(signInSucceeded({ ok: false }), false);
assert.equal(signInSucceeded(undefined), false);
for (const form of ["src/components/auth/SignInForm.tsx", "src/components/auth/SignUpForm.tsx"]) {
const src = read(form);
assert.doesNotMatch(src, /if \((res|result)\?\.ok\)/, `${form} tests ok alone`);
assert.match(src, /signInSucceeded\(/);
}
// 2. A sent message's width cap is on the stack, as a share of the row. On the
// bubble it was a share of the stack, which shrinks to its content.
const css = read("src/app/globals.css");
const stack = css.slice(css.indexOf(".ui-loki-turn-user-stack {"));
assert.match(stack.slice(0, 400), /max-width: 90%/);
assert.match(css, /\.ui-loki-turn-user-stack > \.ui-loki-bubble \{\s*max-width: 100%;/);
// 3. Onboarding: the confirmation row is for a picked repository, not for a
// name that is not empty (the field vanished after one keystroke).
const onboarding = read("src/app/onboarding/page.tsx");
assert.match(onboarding, /\{repoPicked && !showManual \? \(/);
assert.doesNotMatch(onboarding, /\{projectName && !showManual \? \(/);
// 4. The sidebar's width is known to the server, so nothing slides on load.
const layout = read("src/app/(app)/layout.tsx");
assert.match(layout, /SIDEBAR_COLLAPSE_COOKIE/);
assert.match(layout, /initialSidebarCollapsed=/);
const shell = read("src/components/shell/AppShell.tsx");
assert.match(shell, /useState\(initialSidebarCollapsed\)/);
assert.match(shell, /document\.cookie = `\$\{SIDEBAR_COLLAPSE_COOKIE\}=/);
// 5. The app has a skip link, and it has somewhere to land.
assert.match(shell, /href="#content" className="ui-skip-link"/);
assert.match(shell, /<main id="content" tabIndex=\{-1\}/);
// 6. Revoking a token reads the server's answer and asks first.
const tokens = read("src/components/settings/AgentTokenSettings.tsx");
assert.match(tokens, /if \(!res\.ok\) \{\s*setRevokeError\(/);
assert.match(tokens, /<DetailSheet\s+title=\{`Revoke \$\{revoking\.label\}\?`\}/);
assert.doesNotMatch(tokens, /onClick=\{\(\) => remove\(t\.id\)\}/);
// 7. The desktop notifications panel is a dialog on <body>, not inside the bar.
const bell = read("src/components/shell/NotificationsPill.tsx");
assert.match(bell, /function DesktopPanel/);
assert.match(bell, /useEscapeToClose\(onClose\)/);
assert.match(bell, /role="dialog"/);
console.log("✓ ux-round-two: 7 pins hold");