Skip to content

feat(portal): switcher.json lists the patches a person can open - #1294

Merged
allisonmahmood merged 2 commits into
mainfrom
feat/switcher-list
Nov 8, 2026
Merged

allisonmahmood merged 2 commits into
mainfrom
feat/switcher-list

Conversation

@allisonmahmood

@allisonmahmood allisonmahmood commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

What changed

The switcher (#1091) needs to know which patches a person can jump to, and nothing could tell a browser that yet. GET /switcher.json now answers a signed-in person's browser with their company's live patches, with their own open times, and the patches other companies shared with them that they can open now. Another company's public patch never appears, including a shared one while it is public. Nothing calls the route until #1270.

Closes #1269

Look at

The public filter. A guest grant outlives its patch going public and back (Guests.test.ts), so GuestGrants.sharedWith now carries each patch's current scope, and the list leaves out shared rows that are public or that the guest can't open now. Home's use of sharedWith is unchanged. Here it is on a local guests environment: Jo works at Pine Studio and has both Harbor Works patches shared with them. Ben is a Harbor Works member. Ada flips Site notes public and back with the CLI:

$ patchy share --patch 4ylw24ddt1xf public
jo: ["visit-log"]   ben: ["site-notes","visit-log"]
$ patchy share --patch 4ylw24ddt1xf company
jo: ["site-notes","visit-log"]   ben: ["site-notes","visit-log"]

Who gets an answer. Any request whose Sec-Fetch-Site isn't same-origin, and any request with an Authorization header, is refused before authentication, so it can't start a Clerk handshake. Every refusal is JSON with private, no-store, never the sign-in page or a redirect. Once Clerk has read the session, every answer carries the cookies Clerk set, as a page's does. That way a session Clerk refreshed server-side, from an expired session cookie plus its refresh cookie, stays refreshed in the browser. A handshake still answers session_refresh_required without the handshake's cookies, because a script can't follow that redirect. Same environment:

Jo, Sec-Fetch-Site: cross-site             403 application/json {"code":"access_denied"}
Jo, Sec-Fetch-Site: same-site              403 application/json {"code":"access_denied"}
Jo, Sec-Fetch-Site: none                   403 application/json {"code":"access_denied"}
Jo, no Sec-Fetch-Site                      403 application/json {"code":"access_denied"}
signed out, same-origin                    401 application/json {"code":"session_expired"}
Ada's machine token, same-origin           403 application/json {"code":"access_denied"}

That machine token gets 200 from /api/me.

The final shape, for #1270. Close to the issue's sketch:

// 200, cache-control: private, no-store
{
  viewer: { id, companyId, role: "member" | "admin" },
  company: { handle, name },
  whatsNewUnseen: number,  // What's new changes since the viewer last looked
  // The company's live patches the viewer can open, public ones included: their own first, then by name.
  // openedAt (ISO) and score (the halving open score Home's Your usual ranks by) only once they've opened it.
  patches: [{ id, name, title, tier, mine, openedAt?, score? }],
  // Shared with them, openable now, not public: by company name, then patch name.
  shared: [{ id, company: { handle, name }, name, title, tier }]
}

// Refusals: { ok: false, code, error }, cache-control: private, no-store
// After Clerk reads the session, any answer may also carry its Set-Cookie directives.
// 403 access_denied             Sec-Fetch-Site not same-origin (missing and none included), any Authorization
//                               header, no membership, or deactivated
// 401 session_refresh_required  Clerk wants a handshake, or the session token expired
// 401 session_expired           signed out
// 503 unavailable               Clerk or the database failed

The session codes are the runtime stream's own, so the script can follow stream.ts's refresh pattern. title is as published and may be blank, so the client falls back with core's patchTitle. The payload type is SwitcherList.SwitcherList in @patchy/portal. If #1270's browser script wants the type, lift it into core there. Core now exports monogramTint, the mark's tint picker, so the menu's marks match the portal's. monogram renders the same markup as before.

How it was verified

  • PortalPages.test.ts › "the switcher's list", four cases:

    • A member, the owner and an admin each get the full body: their own patches first, mine set, and only the member's own open. A retired patch, a disabled patch and another company's company-scope and public patches are all absent.
    • A guest gets shared rows only. One patch goes public and back on the same grant and drops out, then returns. A revoked grant goes, then a disabled patch. A retired shared patch and the host company's own public patch never appear.
    • Refusals: cross-site, same-site, none and missing Sec-Fetch-Site, with a valid, a stale and no session, all 403 before authentication. A live machine token, with and without a session, gets 403. A stale session gets 401 session_refresh_required, signed out 401 session_expired, no membership and deactivated 403. All are JSON with private, no-store.
    • Clerk's server-side refresh: an expired session cookie plus Clerk's suffixed refresh cookie gets 200 with the refreshed __session and refresh cookies. The portal suite's sessions now use a stub Clerk backend for this. Over the first commit's route, the same request got 200 without the cookies, which was Sol's finding.
  • The tests bite. Dropping the public filter fails the guest case, and dropping the Sec-Fetch-Site check fails the refusal case (expected 200 to equal 403).

  • The stream's refresh rule moved into Session.refreshable so both routes share it. RuntimeStreamApi.test.ts and the browser suite's stream refresh tests still pass.

  • pnpm check: format, lint, typecheck and synth pass. pnpm verify (under the shared lock): postgres-concurrency and tier2-smoke pass. test, test (bun), cli-smoke, install and browser failed only for two local machine reasons:

    • A stray GET / reaches the tests' stub servers on local ports. That broke the CLI stub-log tests and LocalTaskProvider in test, and one tier1.spec.ts case whose "foreign origin" stub saw "/". In test (bun) every file passed (256/256) and the probe only threw uncaught JSON parse errors in devExecution.test.ts's stubs.
    • /usr/bin/node has no npm beside it. That broke install.test.ts, install and cli-smoke's install line.

    Both reasons fail the same way on origin/main. The same four files there fail 12 tests, with the same stray "/" and npm is not on PATH. Rerun alone, the full tier 1 browser suite passed (85/85). After rebasing onto feat(integrations): patches save IMAP attachments into their files #1264: typecheck passes, and PortalPages, RuntimeStreamApi, GuestGrants, Guests and core/html pass (129 tests).

  • After the cookie fix: pnpm check passes format, lint, typecheck and synth. Its tests failed only for the stray GET /, npm is not on PATH, and timeouts under a load average of 43. The nine suites that timed out or that this touches pass when run alone: McpDoor, Tables, SdkApi, QuerySnapshot, InvocationLocal, RequestEvents, RuntimeStreamApi, Guests and Session (110 tests). The whole portal suite passed in that run. I didn't rerun pnpm verify: the fix touches only this JSON route and its test, which none of verify's acceptance suites exercise.

  • Not checked: CI on Linux, which doesn't have either machine issue.

Hit every surface:

  • Wire contract: doesn't apply. The route is Portal-owned and session-only, not in packages/api, so there's no CLI command and no docs/API.md change.
  • Vocabulary: Portal's GLOSSARY.md gains Switcher list. docs/product.md waits for feat(core): Mod+Shift+K opens Patchy's switcher #1270, when people can see something.
  • Served pages: no rendered HTML changes.
  • CLI, dev loop, migrations, company resources, reverse states, repo layout: none apply.

Release impact

Tick exactly one.

  • Breaking — requires action from anyone already running this
  • Not breaking — no action required

A new browser-only route that nothing calls yet. No migration, no CLI or API change.

Built by Claude Opus 5.5 (xhigh) in Claude Code, orchestrated from T3 Code.

@github-actions github-actions Bot added area:server Touches the server area area:core Touches the core area area:docs Touches the docs area area:ui Portal and first-party browser pages, shared rendering and styles size:m 100-500 changed lines labels Nov 7, 2026
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Sol review (round 1)

CHANGES REQUESTED

  1. P2 — Do not discard a successful session refresh. packages/portal/src/SwitcherList.ts:83 and packages/portal/src/SwitcherList.ts:138: an expired session cookie plus Clerk's suffixed refresh cookie can make Session.authenticate refresh server-side and return signed-in with new cookie directives. Reproduced offline: two cookie directives, with Session.refreshable false. This route then returns 200 while dropping both directives, leaving the browser's expired session and old refresh cookie in place; the client never receives session_refresh_required to run its refresh-once recovery. Use script admission that returns refresh-required without performing a server-side refresh, or preserve the verified cookie updates on the JSON response. Add this cookie combination to the admission tests.

Validation: 157 tests passed across the six targeted test files. No code changed.

Reviewed by GPT 6.1 Sol (xhigh) in Codex, orchestrated from T3 Code.

allisonmahmood and others added 2 commits November 7, 2026 15:09
GET /switcher.json answers a signed-in person's browser with their company's
live patches, their own open times, and the patches shared with them that they
can open now and that aren't public. Requests without same-origin fetch
metadata, or with a bearer token, are refused before authentication, and every
refusal is JSON with private, no-store.

GuestGrants.sharedWith gains each patch's scope so the list can leave out a
shared patch while it is public. The stream's refresh rule moves to
Session.refreshable so both routes share it. Core exports the monogram's tint
picker for the switcher's client.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
An expired session cookie with Clerk's suffixed refresh cookie makes Clerk
refresh the session server-side and answer signed in with new cookie
directives. The route answered 200 without them, so the browser kept its
expired session and old refresh cookie. Every answer after Clerk reads the
session now carries its cookies, as pages do; a handshake still answers
session_refresh_required without them.

The portal suite's sessions now use a stub Clerk backend, so a case can
drive the refresh.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added size:l 501-1,000 changed lines and removed size:m 100-500 changed lines labels Nov 7, 2026
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Re the Sol review P2: fixed in 3e778e0. Once Session.authenticate returns signed-in or signed-out, /switcher.json now applies withCookies(response, result.cookies) to every answer, as pages do, so a session Clerk refreshed server-side keeps its new cookies. A handshake still answers session_refresh_required without cookies, and the Sec-Fetch-Site and Authorization refusals before authentication stay cookie-free. The portal suite's sessions now use a stub Clerk backend. The new case, "keeps the session Clerk refreshed on the way", sends an expired session cookie plus Clerk's suffixed refresh cookie and gets 200 with the refreshed __session and refresh cookies. Over the previous route it got 200 without them.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Sol review (round 2)

APPROVE

No findings. The round-1 P2 is fixed: refreshed cookies reach the 200; post-authentication refusals and handled 503s retain Clerk's directives, including signed-out clearing cookies. Handshakes and pre-authentication refusals stay cookie-free.

The stub preserves real session verification and the offline network guard. Tracing the complete portal suite found only the new test's expected refresh request; existing tests made no backend calls.

Validation: 174 tests across nine affected files, eight refusal/cookie probes, and test typechecking passed. The new regression test passes at head and fails against the old route with 200 and both cookies missing. No other regressions found; no code changed.

Reviewed by GPT 6.1 Sol (xhigh) in Codex, orchestrated from T3 Code.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Acceptance: PASS with notes

Checked 3e778e05ff688133e45adfdc221981a3167f3325 (base 64ce90784350341fc2f60fe4f4161a78444f243e) on guests, plus brightline for the live journey, by Claude Opus 5.5 (xhigh) in Claude Code, orchestrated from T3 Code.

Done means

  • A signed-in person's browser gets their company's live patches, with their own open times, plus the patches shared with them that aren't currently public: passed. With Sec-Fetch-Site: same-origin and each person's session, every answer was 200, application/json, private, no-store:

    • Ada (admin) gets Site notes and Visit log with mine: true.
    • Ben (member) gets the same two with mine: false.
    • Jo (Pine Studio) gets no patches and both Harbor Works patches under shared.
    • After Ben and Jo each open Site notes, only Ben's row gains openedAt and score.
    • Ada then published Price list as a public page that isn't shared with Jo. It joins Ben's list. It never joins Jo's, even after Jo opens it.
    • Site notes going public drops out of Jo's list. Jo's grant is still listed by patchy share --list, and Jo can still open the page. Going back to company brings it back.
    • Removing and re-adding Jo on Visit log, and retiring and restoring Site notes, each take the row out and bring it back.
  • Nothing else gets a list: other sites, machine tokens, signed-out or deactivated people: passed. Every refusal is JSON with private, no-store, no Location and no CORS headers:

    Jo, Sec-Fetch-Site: cross-site                     403 {"code":"access_denied"}
    Jo, Sec-Fetch-Site: same-site                      403 {"code":"access_denied"}
    Jo, Sec-Fetch-Site: none                           403 {"code":"access_denied"}
    Jo, no Sec-Fetch-Site                              403 {"code":"access_denied"}
    signed out, same-origin                            401 {"code":"session_expired"}
    tampered session cookie, same-origin               401 {"code":"session_expired"}, Set-Cookie clears it
    Ada's machine token, same-origin                   403 {"code":"access_denied"}
    Ada's machine token with Ada's session             403 {"code":"access_denied"}
    signed in, no membership anywhere                  403 {"code":"access_denied"}
    Ben, deactivated by Ada at /company                403 {"code":"access_denied"}
    Ben, reactivated                                   200, three patches
    

    The same machine token gets 200 from /api/me.

The lists as Ada changes sharing (names only)
$ patchy publish price-list.html --name price-list --share public
ben: ["price-list","site-notes","visit-log"]   jo shared: ["site-notes","visit-log"]
$ patchy share --patch <site-notes> public
ben: ["price-list","site-notes","visit-log"]   jo shared: ["visit-log"]
$ patchy share --patch <site-notes> company
ben: ["price-list","site-notes","visit-log"]   jo shared: ["site-notes","visit-log"]
$ patchy share --patch <visit-log> --remove [email protected]
jo shared: ["site-notes"]
$ patchy share --patch <visit-log> --add [email protected]
jo shared: ["site-notes","visit-log"]
$ patchy retire --patch <site-notes>
ada: ["price-list","visit-log"]   ben: ["price-list","visit-log"]   jo shared: ["visit-log"]
$ patchy restore --patch <site-notes>
ada: ["price-list","site-notes","visit-log"]   ben: same   jo shared: ["site-notes","visit-log"]

Golden journeys

  • Find and open a tool: passed. A pnpm dev film flow on guests closed the setup guide on both commits. As Ben and as Jo, it saved the markup of Home, All patches and Site notes' card. Once patch ids, the instance origin and timestamps are masked, every page matches base and head, including Jo's Shared with you shelf, which reads sharedWith's new column. pnpm dev shot opened Site notes (tier 1) in its frame as Ben and Visit log (tier 2) as Jo, with no browser errors. I rendered 4024 monograms (fixed and random names, both sizes), and every one matches main's markup byte for byte.
  • Use a tool live: passed at the head, on brightline. Jordan sends Priya kudos, and it appears on Priya's open Kudos page with no navigation (screenshot below). The stream's refresh rule moved into Session.refreshable, which reads as the same branches as before. CI's browser job passed on this head; it runs the stream's refresh and sign-out cases. RuntimeStream and RuntimeStreamApi pass locally.
  • Share and unshare, Publish a page: passed on guests, as far as this diff reaches. Ada's CLI published a public page that answered 200 signed out, and patchy share … public and back worked.
  • Sign in, Log a machine in, Invite and join: not touched by the diff.
Portal markup, base vs head
page                 status   differing lines after masking ids, origin, timestamps
ben home             200      0
ben all patches      200      0
ben card             200      0
jo home              200      0
jo all patches       200      0

Tests: all 24 CI checks pass on this head; attio-live and imap-live were skipped as gated. Seven suites pass locally, 184 tests: PortalPages, including the four "the switcher's list" cases, RuntimeStream, RuntimeStreamApi, GuestGrants, core components and html, and Session.

Rollback answers: they match the diff. There is no migration, and nothing changes in packages/api, the CLI or the infrastructure. The only SQL change reads p.scope in sharedWith. A revert leaves nothing behind, since nothing calls the route yet, and rollback-rehearsal passed. It needs no one-way label.

Not run

  • session_refresh_required for a stale Clerk session or a handshake, and keeping the cookies from Clerk's server-side refresh. Dev personas have no refreshable session: an expired or tampered cookie counts as signed out. Clerk mode needs pnpm dev --clerk and a person's browser. The PR's own cases for both pass locally and in CI.
  • A disabled patch leaving the list: nothing disables a patch on a dev environment. The PR's guest case covers it.

Notes

  • Done means holds. The only gaps are the two checks above, which only the PR's tests cover.

Priya's open Kudos page showing Jordan's kudos, "Just in", without a reload

@allisonmahmood
allisonmahmood merged commit 092a450 into main Nov 8, 2026
26 checks passed
@allisonmahmood
allisonmahmood deleted the feat/switcher-list branch November 8, 2026 00:01
allisonmahmood added a commit that referenced this pull request Nov 8, 2026
## What changed

Moving between patches meant the back button, the address bar or a trip
through Home, and inside a patch Patchy showed nothing at all. Now
Mod+Shift+K (⌘⇧K on a Mac) opens Patchy's **Go to…** menu over any
company patch a person can open, a guest's view of a shared patch
included, and over every signed-in portal page. With nothing typed, the
patch they were last in comes first and lit, so ⌘⇧K then ↵ flips back to
it. Escape or the key again closes it and puts the cursor back where it
was, inside the patch's own field too. The look is mock direction 2,
"Quiet list".

How:

- **`/~shell/switcher.js`** is core's second generated script
(`scripts/build-core-scripts.mjs`), plain DOM code with no Preact,
Effect or schema library. The generator now refuses any bundled input
from outside core. Every host serves it like the broker, immutable under
its digest. App pages load it from `htmlPage` when they pass `app`, and
company shells from `renderPatchWrapper`, ahead of Clerk's and the
session's scripts. The tag names the viewer and company the page was
rendered for. Doors, public shells and `patchy dev` don't load it, so
they only claim the key. The script is 14.9 KB raw and 5.6 KB brotli.
- **The menu** is a command list in a modal `<dialog>` with the starting
cover's flat `shell-scrim`, and no animation or blur. It installs `{
open, toggle }` as `window.patchySwitcher`, the contract from #1298, and
opens at once if a press came before it loaded.
- **Nothing typed:** the flip target, then the next five by last open,
then **This patch**, then **Patchy**. Patch slots that opens leave fill
with patches the viewer has never opened, the company's live ones before
those shared with them, each by title, then id, six patch rows in all
(decided by Allison on 2026-11-08). So a new member or a guest sees
patches straight away. With nothing to flip back to, no patch is lit:
the first row after them is, so ⌘⇧K ↵ never opens a patch the person
hasn't been to. An unopened company patch shows no detail; a shared one
shows its company's name. This patch is the card's Overview and
Versions, plus Log and Settings for the owner and admins, shown only
once the list confirms membership. Patchy is the places, minus the
page's own, plus What's new with its dot.
- **Typing** goes through a pure ranking module (`switcher/rank.ts`):
word starts in any order, then initials, then a match inside a word from
three letters. Ties go by open score, then title, then id.
- **The list in the browser** (`switcher/client.ts` over
`switcher/cache.ts`) is one versioned sessionStorage entry keyed to the
page's viewer and company. It holds row metadata and the tab's `{
current, previous }` patch ids.
- It fetches `/switcher.json` on load, and again on open once the copy
is a minute old.
- A stale session is refreshed once through `window.patchySession`, then
the list is fetched once more.
- Signed out, a refusal, someone else's list or a non-list response
clears everything. So does signing out on the page: posting the form to
`/logout` forgets the list and pointers before the browser leaves for
the door, which has no switcher, and an answer still on its way is
dropped (`forgetOnSignOut`).
- A stored entry that is someone else's, an older version's, or doesn't
read back whole is removed, pointers and all. Pointers alone, as before
a first list lands, still read back.
- A list that lands after the menu opened, before the person typed,
moved the selection or pointed at any row (the lit one included), is
drawn as if it had been there at open: the flip first and lit. After any
of those, and on later refreshes, the rows already shown keep their
order and the selection stays put.
  - It takes its inputs as options, so #1271's notices can reuse it.
- **Keys around the chord.** A company shell's switcher tells the
patch's relay it is there with a new shell message, `available`. It
answers each validated `hello` from its frame itself, so this never
depends on the broker's release; it runs before the broker gives the
frame its address, so it hears every `hello`. From then on, an
activating press makes the relay hold every keydown, keypress and keyup
in the frame. The hold lasts until the browser blurs the frame and it
has really lost focus to the menu, `closed` arrives, or a second passes;
a blur the page dispatches itself ends nothing. So the patch never hears
a key meant for the menu. An Enter pressed in the few milliseconds
before the menu has focus is dropped, not flipped; a person's ⌘⇧K ↵ is
slower than that. Without `available` (a public shell, `patchy dev`, an
older shell) nothing is held, and typing goes on as before. The relay
accepts `available` and `closed` only as trusted messages from its real
parent. Nothing is replayed, and the frame never gives up focus. The
menu takes focus before it draws its rows.
- **The field keeps focus.** It is a `<label>`, and a press anywhere in
the dialog but its text, the glyph and panel included, leaves focus in
it.
- **Closing** puts focus back where the menu opened from. Over a patch
that is the frame, then `closed` so the relay restores the field and
selection, once the frame has focus again (Firefox returns it only after
the key event that closed the menu). Focus leaving the open menu, to the
patch, another window or the browser, closes it the same way, so Go to
never shows while typing goes elsewhere. It can also be the shell
control or the starting cover. On app pages it is the element that held
focus. The cover waits while the menu is open, and clearing it never
takes the menu's focus (`stream-status.ts`).
- **Components:** core gains `kbd` and the command-list contract
(`command-list.ts`: field, listbox, lit row, group label, empty line),
with its own scoped reset. `mono`, `page-mark`, `mark`, `tag`,
`shelf-label`, the What's new dot and the `field`/`field-group` rules
moved into `shellStyles`, so a served shell draws them as an app page
does. Escaping, patch marks and the sidebar's places moved into
dependency-free modules (`escape.ts`, `patch-marks.ts`, `places.ts`)
that the browser bundle can carry. Their old exports are unchanged.
- **Smaller changes:** the switcher list's type moved from Portal into
`@patchy/core/switcher`, as #1294 suggested. The shell's console line on
`open` is gone at company scope; `patchy dev` keeps it.

Closes #1270

**This PR changes code from #1298.** The commit `fix(core): the relay
holds the keys after the chord only where a switcher will take them`
changes `packages/core/src/switcher/relay.ts` and `messages.ts`, with
their cases in `switcher-relay.spec.ts` and ADR-0010. Of #1298's
`broker.ts`, this PR changes only the console line on `open`. Without
it, a fast ⌘⇧K ↵ from a patch's field sent the Enter into the patch,
since the browser delivered it inside the frame before the shell had
handled the relay's `open`. The fix needs the shell's switcher to say a
menu exists (`available`), and the relay to hold keys only then and to
accept only its real parent's messages and the browser's own focus and
blur. That only matters once there is a menu, so it lands here rather
than in #1298.

## Look at

**The flip**, filmed on `brightline` as Allison: Spend Requests, then
New Business, then ⌘⇧K ↵ back to Spend Requests, typing to filter, and
the menu on Home.


https://github.com/user-attachments/assets/117eb293-cae5-4fe6-931c-0c391df522cc

**Over a patch**, nothing typed. Spend Requests is lit as the flip
target, and New Business, the patch on screen, isn't a row:

![The switcher over New
Business](https://github.com/user-attachments/assets/b45a9f2f-da83-4d8e-97a3-58a69b89dee4)

**A new member** (Jordan on `brightline`, who hasn't opened anything)
with nothing typed: the company's patches by title, none lit, and the
first place lit:

![The switcher for a new member on
Home](https://github.com/user-attachments/assets/6d6510f6-046f-46aa-a526-5849e0003a3b)

**Typed** ("ku" over Spend Requests), and **on Home**, where Home isn't
offered:

| Typed | On Home |
| --- | --- |
| ![The switcher with ku
typed](https://github.com/user-attachments/assets/a51a9ead-c07c-431f-9491-f9410fb2a731)
| ![The switcher on
Home](https://github.com/user-attachments/assets/069b7972-7257-417c-85fd-7819d1ba8fe3)
|

**Pages with the menu closed don't change.** `pnpm dev compare` as
Allison on `brightline`, before at `66997dd` (#1298's head) and after at
`ab55b42`:

| Page | 1280px | 390px |
| --- | --- | --- |
| `/` | No visible change | No visible change |
| `/brightline/new-business` | No visible change | No visible change |

<details><summary>After, 1280px</summary>

![Home
after](https://github.com/user-attachments/assets/f8972e01-7ba9-4a70-bd3e-f3ac8d6dbd15)

![New Business
after](https://github.com/user-attachments/assets/f0be0e61-a42c-4189-b559-05ba2aaddf8a)

</details>

**The spec caught a real race.** `dialog.close()` queues its `close`
event, and Chrome can handle a fast key press first. Without a guard,
the stale event from an Escape closed a menu reopened straight
afterwards. The menu now acts on its dialog's `close` event only while
the dialog is actually closed. The cover spec reopens it immediately
after Escape to hold that.

## How it was verified

- **`test/browser-tier1/switcher.spec.ts`**, 16 cases, all pass twice
over with `--repeat-each=2` in Chromium, and once more after the rebase
onto `main`. The 14 that aren't Chromium-only (all but the starting
cover's two) also pass twice over in Firefox.
- Someone who has opened nothing: a new colleague's menu on All patches
lists the company's patches by title with Home lit; a guest's lists the
patch shared with them, named with its company's name, with Home lit.
- ⌘⇧K, then ↵ once the menu has focus, three flips in a row from the
patch's field: each lands. Then ⌘⇧K ↵ with no pause: the patch's own
listeners and its form never hear the Enter.
- A menu slow to open (600 ms after the relay asks, the shell otherwise
free) over a patch that forges blur events every 20 ms: the Enter
pressed straight after the chord never reaches the patch, and nothing
flips. The broker never answers `hello`, as #1298's doesn't, so
readiness comes from the switcher alone. With the switcher's answer
disabled, the patch hears the Enter: the case bites.
- A patch that grabs focus back 400 ms after losing it, never leaves Go
to up while typing goes to the patch. In Chromium the menu closes and
"private" lands in the patch. In Firefox the inert frame can't take
focus, and the keys stay in the menu.
- A fresh tab whose list is held back: the menu opens on the places with
Home lit; once the list lands the flip is first and lit. Pressing ↓
first keeps All patches lit instead, and so does pointing at Home, the
lit row.
- A click on a group label, then on the glyph: the field keeps focus,
typing filters and ↵ opens.
- Sign out from the account menu: the tab's entry is gone on the page
the form leads to.
- Over a patch with the cursor in a field: the flip is lit, typing
filters, no match offers All patches, Escape restores the field's
selection (typing replaces it), ⌘⇧K ↵ flips both ways, the arrows wrap,
the key again closes, hover lights a row, the scrim closes and a click
opens.
- On All patches and Home: the flip to the patch the tab left, no own
place, no This patch, and focus back in the sidebar search.
- A guest: shared rows named with their company's name and no This
patch. Revoking the grant drops the row when the held `/switcher.json`
lands, while the menu stays open.
- Another viewer's planted entry is ignored and removed, while the same
entry as the viewer paints from cache. Denied `sessionStorage` still
lists.
- Sessions: stale gets the list back (401, refresh, 200), an exhausted
retry keeps the copy (401, 401), and signed out clears the list and the
entry.
- A host with no `switcher.js`: the key is claimed and `patchySwitcher`
stays `true`. With `/switcher.json` answering a 404 page: places only.
- A public shell loads neither file, and a key typed straight after the
chord lands in the patch's field.
- Over the starting cover: the menu opens over it, Escape returns focus
to the cover, and a cover clearing behind the reopened menu leaves focus
in it. A cover due while the menu is open waits, then takes focus once
it closes.
- **`switcher-relay.spec.ts`** now runs the relay alone on a host
without `switcher.js`, since a loaded menu answers its pending requests.
A new case shows that a page dispatching `available` itself is ignored
and the key after the chord stays the page's. The shell's own
`available` holds the next key, a blur the page forges releases nothing,
and `closed` ends the hold. All 11 pass, as do the 4 `focus.spec.ts` and
7 `starting.spec.ts` cases, twice over in Chromium.
- **Unit tests:**
- `rank.test.ts`: the mock's "sa" order, any-order words, initials,
inside-a-word from three letters, no typos, deterministic ties.
- `cache.test.ts`: round trip, metadata only, removal of another
viewer's or company's entry, of a bad list, bad pointers or an old
version, pointers on their own kept, full or denied storage, pointer
moves.
- `rows.test.ts`: every nothing-typed and typed case above, member vs
admin cards, the hold on refresh, the "4 min" … "Oct 2, 2025" labels.
Never-opened patches: a new member's six of eight by title and none lit,
a guest's shared patches named with their company, the mix (the flip,
then opened, then the company's unopened, then shared, capped at six),
and the patch on screen left out.
- `client.test.ts`: adopt, freshness, refresh once, keep, forget,
pointers, and sign-out forgetting for good with an answer still on its
way.
- `command-list.test.ts`: structure, escaping and the CSS in
`shellStyles`.
- `html.test.ts` and `render.test.ts`: the tag on app pages and company
shells only, ahead of Clerk, with escaped ids.
  - `Pages.test.ts`: `switcher.js` is immutable only under its digest.
- **`pnpm check`** (rerun after the round-three fixes): format, lint,
typecheck and synth pass. Its tests fail only in this machine's known
places, which fail the same on `origin/main` here: a stray `GET /`
reaching CLI stub servers (cli, cliPublish, cliLifecycle, cliLook,
cliRepoRecovery) and npm missing beside `/usr/bin/node` (install).
- **`pnpm verify`** under the shared lock, run before the round-one
fixes, with mise's Node 24 first on PATH: format, lint, typecheck,
synth, postgres-concurrency, cli-smoke, install and tier2-smoke pass.
test and test (bun) fail only on the same stray `GET /` and on load.
RequestEvents, Engine and Supervisor pass alone; Supervisor's case had
hit its 20 s timeout at a load average of 15. The browser job stopped at
its first failure, so I reran the whole tier 1 suite: 103 of 104 pass.
The one failure is `tier1.spec.ts` "hostile navigation", whose
foreign-origin stub heard a bare `GET /` from the local port probe.
#1294 documented it failing the same way on `origin/main`.
- **Not checked:** the hand test on a Mac in Safari, Chrome, Firefox and
Zen. That covers focus and cursor restore, the first moments after a
patch opens, and whether initials matches read clearly without
highlighting. WebKit isn't runnable here, so Safari is unverified. CI
runs Chromium only; the Firefox run was local.

Hit every surface:

- **Served pages:** the `ui-consistency` spec now covers the switcher as
the one shell UI a person opens over a running patch, the command list
and `kbd`, the components `shellStyles` now shares, the switcher script
on app and company shells, and how the starting cover yields to it.
- **Vocabulary and product shape:** Portal's glossary gains
**Switcher**, Serving's **Switcher relay** says what the menu does with
its messages, `docs/product.md` describes the switcher, and GLOSSARY-MAP
and the README layout mention it. ADR-0010 already states the final `{
open, toggle }` contract from #1298.
- **Dev loop:** `pnpm dev` already runs core's generator, which now
emits two scripts. No runner change.
- **Not touched:** the wire contract (`/switcher.json` is Portal's,
browser-only), the CLI (no command, flag or exit code; `patchy dev`
stays claim-only), migrations, company resources, reverse states
(opening and closing are the pair) and the repo layout.

Where this departs from the issue, each a gap the issue left open:

- A shared patch's detail is its company's name: guests record no opens,
so there is no time to show.
- Typed results are one ranked list without group labels, as the mock's
typed state is. Card and place rows keep their icons.
- The place a page belongs to isn't offered, as on the mock's Home.

## Release impact

- [ ] **Breaking** — requires action from anyone already running this
- [x] **Not breaking** — no action required

A new browser script and its route; no API, CLI, schema or configuration
change. #1267 (reopens within 10 minutes count once, PR #1295, now on
main) ships in the same release, so flips don't inflate Your usual.

- **What does a revert leave behind?** A `patchy.switcher` entry in
`sessionStorage` in tabs that loaded the menu. It holds row metadata
only and lasts until the tab closes. Pages already open keep the script
they loaded.
- **Does the release before it still work with that?** Yes. It never
reads the entry. A page from this release asking an older host for
`switcher.js` gets nothing, so the relay claims the key and nothing
opens. An older host without `/switcher.json` gives the menu places
only.

Built by Claude Opus 5.5 (xhigh) in Claude Code, orchestrated from T3
Code.

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
allisonmahmood added a commit that referenced this pull request Nov 8, 2026
## What changed

This adds release 40's What's new entry, written from `08e1fd9`. It
covers everything merged since release 39's `through` (`17b1ad8`), and
sets the `patchy` release to `0.40.0` in `packages/patchy/package.json`
and `CURRENT_RELEASE`.

| Change | PRs |
| --- | --- |
| New: Jump anywhere with ⌘⇧K | #1294, #1298, #1304, #1307 |
| Improved: Your usual stays yours | #1295 |
| Patch changes: Mod+Shift+K no longer reaches patch code; Patchy serves
one script first in every patch document | #1298 |

#1293 is release 39's own entry. The range is exactly the switcher stack
(#1091), which ships as one release. #1295 had to ship no later than the
menu, and it does.

## Look at

- **The entry**, at the top of `releases` in
`packages/core/src/whatsNew.ts`.
- **Rollback safety, from the live commit `64ce907` (release 39) to this
PR's merge:**
- **No PR in the range is `one-way`.** There are no migrations, no API
or CLI contract changes, and no infrastructure changes.
- **#1295** changes only how new opens add to a person's score. Scores
written under the new rule stay valid for release 39, which keeps
counting every open.
- **#1298** inserts the relay into served patch bytes at serve time.
Stored files and digests are unchanged, so release 39 serves them as
before.
- **#1304 and #1307** add a `sessionStorage` entry that release 39 never
reads. #1307's new `claims` field on a completed Clerk handshake exists
only in memory.

**Rollback line:** If this release misbehaves, roll back to
`64ce90784350341fc2f60fe4f4161a78444f243e` (release 39).

## How it was verified

- **Tests:** the `packages/core` What's new test passes (5), the
`packages/api` suites pass (64), and the three files are formatted.
- **The range:** each of #1294, #1298, #1295, #1304 and #1307 was:
- reviewed by GPT 6.1 Sol at xhigh, with every finding fixed or declined
in writing on the PR;
  - accepted on its final head by an agent that didn't write it;
  - merged green on a branch up to date with main.

## Release impact

- [ ] **Breaking** — requires action from anyone already running this
- [x] **Not breaking** — no action required

The changelog entry and the release version only.

- **What does a revert leave behind?** Nothing. CLIs installed from this
release report `0.40.0` and are told to match the server, as at every
release.
- **Does the release before it still work with that?** Yes.

Written by Claude Opus 5.5 in Claude Code, orchestrated from T3 Code.

Co-authored-by: Claude Opus 5.5 <[email protected]>
allisonmahmood added a commit that referenced this pull request Nov 10, 2026
Stacked in the UI overhaul (#1315) after F2; merge the stack together,
not alone.

## What changed

Your agents lived at `/machines` and company management at `/company/…`.
They now have the addresses the new sidebar names: Your agents at
`/agents`, with Connect an app at `/agents/connect?app=<app>` and Add a
computer at `/agents/computer` as pages of their own, and People,
Integrations and Agent access at `/settings/people`,
`/settings/integrations` and `/settings/agent-access` (`/settings` opens
People). Released skills, CLIs and bookmarks carry the old addresses, so
every one of them keeps working. No page is restyled; later lanes
rebuild them.

Closes #1318

## Look at

**1. One map, by method and path: `apps/server/src/Moved.ts`.** Each
entry is an old route exactly as the last release registered it, found
with Effect's own `FindMyWay` under the router's default rules, so any
letter case, trailing slash, repeated slash or percent-encoding the
router accepted before still works. A GET answers 308 to the new URL
with the query as sent; a browser carries the fragment across on its
own. A POST, from a form left open across the move, is handed to the
router under its new URL before routing, so the new route answers it
with every check it makes (same-origin, admin-only, ownership). That is
the pattern `servingHeaders` already uses for HEAD. Anything else under
the old prefixes stays a 404.

| Old | New |
|---|---|
| `GET /machines` | `/agents` |
| `GET /machines?agent=<app>` | `/agents/connect?app=<app>` (other
parameters kept) |
| `GET+POST /machines/revoke-all` | `/agents/disconnect-all` |
| `POST /machines/:id/revoke` | `/agents/computers/:id/disconnect` |
| `POST /machines/agents/:id/disconnect` | `/agents/apps/:id/disconnect`
|
| `GET /company`, `GET /settings` | `/settings/people` |
| `POST /company/invites[/:id/{revoke,resend}]`, `POST
/company/users/:id/role` | `/settings/people/invites…`,
`/settings/people/users/:id/role` |
| `GET+POST /company/users/:id/{deactivate,reactivate}`,
`/company/guests/:id/remove` | `/settings/people/users/…`,
`/settings/people/guests/…` |
| `GET+POST /company/agent-access` | `/settings/agent-access` |
| `/company/connections…`: index, catalogue, connect pages and posts,
Pidgeon's Find addresses, a connection, its five acts and six
confirmations | `/settings/integrations…`, same shape |

`apps/server/src/Moved.test.ts` boots the whole server and walks the
map: every old GET (signed in and out) answers 308 with
`?show=a%20b&q=x+y&empty` kept byte for byte and no fragment, and its
target is a real route. For every old POST, another site's form gets the
same 403 as at the new address, and a member's request for what isn't
theirs gets the identical status, location and page. Two old forms
change what the new routes change: revoking a computer and turning agent
access on. Spellings the router accepted (`/company/`, `/COMPANY?…`,
`/%63ompany`, `//machines//revoke-all`) redirect or post as before;
`?%61gent=codex` and `?app=claude&agent=codex` land on Codex's steps, as
the old page showed. Unknown URLs under the old prefixes still 404. With
the rewrite taken out, the POST tests fail.

