🤖 Branch fix/connect-item-when-linked @ c5ff381. Not merged, not deployed.
The bug and the fix
The account menu offered "Connect your Oficina account" to every magic-link/Keymail session (offersHomeLink tested v.method). So a person whose account was already linked, but who signed in with Memoria's own email link, was still offered it (Paul hit this). Now the stored link decides: offersHomeLink(r, v) finds the viewer's local identity row (homeLocalID, by the keyed address fingerprint) and asks Bridge.Linked(ctx, id). No row means no link can name this person, so it offers. An error on either lookup means unknown and offers nothing. A Home session is the link, so it is never offered there. The chrome.go change is limited to offersHomeLink and its one caller.
Lookup cost
Per menu render: one indexed lookup on memoria_home_local_identities.address_lookup, plus one on home_identity_links' UNIQUE (issuer, person_id) once the person has a row. The person ID was not already in the request context (admissionOf resolves an ID only for Home sessions, and viewer carries none), so it is looked up here.
Unknown-assertion flow
When an Oficina assertion with no link arrives, home leaves a sealed 10-minute marker. The next fresh local sign-in, at /auth/local/complete, starts the link: /auth/start?return_to=%2Faccount%2Fhome%2Fconfirm, then a fresh Home assertion, then the confirm page, then the confirm POST. Memoria-specific fix needed for this: starting the link needs the person's local identity row, and only /account/home created it. So someone who had never opened that page could not resume, and ended up on the Connect page instead. The new localComplete creates the row first, but only for a fresh local sign-in that carries connect's navigation-marker cookie. Ordinary sign-ins still create nothing, as the existing tests require. It checks the cookie by name (it is unexported in connect); the resume test fails if that name changes.
Dependencies: this pins home fix/connect-item-when-linked @ 08bbcf3, which brings estilo fix/connect-item-when-linked @ 0b375d5. Both must merge first, and then this pin should move to their merge commits.
Success page
The confirm POST redirects to /account/home/confirm?connected=1&return_to=…, which shows "Accounts connected". renderHome now calls connect.PageFor(r, …), so the button goes back to the page the sign-in was heading for. The test checks /search?q=nebula, not /.
Button row
Estilo 0b375d5 puts the connect page's buttons in one <div rst-form-foot> row, primary first. static/chrome.css was regenerated (go run ./scripts/writeestilo); TestDoorStylesAreEstilos failed until that was done. That was the only fallout from the estilo bump.
Confirm step: kept
We kept the explicit confirm click. Skipping it would let a remembered unknown assertion plus a local sign-in link the two accounts with no deliberate gesture. Also, the Oficina assertion carries only an opaque subject, so the confirm page cannot name the Oficina address, only the local one. Instead the confirm page now has its own title and copy: "Connect these two accounts?" / "Your Oficina account is confirmed. Connect it to the Memoria account below, and you can sign in to Memoria with Oficina from now on." The unknown page now says "Sign in to your Memoria account once to connect it to your Oficina account." The hub is still not named.
Was the link actually stored?
Yes. The tests read home_identity_links directly. There is no row before the confirm click and exactly one row for the subject after the POST, both from the menu and in the unknown flow. After that, the same session's next page has no menu item, and a fresh Oficina sign-in with that subject signs in as alice.
Tests (internal/memoria/homelinkedtest.go), each seen red with the fix reverted
- unlinked local session, with and without an identity row: offered. Red when
offersHomeLink returned false for no row, and again for a row with no link. - linked, then a magic-link sign-in: no item. Red with the session-method check restored.
- either lookup failing (each table dropped): no item. Red when an error offered the item, for each lookup.
- Home session: no item. Red when every signed-in viewer was offered it.
- confirm POST in the same session: "Accounts connected", the row exists, and the next page has no item. Red with the method check restored.
- unknown flow end to end (unknown page button goes to
/signin/local, then the freshness start, fresh assertion, Memoria confirm copy, POST, stored row, PageFor's way back). Red without localComplete (landed on /account/home), with connect.Page instead of PageFor, and without the copy overrides. - marker age: 9 minutes resumes, 11 minutes lands on
/ with nothing started. This uses the app clock, which WireHome now passes as Now: a.now (time.Now in production). The fixture starts on that clock because the link store refuses to go backwards. Red on the 9-minute case without localComplete. The expiry check itself is home's code and is tested there. - button row: one
rst-form-foot, primary before ghost, on the start page and the confirm page. Red with estilo pinned back to 530cb93 (zero rows).
GOTOOLCHAIN=go1.26.5 make ci is green locally.