Repository navigation
fix(docs): add Better Auth's admin() so the ViteHub Console can open the site - #481
Conversation
…the site The Console's Site access keeps the roles of the people it signs in in user.role of admin(), and refused to open the site without it (AUTH_CONSOLE_UNAVAILABLE). Migration 0005 adds admin()'s columns. vitehub database generate also records the old unique indexes as UNIQUE constraints in the earlier snapshots, as Drizzle Kit 1.0 does.
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Latest result Pull request merged. Final answersSession Pull request merged. Session Pushed `8921de2` to address the Node 22 CI timeout by parsing each candidate motion file once, without raising the timeout. The motion test now passes under the tighter local deadline, all four Site Access tests pass, and lint reports only existing warnings. Hosted CI is pending. The production D1 migration still needs confirmation before merge. Session Pushed `8921de2` to address the Node 22 CI timeout by parsing each candidate motion file once, without raising the timeout. The motion test now passes under the tighter local deadline, all four Site Access tests pass, and lint reports only existing warnings. Hosted CI is pending. The production D1 migration still needs confirmation before merge. Session Pushed `8921de2` to address the Node 22 CI timeout by parsing each candidate motion file once, without raising the timeout. The motion test now passes under the tighter local deadline, all four Site Access tests pass, and lint reports only existing warnings. Hosted CI is pending. The production D1 migration still needs confirmation before merge. Session Pushed `8921de2` to address the Node 22 CI timeout by parsing each candidate motion file once, without raising the timeout. The motion test now passes under the tighter local deadline, all four Site Access tests pass, and lint reports only existing warnings. Hosted CI is pending. The production D1 migration still needs confirmation before merge. Session Pushed `8921de2` to address the Node 22 CI timeout by parsing each candidate motion file once, without raising the timeout. The motion test now passes under the tighter local deadline, all four Site Access tests pass, and lint reports only existing warnings. Hosted CI is pending. The production D1 migration still needs confirmation before merge. Session Pushed `8921de2` to address the Node 22 CI timeout by parsing each candidate motion file once, without raising the timeout. The motion test now passes under the tighter local deadline, all four Site Access tests pass, and lint reports only existing warnings. Hosted CI is pending. The production D1 migration still needs confirmation before merge. Session Pushed `8921de2` to address the Node 22 CI timeout by parsing each candidate motion file once, without raising the timeout. The motion test now passes under the tighter local deadline, all four Site Access tests pass, and lint reports only existing warnings. Hosted CI is pending. The production D1 migration still needs confirmation before merge. |
comark-annotate
comark-badge
comark-bundle
comark-cards
comark-carousel
comark-cast
comark-charts
comark-chat
comark-chips
comark-cjk
comark-code
comark-code-notes
comark-colors
comark-comments
comark-critic
comark-deflist
comark-details
comark-diagrams
comark-diff
comark-embed
comark-fields
comark-figure
comark-file-tree
comark-footnotes
comark-git-graph
comark-github
comark-icon
comark-include
comark-keys
comark-links
comark-linter
comark-magic-move
comark-mark
markdown-it-to-comark
marked-to-comark
comark-mathml
comark-media
comark-metrics
migrate-to-comark
comark-motion
comark-outline
comark-properties
comark-qr
comark-quiz
comark-reading-time
remark-to-comark
comark-sources
comark-steps
comark-table
comark-tabs
comark-tests
comark-time
comark-ui
comark-xref
comark-zoom
commit: |
There was a problem hiding this comment.
Important
The Console can now create a session, but a newly created member still cannot use the page tools, and the pre-deploy migration command does not select the production D1 binding.
Approach: Registering admin() and adding its columns in place is the right fix for session issuance, but the page policies and rollout instructions need to match it.
Reviewed changes
- Session issuance: Checked how the pinned ViteHub and Better Auth versions create member and guest sessions and how the docs authorize those sessions.
- Schema and rollout: Verified that a populated SQLite upgrade preserves existing users, sessions, and indexes, and that Wrangler applies the full migration chain to local D1 when given the generated config. The docs build and typecheck passed.
⚠️ The pre-deploy command cannot find production D1
P1 · Class: migration command selects the wrong Wrangler config. Wrangler 4.152.0 does not follow Nitro’s config redirect for d1 migrations apply. The PR’s pre-deploy command therefore reads the root wrangler.jsonc, which has no D1 binding, and leaves the auth columns unapplied before the automatic Worker deploy.
Technical details
# Select the generated D1 config
## Affected sites
- `wrangler.jsonc` — the source config does not declare the `comark-ui-docs` D1 binding.
- `docs/modules/wrangler-output.ts` — writes the Nitro redirect, but Wrangler’s D1 migration subcommand does not opt into it.
## Required outcome
- Build the docs from this PR and apply `0005_auth-admin.sql` before merging to the auto-deployed branch. From the repo root, use `pnpm exec wrangler d1 migrations apply comark-ui-docs --config docs/dist/server/wrangler.json --remote`.
- The local equivalent without `--config` returned `No migrations present at …/migrations` even after the docs build. With `--config`, all six migrations applied locally. Production was not touched.gpt-6.2-sol(high) | 𝕏
There was a problem hiding this comment.
Caution
This PR introduces a confidentiality regression: an invited guest can read staff comments on unpublished CMS content. The draft document itself remains protected.
Approach: Honoring the exact console grant for the page link is sound, but the shared Comments policy also needs to enforce which threads a grant covers.
Reviewed changes
- Enabled Site Access page tools. Checked the exact
consolerole and action-specific comment grants against the pinned ViteHub runtime. GitHub team and signed RPC checks are unchanged. - Added session-based regression tests. Verified member and guest sessions on Node 24 and 22. The workspace suite passed with 3,254 tests passed and 2 skipped; docs build and typecheck passed.
- Corrected the rollout command. Verified the generated Wrangler config applies all six migrations on isolated local D1. Apply the production migration before merging; production was not touched during review.
gpt-6.2-sol(high) | 𝕏
There was a problem hiding this comment.
✅ No new issues found. The draft-feedback disclosure is fixed, and no P0 or P1 finding remains.
Approach: Keeping Comments team-only is the right fix while draft previews and published pages share threads.
Reviewed changes
Reviewed b2d9df1 since the previous Pullfrog review at 799f9ca.
- Restricted shared threads to the team. Verified that guest grants no longer allow reads or writes and that Console members need a verified team email and the grant for the requested action. GitHub team and signed RPC checks are unchanged.
- Expanded session regression coverage. All 12 docs tests passed, including the four Site Access tests, and docs typecheck passed.
gpt-6.2-sol(high) | 𝕏
There was a problem hiding this comment.
✅ No new issues found. No P0 or P1 findings remain.
Reviewed changes
Reviewed 8921de2 since the prior Pullfrog review at b2d9df1. No docs auth or migration files changed.
- Reduced motion scan work. The scan now skips files with no motion markers and strips comments once per remaining file. Both motion tests passed, and the filtered and unfiltered scans reported the same results on the workspace and representative cases for every detector.
gpt-6.2-sol(high) | 𝕏

