Skip to content

Extract shared admin UI primitives - #649

Merged
kentcdodds merged 4 commits into
mainfrom
cursor/admin-ui-reuse-cleanup-6213
Jul 7, 2026
Merged

kentcdodds merged 4 commits into
mainfrom
cursor/admin-ui-reuse-cleanup-6213

Conversation

@kentcdodds

@kentcdodds kentcdodds commented Jul 6, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Adds a reusable AccountManagementLinkNav for shared pill-style navigation.
  • Reuses that link nav for both admin section navigation and community-report status filters.
  • Extracts shared account-management table styles for Usage and System email tables.
  • Reuses the existing notice-card style for admin invite setup and usage warning surfaces.
  • Moves Remote Connectors onto the shared account-management layout/sidebar/list primitives.
  • Aligns the Account landing page with the shared account shell/header/message semantics.
  • Reuses shared app chrome link/button styles and the shared clipboard fallback helper.
  • Keeps the full cleanup net-negative: 165 additions / 263 deletions.

Walkthrough

Latest account UI primitive reuse:

account-ui-primitive-reuse.mp4

Final Remote Connectors state:

Remote connectors using shared account-management sidebar

Earlier admin reuse cleanup:

admin-ui-reuse-cleanup.mp4

Testing

  • git push -u origin cursor/admin-ui-reuse-cleanup-6213 (latest pre-push ran typecheck, unit tests, client build, and full Playwright E2E: 186 unit files / 586 tests passed; 6 E2E passed)
  • Manual browser walkthrough verified Account, Remote Connectors, connector copy feedback, Package token copy feedback, shared admin nav, report status filters, usage/system-email tables, and invite setup notice card.
System recap — composes existing primitives (low risk)

Mode: recap · Base: main @ 07d14bf · Head: 9fb1eb3

Classification: composes — no primitives added or changed; this PR reuses existing app/account/admin UI primitives across more routes.

Primitives touched

Primitive Group Impact
app-ui surfaces composes — shared account layout/list, pill-link nav, notice card, table styles, app chrome styles, and clipboard helper replace duplicated page-local code

System map

flowchart LR
	appUi["app-ui"]:::touched
	rbac["rbac"]:::untouched
	appSessions["app-sessions"]:::untouched
	appSessions --> appUi
	rbac --> appUi
	classDef touched fill:#1a7f37,color:#fff
	classDef extended fill:#9a6700,color:#fff
	classDef added fill:#cf222e,color:#fff
	classDef untouched fill:#57606a,color:#fff
Loading

Before / after

Before After
Remote Connectors hand-rolled account sidebar/list/selected-item styling. Remote Connectors uses AccountManagementLayout, AccountManagementSidebar, AccountManagementList, and AccountManagementListItemButton.
Account hub hand-rolled shell/header/status message semantics. Account hub uses AccountManagementShell, AccountManagementHeader, and AccountManagementMessage.
App nav duplicated primaryLinkCss; copy actions bypassed shared clipboard fallback. App chrome and clipboard actions reuse existing primitives.
Community report filters duplicated admin nav pill-link styling. Section nav and report filters share AccountManagementLinkNav.
Usage/system email duplicated table style objects. Tables reuse shared account-management table style constants.
Invites reimplemented notice card styling. Invite setup and usage warning states reuse noticeCardCss.
Open in Web Open in Cursor 

Summary by CodeRabbit

  • New Features

    • Added a reusable labeled navigation component with active-state support for account and admin pages.
    • Adopted shared account-management layout and styling primitives (including table/card UI) across multiple routes.
  • Bug Fixes

    • Standardized copy-to-clipboard for tokens and connector URLs via a shared clipboard helper.
    • Prevented connector selection while mutations are in progress.
  • Style

    • Refreshed headers/navigation and admin/account table styling to use shared primitives.
    • Updated loading/action text to use the single-character ellipsis (…).

@coderabbitai

coderabbitai Bot commented Jul 6, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 21525bc4-01cf-49ab-8bf1-997bb4c71836

📥 Commits

Reviewing files that changed from the base of the PR and between 11e8ffe and 0ccc0a0.

📒 Files selected for processing (1)
  • packages/worker/client/routes/account-remote-connectors.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/worker/client/routes/account-remote-connectors.tsx

