Skip to content

feat: move admin ui into sub crate#91

Merged
bzp2010 merged 5 commits intomainfrom
bzp/feat-split-admin-ui-crate
May 5, 2026
Merged

feat: move admin ui into sub crate#91
bzp2010 merged 5 commits intomainfrom
bzp/feat-split-admin-ui-crate

Conversation

@bzp2010
Copy link
Copy Markdown
Collaborator

@bzp2010 bzp2010 commented May 5, 2026

Summary by CodeRabbit

  • Refactor

    • Moved the admin UI into a dedicated, reusable package and switched runtime routing to use that packaged UI.
    • Updated static asset embedding to serve from the packaged output location.
  • Build / CI

    • Root build no longer builds UI by default; the packaged UI provides its own optional build step.
    • CI now builds the packaged UI and caches its output; workflows updated accordingly.
  • Chores

    • Added new admin-ui crate and adjusted workspace dependencies.
    • Updated ignore rules for generated UI artifacts.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4ca7f51d-5869-4bfa-a246-da3f2d974f44

📥 Commits

Reviewing files that changed from the base of the PR and between e8d97c7 and bf6b06c.

📒 Files selected for processing (1)
  • .github/workflows/build.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/build.yaml

📝 Walkthrough

Walkthrough

Moves UI build and assets into a new crates/admin-ui crate (output renamed ui-dist/), removes UI-building logic from root build.rs, updates workspace/Cargo and CI cache/build steps, switches admin UI routes to the new crate, and refactors aisix-llm module declarations.

Changes

UI Build System Extraction to Admin-UI Crate

Layer / File(s) Summary
Workspace Membership & Features
Cargo.toml
Adds crates/admin-ui to workspace members; changes build-ui feature to aisix-admin-ui/build-ui; adds anyhow to workspace deps and moves many deps to *.workspace = true.
Root Build Script Simplification
build.rs
Removes prior UI build logic; now only emits vergen/git metadata and cargo:rerun-if-changed=build.rs.
New Crate Manifest
crates/admin-ui/Cargo.toml
Introduces aisix-admin-ui crate with build-ui feature, runtime deps (axum, http, mime_guess, rust-embed), dev-deps, and anyhow build-dep.
Crate Build Script
crates/admin-ui/build.rs
Creates ui-dist directory; when CARGO_FEATURE_BUILD_UI is set runs pnpm install --frozen-lockfile and pnpm run build in crates/admin-ui/ui/; emits rerun-if-changed and fails on non-zero exit codes.
Asset Embedding & Vite Output
crates/admin-ui/src/lib.rs, crates/admin-ui/ui/vite.config.ts
rust_embed now points at ui-dist/; Vite config imports node:path and sets build.outDir to resolve(process.cwd(), '../ui-dist').
Admin Router Integration
src/admin/mod.rs
Routes GET /ui/ and GET /ui/{*path} to aisix_admin_ui::handler instead of the former local ui::handler.
VCS Ignore
.gitignore
Replaces prior ui/node_modules/ and ui/dist/ ignores with ui-dist/.
CI Workflow Cache Paths
.github/workflows/build.yaml
Updates Node cache dependency path to crates/admin-ui/ui/pnpm-lock.yaml, caches crates/admin-ui/ui-dist, and replaces pnpm build steps with cargo build -p aisix-admin-ui --features build-ui -vv; adds --workspace to clippy/test steps.

Module Declaration Refactoring

Layer / File(s) Summary
Module Organization
crates/aisix-llm/src/lib.rs
Replaces #[path = "..."] attribute-backed module declarations with direct pub mod ..., introduces pub mod gateway, and re-exports Gateway as pub use gateway::Gateway.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • api7/aisix#44: Related—also modifies build-ui feature and UI build-time packaging/location.
  • api7/aisix#45: Related—adds/adjusts pnpm install steps when CARGO_FEATURE_BUILD_UI is enabled.
  • api7/aisix#46: Related—changes build.rs behavior and vergen/git metadata emission alongside UI build placement.

