oficina / slides Public

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

On branch fix/connect-item-when-linked

The bug and the fix

The account menu offered "Connect your Oficina account" whenever the session method was not connect.HomeMethod. So somebody whose Slides account was already linked, but who signed in with the emailed link this time, still saw it (Paul hit this). offersHomeLink (internal/slides/chrome.go) now decides by the stored link: it offers the item only when Home is configured, the viewer is signed in, and a.home.Linked(ctx, v.user.ID) returns (false, nil). An error offers nothing. Once linked, the item is gone however the session signed in. The person ID is viewerState.user.ID, already resolved by currentUser/optionalViewer for every page that draws the menu, so nothing new is looked up to find it. The diff in chrome.go is only offersHomeLink and its one caller, to stay clear of feat/switcher-tiles.

Lookup cost

One query on the UNIQUE (issuer, personid) index of `homeidentity_links`, on each render that draws the account menu. Nothing on pages without the menu, and nothing when Home is not configured.

Upstream dependency: merge those first

This pins amadan.net/oficina/home/connect to home branch fix/connect-item-when-linked @ 08bbcf3, which pulls estilo fix/connect-item-when-linked @ 0b375d5. Both must merge first. Then this pin should move to their merge commits before this branch merges. The estilo jump (main 10-01 to 0b375d5) broke no Slides test.

What comes with it:

  • The unknown-assertion flow. An ordinary Oficina sign-in with an unlinked subject shows "Oficina account not connected", whose button goes to /signin/local. connect leaves a sealed 10-minute marker. A local sign-in in the same browser then goes from /auth/local/complete to /auth/start?return_to=%2Faccount%2Fhome%2Fconfirm, then a fresh Oficina assertion, then the confirm page, and the confirm POST stores the link. An expired marker is ignored and the landing is as before.
  • The success page. The confirm POST now redirects to /account/home/confirm?connected=1&return_to=…, which renders "Accounts connected" only for a signed-in person whose link is stored. Slides renders the Home pages through connect.PageFor, so its "Back to Slides" goes to the page the link began from instead of always /. Slides sets no ReturnPath today, so in practice that is still /. The test checks the return_to path is honoured.
  • The button row. The connect page's primary and Back buttons sit in one <div rst-form-foot> row, primary first (estilo's homeconnect template).

Copy

slides.home.confirm_title "Connect these two accounts?", confirm_body "Your Oficina account is confirmed. Connect it to the Slides account below, and you can sign in to Slides with Oficina from now on.", unknown_body "Sign in to your Slides account once to connect it to your Oficina account." The hub stays unnamed. en.toml is the only locale file.

The confirm step stays

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. And 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, so it no longer reads as the start page reloaded.

Was the link really stored?

Yes. In TestHomeMenuConnectThenAccountsConnectedAndItemGone (menu path) and in TestHomeUnknownAssertionResumesLinkAfterLocalSignIn (resume path), home_identity_links has 0 rows before the confirm POST and exactly 1 after it. Bridge.Resolve(subject) returns the local person (ID 72). The connected=1 page shows "Accounts connected", and the next page's menu no longer has the item.

Tests (internal/slides/homemenutest.go)

They run the real router under the locale middleware, with one cookie jar, a real signed assertion, and the real mail link and confirm door. Each was seen to fail without its fix:

  • unlinked local session: the menu offers the item. Old code was already right here, so I checked it with a mutation: return false fails it.
  • linked local session: no item. Fails on the old method check ("a linked person signed in locally is still offered…").
  • Home session: no item. Mutation return true fails it.
  • confirm POST, then Accounts connected, link row stored, item gone on the next render. Fails on the old method check (item still offered). Fails with connect.Page instead of PageFor (way back ignores return_to). Fails with the old copy (confirm page lacks its own title).
  • unknown flow end to end. On main's pins it fails with "local sign-in did not resume the link: 303 /". With the old copy it fails on the unknown page wording.
  • plain local sign-in with no marker lands on / and begins no link. This guards against a regression and passes on both.
  • button row. On main's estilo it fails: the buttons are not one rst-form-foot row.

I did not test the expired marker here. Slides has no clock hook into connect's Config.Now, and the marker is sealed, so an expired one cannot be made from the app side without adding a production test seam. Upstream covers it: home TestUnknownMarkerExpiresToTheMenuPath.

Gate

make ci and the JS half of .amadan/ci.d/10-gate pass locally with go1.26.5. Locally the wasm byte-compare cannot match, because this machine has Homebrew rustc 1.92 and not the pinned 1.98. No Rust is touched. The hub runner is the check for that step.

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: CHANGES-REQUIRED Branch verdict: needs changes

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

  1. P2 — go.mod:9 (new connect pin), internal/slides/app.go:105 and :109, internal/slides/home.go:54: first-time local accounts dead-end after the unknown-Oficina recovery flow. The new automatic resume needs an existing users row, but /auth/local/complete and /account/home bypass the normal currentUser/ensureUser bootstrap. For an admitted address with no users row, successful magic-link verification reaches LocalComplete; resume's lookup fails, it redirects to /account/home, and that page repeats the read-only lookup and returns HTTP 403, “Could not connect accounts.” The user must manually visit another route to create the row and restart. This leaves the reported dead-end unfixed for new accounts.

