Skip to content

[Admin] Add scoped resource discovery with TDesign tables - #117

Merged
XnLemon merged 34 commits into
mainfrom
codex/112-admin-tdesign
Sep 4, 2026
Merged

[Admin] Add scoped resource discovery with TDesign tables#117
XnLemon merged 34 commits into
mainfrom
codex/112-admin-tdesign

Conversation

@XnLemon

@XnLemon XnLemon commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Summary

Implements Issue #112 as a staged TDesign Admin control-plane experience.

This PR now includes:

  • Scoped Tenant, App, Revision, Model, Backend, and Binding discovery with stable ordering, status filters, query support, and cursor pagination.
  • In-memory, PostgreSQL, and MySQL list repository implementations with tenant-scope enforcement.
  • A server-backed TDesign admin UI with resource tables, empty/error/retry states, pagination, detail navigation, and responsive desktop/mobile layouts.
  • Drawer-based creation flows for tenants and resource profiles, replacing the previous large inline creation panels.
  • Same-origin administrator login with username/password authentication, signed HttpOnly sessions, credential-version invalidation, CSRF origin checks, logout, and static Bearer-token compatibility.
  • Production /admin mounting support, including Vite asset paths, development SPA fallback, and deep-link routing.
  • The official tRPC Agent logo shared across the login page and admin shell.
  • README documentation and an Admin login preview asset.
  • .smoke artifacts removed from Git tracking and ignored for future local smoke-test output.

Issue Ledger

  • Tenant and resource collection discovery with scoped filtering and pagination across in-memory, PostgreSQL, and MySQL repositories.
  • /me principal context for the Admin shell.
  • TDesign list/table interactions for Tenant, App, Revision, Model, Backend, and Binding discovery.
  • Responsive admin shell and mobile navigation.
  • Drawer-based create flows for admin resources.
  • Same-origin browser session boundary with username/password login, session probe, logout, signed HttpOnly cookies, CSRF origin checks, and Bearer compatibility.
  • /admin production mount and development deep-link behavior.
  • README/Admin UI documentation and local smoke-artifact hygiene.
  • Model/Backend catalog query endpoints and server-driven form options.
  • Complete snake_case wire migration, including all response DTOs and compatibility tests.
  • Audit, usage/cost, health-summary query surfaces and corresponding pages.

The unchecked items are independent follow-up capabilities and remain documented in docs/docs/admin-web-ui.md.

Validation

  • go test ./... -count=1
  • go test -race ./trpcservice/admin ./trpcservice/gateway ./trpcservice/bootstrap
  • npm test from admin-ui
  • npm run build from admin-ui
  • npx tsc --noEmit from admin-ui
  • git diff --check

Review Fixes Included

  • MySQL repositories implement all Admin list contracts and map the shared MySQL storage sentinel to the documented 503 storage_unavailable response.
  • In-memory revision search matches PostgreSQL behavior, including GlobalInstruction.
  • Tenant reset reloads with cleared filters, and tenant list loading remains stable across renders.
  • Admin sessions are self-contained HMAC-signed cookies that validate across replicas, reject tampering, and invalidate when credentials change.
  • New App drafts initialize an empty TDesign editor before the first create request.
  • Same-origin checks and Secure cookies honor the public protocol when TLS terminates at a trusted reverse proxy.
  • The Redis runtime provider and tenant-scoped bootstrap/deployment compatibility are preserved.
  • Platform wildcard TRPC_ADMIN_TENANTS=* is explicit while empty and explicit scopes remain isolated.

Latest Follow-up

  • Added exhaustive SQL-mocked contract coverage for PostgreSQL Agent List, ListRevisions, and scanRevisionNumbers: receiver/storage guards, page bounds, valid and invalid cursors, filters, empty pages, query/scan/iteration/load failures, UTC normalization, and row-close errors.
  • List, ListRevisions, and scanRevisionNumbers each reach 100% statement coverage in the PostgreSQL package.
  • go test ./trpcservice/agent/... -count=1
  • go test -race ./trpcservice/agent/postgres -count=1
  • PostgreSQL list calls now propagate context.Canceled before checking storage, matching the repository cancellation contract.
  • Refactored the PostgreSQL list readiness guard into checkList, preserving canceled-context precedence while keeping the list handler below the repository gocyclo threshold.
  • Added exhaustive SQL-mocked return and route fallback coverage for Admin, Agent, Backend, Channel, Model, and Tenant list/auth paths.
  • Added the missing ambient TDesign Drawer declaration and export used by the Admin shell and resource drawers.
  • npx tsc --noEmit --pretty false, npm test, and npm run build pass from admin-ui.
  • Final head c528eab6e30ff746dd8fb290a94e174d572639f9 has all GitHub checks passing; the review finding for this head is resolved.