Suggested reviewers

  • membphis
🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately summarizes the main change: moving the admin UI into a separate subcrate by extracting it from the root into crates/admin-ui.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
E2e Test Quality Review ✅ Passed Structural refactoring moving admin UI to sub-crate. Existing E2E tests adequately cover full business flow. Handler implementation is simple and correct. No new tests required for refactoring.
Security Check ✅ Passed PR introduces no new security vulnerabilities. Pre-existing UI authorization pattern (unprotected routes) is preserved. All 7 security categories reviewed.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bzp/feat-split-admin-ui-crate

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
crates/aisix-llm/src/lib.rs (1)

3-3: ⚡ Quick win

Add public API docs for newly exposed module and re-export.

Please add /// doc comments for pub mod gateway; and pub use gateway::Gateway; so the newly exposed API surface is self-documented.

As per coding guidelines, use /// for doc comments on public items in Rust.

Also applies to: 11-11

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/aisix-llm/src/lib.rs` at line 3, Add Rust doc comments for the newly
exposed public items: add a /// comment above pub mod gateway; describing the
module's purpose and responsibilities, and add a /// comment above the pub use
gateway::Gateway; re-export describing what Gateway represents and when to use
it; ensure both use /// (not // or /**/) and follow existing crate doc style and
tone.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@crates/aisix-llm/src/lib.rs`:
- Line 3: Add Rust doc comments for the newly exposed public items: add a ///
comment above pub mod gateway; describing the module's purpose and
responsibilities, and add a /// comment above the pub use gateway::Gateway;
re-export describing what Gateway represents and when to use it; ensure both use
/// (not // or /**/) and follow existing crate doc style and tone.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9ceeb4d4-8f08-4853-8bce-f6046cc4587e

📥 Commits

Reviewing files that changed from the base of the PR and between 8167359 and 25a9bce.

⛔ Files ignored due to path filters (3)
  • Cargo.lock is excluded by !**/*.lock
  • crates/admin-ui/ui/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • crates/admin-ui/ui/src/assets/react.svg is excluded by !**/*.svg
