Branch fix/connect-item-when-linked @ 79e1477.
The bug and the fix
In Docs, a person whose account was already linked but who signed in with the app's own email link was still offered "Connect your Oficina account": the item was decided by how the session signed in. In Calendar the item was not there at all. It was dropped when Calendar adopted the shared chrome (dbee441), so /account/home could only be reached by typing the URL.
It is back now, and decided by the stored link. handlers.offerHomeConnect (home.go) offers it only when all of these hold:
- Home is configured;
- the session is local (
magiclink or keymail, read with sessions.Current); - requirePerson's person is on the request;
Bridge.Linked(ctx, person.ID) returns (false, nil).
An error offers nothing. A Home session never gets it. h.page (render.go) appends the item. chrome_calendar.go is untouched, so this cannot collide with feat/switcher-tiles.
Lookup cost
One SELECT 1 on the UNIQUE (issuer, personid) index of `homeidentity_links per render that draws the menu. The person ID is requirePerson's (CurrentPerson`), so no extra person lookup. Pages outside requirePerson (errors, the connect pages themselves) have no person and are not offered the item.
Unknown-assertion flow (dependency)
The bump to home/connect fix/connect-item-when-linked @ 08bbcf3 adds this flow:
- An Oficina sign-in whose subject has no link shows "Oficina account not connected". Its button goes to
/signin/local, and a sealed 10-minute marker is set. - The next fresh local sign-in lands on
/auth/start?return_to=%2Faccount%2Fhome%2Fconfirm with __Host-oficina-home-init set. - Then the fresh assertion, then the confirm page, then the confirm POST.
An expired marker is ignored. This needs home fix/connect-item-when-linked @ 08bbcf3 and estilo fix/connect-item-when-linked @ 0b375d5. Both must merge first, and then this pin should move to their merge commits. The estilo bump also re-wrote static/chrome.css through writeestilo (estilo main added the rail-account CSS). No other fallout.
Success page
The confirm POST now redirects to /account/home/confirm?connected=1&return_to=…. That renders "Accounts connected" only for a signed-in person whose link is stored. The app now calls connect.PageFor(r, state, label), so the page's button goes back to where the link began, not to "/".
Button row
The connection pages' buttons are one <div rst-form-foot> row, primary first (estilo homeconnect at 0b375d5).
Confirm step: kept
We kept the explicit confirm click. Skipping it would let a remembered unknown assertion plus a local sign-in link 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?". Calendar overrides none of connect's copy, so it gets the new English as is.
Was the link actually stored?
Yes. The tests count rows in home_identity_links directly rather than asking the bridge:
- 0 rows before the confirm click, 1 after;
Bridge.Resolve(subject) returns alice;- the next page's menu drops the item.
Tests (internal/calendar/homeconnectitem_test.go), each seen red
TestConnectItemOfferedToALocalUnlinkedPerson: red with no item (main's state).TestConnectItemNotOfferedToALinkedPersonSignedInLocally: link, then a fresh emailed-link sign-in in a new browser. Red with the session-method rule (the Docs bug).TestConnectItemNotOfferedToAHomeSession: red when the item is offered to every signed-in session.TestConfirmLeadsToAccountsConnectedAndRetiresTheItem: the redirect has connected=1, the page says "Accounts connected", the row exists, and the next menu has no item. Red with the session-method rule, and red on the old pin.TestAccountsConnectedReturnsToWhereTheLinkBegan: red with connect.Page.TestUnknownOficinaSigninResumesAfterLocalSignin: the full flow above. Red on the old pin (lands "/").TestUnknownOficinaSigninExpiresAfterTenMinutes: uses a lagging Home clock (unexported Config.homeNow) that starts 11 minutes behind. The fixture has to start the clock behind because the hand-off store's clock fence refuses to move backwards. Red at 9 minutes, where the marker is still valid and resumes.TestConnectPageButtonsShareOneFormFootRow: red on the old estilo pin.
The Home router fixture now returns the local landing from local and can take that clock lag.
make ci is green locally with go1.26.5. One unrelated flake was seen once: TestPublicBookingPostRegistersItsHoldAndMail. It passed 8 times in a row on rerun.
Not merged, not deployed.