diff --git a/.planning/phases/36-granular-mcp-oauth-api-token-scope-picker/36-UI-SPEC.md b/.planning/phases/36-granular-mcp-oauth-api-token-scope-picker/36-UI-SPEC.md new file mode 100644 index 00000000..b714a8a3 --- /dev/null +++ b/.planning/phases/36-granular-mcp-oauth-api-token-scope-picker/36-UI-SPEC.md @@ -0,0 +1,651 @@ +--- +phase: "36" +slug: "granular-mcp-oauth-api-token-scope-picker" +status: approved +reviewed_at: "2026-11-24" +shadcn_initialized: false +preset: none +created: "2026-11-24" +--- + +# Phase 36 — UI Design Contract + +> Visual and interaction contract for frontend phases. Generated by msd-ui-researcher, verified by msd-ui-checker. + +This phase replaces the flat scope checkbox list on both administrator scope-granting surfaces in the embedded admin SPA (`admin/`, served by `boardwalk`) with a shared 3-tier access selector (`Full *` | `Read-only admin:read` | `Custom`) and a scalable grouped `ScopePicker` designed for dozens of plugins and hundreds of feature-level scopes. No new design tokens, fonts, radii, shadows, or npm packages are added. + +1. **Administrator MCP OAuth consent screen** (`admin/src/views/ConnectView.vue`, modified). Keeps its calm `480px` standalone white card on the navy gradient matching `LoginView.vue` (Phase 32.2). Replaces the flat scope checkbox list with `ScopeAccessControl.vue` (3-tier selector defaulting to `Read-only (admin:read)` when requested and grantable, D-03, plus compact elevated-first summary box) and a Reka `Dialog` **Customize scopes** modal (full-screen `100dvh` sheet on `< 640px`, centered `max-w-[640px] max-h-[85dvh]` modal on `≥ 640px`, D-10) hosting `ScopePicker.vue` pinned to light-literal tokens (D-12). +2. **Personal API token creation dialog** (`admin/src/components/account/ApiTokenCreateDialog.vue`, modified). Keeps its `max-w-[560px]` Reka `Dialog` width across all views and its unchanged Step 2 show-once plaintext screen. Replaces the flat scope list in Step 1 with `ScopeAccessControl.vue` (defaulting to `Read-only (admin:read)`, falling back to `Full (*)`, D-08) and swaps the dialog body in place to `ScopePicker.vue` (`← Back to token` / `Apply scopes`, never stacking a second modal overlay, D-02, D-13). +3. **Shared scope selection module** (`admin/src/app/scopeCatalog.ts`, `admin/src/components/scopes/useScopeSelection.ts`, `ScopeAccessControl.vue`, `ScopePicker.vue`, new). Encapsulates feature-level scope grouping by `(plugin_id, group)` (D-01, D-17), opt-in combinable `admin:read` locking with `via admin:read` badges (D-04), elevated-first summary chips capped at 6 with `+N more` (D-06), smart accordion expansion (D-07), tier memory + auto-open Custom when empty (D-09), and draft-until-apply semantics (D-11). +4. **Personal API token list compatibility** (`admin/src/components/account/ApiTokensPanel.vue`, unchanged). Confirmed backwards-compatible with the additive `plugin_id` and `group` fields on `AdminAPITokenScope` (D-15). + +Out of scope: Go backend `pact.TokenScope.Group`, `cabana` fallback resolution, `pier.Mount` boot warnings, core plugin `HasTokenScopes` rollouts (`sm-seo-plugin`, `sm-sitemap-plugin`), frontend member (`usr_` / `vue-oauth-layer`) consent flows, and production deployment of `sm-grzybyfunkcjonalne-app`. + +Sources: +- `36-CONTEXT.md` D-01 through D-20 (locked) and Claude's Discretion items. +- `.planning/notes/2026-11-24-mcp-consent-granular-scope-picker.md` (Option D layout, `admin:read` PII footgun, feature-level granularity). +- `32.2-UI-SPEC.md` (approved Phase 32.2 consent screen contract and light-literal palette). +- Codebase scan: `admin/src/views/ConnectView.vue`, `admin/src/components/account/ApiTokenCreateDialog.vue`, `admin/src/components/account/ApiTokensPanel.vue`, `admin/src/components/ui/Button.vue`, `admin/src/components/form/control.ts`, `admin/src/app/i18n.ts`, `admin/src/app/hotkeys.ts`, `admin/src/api/types.ts`, `admin/src/styles/main.css`, `modules/cabana/account_tokens.go`, `modules/cabana/token_scopes.go`, `modules/phrasebook/backend/lang/{en,pl}/lang.yaml`. + +--- + +## Design System + +| Property | Value | +|----------|-------| +| Tool | none. There is no shadcn: this is a Vue 3 SPA with its own Direction C v2 system (same ruling as Phases 10.1, 12.1, 12.2, 16.3, 32.2, 35) | +| Preset | not applicable | +| Component library | Reka UI 2.9.10 (headless `Dialog*`, `RadioGroup*` primitives) plus local components in `admin/src/components/` | +| Icon library | `@lucide/vue` 1.17.0, named imports only. Sizes: 24px in the 48px client/expired circle, 20px in the wordmark, 18px in `ConnectView` alert blocks, 16px in buttons/search/chevrons/dialog close/back, 14px in inline notes, error lines, and `via admin:read` lock badges | +| Font | DM Sans 400/600/700 (self-hosted `@fontsource/dm-sans`). DM Mono 400 (`font-mono`) for scope codes, redirect host, and plaintext tokens. `tabular-nums` on every count and date | + +**This contract adds no new CSS custom properties (`--c-*`), colors, fonts, radii, shadows, or npm dependencies.** Every visual style reuses existing tokens from `admin/src/styles/main.css`. + +--- + +## Component Inventory + +Enumerated by `node --input-type=module -e "import * as r from 'reka-ui'; import pkg from './node_modules/reka-ui/package.json' with { type: 'json' }; console.log(pkg.version, Object.keys(r).length)"` (run in `admin/`) — 478 exports — reka-ui@2.9.10 — 2026-11-24. +Local components enumerated by `find admin/src/components -name '*.vue' | wc -l` — 69 components — summercms-admin@unversioned (private workspace package with no `version` in `admin/package.json`; pinned by repo commit `c6b1a2bf`) — 2026-11-24. +Icons verified by `node --input-type=module -e "import * as l from '@lucide/vue'; import pkg from './node_modules/@lucide/vue/package.json' with { type: 'json' }; console.log(pkg.version, Object.keys(l).length); for (const n of ['Search','X','ChevronDown','ChevronRight','Lock','ArrowLeft','SlidersHorizontal','Info','CircleAlert','Check','LoaderCircle','Bot','Clock','Sun','Copy','TriangleAlert']) console.log(n, n in l)"` (run in `admin/`) — 5882 exports — @lucide/vue@1.17.0 — 2026-11-24. All 16 icons are confirmed exported. + +This table is a **non-exhaustive** list of known-good components for this phase, never a closed allowlist. Checking for another Reka export or local component is the expected path. + +| Component / Primitive | Import path | Role in Phase 36 | +|-----------------------|-------------|------------------| +| `DialogRoot`, `DialogPortal`, `DialogOverlay`, `DialogContent`, `DialogTitle`, `DialogDescription` | `reka-ui` | Powers both `ApiTokenCreateDialog.vue` (existing) and `ConnectView.vue`'s Customize scopes modal (new, D-10) | +| `RadioGroupRoot`, `RadioGroupItem` | `reka-ui` | Powers the 3-tier **Access level** segmented selector in `ScopeAccessControl.vue` (and existing Expiration selector in `ApiTokenCreateDialog.vue`) | +| `Button` | `admin/src/components/ui/Button.vue` | Footer actions inside `ApiTokenCreateDialog.vue` (and inside `ScopePicker.vue` when rendered through semantic tokens, where `.connect-light-surface` in `main.css` pins both `--c-*` and `--color-*` on `ConnectView`'s modal) | +| `controlClass` | `admin/src/components/form/control.ts` | Shared 44px input border/surface/focus styling for the token Name input and `ScopePicker` search input | +| `t`, `tc`, `currentLocale` | `admin/src/app/i18n.ts` | All localized copy, CLDR plurals (`tc`), and locale-aware alphabetical group collation (`currentLocale`) | +| `shortcutHint` | `admin/src/app/hotkeys.ts` | Tooltip for `Create token` (`mod+s mod+enter`), active only when `ApiTokenCreateDialog` is on the token form view | +| `api`, `AdminAPITokenScope`, `MCPConsent` | `admin/src/api/client.ts`, `admin/src/api/types.ts` | Generated OpenAPI client and types (updated with additive `plugin_id: string` and `group: string` via `scripts/check-admin-openapi.sh`) | +| `ConnectView.vue` | `admin/src/views/ConnectView.vue` | Standalone consent screen integrating `ScopeAccessControl` + light-literal Customize modal | +| `ApiTokenCreateDialog.vue` | `admin/src/components/account/ApiTokenCreateDialog.vue` | Two-step token creation dialog integrating `ScopeAccessControl` + in-dialog `ScopePicker` view swap | +| `ApiTokensPanel.vue` | `admin/src/components/account/ApiTokensPanel.vue` | Unchanged list consumer; verified compatible with additive `plugin_id` / `group` fields | +| `scopeCatalog.ts` *(new)* | `admin/src/app/scopeCatalog.ts` | Pure functions: catalog partitioning, `(plugin_id, group)` grouping & locale sort, query matching, smart expand defaults, elevated-first chip builder, submitted-scope serializer | +| `useScopeSelection.ts` *(new)* | `admin/src/components/scopes/useScopeSelection.ts` | Reactive composable: 3-tier state, tier memory, auto-open empty Custom, draft cloning, apply/discard with tier revert | +| `ScopeAccessControl.vue` *(new)* | `admin/src/components/scopes/ScopeAccessControl.vue` | 3-tier `RadioGroupRoot` + compact effective-access summary box with capped chips, `+N more`, subtitle, and **Customize scopes…** button | +| `ScopePicker.vue` *(new)* | `admin/src/components/scopes/ScopePicker.vue` | Surface-agnostic sticky-header / scrollable-accordion / sticky-footer scope picker | + +--- + +## Visual Hierarchy & Focal Points + +Every screen and sub-view has one primary visual anchor and at most one primary-filled CTA visible at a time. + +| Screen / View | Primary Visual Anchor | Reading & Scanning Hierarchy (Top to Bottom) | Primary CTA (Single `bg-primary`) | +|---------------|-----------------------|----------------------------------------------|-----------------------------------| +| **1. `ConnectView.vue` — Consent Card (`480px`)** | `h1` decision heading (`"Allow :client to use the admin as you?"`, 22px/700) anchored by the 48px client mark | (1) Client mark + `h1` + subline + optional previously-allowed note → (2) Signed-in admin & redirect-host fact box (`bg-[#f3f5f8]`) → (3) `ScopeAccessControl` (3-tier radio bar + compact effective-access summary box) → (4) Optional `offline_access` checkbox row → (5) Inline error slot → (6) Deny (outline) + Allow (primary) button pair | **Allow** (bottom right; never auto-focused, no hotkey) | +| **2. `ConnectView.vue` — Customize Scopes Modal (`Dialog`, light-literal)** | Modal `DialogTitle` (`"Customize scopes"`, 20px/700) + sticky search input framing the scrollable plugin/group accordion list | (1) Sticky title bar (title, description, Close `X`) → (2) Sticky `ScopePicker` controls (Search input → `All \| Selected \| Read-only` filter pills → opt-in `admin:read` banner) → (3) Scrollable flat `(plugin_id, group)` accordions with count badges and per-group `Read` / `All` / `Clear` actions → (4) Sticky footer (live draft count + **Discard changes** + **Apply scopes**) | **Apply scopes** (sticky footer right) | +| **3. `ApiTokenCreateDialog.vue` — Token Form View (Step 1, `max-w-[560px]`)** | `DialogTitle` (`"New API token"`, 20px/700) and auto-focused Name input | (1) Dialog header (title, description, Close `X`) → (2) Scrollable form stack: Name input → Expiration 4-segment radio bar + expiry preview → `ScopeAccessControl` (3-tier radio bar + compact summary box) → (3) Footer (**Discard token** + **Create token**) | **Create token** (footer right; `mod+s` / `mod+enter` active only here) | +| **4. `ApiTokenCreateDialog.vue` — Swapped ScopePicker View (`max-w-[560px]`)** | `← Back to token` header + `DialogTitle` (`"Customize scopes"`, 20px/700) + auto-focused search input | (1) Fixed dialog header (`← Back to token` button + `"Customize scopes"` title + Close `X`) → (2) Sticky `ScopePicker` controls (Search → filter pills → opt-in `admin:read` banner) → (3) Scrollable flat accordions → (4) Sticky footer (live draft count + **Back to token** + **Apply scopes**) | **Apply scopes** (sticky footer right) | + +### Icon-Only Controls & Accessible Labels + +Every icon-only button and compact per-group quick action declares an explicit translated `aria-label`; all decorative icons carry `aria-hidden="true"`. + +| Control | Icon (`@lucide/vue`) | Visible Label | Required `aria-label` (EN / PL) | +|---------|----------------------|---------------|---------------------------------| +| Dialog close button (`ConnectView` modal & `ApiTokenCreateDialog`) | `X` (16px) | none (icon-only) | `backend::lang.form.close` ("Close" / "Zamknij") | +| Scope search clear button (`ScopePicker`) | `X` (16px) | none (icon-only) | `backend::lang.api_tokens.scope_search_clear` ("Clear search" / "Wyczyść wyszukiwanie") | +| Accordion header toggle button | `ChevronDown` / `ChevronRight` (16px, `aria-hidden="true"`) | Group label + `selected/total` badge | None needed (visible text labels the button; carries `aria-expanded` and `aria-controls`) | +| Per-group `Read` quick action | none | `Read` / `Odczyt` | `backend::lang.api_tokens.group_select_read_named` ("Select read-only scopes in :group" / "Zaznacz zakresy tylko do odczytu w grupie :group") | +| Per-group `All` quick action | none | `All` / `Wszystkie` | `backend::lang.api_tokens.group_select_all_named` ("Select all scopes in :group" / "Zaznacz wszystkie zakresy w grupie :group") | +| Per-group `Clear` quick action | none | `Clear` / `Wyczyść` | `backend::lang.api_tokens.group_clear_named` ("Clear selected scopes in :group" / "Wyczyść wybrane zakresy w grupie :group") | +| Locked read-only badge (`via admin:read`) | `Lock` (14px, `aria-hidden="true"`) | `via admin:read` / `przez admin:read` | None needed (visible text accompanies icon; never communicates lock by icon or color alone) | +| Decorative icons (`Search`, `SlidersHorizontal`, `ArrowLeft`, `Info`, `CircleAlert`, `LoaderCircle`, `Bot`, `Clock`, `Sun`) | 14–24px, `aria-hidden="true"` | Always paired with visible label/placeholder/text | Not focusable | + +--- + +## Spacing Scale + +All new Phase 36 layout spacing uses the 8-point scale strictly (multiples of 4 only; zero new non-4-multiple spacing values). + +| Token | Value | Tailwind | Usage in Phase 36 | +|-------|-------|----------|-------------------| +| xs | 4px | `gap-1`, `p-1` | Segmented tier radio track padding; filter pill bar padding and button gap; per-group quick action gap; label-to-mono-code gap; `Lock`-to-text gap inside `via admin:read` and `admin:read` chips | +| sm | 8px | `gap-2`, `px-2`, `py-2` | Summary box internal stack gap; summary chip wrap gap and chip horizontal padding (`px-2`); `ScopePicker` sticky header vertical stack gap and sticky footer button pair gap (`gap-2`); accordion list vertical gap; accordion header padding (`py-2`) and toggle icon-to-label gap; quick action horizontal padding (`px-2`); search clear button inset (`right-2`); empty-state vertical stack gap | +| md | 16px | `gap-4`, `p-4`, `px-4`, `py-4` | Summary box padding (`p-4`); `ScopePicker` sticky header, scrollable body, and sticky footer padding (`p-4`); modal header padding (`p-4`); filter pill horizontal padding (`px-4`); accordion header horizontal padding (`px-4`); dialog section stack gap (`gap-4`) | +| lg | 24px | `gap-6`, `p-6`, `px-6` | Wordmark-to-card column gap on `ConnectView` (inherited); `ApiTokenCreateDialog` Step 1/2 outer padding (`p-6`, inherited); empty-state horizontal padding (`px-6`) | +| xl | 32px | `p-8`, `py-8` | `ConnectView` consent card padding (inherited); `ScopePicker` empty-state vertical padding (`py-8`) | +| 2xl | 48px | `size-12` | `ConnectView` client mark / expired clock circle (size, inherited) | +| 3xl | 64px | — | Not used | + +Additional multiple-of-4 utility used on `ScopePicker` search icon inset: `12px` (`left-3`, matching the 40px `pl-10` text start with 16px icon + 12px left/right clearance). + +**Inherited Direction C exceptions (copied verbatim from existing components; zero new non-4-multiple exceptions introduced):** +- `18px` (`gap-[18px]`): `ConnectView` card stack gap and `ApiTokenCreateDialog` Step 1 fieldset stack gap (inherited from `LoginView`, `ConnectView`, `ApiTokenCreateDialog`). +- `12px` (`py-3`, `gap-3`), `56px` (`min-h-[56px]`), `2px` (`mt-0.5`): scope row vertical padding, checkbox-to-text gap, minimum row height, and checkbox optical nudge (inherited from `ApiTokenCreateDialog` and `ConnectView` scope rows). +- `10px` (`gap-2.5`, `px-2.5`): existing footer button pair gap (`ConnectView` Allow/Deny and `ApiTokenCreateDialog` Step 1 form footer) and inherited `Read-only` pill horizontal padding (`px-2.5`). +- `14px` (`px-3.5`): `controlClass` horizontal input padding (overridden by `pl-10 pr-10` on the `ScopePicker` search input) and `LoginView`-style alert block horizontal padding (`px-3.5 py-3`). +- `6px` (`gap-1.5`): label-to-control stack gap inside form fields (`ApiTokenCreateDialog`, `ConnectView`, and the `ScopeAccessControl` root that replaces their existing `data-field="scopes"` stack). + +**Fixed component dimensions (sizes, not spacing):** +- `44px` (`h-input`): `ConnectView` Allow/Deny buttons, search input, Name input, `admin:read` toggle row minimum height. +- `42px` (`h-button`): `Button` (`size="md"`), `ScopePicker` footer buttons. +- `38px` (`h-[38px]`): `Button` (`size="sm"`), **Customize scopes…** button, tier radio segment min-height, accordion toggle hit target. +- `34px` (`size-[34px]`, `h-[34px]`): dialog Close `X` button, `← Back to token` header button, inherited wordmark circle. +- `32px` (`h-8`): filter pills (`All`, `Selected`, `Read-only`) and per-group quick action buttons (`Read`, `All`, `Clear`). +- `24px` (`h-6`): summary chips, `+N more` chip, `Read-only` badge, `via admin:read` badge, group count badge. +- `20px` (`size-5`): checkboxes (`rounded-[6px]`). +- Widths/heights: `ConnectView` card `max-w-[480px]`; `ConnectView` Customize modal `100dvh` full-screen on `< 640px` and `max-w-[640px] max-h-[85dvh]` on `≥ 640px` (D-10); `ApiTokenCreateDialog` fixed `max-w-[560px]` across all views (D-13). + +--- + +## Typography + +Four sizes total. All inherit DM Sans (`14px / 1.5`) from `html` in `admin/src/styles/main.css`. + +| Role | Size | Weight | Line Height | Used by | +|------|------|--------|-------------|---------| +| Meta / Code | 13px | 400 / 600 | 1.5 | Scope mono code (`font-mono`), scope description, redirect host (`font-mono`), `admin:read` toggle subtext, summary subtitle (`tabular-nums`), footer draft count (`tabular-nums`), empty-state body; **600** for summary chips, `+N more` chip, `Read-only` pill, `via admin:read` badge, group selection count badge (`tabular-nums`), active filter pill, per-group quick actions (`Read`/`All`/`Clear`), inactive/active tier radio tab text | +| Body / Label | 14px | 400 / 600 | 1.5 | **400**: consent subline, dialog description, search input text, signed-in admin value, alert text, expired/error copy. **600**: field labels (`Access level`, `Scopes`), tier active label, group accordion title, scope row title, `admin:read` toggle title, summary full/read-only heading, `← Back to token`, **Customize scopes…**, **Apply scopes**, **Discard changes**, **Allow**, **Deny**, **Create token** | +| Dialog Heading | 20px | 700 *(inherited)* | 1.2 (`tracking-[-0.01em]`) | `ApiTokenCreateDialog` `DialogTitle` (all views: `"New API token"`, `"Customize scopes"`, `"Copy your new token"`) and `ConnectView` Customize scopes `DialogTitle` (`"Customize scopes"`) | +| Consent Heading | 22px | 700 *(inherited)* | 1.2 (`tracking-[-0.02em]`) | `ConnectView` card `h1` across all states (copied verbatim from `LoginView` / Phase 32.2) | + +**Weight rule:** All new content in Phase 36 uses weights **400 and 600 only**. Weight **700 is the inherited heading-only exception** locked in Phase 16.3 and re-applied in Phase 32.2 — it appears exclusively on the 22px `ConnectView` `h1`, the 20px `DialogTitle`, and the unchanged inherited 18px wordmark / `ApiTokensPanel` `h2`. +**Monospace & numerals:** DM Mono (`font-mono`) is used only for scope codes (`*`, `admin:read`, `journal:read`), redirect host, and the Step 2 plaintext token. `tabular-nums` is required on every counter (`selected/total`, filter pill counts, `+N more`, summary counts, footer draft counts) and every date. + +--- + +## Color + +### Surface-Matched Theming Mechanism (D-12, Zero New Tokens) + +`ScopeAccessControl.vue` and `ScopePicker.vue` use **only semantic Direction C v2 Tailwind utilities** (`bg-surface`, `bg-subtle`, `bg-hover`, `border-border`, `border-border-strong`, `text-text`, `text-muted`, `placeholder:text-placeholder`, `bg-primary`, `text-on-primary`, `accent-primary`, `text-danger`, `border-danger`, `bg-danger-soft`, `bg-skel`). + +- **`ApiTokenCreateDialog.vue` (authenticated admin shell):** Inherits `:root` in light mode and `.dark` in dark mode automatically. +- **`ConnectView.vue` (standalone login/consent flow):** Applies `.connect-light-surface` — defined definitively in `@layer components` in `admin/src/styles/main.css` (never Vue `