📒 Files selected for processing (128)
  • .gitignore
  • Cargo.toml
  • build.rs
  • crates/admin-ui/Cargo.toml
  • crates/admin-ui/build.rs
  • crates/admin-ui/src/lib.rs
  • crates/admin-ui/ui/.gitignore
  • crates/admin-ui/ui/.prettierignore
  • crates/admin-ui/ui/.prettierrc
  • crates/admin-ui/ui/components.json
  • crates/admin-ui/ui/eslint.config.js
  • crates/admin-ui/ui/index.html
  • crates/admin-ui/ui/package.json
  • crates/admin-ui/ui/src/components/apikeys/apikey-form.tsx
  • crates/admin-ui/ui/src/components/layout/admin-key-modal.tsx
  • crates/admin-ui/ui/src/components/layout/page-header.tsx
  • crates/admin-ui/ui/src/components/layout/sidebar.tsx
  • crates/admin-ui/ui/src/components/models/model-form.tsx
  • crates/admin-ui/ui/src/components/playground/api-key-picker.tsx
  • crates/admin-ui/ui/src/components/playground/api.ts
  • crates/admin-ui/ui/src/components/playground/column-panel.tsx
  • crates/admin-ui/ui/src/components/playground/model-picker.tsx
  • crates/admin-ui/ui/src/components/playground/msg-card.tsx
  • crates/admin-ui/ui/src/components/playground/params-popover.tsx
  • crates/admin-ui/ui/src/components/playground/picker-styles.ts
  • crates/admin-ui/ui/src/components/playground/state.ts
  • crates/admin-ui/ui/src/components/playground/types.ts
  • crates/admin-ui/ui/src/components/providers/provider-form.tsx
  • crates/admin-ui/ui/src/components/theme-provider.tsx
  • crates/admin-ui/ui/src/components/ui/badge.tsx
  • crates/admin-ui/ui/src/components/ui/button.tsx
  • crates/admin-ui/ui/src/components/ui/checkbox.tsx
  • crates/admin-ui/ui/src/components/ui/combobox.tsx
  • crates/admin-ui/ui/src/components/ui/data-table.tsx
  • crates/admin-ui/ui/src/components/ui/dialog.tsx
  • crates/admin-ui/ui/src/components/ui/input-group.tsx
  • crates/admin-ui/ui/src/components/ui/input.tsx
  • crates/admin-ui/ui/src/components/ui/label.tsx
  • crates/admin-ui/ui/src/components/ui/monaco-json-editor.tsx
  • crates/admin-ui/ui/src/components/ui/select.tsx
  • crates/admin-ui/ui/src/components/ui/sheet.tsx
  • crates/admin-ui/ui/src/components/ui/table.tsx
  • crates/admin-ui/ui/src/components/ui/textarea.tsx
  • crates/admin-ui/ui/src/components/ui/tooltip.tsx
  • crates/admin-ui/ui/src/hooks/use-admin-key.ts
  • crates/admin-ui/ui/src/hooks/use-sidebar.ts
  • crates/admin-ui/ui/src/i18n/index.ts
  • crates/admin-ui/ui/src/i18n/locales/en.json
  • crates/admin-ui/ui/src/i18n/locales/zh-CN.json
  • crates/admin-ui/ui/src/index.css
  • crates/admin-ui/ui/src/lib/api/client.ts
  • crates/admin-ui/ui/src/lib/api/types.ts
  • crates/admin-ui/ui/src/lib/queries/apikeys.ts
  • crates/admin-ui/ui/src/lib/queries/index.ts
  • crates/admin-ui/ui/src/lib/queries/models.ts
  • crates/admin-ui/ui/src/lib/queries/providers.ts
  • crates/admin-ui/ui/src/lib/utils.ts
  • crates/admin-ui/ui/src/main.tsx
  • crates/admin-ui/ui/src/routeTree.gen.ts
  • crates/admin-ui/ui/src/routes/__root.tsx
  • crates/admin-ui/ui/src/routes/_layout.tsx
  • crates/admin-ui/ui/src/routes/_layout/apikeys/$id.tsx
  • crates/admin-ui/ui/src/routes/_layout/apikeys/create.tsx
  • crates/admin-ui/ui/src/routes/_layout/apikeys/index.tsx
  • crates/admin-ui/ui/src/routes/_layout/models/$id.tsx
  • crates/admin-ui/ui/src/routes/_layout/models/create.tsx
  • crates/admin-ui/ui/src/routes/_layout/models/index.tsx
  • crates/admin-ui/ui/src/routes/_layout/playground/index.tsx
  • crates/admin-ui/ui/src/routes/_layout/providers/$id.tsx
  • crates/admin-ui/ui/src/routes/_layout/providers/create.tsx
  • crates/admin-ui/ui/src/routes/_layout/providers/index.tsx
  • crates/admin-ui/ui/src/routes/_layout/settings.tsx
  • crates/admin-ui/ui/src/routes/index.tsx
  • crates/admin-ui/ui/tsconfig.app.json
  • crates/admin-ui/ui/tsconfig.json
  • crates/admin-ui/ui/tsconfig.node.json
  • crates/admin-ui/ui/ui.pen
  • crates/admin-ui/ui/vite.config.ts
  • crates/aisix-llm/src/error.rs
  • crates/aisix-llm/src/formats/anthropic_messages.rs
  • crates/aisix-llm/src/formats/mod.rs
  • crates/aisix-llm/src/formats/openai/mod.rs
  • crates/aisix-llm/src/formats/openai/responses.rs
  • crates/aisix-llm/src/gateway.rs
  • crates/aisix-llm/src/lib.rs
  • crates/aisix-llm/src/provider_instance.rs
  • crates/aisix-llm/src/providers/anthropic/mod.rs
  • crates/aisix-llm/src/providers/anthropic/transform.rs
  • crates/aisix-llm/src/providers/azure.rs
  • crates/aisix-llm/src/providers/bedrock.rs
  • crates/aisix-llm/src/providers/bedrock/transform.rs
  • crates/aisix-llm/src/providers/cohere.rs
  • crates/aisix-llm/src/providers/deepseek.rs
  • crates/aisix-llm/src/providers/fireworks.rs
  • crates/aisix-llm/src/providers/gemini.rs
  • crates/aisix-llm/src/providers/groq.rs
  • crates/aisix-llm/src/providers/macros.rs
  • crates/aisix-llm/src/providers/mistral.rs
  • crates/aisix-llm/src/providers/mod.rs
  • crates/aisix-llm/src/providers/modelscope.rs
  • crates/aisix-llm/src/providers/moonshot.rs
  • crates/aisix-llm/src/providers/openai.rs
  • crates/aisix-llm/src/providers/openrouter.rs
  • crates/aisix-llm/src/providers/siliconflow.rs
  • crates/aisix-llm/src/providers/stepfun.rs
  • crates/aisix-llm/src/providers/xai.rs
  • crates/aisix-llm/src/providers/zhipuai.rs
  • crates/aisix-llm/src/session.rs
  • crates/aisix-llm/src/streams/bridged.rs
  • crates/aisix-llm/src/streams/hub.rs
  • crates/aisix-llm/src/streams/mod.rs
  • crates/aisix-llm/src/streams/native.rs
  • crates/aisix-llm/src/streams/reader/aws_event_stream.rs
  • crates/aisix-llm/src/streams/reader/mod.rs
  • crates/aisix-llm/src/streams/reader/sse.rs
  • crates/aisix-llm/src/traits/chat_format.rs
  • crates/aisix-llm/src/traits/mod.rs
  • crates/aisix-llm/src/traits/native.rs
  • crates/aisix-llm/src/traits/provider.rs
  • crates/aisix-llm/src/types/anthropic.rs
  • crates/aisix-llm/src/types/bedrock.rs
  • crates/aisix-llm/src/types/common.rs
  • crates/aisix-llm/src/types/embed.rs
  • crates/aisix-llm/src/types/mod.rs
  • crates/aisix-llm/src/types/openai/mod.rs
  • crates/aisix-llm/src/types/openai/responses.rs
  • crates/aisix-llm/src/types/response.rs
  • src/admin/mod.rs

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/build.yaml (1)