📝 Walkthrough

Walkthrough

This PR adds shared account-management navigation, table, notice, and clipboard primitives, then updates the app shell and several account/admin routes to use them instead of local implementations.

Changes

Shared account-management components and adoption

Layer / File(s) Summary
New shared nav/table style primitives
packages/worker/client/routes/account-management-components.tsx
Adds AccountManagementLinkNavItem and AccountManagementLinkNav, updates AdminPageHeader to use the shared nav, and adds exported table CSS constants.
app.tsx navigation styling refactor
packages/worker/client/app.tsx
Replaces local nav link styling with primaryLinkCss and refactors the logout button to build on getSecondaryButtonCss().
account.tsx shell/header/message components
packages/worker/client/routes/account.tsx
Replaces inline account page header, description, and alert markup with AccountManagementShell, AccountManagementHeader, and AccountManagementMessage.
admin-community-reports.tsx status filter using AccountManagementLinkNav
packages/worker/client/routes/admin-community-reports.tsx
Replaces the inline report-status button group with AccountManagementLinkNav driven by statusOptions and statusFilter.
Shared clipboard helper adoption
packages/worker/client/routes/account-package-invocation-tokens.tsx, packages/worker/client/routes/account-remote-connectors.tsx
Swaps direct clipboard writes to the shared writeClipboardText helper in both routes.
account-remote-connectors.tsx layout refactor
packages/worker/client/routes/account-remote-connectors.tsx
Replaces the configured-connectors section with AccountManagementLayout, AccountManagementSidebar, AccountManagementList, and AccountManagementListItemButton.
Admin pages table and notice styling updates
packages/worker/client/routes/admin-invites.tsx, packages/worker/client/routes/admin-system-email.tsx, packages/worker/client/routes/admin-usage.tsx
Switches admin pages to shared table and notice CSS primitives and updates loading/action labels to use ellipsis characters.

Estimated code review effort: 2 (Simple) | ~15 minutes

Possibly related PRs

  • kentcdodds/kody#599: Both PRs modify packages/worker/client/app.tsx navigation styling in the shared header code.
  • kentcdodds/kody#612: Both PRs touch the shared account-management shell/component code used by AccountManagementShell and related layout primitives.
  • kentcdodds/kody#647: Both PRs modify packages/worker/client/routes/account-management-components.tsx and the shared admin section navigation used by account-management routes.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the PR’s main refactor toward shared admin UI primitives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/admin-ui-reuse-cleanup-6213

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@kentcdodds
kentcdodds marked this pull request as ready for review July 6, 2026 22:52
@github-actions

github-actions Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

🔎 Preview deployed: https://kody-pr-649.kody-a99.workers.dev

Worker: kody-pr-649
D1: kody-pr-649-db
KV: kody-pr-649-oauth-kv

Mocks:

@coderabbitai coderabbitai 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

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

⚠️ Outside diff range comments (1)
packages/worker/client/routes/account-remote-connectors.tsx (1)

610-649: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Connector selection isn't blocked during save/delete, risking editor-state clobbering.

AccountManagementListItemButton here has no disabled prop and onClick calls selectConnector unconditionally. Compare with the sibling refactor in account-package-invocation-tokens.tsx, which passes disabled={isMutating} and guards the click handler (if (isMutating) return) for the identical shared component.

Without this guard, selecting a different connector while saveConnector/deleteConnector is in flight can corrupt state:

  • deleteConnector unconditionally does editorState = createEmptyEditorState() after its await resolves, wiping out whatever connector the user selected in the meantime.
  • saveConnector's applyPayload reads the (possibly since-changed) global editorState.id to decide what to refresh, showing the wrong connector's data after a mid-flight selection change.
🔒 Proposed fix: guard selection during mutation
 <AccountManagementListItemButton
 	active={editorState.id === connector.id}
-	onClick={() => selectConnector(connector)}
+	disabled={isMutating}
+	onClick={() => {
+		if (isMutating) return
+		selectConnector(connector)
+	}}
 >