**2. Your agents' "add" disclosures became links to their own pages,**
because the old `?agent=` link now needs a destination of its own. The
links keep the ids old `/machines#add-a-computer` and
`#connect-an-agent` links name; `test/browser-tier1/moved.spec.ts`
follows both old links in a browser. Screenshots below come from `pnpm
dev compare` on throwaway `brightline` instances. *Before* opens the old
address on the base; *after* opens the same old address on this head,
which follows the redirect.

## How it was verified

- `pnpm check`: format, lint, typecheck and synth pass. In the offline
tests, the only failures were the CLI stub tests that a local tool's
stray `GET /` breaks on this machine (a different handful each run, none
touching these paths) and load-sensitive execution tests. Each passes
alone; CI runs the full suite.
- After rebasing on #1294/#1298: auth, companies, core, integrations,
portal, MCP and the server wiring suites, 1,176 tests, pass.
- `pnpm dev up imap`: the dev runner connected `imap/invoices` through
the moved connect page and its new URL wait, then published.
- Enrollment refuses the `agents` handle (`Companies.test.ts`, and
`/join` in `AuthPages.test.ts`). `settings` was reserved already.
- **Not run locally:** the browser suites (CI runs `moved.spec.ts`) and
live Clerk (`login-door`, `patchy-login` now open `/settings/people` and
`/agents`).
- **Not checked:** whether a production company already holds the
`agents` handle. That's left to the orchestrator before release.

