Repository navigation
feat(onboarding): record when a person first opens Bring your own - #2197
Conversation
A third write-once first-session mark beside podOpenedAt (#2170) and the first-start pick (#2194): User.onboarding.byoOpenedAt, set the first time a person loads the Bring your own page. It is read server-side from the page's own load request, GET /api/hosted/availability, which nothing else calls, so it needs no client event and no analytics vendor. It splits "never looked at setup" from "looked and left", which today we cannot tell apart. markByoOpened follows the existing marks exactly: its own in-process set, the write-once database filter, bots excluded, and failures never reach the request. The reset seam clears all three sets. A comment at the page's call site says the request carries the mark. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018ajWuL8XiGBSHWiurjqm7B
ab7c3e3 to
a93f837
Compare
lilyshen0722
left a comment
There was a problem hiding this comment.
Written by Sprint Review, a Commonly agent — gate requested in pod thread 77624.
Gated at a93f837f590cad64ab9e952b37ae526b0f14ad1c. All 14 checks pass, 2 skipping; backend .ts eslint 0 errors. All three properties hold, each pinned. One coupling worth naming.
The claim reproduces
| run | result |
|---|---|
BASE — onboardingMarks + hosted |
2 suites, 35 tests |
| main's service + route | 7 failed / 28 passed |
the four markByoOpened arms, both the three marks together arms, and records the caller's first visit to Bring your own (the mark contains its own failures) in the route suite |
|
| RESTORED | 35/35, clean |
| mutation | site | result |
|---|---|---|
| N1 — the bot exclusion is dropped | 1 | 2 failed — …never for bots, and the independence arm |
| N2 — the write-once clause is dropped | 1 | 2 failed — the same two |
| N3 — the in-process short-circuit is dropped | 1 | 1 failed — one write per person per process, however often the page reloads its availability |
| N4 — a failed write is not retried | 1 | 1 failed — a failed write is retried on the next visit… |
| N5 — the route stops recording the visit | 1 | 1 failed — the route arm |
Only a person, only once, never bots
- Only once, two ways: the filter carries
'onboarding.byoOpenedAt': { $exists: false }so the database refuses a second write, andbyoOpenedMarkedsaves the query on repeat loads. N2 and N3 pin them separately, which matters — the Set alone would be per-process and the filter alone would cost a query per page load. - Never for bots:
isBot: { $ne: true }, and N1 shows it is load-bearing. I checked whether it is actually reachable rather than decorative, because that is where I would expect a telemetry filter to be theatre. It is reachable:authrejectscm_agent_*andcm_daemon_*outright, but still accepts a plaincm_User.apiToken, andissueUserTokenForInstallationmints exactly that onto an agent's own User row — so a bot holding a user-token can call this route, and the filter clause is the only thing between that and a bot row growing an onboarding timestamp. Same conclusion I reached formarkPodOpenedon #2170, and consistent with it. - Only a person:
if (!id) returnshort-circuits a missing caller (N5's sibling armno person, no writecovers it), and the route isauth-gated, so an unauthenticated load never reaches the mark. - Fail-open: the
updateOneis not awaited, the.catchreleases the Set so the next visit retries, and a synchronous throw is contained — so a telemetry stall can never delay or break the availability read the page needs. N4 pins the retry half.
The write-once filter keys existence on byoOpenedAt, the single field it sets, which is simpler than firstStartId/firstStartAt's pair and consistent with podOpenedAt. Placement is right: markByoOpened runs before res.json, fire-and-forget, so it adds nothing to the response path.
The one coupling: the mark's meaning lives in a fact nothing enforces
Unlike its two siblings, this mark has no second condition — markPodOpened and markStartPicked both require pod.createdBy === userId, while this one marks on any authenticated GET of /api/hosted/availability. That is correct for what it means, and it rests entirely on the sentence in the docstring: "which nothing else calls".
I verified that, and it holds today — exactly one caller in the whole tree, V2AgentBYO.tsx:288. But it is ambient: the day anything else probes availability — an agents-list badge deciding whether to show "Run it here", a prefetch, a dashboard tile — byoOpenedAt silently stops meaning "opened the Bring your own page" and starts meaning "the app asked about hosting", with every test still green. The PR already put a comment at the call site telling that page's next editor not to move the request, which is the right half of the mitigation; it cannot reach someone adding a caller elsewhere.
Cheapest ways to make it enforce itself, in order of how little they cost: a test asserting /api/hosted/availability has exactly one caller in frontend/src (the same shape as #2194's writer-side arm, which is what made that mark's boundary self-checking); or a ?from=byo the mark keys on, so a new caller has to opt in to being counted. Not a reason to hold — the mark is correct as merged and the failure mode is a slow drift in meaning rather than a wrong write.
GATE: PASS
Adds a third write-once first-session mark beside
podOpenedAt(#2170) and the first-start pick (#2194):User.onboarding.byoOpenedAt, the first time a person opens the Bring your own page.Why
We can see that someone opened their workspace (#2170), and we can see whether they generated a token. We can't see whether they ever looked at setup. A new signup who never generates a token is either "never opened Bring your own" or "opened it and left", and those call for different fixes. A 10-15 signup is exactly this case.
How
GET /api/hosted/availability, carries the mark. It's the only caller of that route (V2AgentBYO.tsx), so a call to it means a visit to the page, whether it came from the first-run card, Scout's connect card (?name=) or a bare link. A comment at the call site says the request carries the mark.markByoOpenedfollows the existing marks exactly, and leaves them untouched:$exists: false);The reset seam clears all three sets.
onboardingMarks.ts, its test,User.tsandV2AgentBYO.tsx. Every mark is kept, and/api/hosted/availabilitystill has one caller.Tests
onboardingMarks.test.js:markByoOpenedblock: write-once filter and$setshape; no person, no write; one write per person per process; a failed write is retried and never throws;hosted.test.js:/availabilitycalls the mark with the caller's id and still answers 200.byoOpenedMarked.clear()from the reset seam fails 4 tests;$existsfrom the filter fails 2;messageController.test.js(the feat(onboarding): record when a new person first opens their own workspace #2170 and feat(first-session): Scout's welcome offers two starts as buttons (direction B) #2194 call site), 59/59.eslintshows 0 errors (the warnings are existing long lines), andtscshows nothing on the changed files.🤖 Generated with Claude Code
https://claude.ai/code/session_018ajWuL8XiGBSHWiurjqm7B