|
| 1 | +# Configure AI Tools — Webview Panel Design Spec |
| 2 | + |
| 3 | +## Goal |
| 4 | + |
| 5 | +Replace the VS Code QuickPick flow for "Configure AI Tools" with an inline accordion panel that expands within the homescreen sidebar webview. Skills and MCP server configuration are presented as checklists in a single panel — no modal menus, no context switching. |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## Interaction Model |
| 10 | + |
| 11 | +The "Configure AI Tools" action row gains a chevron on the right. Clicking it toggles an accordion panel directly below the button. The rest of the homescreen (footer) is pushed down; the sidebar scrolls if needed. |
| 12 | + |
| 13 | +### Accordion States |
| 14 | + |
| 15 | +| State | Description | |
| 16 | +|-------|-------------| |
| 17 | +| **Loading** | Shown immediately on open. Extension fetches skill list from GitHub and reads workspace status in parallel, then posts `aiToolsData` to the webview. Spinner or skeleton rows. | |
| 18 | +| **Ready** | Skills checklist + MCP servers checklist + Apply button visible. | |
| 19 | +| **Applying** | Apply button becomes "Applying…" (disabled). Each row updates with ✓ or ✗ as it completes. | |
| 20 | +| **Done** | All rows show final status. Accordion stays open so user can review results. | |
| 21 | + |
| 22 | +--- |
| 23 | + |
| 24 | +## Panel Content |
| 25 | + |
| 26 | +### Skills Sub-section |
| 27 | + |
| 28 | +Header: `Skills` |
| 29 | + |
| 30 | +A 3-button segmented control selects the IDE target: |
| 31 | +- **Claude Code** (default unless `detectEditor()` returns `cursor` or `vscode`) |
| 32 | +- **Cursor** |
| 33 | +- **VS Code Copilot** |
| 34 | + |
| 35 | +Pre-selected based on `detectEditor()`. User can change before clicking Apply. |
| 36 | + |
| 37 | +Below the IDE selector, a flat checklist — one row per skill: |
| 38 | + |
| 39 | +``` |
| 40 | +☑ cloudinary-docs ✓ installed |
| 41 | +☑ cloudinary-react not installed |
| 42 | +☑ cloudinary-transformations not installed |
| 43 | +``` |
| 44 | + |
| 45 | +- Checkbox always starts **checked** regardless of install status (overwrite prompt in the extension is the safety net for already-installed skills) |
| 46 | +- Status label is small and muted, shown to the right of the skill name |
| 47 | + |
| 48 | +### MCP Servers Sub-section |
| 49 | + |
| 50 | +Header: `MCP Servers` |
| 51 | + |
| 52 | +Same flat checklist pattern. Smart defaults: already-configured servers start **unchecked** to protect credentials from silent overwrite. |
| 53 | + |
| 54 | +``` |
| 55 | +☐ Asset Management ✓ configured |
| 56 | +☑ MediaFlows not configured |
| 57 | +``` |
| 58 | + |
| 59 | +### Apply Button |
| 60 | + |
| 61 | +Full-width button at the bottom of the accordion, labelled **"Apply"**. |
| 62 | + |
| 63 | +- Disabled when no items are checked |
| 64 | +- During apply: label becomes "Applying…", button disabled |
| 65 | +- After apply: button label returns to "Apply" (panel stays open) |
| 66 | + |
| 67 | +--- |
| 68 | + |
| 69 | +## Data Flow |
| 70 | + |
| 71 | +### Open accordion |
| 72 | + |
| 73 | +1. User clicks the "Configure AI Tools" row |
| 74 | +2. Webview toggles accordion open, shows loading state |
| 75 | +3. Webview posts `{ command: "aiToolsExpanded" }` to extension |
| 76 | +4. Extension in parallel: |
| 77 | + - Fetches skill list from GitHub (`fetchSkillList()`) |
| 78 | + - Reads workspace status (`readInstalledSkillDirNames`, `readConfiguredMcpServerKeys`) for all three IDE targets |
| 79 | + - Detects editor (`detectEditor()`) |
| 80 | +5. Extension posts to webview: |
| 81 | +```json |
| 82 | +{ |
| 83 | + "command": "aiToolsData", |
| 84 | + "skills": [ |
| 85 | + { "name": "cloudinary-docs", "dirName": "cloudinary-docs", "description": "..." } |
| 86 | + ], |
| 87 | + "installedByIde": { |
| 88 | + "Claude Code": ["cloudinary-docs"], |
| 89 | + "Cursor": [], |
| 90 | + "VS Code (Copilot)": [] |
| 91 | + }, |
| 92 | + "mcpServers": [ |
| 93 | + { "key": "cloudinary-asset-mgmt", "label": "Asset Management", "description": "..." } |
| 94 | + ], |
| 95 | + "configuredMcpKeys": ["cloudinary-asset-mgmt"], |
| 96 | + "detectedIde": "Claude Code" |
| 97 | +} |
| 98 | +``` |
| 99 | +6. Webview renders the checklist from this data |
| 100 | + |
| 101 | +### Apply |
| 102 | + |
| 103 | +1. User clicks Apply |
| 104 | +2. Webview posts: |
| 105 | +```json |
| 106 | +{ |
| 107 | + "command": "installAiTools", |
| 108 | + "skills": ["cloudinary-react", "cloudinary-transformations"], |
| 109 | + "ideTarget": "Claude Code", |
| 110 | + "mcpServers": ["mediaflows"] |
| 111 | +} |
| 112 | +``` |
| 113 | +3. Extension processes each item, posting progress after each: |
| 114 | +```json |
| 115 | +{ "command": "aiToolsProgress", "item": "cloudinary-react", "status": "done" } |
| 116 | +{ "command": "aiToolsProgress", "item": "mediaflows", "status": "done" } |
| 117 | +``` |
| 118 | +4. Extension posts final result: |
| 119 | +```json |
| 120 | +{ "command": "aiToolsResult", "errors": [] } |
| 121 | +``` |
| 122 | +5. Webview updates row statuses; shows error rows if any |
| 123 | + |
| 124 | +### Error on skill fetch |
| 125 | + |
| 126 | +If GitHub fetch fails, extension posts: |
| 127 | +```json |
| 128 | +{ "command": "aiToolsData", "error": "Failed to fetch skills: <message>" } |
| 129 | +``` |
| 130 | +Webview shows the error inline in the accordion. |
| 131 | + |
| 132 | +--- |
| 133 | + |
| 134 | +## File Map |
| 135 | + |
| 136 | +| Action | File | What changes | |
| 137 | +|--------|------|-------------| |
| 138 | +| Modify | `src/webview/homescreenView.ts` | Add accordion HTML; handle `aiToolsExpanded` / `installAiTools` messages; send `aiToolsData` / `aiToolsProgress` / `aiToolsResult` | |
| 139 | +| Modify | `src/webview/client/homescreen.ts` | Accordion toggle logic; render panel from `aiToolsData`; wire Apply; handle progress/result messages | |
| 140 | +| Modify | `src/commands/configureAiTools.ts` | Extract `installSkill()` and `installMcpServers()` as exported functions; the `cloudinary.configureAiTools` command becomes a thin wrapper (or is removed if the button is the only entry point) | |
| 141 | + |
| 142 | +--- |
| 143 | + |
| 144 | +## Styling Constraints |
| 145 | + |
| 146 | +- Follow existing homescreen CSS patterns (`--vscode-*` CSS variables only, no hardcoded colours) |
| 147 | +- Accordion panel uses the same `hs-action` row sizing and typography |
| 148 | +- Segmented control uses existing button/border styles |
| 149 | +- Checklist rows are compact: ~28–30px per row to fit within narrow sidebar |
| 150 | +- Apply button matches `.hs-setup-banner-btn` style but full-width |
| 151 | + |
| 152 | +--- |
| 153 | + |
| 154 | +## Out of Scope |
| 155 | + |
| 156 | +- The `cloudinary.configureAiTools` VS Code command (palette entry) continues to exist as a thin wrapper calling the same install logic — no regression for keyboard users |
| 157 | +- No animations on accordion open/close beyond CSS `max-height` transition (keep it simple) |
| 158 | +- No per-section independent Apply buttons — one Apply commits everything |
0 commit comments