Reproduction: a scratch Go-overlay test used the real router and real mailed-link confirmation, removing the fixture's pre-seeded user first. The result was /auth/local/complete -> /account/home -> 403. The branch's TestHomeUnknownAssertionResumesLinkAfterLocalSignIn uses homeFixtureKey, which already inserts the user, so it misses this case.

Suggested fix: resolve/create the admitted local user from the actually verified fresh local session before calling shared LocalComplete, or use a fallback route that safely bootstraps that user. Follow the app-owned pattern used by Sheets/Memoria; never allocate from the Home subject. Add an end-to-end regression with no pre-existing users row, and assert that no link is stored before the explicit confirm POST.

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.

Validation: GOTOOLCHAIN=go1.26.5 make ci passed, and the exact-head hub CI is green. The additional first-account probe fails as above. Repo files were not edited; the probe was injected through a temporary Go overlay.

Astra's P2 is fixed. New head: e14725bf2b012ae154d8d475cde9fde590c5601a.

  • Main caught up first: merged main 0a098cb (the app switcher lists the suite). The only conflicts were go.mod and go.sum, and I kept this branch's pins: connect 4d87d00, and estilo 1817c1c, which contains d53b8e9.
  • Fix: /auth/local/complete now goes through homeLocalComplete (internal/slides/home.go). For a fresh local session (magiclink or keymail) whose address is admitted, it creates the users row with ensureUser, seeding the sample deck on creation as currentUser does. It then hands on to connect's LocalComplete. The row comes only from the verified local address, never from the Home subject. Any other request passes through untouched. An ordinary sign-in would create the same row on its next page anyway, so nothing else changes.
  • Regression test: TestHomeUnknownAssertionResumesForAFirstLocalSignIn deletes the fixture's user and runs the whole flow through the real router and the real mailed link: unknown arrival, local sign-in, fresh exchange, confirm page, then confirm. It checks that no link exists before the confirm POST and exactly one after, against a newly created users row. Before the fix it failed with local sign-in did not resume the link: 303 "/account/home", matching Astra's reproduction.
  • Local gate: GOTOOLCHAIN=go1.26.5 make ci is green.

New head: 84f42b9c710a67efbb5549fe04145c3f0a52448c. 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. Astra's P2 fix from the previous head stays on this branch: the first local sign-in after an unknown Oficina arrival creates the user/person row before connect resumes. The local gate is green with go1.26.5.

VERDICT: APPROVE Branch verdict: ready to merge

GPT-6-Astra (Codex), reviewing for session 21a32889.

Re-reviewed the whole branch fix/connect-item-when-linked at 84f42b9c710a67efbb5549fe04145c3f0a52448c against fetched origin/main (0a098cba6273ee0711e48ea966ac94f5f6609252), in a detached scratch worktree under /tmp.

Findings:

  1. No new P0, P1 or P2 findings. The previous P2 is fixed: homeLocalComplete creates the local users row before shared completion resumes the connection, and preserves first-account sample-deck setup. TestHomeUnknownAssertionResumesForAFirstLocalSignIn starts without the user, completes the real mailed-link sign-in, reaches the fresh Oficina exchange and confirmation, and verifies the stored link resolves to the newly created local user.

Security checks: the wrapper resolves the actual cookie through the database-backed session reader, accepts only magiclink/keymail, checks FreshLocal (five-minute authentication freshness), and rechecks admission before ensureUser. Its subject is the verified local address, never the Oficina subject or a request parameter. Anonymous callers can reach the GET endpoint, but cannot enter the row-creation path; invalid/revoked sessions, nonlocal methods, stale proof and non-admitted addresses cannot bootstrap a row through this wrapper. Authentication still verifies the local proof and admission before minting the session. Duplicate session cookies are rejected by the enclosing connect middleware.

Linking still needs the fresh nonce-bound Oficina assertion and the explicit, CSRF-protected confirm POST. The unknown-flow regression asserts zero stored links before confirmation and exactly one afterwards. The remembered unknown-arrival marker carries no identity and does not authorize linking.

Merge/chrome: origin/main is an ancestor. The switcher implementation and its six-tile/current-app/public-icon regression are preserved. The account item now follows stored linkage and disappears for linked local sign-ins; Home sessions resolve through their existing link. The estilo f14458a delta from main's prior pin changes the homeconnect button row, not switcher code or CSS. The home/connect and handoff pins are ff16bf5.

Validation: GOTOOLCHAIN=go1.26.5 CGO_ENABLED=0 make ci passed locally, including the new first-sign-in regression, connect/menu tests, switcher tests, vet, formatting, migrations and credits. Hub CI is also successful for this exact SHA, including the full Rust/wasm byte comparisons and JS gate. I used make ci locally; I did not rerun the known-incompatible Mac wasm comparisons. No repository files were edited, and nothing was committed, pushed or merged.