Skip to content

fix(web): retry transient cookie renewal during startup - #504

Merged
lukemaj merged 2 commits into
mainfrom
fix/330-startup-renewal-retry
Oct 18, 2026
Merged

lukemaj merged 2 commits into
mainfrom
fix/330-startup-renewal-retry

Conversation

@lukemaj

@lukemaj lukemaj commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

What: A paired browser whose cookie renewal fails briefly at startup now shows a reconnecting state and retries, instead of asking to pair again.
Why: Startup caught every renewal failure as null and returned requires-auth, even when the durable renewal secret was still valid and the failure was transient.
So what: Luna review and CI, then the backlog coordinator merges.

Problem

apps/web/src/environments/primary/auth.ts turned any renewal failure (network error, HTTP 5xx, renewal-store failure) into requires-auth, so a returning paired browser saw the pairing prompt during a short server or network hiccup.

Fix

  • Typed transient renewal failures return a retryable startup result with capped exponential delays (500, 1000, 2000, 4000, then at most 5000 ms).
  • The root route shows a reconnecting surface and invalidates the router after the delay, cleaning up its timer on state change or unmount.
  • The chat route keeps the requested route during retry; the pair route handles the new variant.
  • Definitive renewal rejection and an absent enrollment still require pairing; explicit pairing intent is preserved.
  • packages/client-runtime/src/connection/supervisor.ts is untouched (PR fix(auth): pace renewal when the client clock is ahead #473 owns its pacing).

Upstream

No matching fix in pingdotgg/t3code; renewal is fork-owned. Details: #330 (comment)

Proof

  • vp test run apps/web/src/authBootstrap.test.ts: 38 passed (worker, and again by the coordinator after rebasing onto 7f300491d3).
  • The network, HTTP 500 and storage regressions fail against the original auth.ts with requires-auth instead of retryable; definitive rejection passes on both.
  • Tests use the real SessionRenewal with fake transport and storage boundaries.
  • Targeted lint and apps/web typecheck passed (worker); scripts/fork-check.sh OK after rebase.
  • Not exercised in a real browser; the rendered reconnecting timer is covered only through the bootstrap path.

Elon record

Closes #330

Implemented by GPT-6.1 Sol (Codex harness in T3 Code). Committed, rebased and opened by Claude Opus 5.5 (Claude Code in T3 Code) because the worker's git commit was blocked by a ContextMD hook.

🤖 Generated with Claude Code

A transient renewal failure (network, HTTP 5xx, renewal store) while the
durable renewal secret is still valid now yields a retryable startup
result with capped backoff and a reconnecting surface instead of the
pairing prompt. Definitive rejection still requires pairing.

Implemented by GPT-6.1 Sol (Codex in T3 Code); committed by the backlog
coordinator because the worker's commit was blocked by a hook.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lukemaj

lukemaj commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

Luna review round 1 at 230a6a9: CHANGES REQUESTED

The requested auth behavior otherwise checks out: the server maps a rejected renewal secret to 401 / RenewalRejected, which exits retry and requires pairing; transport/storage failures and server errors become ConnectionTransientError; retry delays cap at 5000 ms and reset after a non-retryable outcome; the root retry timer cleans up on state change or unmount; and route invalidation preserves the active location. Mobile does not use the web root bootstrap path, and desktop uses the shared web root, so the web-only startup scope is consistent. The focused tests cover bootstrap results, real renewal transport/storage recovery, definitive rejection, capped/reset delay, concurrency, and explicit pairing intent. Fork allowlist registration includes the added web files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lukemaj

lukemaj commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

Luna review round 2 at 96be3c6: APPROVE

@github-actions github-actions Bot added the vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. label Oct 18, 2026
@lukemaj
lukemaj merged commit 7f5a85e into main Oct 18, 2026
27 checks passed
@lukemaj
lukemaj deleted the fix/330-startup-renewal-retry branch October 18, 2026 23:56
lukemaj added a commit that referenced this pull request Oct 29, 2026
* fix(web): retry transient cookie renewal during startup

A transient renewal failure (network, HTTP 5xx, renewal store) while the
durable renewal secret is still valid now yields a retryable startup
result with capped backoff and a reconnecting surface instead of the
pairing prompt. Definitive rejection still requires pairing.

Implemented by GPT-6.1 Sol (Codex in T3 Code); committed by the backlog
coordinator because the worker's commit was blocked by a hook.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(fork): list PR #504 in paired-session-renewal record

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(web): retry transient cookie renewal during startup

1 participant