Opening the site from the ViteHub Console failed with
AUTH_CONSOLE_UNAVAILABLE: "Site access keeps permissions as roles of Better Auth's admin() plugin." Site access stores the roles of the people it signs in (console,guest, the comment roles) inuser.role, which onlyadmin()adds.docs/server/auth.tsaddsadmin()toplugins.user.role,banned,ban_reason,ban_expires, andsession.impersonated_by. Migration0005_auth-adminadds them withALTER TABLE … ADD, so nothing is rebuilt or lost.vitehub database generatealso recorded the old unique indexes as UNIQUE constraints in the earlier snapshots, as Drizzle Kit 1.0 declares them. Only the snapshots change; the database keeps its indexes.Checked
On
nuxt devwith the migrations applied to the local D1, asite.invitelink now redeems with a 303 to/?vitehuband a Better Auth session cookie, and the new user hasrole = guest,comments-write. Docs typecheck passes.Regression tests also check authorization with the session cookies created by the Site access host APIs, for both Console members and invited guests.
Before merging (main deploys automatically)
The binding is native D1, so the migration doesn't run on deploy. Apply it to production first (the columns are nullable, so the current Worker ignores them). Build this branch and explicitly select the generated Wrangler config, which contains the D1 binding and migration directory. From the repository root:
pnpm docs:build pnpm exec wrangler d1 migrations apply comark-ui-docs --config docs/dist/server/wrangler.json --remote🤖 Generated with Claude Code