Skip to content

feat(onboarding): tell people their seat was never started (W4 item 3) - #956

Merged
lilyshen0722 merged 1 commit into
mainfrom
feat/stalled-connect-nudge
Aug 15, 2026
Merged

lilyshen0722 merged 1 commit into
mainfrom
feat/stalled-connect-nudge

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

W4 item 3, to @ux-lead's stalled-connect-spec.md. The recovery path for the population #954 cannot see.

The case that motivated it, from last night

user-fbd3, signed up 2026-08-15 02:25 UTC:

02:25:43  signed up
02:25:45  Scout posts its opener                                    (+2s)
02:27:00  installs a BYO agent, "ai1-agent"                         (+77s)
02:27:02  runtime token issued
02:27:01  the seat posts "Nothing is running me yet…"   ← #943 working
          ── nothing ever follows up ──
03:37     token lastUsedAt = NEVER · messages typed = 0 · gone

They moved fast and deliberately. #943 told them the truth at minute zero, and then the platform never spoke again. #954 is blind to this person — it fires on someone speaking and getting no answer, and they never spoke.

Fifteen minutes after a token is issued and still unused, the seat now says so in the room, addressed to the installer by name, with the exact command.

Three corrections from the fleet, all of which changed the code

@pod-architect — the episode key must be the union. max(createdAt) across both token stores, matching the union deriveAgentState already uses for liveness. Key off one store while triggering off the union and a reissue on the other path never resets the episode, so the spec's "a reissue earns one more nudge" silently stops firing. Exported as resolveTokenEpisode so @sprint-impl's reactive responder shares one definition instead of recomputing it.

@pod-architect — the stores are not symmetric. User.agentRuntimeTokens has expiresAt; AgentInstallation.runtimeTokens does not. Verified in both schemas. So "the life of the current newest token" genuinely ends differently depending on which minted it — expiry on one path, supersession-only on the other. Recorded as tokenSource rather than left to be discovered later.

@ux-lead — the confirmation is not time-bounded, and is compound. Flat for the past (a first-connection timestamp is a fact), derived at post time for the present (an inference). Connected (first seen 09:00 UTC). It isn't running right now — restart it with ... That also dissolved a case I'd flagged as unhandleable: lastUsedAt leaving null is a permanent transition, so a wrapper that connects and stops between two passes isn't invisible — it just gets a different present tense.

i18n is deferred, and the seam is visible

The spec asked for en + zh-CN from day one. There is no mechanism: language lives in frontend localStorage, never reaches the backend, there is no User.language, and there is no server-side i18n layer at all — #715–720 was frontend-only. composeInstallIntro (#943) shipped English-only for the same audience with the same argument available.

@ux-lead ruled option 1 and owned the spec defect: ship en now, because the load-bearing content is the fixCommand and that is language-neutral, so an English nudge beats silence — and blocking inverts the harm for every user. Two riders, both honored: the composers take a locale they currently ignore so the layer changes only them, and the separate filing should capture the switcher choice as User.language — what the user chose, not what the browser guessed — which retro-covers #943 and the digest at the same time.

Design notes

  • Claim before post. The episode row is created before the message goes out, so a losing race costs one nudge instead of delivering two. A second message in someone's room cannot be taken back; a missed one can be retried next pass.
  • One derivation. deriveAgentState decides connected-ness. The 15 minutes is a patience window on top of its verdict, never a second inference — which is why this only ever fires on never-connected, the structurally certain case, and can afford flat declarative copy. If it's ever extended to gone-dark, the copy must hedge; the comment says so.
  • Cron, not delayed event, per spec: re-deriving from state each pass is drop-proof, where a delayed AgentEvent inherits the pending-GC caveat.
  • Unconditional per-pass log line, learned from fix(onboarding): make the silence detector observably alive #955 an hour ago — a detector nobody can observe is indistinguishable from a dead one.

Verification

14 new tests, 63 green across the affected suites, tsc:check clean.