41-53: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Update remaining UI cache/build paths to the new crates/admin-ui location.

Line [30] was migrated, but Line [45], Line [46]-[47], and Line [52]-[53] still use legacy ui/... paths. This can cause wrong cache keys/artifacts and likely breaks the UI build step after the crate move.

Suggested patch
       - name: Cache UI build
         id: ui-cache
         uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # 5.0.4
         with:
-          path: ui/dist
-          key: ui-dist-${{ hashFiles('ui/src/**', 'ui/index.html', 'ui/vite.config.ts',
-            'ui/tsconfig*.json', 'ui/package.json', 'ui/pnpm-lock.yaml') }}
+          path: crates/admin-ui/ui-dist
+          key: ui-dist-${{ hashFiles('crates/admin-ui/ui/src/**', 'crates/admin-ui/ui/index.html', 'crates/admin-ui/ui/vite.config.ts',
+            'crates/admin-ui/ui/tsconfig*.json', 'crates/admin-ui/ui/package.json', 'crates/admin-ui/ui/pnpm-lock.yaml') }}

       - name: Build UI
         if: steps.ui-cache.outputs.cache-hit != 'true'
         run: |
-          pnpm -C ui install --frozen-lockfile
-          pnpm -C ui build
+          pnpm -C crates/admin-ui/ui install --frozen-lockfile
+          pnpm -C crates/admin-ui/ui build
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/build.yaml around lines 41 - 53, Cache and build steps
still reference legacy ui/... paths; update the Cache UI build step (id:
ui-cache, key: ui-dist-..., path: ui/dist) and the Build UI step's pnpm -C ui
commands to the new crate location crates/admin-ui. Replace path: ui/dist with
crates/admin-ui/dist, update hashFiles entries from 'ui/src/**',
'ui/index.html', 'ui/vite.config.ts', 'ui/tsconfig*.json', 'ui/package.json',
'ui/pnpm-lock.yaml' to the corresponding 'crates/admin-ui/...' paths, and change
the Build UI commands to pnpm -C crates/admin-ui install --frozen-lockfile and
pnpm -C crates/admin-ui build so the cache key and build run against
crates/admin-ui.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In @.github/workflows/build.yaml:
- Around line 41-53: Cache and build steps still reference legacy ui/... paths;
update the Cache UI build step (id: ui-cache, key: ui-dist-..., path: ui/dist)
and the Build UI step's pnpm -C ui commands to the new crate location
crates/admin-ui. Replace path: ui/dist with crates/admin-ui/dist, update
hashFiles entries from 'ui/src/**', 'ui/index.html', 'ui/vite.config.ts',
'ui/tsconfig*.json', 'ui/package.json', 'ui/pnpm-lock.yaml' to the corresponding
'crates/admin-ui/...' paths, and change the Build UI commands to pnpm -C
crates/admin-ui install --frozen-lockfile and pnpm -C crates/admin-ui build so
the cache key and build run against crates/admin-ui.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 999fea65-9d9e-4eeb-9f2e-a50bba5df59a

