Files
loki/scripts/test/navigation.ts
CatoandClaude Fable 5.2 9ac77daea4 fix(nav): a phone can find the Terminal and sign Claude in; a failed task says why (#1628)
* design: Loki has no orange; the public call to action is the achromatic accent

The app's own buttons went monochrome on 2026-10-19; the public site kept
a warm orange (#ff5c00) on Start a project, Get started, the auth submit,
the focus ring and the essay progress bar. It is not Bitcoin orange and it
means nothing on a product that is not about Bitcoin (owner, 2026-11-11).

- --accent-warm, --accent-warm-hover and --public-accent are removed; every
  class that used them reads --accent-primary / --accent-hover, so one
  filled button exists in Loki and it is theme-aware
- --on-accent is the inverted text. It was a fixed near-black, which on the
  near-black light-theme accent left .ui-btn-xs.ui-btn-primary unreadable
- the focus ring and the public glow are neutral
- token-drift declares the divergence from @bitbaum/design-tokens; the
  widget theme is regenerated from the tokens

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

* fix(workbench): a failed task says why and gives the words back

Sent an OrangeCat task from the workbench on 2026-11-11. Claude was signed
out on the cloud runner; the status API said so with the fix, and the
composer showed the two words 'Dispatch failed' over an emptied box.

- dispatchFailureForPerson: a signed-out agent is named in the sender's
  words; any other reason is passed through instead of dropped
- the composer shows that reason under the label and offers 'Put my words
  back', since the box is cleared on send

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

* fix(nav): the phone's chat screen names Home, Projects and Terminal

The owner, signed in on a phone on 2026-11-11, could not find the terminal.
The chat is the default screen and hides the tab bar; its left button opened
a list of chats and nothing else, and its menu offered 'Projects' (which
only set the chat's project) and 'Everything else'. The page itself was
called Sessions, so no menu contained the word.

- CHAT_PLACES (config/navigation.ts) is one list of Home, Projects, Terminal
- the chat menu lists them by name, then 'All pages'; the item that sets
  the chat's project says so
- the chats panel the left button opens lists the same three, phones only
- the page is called Terminal in the nav, its title and its links

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

* fix(sessions): a signed-out Claude is one button in the chat view

A session opens in its Chat view. When Claude's login had expired, that view
showed the agent's own line, 'Please run /login', and reply chips that would
fail the same way; the 'Sign in /login' button existed only in the Terminal
view. The owner, on a phone, could not find how to sign in (2026-11-11).

The chat view reads the reply through the same detector as the terminal
(screenActions) and offers 'Sign Claude in', which types /login and switches
to the terminal where the link is printed.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-11 09:31:18 +01:00

185 lines
8.0 KiB
TypeScript

import assert from "node:assert/strict";
import {
ACCOUNT_NAV_ITEMS,
FLEET_SURFACES,
MOBILE_NAV_ITEMS,
NAV,
NAV_ITEMS,
SIDEBAR_SECTIONS,
SITE_NAV_ITEMS,
} from "../../src/config/navigation";
// ─── The loop is the taxonomy ────────────────────────────────────────────────
// Loki's sidebar answers three operator questions and nothing else. This test
// exists because the previous structure decayed in a way a reviewer could not
// see: a section literally named "More" accumulated Approvals, Terminal,
// Prompts, Activity, System, Thoughts and the public /fleet register — seven
// unrelated pages whose only shared property was that nobody had decided where
// they went. A landfill does not announce itself; it has to be made
// unrepresentable.
const LOOP = [
// Four words first, a person's questions (2026-11-01, AGENTS.md "Why Loki
// exists"): Loki (the default screen), Home, Projects — bare, no header.
{ id: "now", items: ["loki", "control", "projects"], bare: true },
// Everything else folded, each group one question — never a drawer.
{ id: "waiting", items: ["approvals", "feedback"], bare: false },
{ id: "day", items: ["today", "suggestions"], bare: false },
// "bots" opens the one list on OrangeCat (the bot's face is OrangeCat's,
// its work is Loki's; one list, not two — #1495).
{ id: "talk", items: ["voice", "bots"], bare: false },
{ id: "across", items: ["terminal", "missions", "activity", "prompts"], bare: false },
{ id: "hood", items: ["packages", "system"], bare: false },
] as const;
for (const expected of LOOP) {
const section = SIDEBAR_SECTIONS.find((s) => s.id === expected.id);
assert.ok(section, `${expected.id} section exists`);
assert.deepEqual(
section.items.map((i) => i.id),
[...expected.items],
`${expected.id} holds exactly the pages that answer its question`,
);
assert.ok(
section.question.trim().length > 0,
`${expected.id} states the operator question it answers — a section that ` +
`cannot state its question is the "More" failure starting over`,
);
assert.equal(
Boolean(section.bare),
expected.bare,
`${expected.id} is ${expected.bare ? "the bare four" : "a folded group with a header"}`,
);
if (!expected.bare)
assert.ok(
section.foldedByDefault,
`${expected.id} is folded until opened — the sidebar reads as four words`,
);
}
// The bare section is exactly the phone's bottom bar: one list, two shapes.
assert.deepEqual(
SIDEBAR_SECTIONS.find((s) => s.bare)?.items.map((i) => i.id),
MOBILE_NAV_ITEMS.map((i) => i.id),
"the four words and the bottom bar are the same list",
);
// Every folded page says what it is for on hover (SidebarNavItem title).
for (const section of SIDEBAR_SECTIONS.filter((s) => !s.bare))
for (const item of section.items)
assert.ok(item.description.trim().length > 0, `${item.id} says what it is for`);
// The landfill, by every name it might return under.
for (const banned of ["more", "other", "misc", "site", "tools"]) {
assert.equal(
SIDEBAR_SECTIONS.some((s) => s.id === banned),
false,
`"${banned}" is not a section — a section is one operator question, not a drawer`,
);
}
// ─── Nothing is listed twice ─────────────────────────────────────────────────
const sidebarIds = SIDEBAR_SECTIONS.flatMap((s) => s.items.map((i) => i.id));
assert.equal(new Set(sidebarIds).size, sidebarIds.length, "no nav item is listed in two sections");
// The sidebar navigates; the account menu acts on the account. An item in both
// is how the sidebar footer quietly became a second settings page.
for (const item of ACCOUNT_NAV_ITEMS) {
assert.equal(
sidebarIds.includes(item.id),
false,
`${item.id} belongs to the account menu, not the sidebar`,
);
}
// ─── Marketing pages left the signed-in shell, but stay findable ─────────────
// "Investors" was in the authenticated sidebar. Curating the sidebar must not
// make a page unreachable, so the palette still indexes every one of them.
for (const item of SITE_NAV_ITEMS) {
assert.equal(
sidebarIds.includes(item.id),
false,
`${item.id} is a public marketing page — not an operator surface`,
);
assert.ok(
NAV_ITEMS.some((i) => i.id === item.id),
`${item.id} stays in NAV_ITEMS so Cmd-K can still reach it`,
);
}
// ─── Retired routes are deleted, not hidden ──────────────────────────────────
// `agents` → /control and `atlas` → /projects survived as NAV entries pointing
// at the pages that replaced them. Because NAV_ITEMS is what AppTopBar and
// PageTitle search for "which page am I on?", the first match won: /control
// would have been titled "Agents". The redirect pages reference their TARGETS
// (NAV.control, NAV.projects), so the redirects stay honest without them.
for (const retired of ["agents", "atlas", "duet"]) {
assert.equal(
retired in NAV,
false,
`${retired} is retired — a nav entry pointing at its own replacement shadows it`,
);
}
// No two nav items may share an href, for the same reason.
const hrefs = NAV_ITEMS.map((i) => i.href);
assert.equal(
new Set(hrefs).size,
hrefs.length,
"no two nav items share an href — the 'which page am I on?' lookup takes the first match",
);
// ─── Mobile bottom bar mirrors the loop ──────────────────────────────────────
// Home, Projects, Loki, plus More. A tab that is not in a section would mean
// the bar and the sheet describe different products.
assert.deepEqual(
MOBILE_NAV_ITEMS.map((i) => i.id),
["loki", "control", "projects"],
"the bottom bar carries what is opened daily — Loki first, Home, Projects — and More holds the rest",
);
assert.equal(NAV.control.label, "Home", "Control is called Home");
for (const tab of MOBILE_NAV_ITEMS) {
assert.ok(sidebarIds.includes(tab.id), `${tab.id} is a real sidebar destination`);
}
// A heading over a single row reads as a menu that lost its contents ("Your
// day" over Today alone, "Build" over Terminal alone — owner, 2026-10-19).
// On the phone the tabs are filtered out of More, so count what is left.
const tabIds = new Set(MOBILE_NAV_ITEMS.map((i) => i.id));
// The bare three ARE the tabs, so the sheet shows nothing of theirs: skipped.
for (const section of SIDEBAR_SECTIONS.filter((s) => !s.private && !s.bare)) {
const inMore = section.items.filter((i) => !tabIds.has(i.id));
assert.ok(
inMore.length >= 2,
`"${section.label}" shows ${inMore.length} row(s) in the phone's More sheet — at least two, or fold it into another section`,
);
}
assert.equal(
NAV.terminal.label,
"Terminal",
"the page of agent sessions is called by the word people look for",
);
// ─── Private zone ────────────────────────────────────────────────────────────
const priv = SIDEBAR_SECTIONS.find((s) => s.id === "private");
assert.ok(priv, "private section exists");
assert.ok(priv.private, "private section is PIN-gated");
for (const id of ["people", "robots", "crew"] as const) {
assert.ok(
priv.items.some((i) => i.id === id),
`${id} stays in the private book`,
);
assert.equal(NAV[id].href, `/${id}`, `${id} has its own route`);
}
// ─── Project workspace tabs ──────────────────────────────────────────────────
assert.ok(
FLEET_SURFACES.some((s) => s.id === "terminal"),
"Terminal stays a project-scoped fleet tab",
);
for (const surface of FLEET_SURFACES) {
assert.ok(
NAV_ITEMS.some((i) => i.href === surface.href),
`${surface.id} points at a real nav destination`,
);
}
console.log("✓ navigation IA tests passed");