Not yet exercised against a live stalled seat. There are real candidates in production right now (user-fbd3's ai1-agent among them), so the first deploy will produce real nudges — worth a look at the first one before trusting the rest.

@sprint-impl has confirmed no collision: their reactive WIP used an embedded AgentInstallation.connectionNudge with a SHA key, and they'll rebuild on this contract.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XeUH4HVDsDHYPsHJthXjB8

`user-fbd3` signed up on 2026-08-15, installed a BYO agent 77 seconds
later, never ran it, never typed a word, and left. The seat's install intro
(#943) told them the truth at minute zero — "nothing is running me yet" —
and then nothing ever followed up. That is the modal onboarding failure and
it is the one the silence alert (#954) is blind to by construction, because
it fires on someone speaking and these people never speak.

Fifteen minutes after a runtime token is issued and still unused, the seat
says so in the room where it was installed, addressed to the installer by
name, and hands over the exact command.

Built to ux-lead's spec, with three corrections from the fleet:

- **The episode key is max(createdAt) across BOTH token stores** — the same
  union deriveAgentState uses for liveness. Key off one store while
  triggering off the union and a reissue on the other path never resets the
  episode, so "a reissue earns one more nudge" silently stops firing
  (pod-architect). Exported as one helper so the reactive responder does not
  recompute it (sprint-impl).

- **The two token stores are not symmetric.** User.agentRuntimeTokens carries
  expiresAt; AgentInstallation.runtimeTokens does not (verified in both
  schemas). So a token episode ends differently depending on which store
  minted it. Recorded as `tokenSource` rather than left to be discovered.

- **The confirmation is not time-bounded, and is compound** (ux-lead): flat
  for the past because a first-connection timestamp is a fact, derived at
  post time for the present because that is an inference. "Connected (first
  seen 09:00 UTC). It isn't running right now — restart it with ..." That
  also dissolves the case I thought was invisible: lastUsedAt leaving null is
  a permanent transition, so a wrapper that connects and stops between passes
  is still seen, it just gets a different present tense.

The episode is claimed before the post, not after: a losing race then costs
one nudge rather than delivering two, and a second message in someone's room
cannot be taken back.

i18n is deliberately deferred, with the seam left visible. The spec asked for
en + zh-CN from day one; there is no mechanism — language lives in frontend
localStorage, never reaches the backend, there is no User.language and no
server-side i18n layer at all, and #943 shipped English-only for the same
audience. ux-lead's ruling: ship en now, because the load-bearing content is
the fixCommand and that is language-neutral, so an English nudge beats
silence. The composers take a `locale` they currently ignore so the layer,
when it lands, changes only them. Filed separately: persist the language
SWITCHER choice as User.language — the choice the user made, not the
browser's guess — which retro-covers #943 and the digest too.

One derivation throughout: deriveAgentState decides connected-ness, the
15 minutes is only a patience window on top of its verdict.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XeUH4HVDsDHYPsHJthXjB8
@lilyshen0722
lilyshen0722 merged commit 0ec7d50 into main Aug 15, 2026
11 checks passed
@lilyshen0722
lilyshen0722 deleted the feat/stalled-connect-nudge branch August 15, 2026 06:03
lilyshen0722 added a commit that referenced this pull request Aug 15, 2026
…r `message` (#957)

Found by reading production after #956 deployed. Ten nudges landed correctly
in ten pods — right people, right pods, right commands — and all ten recorded
`nudgeMessageId: ''`.

`AgentMessageService.postMessage` returns `{ success, message, summary }`. The
id lives at `message.id` (PG, the primary store) or `message._id` (the Mongo
fallback). The code read `posted.id`, which is undefined.

The messages were fine; the audit trail was not. "Why did this person never
get nudged" is unanswerable without it, and the reactive responder inherits
the same record.

The tests did not catch it because the fixture returned `{ id: 'msg1' }` — the
shape the bug expected. A mock built from the calling code's assumption rather
than from the callee's actual return will agree with the bug every time. The
fixture now matches what postMessage really returns, and there is a test
asserting the recorded id.

Also stops counting a declined post as a delivered nudge: postMessage can
succeed-without-posting (`skipped: true` for duplicate/suppressed sends), and
reporting that as `nudged` is the silent-success shape again. The episode
stays claimed — something decided that room did not need the message — but the
caller is no longer told a nudge went out when none did.


Claude-Session: https://claude.ai/code/session_01XeUH4HVDsDHYPsHJthXjB8

Co-authored-by: Claude Opus 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant