oficina / sheets Public

Connect item follows the stored link; unknown arrival resumes the link open

On branch fix/connect-item-when-linked

Branch fix/connect-item-when-linked @ dc23a0d. Not merged, not deployed.

The bug and the fix

offersHomeLink refused only Home-method sessions. So a person whose Sheets account was already linked, but who signed in with the email link, was still offered "Connect your Oficina account" (the same thing Paul hit in Docs). Sheets had the bug.

The menu item now follows the stored link, not the session method: it is offered only when Home is configured, the viewer has a local (non-Home) session, and a.home.Linked(ctx, memberID) returns (false, nil). An error offers nothing. Once linked, the item never appears, however the session signed in. The person ID is the members.id for the session's address (read without creating, via a new localMemberID helper in home.go). Nothing in the request context already carried it. The chrome.go diff is confined to offersHomeLink and its one call (it now takes the address), so it should merge cleanly with feat/switcher-tiles.

Lookup cost

Each render that draws the account menu costs two indexed point reads: members by its unique address index, then home_identity_links on its UNIQUE (issuer, person_id) index.

Unknown-assertion flow (dependency)

This pins amadan.net/oficina/home/connect to home branch fix/connect-item-when-linked @ 08bbcf3, which brings estilo fix/connect-item-when-linked @ 0b375d5. Both must merge first, and this pin should then move to their merge commits. With it, an Oficina sign-in with no link shows the unknown page ("Sign in to your Sheets account once to connect it to your Oficina account.", button to /signin/local) and leaves a 10-minute sealed marker. The next fresh local sign-in in that browser begins the link itself: /auth/start?return_to=%2Faccount%2Fhome%2Fconfirm, then a fresh Home assertion, then the confirm page. Without the marker, the landing is /sheets as before.

Success page

The confirm POST now leads to /account/home/confirm?connected=1&return_to=..., which renders "Accounts connected". Sheets now calls connect.PageFor(r, ...), so its "Back to Sheets" goes to the page sign-in began from (e.g. /sheets), not /.

Button row

The connect page's buttons now sit in one <div rst-form-foot> row, primary first (estilo 0b375d5). A render-level test asserts this.

Confirm-step decision

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. The confirm page now has its own title and copy: "Connect these two accounts?" / "Your Oficina account is confirmed. Connect it to the Sheets account below, and you can sign in to Sheets with Oficina from now on." The hub stays unnamed.

Was the link actually stored?

Yes. The tests count home_identity_links rows for the member: 0 on the confirm page before the click, and 1 after the confirm POST. This holds for both the menu flow and the resumed unknown flow. The very next /sheets render in the same session no longer offers the item.

Tests (internal/sheets/homeconnectitem_test.go), each seen red without its fix

  • TestConnectItemFollowsTheStoredLink: unlinked local session sees the item; after linking, the same session does not, and neither does a later email-link session; a Home session does not. Red with the old offersHomeLink ("a linked person signed in by email link is offered the connection").
  • TestConfirmLeadsToAccountsConnected: Sheets' confirm copy; buttons in one form-foot row, primary then ghost; no link before the click; POST then "Accounts connected"; row stored; menu item gone. Red with the old offersHomeLink (menu), the old copy (confirm copy), and the old module pins (no rst-form-foot row).
  • TestUnknownArrivalResumesTheLinkAfterLocalSignIn: the full flow above, through a real magic link, ending in "Accounts connected" with href="/sheets". Red with the old pins (local sign-in landed on /sheets), with connect.Page instead of PageFor (wrong back link), with the old copy, and with the old offersHomeLink.
  • TestUnknownArrivalForgottenLandsAsBefore: the marker is set with Max-Age 600. With it gone (what the browser does after ten minutes), the local sign-in lands on /sheets and the item is offered. Red with the old pins (no marker). The sealed in-marker expiry can't be driven from Sheets, because connect's navigation clock isn't injectable from the app. It is covered upstream by TestUnknownMarkerExpiresToTheMenuPath.
  • The unlinked and Home-session cases are regression guards: they pass both before and after the fix.
  • Fixture: home_test.go's link helper now checks the new confirm title.

make test (GOTOOLCHAIN=go1.26.5) is green locally. The estilo bump broke nothing else.

Review: not yet reviewed by the highest-capability model (AGENTS.md §Review), so that pass is still owed before merge.

Re-pinned after the coordinator restart. home/connect is now 4d87d00, the connect branch caught up with home main 0ceb238, and estilo comes in at 1817c1c, the homeconnect row branch caught up with switcher tiles d53b8e9. The local gate is green with go1.26.5. The pins should move to the merge commits once estilo and home land.

On "name both accounts" (item 4): the Oficina half cannot be named, by design. The assertion's subject is an opaque person ref, and Home's one rule is that it never stores a readable address, so no Oficina address exists anywhere to show. The confirm step names the local account and gets its own question for a title. The explicit click stays, because the resumed flow would otherwise link accounts with no deliberate gesture.

VERDICT: APPROVE-WITH-NITS Branch verdict: ready to merge

GPT-6-Astra (Codex), reviewing for session 21a32889. Reviewed the whole branch at 7afefc360517491b669b43cc727dd601a1d314d3 against fetched origin/main.

  1. No blocking P0/P1/P2 findings. Security review: I found no P0/P1 issue or demonstrated login-CSRF/account-link substitution in the changed flow. The sealed, ten-minute marker carries no identity; the resumed link still uses the actual fresh local session, a fresh nonce-bound Home assertion, and an explicit CSRF-protected confirmation POST. Success is checked against stored linkage. This is a code-review verdict, not a waiver of the required merge gate.

The app-owned homeLocalComplete resolves/creates the member only from a verified fresh admitted local session before calling shared completion. This covers new accounts without using the unknown Oficina subject as local identity. Menu visibility follows the stored link; confirmation remains explicit and success follows stored state.

Note on query cost: this app's helper can do two indexed reads per relevant render, one to resolve the member by address and one to check issuer/person linkage. It is not literally one extra SQL query in this implementation. The cost is small and bounded, but the one-query comment should describe both reads or reuse an already-resolved member.

Validation: GOTOOLCHAIN=go1.26.5 make test passed, including store/live race tests. The exact-head hub CI is green. Land the reviewed estilo/home dependencies first and refresh pins after squash if necessary.

New head: e10babd20d2b1f7583b21d8930429360ce5efb35. estilo #25 and home #84 have merged, so this branch now pins main: estilo f14458a, and home/connect and home/handoff ff16bf5. Current origin/main is merged in; only go.mod and go.sum conflicted, and those were resolved to the new pins. writeestilo, where this repo has it, leaves the vendored CSS unchanged. The local gate is green with go1.26.5.