📥 Commits

Reviewing files that changed from the base of the PR and between 25a9bce and b30ea4d.

📒 Files selected for processing (1)
  • .github/workflows/build.yaml

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
.github/workflows/build.yaml (1)

55-55: ⚡ Quick win

Add --locked to the UI cargo build step for reproducibility and consistency.

Line 55 is the only cargo build-related command in this workflow without --locked; all other cargo commands (clippy, build, test) include it. Adding --locked ensures consistent lockfile resolution behavior.

Suggested patch
-        run: cargo build -p aisix-admin-ui --features build-ui -vv
+        run: cargo build -p aisix-admin-ui --features build-ui --locked -vv
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/build.yaml at line 55, Update the cargo build step that
runs "cargo build -p aisix-admin-ui --features build-ui -vv" to include the
--locked flag so it matches the other cargo steps; modify that run command to
"cargo build -p aisix-admin-ui --features build-ui --locked -vv" to ensure
lockfile-based reproducible builds.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/build.yaml:
- Around line 46-51: Add crates/admin-ui/build.rs and crates/admin-ui/Cargo.toml
to the cache key generation so changes in the Rust build driver invalidate the
ui-dist cache; update the key expression that currently hashes UI files
(referenced as ui-dist-${{ hashFiles(...) }}) to also include
'crates/admin-ui/build.rs' and 'crates/admin-ui/Cargo.toml' so the "Build UI"
step that runs cargo build -p aisix-admin-ui --features build-ui will re-run UI
packaging when build.rs or Cargo.toml changes.

---

Nitpick comments:
In @.github/workflows/build.yaml:
- Line 55: Update the cargo build step that runs "cargo build -p aisix-admin-ui
--features build-ui -vv" to include the --locked flag so it matches the other
cargo steps; modify that run command to "cargo build -p aisix-admin-ui
--features build-ui --locked -vv" to ensure lockfile-based reproducible builds.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e03188e7-9202-4d94-bffa-827938283983

📥 Commits

Reviewing files that changed from the base of the PR and between b30ea4d and 1569d4c.

📒 Files selected for processing (1)
  • .github/workflows/build.yaml

Comment thread .github/workflows/build.yaml Outdated
@bzp2010 bzp2010 merged commit eaaed3e into main May 5, 2026
3 checks passed
@bzp2010 bzp2010 deleted the bzp/feat-split-admin-ui-crate branch May 5, 2026 08:54
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