# Dashboard Studio Integration Implementation Plan
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
**Goal:** Integrate the standalone Studio app into the AISBF dashboard as a role-aware `Studio` page with dashboard-native theming, unified model selection across providers/rotations/autoselects, and best-effort capability inference for autodetected and manually configured models.
**Architecture:** Add a new dashboard Studio route and template that reuse the existing dashboard shell while introducing a workspace-oriented layout. Back the page with a dedicated Studio catalog service that resolves visible resources for the current principal, normalizes provider/rotation/autoselect entries into a stable frontend payload, and merges explicit plus inferred capabilities. Extend existing provider/model save flows so capability inference runs whenever models are autodetected or edited.
- Modify: `aisbf/routes/dashboard/providers.py` - add `/dashboard/studio` page route plus Studio JSON endpoints near other dashboard routes.
- Modify: `main.py` - ensure the updated dashboard router is still initialized; verify no extra registration is needed.
**Studio data/service layer:**
- Create: `aisbf/studio.py` - shared helpers for capability inference, catalog normalization, scope filtering, and diagnostics formatting.
- Modify: `aisbf/handlers.py` - reuse or extract existing `_detect_capabilities()` logic so Studio and API model-list flows share one inference vocabulary instead of diverging.
- Modify: `aisbf/config.py` - extend `ProviderModelConfig` to store Studio-related capability metadata and optional inference metadata cleanly.
**Persistence and config integration:**
- Modify: `aisbf/database.py` - add helper methods for normalized user-owned resource loading if needed by Studio catalog resolution, without changing current storage model.
- Modify: `aisbf/routes/dashboard/providers.py` - hook capability inference into manual model save and autodetect save flows.
- Modify: `aisbf/routes/dashboard/settings.py` - if existing save endpoints are reused for user resource writes, route capability refresh through the shared Studio helper.
**Templates and frontend assets:**
- Modify: `templates/base.html` - add `Studio` navigation link for both admin and users; allow a full-width/Studio page body mode.
- Create: `templates/dashboard/studio.html` - dashboard-native Studio page bootstrapped with serialized catalog JSON and theme-aware workspace markup.
- Create: `static/dashboard/studio.js` - client bootstrap, target switching, capability-state rendering, diagnostics display, and future-ready data wiring.
- Modify: `static/i18n/en.json` - add `nav.studio` and Studio UI strings used by the page.
**Tests:**
- Create: `tests/test_studio.py` - unit tests for catalog normalization, scope filtering, and capability inference.
- Modify: `tests/providers/test_claude_provider.py` or create a new dashboard-focused test module only if provider autodetect persistence needs route-level regression coverage.
- Create: `tests/routes/test_dashboard_studio.py` - route tests for admin/user Studio page and JSON catalog behavior.
---
### Task 1: Build the shared Studio catalog and capability service
**Files:**
- Create: `aisbf/studio.py`
- Modify: `aisbf/handlers.py:1671-1804`
- Test: `tests/test_studio.py`
-[]**Step 1: Write the failing catalog normalization and capability inference tests**
If the file already uses a different variable name, preserve the local naming but apply the same transformation exactly once immediately before persistence.
-[]**Step 6: Run tests to verify they pass**
Run: `pytest tests/test_studio.py -v`
Expected: PASS for all Studio unit tests, including the new persistence cases
Then update `build_studio_catalog()` so rotation and autoselect entries use `derive_collection_capabilities()` when no explicit `capabilities` are set:
Apply the same pattern to autoselects by mapping each `available_model` reference back to a provider-model capability list where possible, and defaulting to explicit autoselect capabilities when already present.
-[]**Step 4: Surface partial capability states in the Studio UI**
In `static/dashboard/studio.js`, ensure `partial_capabilities` render with `partial` chip styling and add availability note text when `availability_state === 'partial'`.
In `templates/dashboard/studio.html`, change the workspace placeholder block to:
Review whether the new Studio page and `aisbf/studio.py` count as a significant project-structure or key-functionality change under `AI.PROMPT`. If yes, add a concise section documenting the new Studio integration points and capability inference responsibilities.
Suggested addition:
```markdown
### aisbf/studio.py
Shared Studio integration helpers:
- Normalizes dashboard-visible provider/rotation/autoselect resources into a unified Studio catalog
- Infers and merges Studio capability metadata for autodetected and manually configured models
- Supports current user-only visibility and future permission-aware expansion
Expected: PASS or, if unrelated failures already exist, capture them explicitly and confirm no Studio-related regressions are introduced
-[]**Step 4: Manually verify the Studio page in both roles**
Run the app with the project’s normal startup command, sign in as:
- admin
- regular user with user-owned providers/rotations/autoselects
Verify:
-`Studio` appears in nav for both roles
-`/dashboard/studio` uses dashboard theme tokens in dark and light themes
- user catalog shows only user-owned resources
- admin catalog shows global resources
- entries with incomplete capability metadata render as partial rather than disappearing
-[]**Step 5: Commit documentation updates if made**
```bash
git add AI.PROMPT
git commit -m"docs: document dashboard studio integration"
```
Skip this commit if `AI.PROMPT` does not change.
---
## Self-Review
- Spec coverage: this plan covers the new dashboard page, shared theming, unified provider/rotation/autoselect catalog, user-only visibility for now with future permission-ready service boundaries, best-effort capability inference on autodetect/manual insert, partial/unknown handling, and tests.
- Placeholder scan: all implementation tasks include concrete files, code snippets, commands, and expected outcomes; no `TODO`/`TBD` placeholders remain.
- Type consistency: the plan consistently uses `build_studio_catalog`, `infer_model_capabilities`, `apply_inferred_capabilities_to_model`, `derive_collection_capabilities`, `StudioCapabilityResult`, and `StudioAggregateCapabilityResult` across tasks.