Surfaces it follows through to: every href, form action, receipt
redirect and refusal link; the dev personas hint; device-login and
consent links (their routes don't move); hints agents read from the API,
MCP door, publish warnings, SDK generation and the CLI; the global
`patchy` skill (`skills-lock.json` refreshed) and its onboarding
reference; the project skills under `packages/sdk/skills`; `docs/API.md`
(regenerated), `docs/product.md`, ADR-0004, README, DEVELOPMENT,
OPERATIONS, the auth glossary and the acceptance skill; the dev runner's
connect URLs and URL waits. The rollback rehearsal drives the live
release as well as this head, so it opens People and Disconnect
everything at the old addresses (both releases answer them) and accepts
either form address. Past What's new entries hold no old paths. Seeds
and scenarios don't change.

Left for later lanes: copy that names the old Company group ("Back to
Company", "Turn it on at Company", the sidebar's group label) goes to N
and the page lanes, and Revoke → Disconnect to P4. No core additions.
Core's sidebar place list changes only its hrefs.

## Release impact

- [ ] **Breaking** — requires action from anyone already running this
- [x] **Not breaking** — no action required

Every old address keeps answering: GETs redirect permanently, POSTs are
served where they were. No schema, API shape or configuration changes;
hint strings name the new addresses.

- **What does a revert leave behind?** No schema or rows. It does leave
the new addresses that people's agents and clients now rely on: the
global `patchy` skill on `main` sends people to `/agents`, this
release's CLI hints name `/settings/integrations`, `/settings/people`
and `/settings/agent-access`, and the API, MCP and publish hints it
served say the same, as do bookmarks people make.
- **Does the release before it still work with that?** No. It serves
none of `/agents…` or `/settings/…`, so every one of those links and
hints answers 404 until production rolls forward again. Nothing else
breaks: no data or schema changes. Labelled `one-way`.

Built by Claude Opus 5.5 (xhigh) in Claude Code, orchestrated by Fermy.

<!-- patchy-dev:compare:allison -->

#### Before and after, as Allison Mahmood (admin)

Before is `0a78106` (where this branch left main) and after is `529f6be`
(ui/u-addresses), both on the `brightline` scenario, from `pnpm dev
compare`.

##### `/machines`

**1280px, after**

![After: /machines at
1280px](https://github.com/user-attachments/assets/5d9f5f83-85bd-450d-a8d0-922664d71f6c)

<details><summary>1280px, before</summary>

![Before: /machines at
1280px](https://github.com/user-attachments/assets/809206ef-52d2-4a6f-a38f-4f7ba223093f)

</details>

| Width | Before | After |
| --- | --- | --- |
| 390px | ![Before: /machines at
390px](https://github.com/user-attachments/assets/5b269bee-e9e3-4d97-965a-84fb39fcf24e)
| ![After: /machines at
390px](https://github.com/user-attachments/assets/f6c6844d-d6e1-4207-868c-9fcac37dd8b1)
|

##### `/machines?agent=codex`

**1280px, after**

![After: /machines?agent=codex at
1280px](https://github.com/user-attachments/assets/ed835e8f-fe5f-4fec-b1bc-01a92fe99871)

<details><summary>1280px, before</summary>

![Before: /machines?agent=codex at
1280px](https://github.com/user-attachments/assets/6c322fc0-2e4d-4f60-b54e-9b206a0f7cf8)

</details>

| Width | Before | After |
| --- | --- | --- |
| 390px | ![Before: /machines?agent=codex at
390px](https://github.com/user-attachments/assets/ad85cfea-863e-4f83-bc60-19179f439234)
| ![After: /machines?agent=codex at
390px](https://github.com/user-attachments/assets/337c5748-c3be-49da-b0e1-dec374238319)
|

##### `/agents/computer`

**1280px, after**

![After: /agents/computer at
1280px](https://github.com/user-attachments/assets/bd137049-1899-4f77-94c2-67d59702fca3)

<details><summary>1280px, before</summary>

![Before: /agents/computer at
1280px](https://github.com/user-attachments/assets/c0fcdab8-3792-47e9-83f2-ab77696578f3)

</details>

| Width | Before | After |
| --- | --- | --- |
| 390px | ![Before: /agents/computer at
390px](https://github.com/user-attachments/assets/778f167c-fe67-49fe-934e-3547fd719424)
| ![After: /agents/computer at
390px](https://github.com/user-attachments/assets/b0e8f065-f304-40d6-bea7-b9da60e1c0f5)
|

- Before at 1280px answered 404; 1 browser error(s): `Failed to load
resource: the server responded with a status of 404 (Not Found)`.
- Before at 390px answered 404; 1 browser error(s): `Failed to load
resource: the server responded with a status of 404 (Not Found)`.

##### `/company`

**1280px, after**

![After: /company at
1280px](https://github.com/user-attachments/assets/0f2b2e47-dc63-458f-9f22-d7efe25cb2f0)

No visible change at 1280px.

| Width | Before | After |
| --- | --- | --- |
| 390px | No visible change | ![After: /company at
390px](https://github.com/user-attachments/assets/5c7cef63-832c-4528-bdac-42a1c221204e)
|

<!-- /patchy-dev:compare:allison -->

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core Touches the core area area:docs Touches the docs area area:server Touches the server area area:ui Portal and first-party browser pages, shared rendering and styles size:l 501-1,000 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(portal): switcher.json lists the patches a person can open

1 participant