@XnLemon
XnLemon deployed to telegram-e2e September 2, 2026 11:37 — with GitHub Actions Active
@XnLemon XnLemon self-assigned this Sep 2, 2026
@XnLemon
XnLemon deployed to telegram-e2e September 2, 2026 11:40 — with GitHub Actions Active
@XnLemon
XnLemon deployed to telegram-e2e September 2, 2026 11:44 — with GitHub Actions Active
Comment thread trpcservice/admin/api.go Outdated
@XnLemon
XnLemon deployed to telegram-e2e September 2, 2026 18:10 — with GitHub Actions Active
@XnLemon
XnLemon deployed to telegram-e2e September 2, 2026 18:15 — with GitHub Actions Active

@XnLemon XnLemon left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

The inline reply documents the scoped tenant-discovery fix and its regression coverage. Submitting this existing draft closes the older review so a fresh clean review can target the latest head.

Comment thread trpcservice/admin/api.go Outdated
@XnLemon
XnLemon deployed to telegram-e2e September 2, 2026 18:40 — with GitHub Actions Active
@XnLemon
XnLemon deployed to telegram-e2e September 2, 2026 18:51 — with GitHub Actions Active
Comment thread admin-ui/src/pages/TenantsPage.tsx Outdated
Comment thread trpcservice/agent/inmemory/inmemory.go
Comment thread trpcservice/admin/api.go
@XnLemon
XnLemon deployed to telegram-e2e September 2, 2026 19:36 — with GitHub Actions Active
@XnLemon
XnLemon deployed to telegram-e2e September 2, 2026 19:39 — with GitHub Actions Active

@XnLemon XnLemon left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

LGTM

@XnLemon XnLemon left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

LGTM

@XnLemon
XnLemon deployed to telegram-e2e September 2, 2026 22:57 — with GitHub Actions Active
@XnLemon
XnLemon deployed to telegram-e2e September 3, 2026 14:29 — with GitHub Actions Active
@XnLemon
XnLemon deployed to telegram-e2e September 3, 2026 14:31 — with GitHub Actions Active

@XnLemon XnLemon left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

LGTM

@XnLemon
XnLemon deployed to telegram-e2e September 3, 2026 19:18 — with GitHub Actions Active
@XnLemon
XnLemon deployed to telegram-e2e September 3, 2026 23:51 — with GitHub Actions Active
Comment thread trpcservice/agent/postgres/repository_list_test.go
@XnLemon
XnLemon deployed to telegram-e2e September 4, 2026 00:04 — with GitHub Actions Active
@XnLemon
XnLemon deployed to telegram-e2e September 4, 2026 00:08 — with GitHub Actions Active

@XnLemon XnLemon left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

LGTM

@XnLemon
XnLemon deployed to telegram-e2e September 4, 2026 00:26 — with GitHub Actions Active

@XnLemon XnLemon left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

LGTM

@XnLemon
XnLemon deployed to telegram-e2e September 4, 2026 02:34 — with GitHub Actions Active
@XnLemon
XnLemon deployed to telegram-e2e September 4, 2026 02:46 — with GitHub Actions Active
Comment thread admin-ui/src/types/tdesign-react.d.ts
@XnLemon
XnLemon deployed to telegram-e2e September 4, 2026 03:51 — with GitHub Actions Active

@XnLemon XnLemon left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

LGTM

@XnLemon

XnLemon commented Sep 4, 2026

Copy link
Copy Markdown
Owner Author

lets go LGTM

@XnLemon
XnLemon merged commit 682b5be into main Sep 4, 2026
12 checks passed
@XnLemon XnLemon linked an issue Sep 4, 2026 that may be closed by this pull request
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.

[Admin] 使用 TDesign React 开发管理后台

1 participant