🤖 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 `@packages/worker/client/routes/account-remote-connectors.tsx` around lines 610
- 649, Selection in the connector list must be blocked while save/delete
mutations are in flight, because `selectConnector` can clobber `editorState`
mid-operation. Update the `AccountManagementListItemButton` usage in
`account-remote-connectors.tsx` to accept the same `disabled={isMutating}`
pattern used in `account-package-invocation-tokens.tsx`, and add an early return
in the click handler when mutating. Make sure the guard applies around the
`connectors.map(...)` item button and uses the existing `isMutating` state so
`saveConnector` and `deleteConnector` can complete without the user switching
entries.
🧹 Nitpick comments (2)
packages/worker/client/routes/account-management-components.tsx (2)

21-26: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider exporting AccountManagementLinkNavItem.

The type isn't exported, so consumers building items arrays (e.g. admin-community-reports.tsx) can only rely on structural typing rather than importing the shared shape. Since this is explicitly a "shared primitive" meant for reuse across surfaces, exporting it would make the contract explicit for future consumers.

🤖 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 `@packages/worker/client/routes/account-management-components.tsx` around lines
21 - 26, Export the shared AccountManagementLinkNavItem type so other surfaces
can import the explicit contract instead of depending on structural typing.
Update the type declaration in account-management-components.tsx to be exported,
and keep its shape aligned with the existing usage in the account management
link components and any consumers like admin-community-reports.tsx.

138-144: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Active-state styling duplicates hover colors already in getSecondaryButtonCss.

The inline borderColor: colors.primary / backgroundColor: colors.primarySoftest override for item.active duplicates the same color pair already used in getSecondaryButtonCss's :hover state. Not a bug, but worth noting since this file is meant to centralize such styling.

🤖 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 `@packages/worker/client/routes/account-management-components.tsx` around lines
138 - 144, The active-state inline styling in the account management component
duplicates the same primary/softest color pair already defined in
getSecondaryButtonCss hover styles. Update the item.active branch in
account-management-components.tsx to reuse the shared button styling logic
instead of repeating borderColor/backgroundColor overrides, keeping the active
appearance consistent with the centralized styling helper.
🤖 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 `@packages/worker/client/routes/account-remote-connectors.tsx`:
- Around line 610-649: Selection in the connector list must be blocked while
save/delete mutations are in flight, because `selectConnector` can clobber
`editorState` mid-operation. Update the `AccountManagementListItemButton` usage
in `account-remote-connectors.tsx` to accept the same `disabled={isMutating}`
pattern used in `account-package-invocation-tokens.tsx`, and add an early return
in the click handler when mutating. Make sure the guard applies around the
`connectors.map(...)` item button and uses the existing `isMutating` state so
`saveConnector` and `deleteConnector` can complete without the user switching
entries.

---

Nitpick comments:
In `@packages/worker/client/routes/account-management-components.tsx`:
- Around line 21-26: Export the shared AccountManagementLinkNavItem type so
other surfaces can import the explicit contract instead of depending on
structural typing. Update the type declaration in
account-management-components.tsx to be exported, and keep its shape aligned
with the existing usage in the account management link components and any
consumers like admin-community-reports.tsx.
- Around line 138-144: The active-state inline styling in the account management
component duplicates the same primary/softest color pair already defined in
getSecondaryButtonCss hover styles. Update the item.active branch in
account-management-components.tsx to reuse the shared button styling logic
instead of repeating borderColor/backgroundColor overrides, keeping the active
appearance consistent with the centralized styling helper.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 084546e2-caee-4aea-8b7b-a8600045b8e1

📥 Commits

Reviewing files that changed from the base of the PR and between 0a5411b and 9fb1eb3.

📒 Files selected for processing (9)
  • packages/worker/client/app.tsx
  • packages/worker/client/routes/account-management-components.tsx
  • packages/worker/client/routes/account-package-invocation-tokens.tsx
  • packages/worker/client/routes/account-remote-connectors.tsx
  • packages/worker/client/routes/account.tsx
  • packages/worker/client/routes/admin-community-reports.tsx
  • packages/worker/client/routes/admin-invites.tsx
  • packages/worker/client/routes/admin-system-email.tsx
  • packages/worker/client/routes/admin-usage.tsx

@kentcdodds
kentcdodds merged commit f497ee9 into main Jul 7, 2026
5 checks passed
@kentcdodds
kentcdodds deleted the cursor/admin-ui-reuse-cleanup-6213 branch July 7, 2026 01:25
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