feat: add Convex auth recovery#301
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 2519738 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: de71b7a934
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| | `useMaybeAuth()` | `boolean` | Has token (optimistic, may not be verified) | | ||
| | `useIsAuth()` | `boolean` | Server-verified authentication | | ||
| | `useAuthGuard()` | `() => boolean` | Guard mutations, returns true if blocked | | ||
| | `useConvexAuthRecovery()` | `{ recover, status, error }` | Rebind Convex auth after a transient token failure | |
There was a problem hiding this comment.
Regenerate the local kitcn skill mirror
This updates the published kitcn skill source, but the generated mirror at .agents/skills/kitcn/references/features/auth.md still lacks the new useConvexAuthRecovery row and recovery section, so repo-local agents will read stale auth guidance until the mirror is regenerated and committed. Please run bun tooling/sync-kitcn-skill.ts or bun install and include the generated diff.
AGENTS.md reference: AGENTS.md:L6-L7
Useful? React with 👍 / 👎.
| if (!pending.isBound || snapshot.isLoading) { | ||
| return; | ||
| } | ||
| if (snapshot.isAuthenticated) { | ||
| settleRecovery(null); |
There was a problem hiding this comment.
Correlate success to the replacement auth callback
When a recovery starts, pending.isBound only proves the replacement fetcher was invoked; the later snapshot.isAuthenticated value is the global Convex auth state, so a stale onChange(true) from the previous binding or any other auth-state transition after the new fetch starts can resolve recover() before Convex has accepted the replacement binding. In that race, callers proceed as if recovery succeeded even though the new binding may still be rejected; the confirmation needs to be versioned to the replacement binding's own auth callback, not just any authenticated snapshot.
Useful? React with 👍 / 👎.
🐛 Fixes #299
🟢 95-100% confidence
noAuth; Better Auth refresh returnsnullbun check; clean autoreview✅ Outcome
useConvexAuthRecovery()with typed status, errors, timeout, and exact concurrent dedupe.🏗️ Design
client.setAuth, remount descendants, or depend on Convex private callbacks.🧪 Verified
bun test packages/kitcn/src/react/auth-store.test.tsx packages/kitcn/src/auth-client/convex-auth-provider.test.tsx packages/kitcn/src/react/index.test.tsbun --cwd packages/kitcn buildbun --cwd www buildbun run intent:validateplus skill stale auditbun check