Skip to content

Replace native TreeView sidebar with a webview sidebar #673

Description

@jeonghun-jj-lee

Important

Problem: The Amicode sidebar is a native VS Code TreeDataProvider that clones the workspace file explorer — it cannot render custom UI (styled buttons, status pills, device lists) and has no awareness of which project the active session is bound to.

Approach: Replace the amicode.workspace view registration from type: "tree" to type: "webview". Implement a WebviewViewProvider with a vanilla TS/DOM browser entry point and a dedicated typed postMessage bridge. The sidebar renders a fixed header (Chat + New Project buttons), a session-aware unified project tree (Research Projects with lifecycle metadata + Dev Projects as plain nodes), and a fleet section placeholder.

Scope: The sidebar registration, provider, browser-side rendering, message bridge, project scanning, and session-to-project binding. Does NOT include fleet implementation (deferred), the in-app Rail concept (deferred), or a recently-deleted recovery section (future enhancement).

Assumptions: Research Projects are detected by project.toml presence (ADR 0012). Fleet section ships as a placeholder. The sidebar is navigation chrome — destinations open in the editor area. Sessions are bound to exactly one Project (ADR 0012).

Branching

  • Base branch: amico/issue-663-research-projects
  • Implementation branch: amico/issue-673-webview-sidebar
  • PR target: amico/issue-663-research-projects (not main)

The sidebar's Research Project nodes depend on the project.toml detection and prescribed layout introduced by #663. The two features ship together.

Acceptance Criteria

Registration and build

  • package.json registers amicode.workspace as type: "webview"
  • SidebarViewProvider implements WebviewViewProvider with CSP-nonce HTML shell
  • sidebar_webview.ts added as a browser entry point in esbuild.config.mjs (browser/iife)
  • New sidebar_bridge.ts with typed message protocol (separate from chat_bridge.ts)
  • Sidebar respects VS Code theme tokens (--vscode-sideBar-background, etc.)
  • workspace_tree.ts and trees.ts are deleted

Fixed header

  • Two half-width styled buttons rendered side by side: "Chat with Amico" and "+ New Project"
  • Chat button opens/focuses ChatPanel in editor; dims when chat is already open
  • New Project button triggers project creation flow (name, directory, project.toml scaffold)

Project tree

  • Research Project nodes show name, lifecycle phase pill, last-active timestamp
  • Research Project nodes expand to show file tree (lazy-loaded, respects files.exclude, hides .git)
  • Research Project nodes show hover-revealed action icons (new session, open)
  • Dev Projects and plain workspace folders show as expandable file tree nodes (no metadata)
  • Right-click context menu on all node types with full file-operation parity: new file, new folder, rename, delete (trash only), copy path, copy relative path, reveal in Finder, open in terminal, open to side
  • Research Project root nodes additionally offer "New Session" in context menu
  • Workspace root nodes offer "Remove from Workspace"
  • Delete always moves to trash (useTrash: true) — no permanent delete option

Session awareness

  • Sidebar highlights and auto-expands the project bound to the active session
  • Switching sessions (chat tabs) updates the sidebar's active project highlight
  • No highlight when no session is open (Landing / fresh chat state)
  • Clicking a non-active project only browses (expands file tree); does not switch sessions

Fleet (deferred)

  • Fleet section present as a collapsible placeholder or hidden behind feature flag

Cleanup

  • Existing workspace-tree tests removed or migrated

Key Decisions

Decision Choice Ref
Sidebar rendering WebviewViewProvider (webview), not TreeDataProvider ADR 0013
Rendering technology Vanilla TS/DOM, no framework ADR 0013
Communication New sidebar_bridge.ts (typed postMessage)
Project + file model Unified tree: Research Projects (rich) + Dev Projects (plain)
Session awareness Sidebar follows active session; highlights bound project
Delete behavior Trash only, no permanent delete
Fleet Collapsible section, deferred
View registration Replace amicode.workspace in-place, no coexistence ADR 0013

Constraints & Invariants

  • The sidebar is navigation chrome — it never hosts a chat surface or rich visualizations
  • The sidebar follows sessions; it never drives session switching
  • Directory tree is lazy-loaded (read on expand, not upfront)
  • File operations reach parity with the deleted TreeView (context menus by node type)
  • Delete always uses { useTrash: true } — no permanent deletion from the sidebar
  • CSP nonce pattern matches existing webview panels (OnboardingPanel precedent)

Future Enhancements

  • Recently Deleted section — in-sidebar recovery for trashed items (needs managed trash or OS-level restore integration)
  • Fleet section — device list with name, role, connection status once fleet is formalized

Source

ADR 0013: docs/adr/0013-webview-sidebar.md

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions