Skip to content

fix(docs): add Better Auth's admin() so the ViteHub Console can open the site - #481

Merged
vite-hub[bot] merged 4 commits into
mainfrom
fix/docs-console-admin
Nov 22, 2026
Merged

vite-hub[bot] merged 4 commits into
mainfrom
fix/docs-console-admin

Conversation

@onmax

@onmax onmax commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

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) in user.role, which only admin() adds.

  • docs/server/auth.ts adds admin() to plugins.
  • The schema gets admin()'s columns: user.role, banned, ban_reason, ban_expires, and session.impersonated_by. Migration 0005_auth-admin adds them with ALTER TABLE … ADD, so nothing is rebuilt or lost.
  • vitehub database generate also 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.
  • The page policies honor Site access roles for the Console link and the permitted comment actions, without changing the GitHub team or signed RPC checks.

Checked

On nuxt dev with the migrations applied to the local D1, a site.invite link now redeems with a 303 to /?vitehub and a Better Auth session cookie, and the new user has role = 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

…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.
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-22T15:31:31.700611Z
We couldn’t complete this review. Comment @codex review to try again.
c286b05 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@vite-hub

vite-hub Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor
Session Status Started Duration
Pending Completed Not started —
View session Starting Not started —

Latest result

Pull request merged.

Final answers

Session

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.

@pkg-pr-new

pkg-pr-new Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

comark-annotate

pnpm add https://pkg.pr.new/comark-annotate@481

comark-badge

pnpm add https://pkg.pr.new/comark-badge@481

comark-bundle

pnpm add https://pkg.pr.new/comark-bundle@481

comark-cards

pnpm add https://pkg.pr.new/comark-cards@481

comark-carousel

pnpm add https://pkg.pr.new/comark-carousel@481

comark-cast

pnpm add https://pkg.pr.new/comark-cast@481

comark-charts

pnpm add https://pkg.pr.new/comark-charts@481

comark-chat

pnpm add https://pkg.pr.new/comark-chat@481

comark-chips

pnpm add https://pkg.pr.new/comark-chips@481

comark-cjk

pnpm add https://pkg.pr.new/comark-cjk@481

comark-code

pnpm add https://pkg.pr.new/comark-code@481

comark-code-notes

pnpm add https://pkg.pr.new/comark-code-notes@481

comark-colors

pnpm add https://pkg.pr.new/comark-colors@481

comark-comments

pnpm add https://pkg.pr.new/comark-comments@481

comark-critic

pnpm add https://pkg.pr.new/comark-critic@481

comark-deflist

pnpm add https://pkg.pr.new/comark-deflist@481

comark-details

pnpm add https://pkg.pr.new/comark-details@481

comark-diagrams

pnpm add https://pkg.pr.new/comark-diagrams@481

comark-diff

pnpm add https://pkg.pr.new/comark-diff@481

comark-embed

pnpm add https://pkg.pr.new/comark-embed@481

comark-fields

pnpm add https://pkg.pr.new/comark-fields@481

comark-figure

pnpm add https://pkg.pr.new/comark-figure@481

comark-file-tree

pnpm add https://pkg.pr.new/comark-file-tree@481

comark-footnotes

pnpm add https://pkg.pr.new/comark-footnotes@481

comark-git-graph

pnpm add https://pkg.pr.new/comark-git-graph@481

comark-github

pnpm add https://pkg.pr.new/comark-github@481

comark-icon

pnpm add https://pkg.pr.new/comark-icon@481

comark-include

pnpm add https://pkg.pr.new/comark-include@481

comark-keys

pnpm add https://pkg.pr.new/comark-keys@481

comark-links

pnpm add https://pkg.pr.new/comark-links@481

comark-linter

pnpm add https://pkg.pr.new/comark-linter@481

comark-magic-move

pnpm add https://pkg.pr.new/comark-magic-move@481

comark-mark

pnpm add https://pkg.pr.new/comark-mark@481

markdown-it-to-comark

pnpm add https://pkg.pr.new/markdown-it-to-comark@481

marked-to-comark

pnpm add https://pkg.pr.new/marked-to-comark@481

comark-mathml

pnpm add https://pkg.pr.new/comark-mathml@481

comark-media

pnpm add https://pkg.pr.new/comark-media@481

comark-metrics

pnpm add https://pkg.pr.new/comark-metrics@481

migrate-to-comark

pnpm add https://pkg.pr.new/migrate-to-comark@481

comark-motion

pnpm add https://pkg.pr.new/comark-motion@481

comark-outline

pnpm add https://pkg.pr.new/comark-outline@481

comark-properties

pnpm add https://pkg.pr.new/comark-properties@481

comark-qr

pnpm add https://pkg.pr.new/comark-qr@481

comark-quiz

pnpm add https://pkg.pr.new/comark-quiz@481

comark-reading-time

pnpm add https://pkg.pr.new/comark-reading-time@481

remark-to-comark

pnpm add https://pkg.pr.new/remark-to-comark@481

comark-sources

pnpm add https://pkg.pr.new/comark-sources@481

comark-steps

pnpm add https://pkg.pr.new/comark-steps@481

comark-table

pnpm add https://pkg.pr.new/comark-table@481

comark-tabs

pnpm add https://pkg.pr.new/comark-tabs@481

comark-tests

pnpm add https://pkg.pr.new/comark-tests@481

comark-time

pnpm add https://pkg.pr.new/comark-time@481

comark-ui

pnpm add https://pkg.pr.new/comark-ui@481

comark-xref

pnpm add https://pkg.pr.new/comark-xref@481

comark-zoom

pnpm add https://pkg.pr.new/comark-zoom@481

commit: 8921de2

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.2-sol(high) | 𝕏

Comment thread docs/server/auth.ts Resolved

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 console role 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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.2-sol(high) | 𝕏

Comment thread docs/server/comments.ts Resolved

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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.

Pullfrog  | View workflow run | Using gpt-6.2-sol(high) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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.

Pullfrog  | View workflow run | Using gpt-6.2-sol(high) | 𝕏

@vite-hub
vite-hub Bot merged commit 7270a61 into main Nov 22, 2026
7 checks passed
@vite-hub
vite-hub Bot deleted the fix/docs-console-admin branch November 22, 2026 19:35
@github-actions github-actions Bot mentioned this pull request Nov 22, 2026
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.

2 participants