You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Preview as sidebar companion — reactive file viewer driven by Sidebar and Chat #931
Problem: The Preview tab is a self-contained Finder (directory listing, breadcrumbs, search) that duplicates the Sidebar's file tree. Clicking a file in the Sidebar opens a native VS Code editor tab, bypassing Preview entirely — the two surfaces are disconnected. Users navigate files in the Sidebar but view them in a separate VS Code tab, splitting attention across windows.
Approach: Turn Preview into a reactive companion viewer driven by file selection in the Sidebar and Chat. Strip the Finder from Preview (the Sidebar is the file tree), route single-clicks to Preview via an extension-mediated bridge, and reserve double-clicks for native VS Code editor tabs.
Shared VS Code state — workspaceState polling. Rejected: no reliable change events for webviews, adds latency.
Direct webview-to-webview messaging — collapses to the bridge approach (VS Code routes all webview messages through the extension host).
Scope: Preview tab + sidebar click handlers + chat file-pill routing. Does not touch: Pulse Inspector, Files Changed, Context tab, Home tab, sidebar tree rendering/structure, no-project fallback (deferred).
Assumptions: The side panel auto-open API works reliably from the bridge message handler. The ~250ms single/double-click debounce is acceptable UX latency.
Acceptance Criteria
Sidebar single-click → Preview: clicking a file in the Sidebar opens it in the Preview tab. If the side panel is closed or on another tab, it auto-opens and switches to Preview.
Sidebar double-click → VS Code tab: double-clicking a file in the Sidebar opens a native VS Code editor tab.
Chat file pills → Preview: clicking a file reference in chat opens the file in Preview instead of a VS Code tab.
Finder stripped: Preview has no directory listing, no breadcrumb navigation, no search input, no walk-tree cache. File selection comes exclusively from external sources (Sidebar, Chat).
Empty state: when no file is selected, Preview shows a "Select a file from the sidebar" placeholder.
File rendering unchanged: markdown renders with Preview/Edit toggle; text/code opens in CM6 editor; images/PDFs render inline; binary/error/oversize show placeholders.
Per-file state preserved: mode (preview/edit), scroll position, and unsaved content survive across file switches within a session.
Single/double-click debounce: single-click fires only after ~250ms with no following double-click. Double-click fires immediately.
Testing Decisions
Extend the existing preview test suite (preview-file-routing, preview-nav-state). Add integration tests for the bridge message flow (sidebar → extension → chat webview). Unit tests for the single/double-click debounce logic in the sidebar webview.
Key Decisions
Click model: single = Preview, double = VS Code
Mirrors VS Code's own preview-tab convention. Single-click is non-committal viewing; double-click commits to a full editor session.
Extension-mediated bridge
Message chain: sidebar webview → extension host → chat webview → SolidJS app. New message kind preview-file (extension → chat). The existing open-file from sidebar is re-routed at the extension host. Chat file-pill open-file is similarly re-routed.
Preview state lifted to session layout
selectedFile moves from a component-local store to a signal at the session-layout level (reachable from the bridge message handler). The per-file store shrinks to mode/scroll/unsaved only.
No-project sessions show empty state
The prior fallback mode (listing session-touched files) is deferred — not part of this design.
Important
Problem: The Preview tab is a self-contained Finder (directory listing, breadcrumbs, search) that duplicates the Sidebar's file tree. Clicking a file in the Sidebar opens a native VS Code editor tab, bypassing Preview entirely — the two surfaces are disconnected. Users navigate files in the Sidebar but view them in a separate VS Code tab, splitting attention across windows.
Approach: Turn Preview into a reactive companion viewer driven by file selection in the Sidebar and Chat. Strip the Finder from Preview (the Sidebar is the file tree), route single-clicks to Preview via an extension-mediated bridge, and reserve double-clicks for native VS Code editor tabs.
Approaches considered:
Scope: Preview tab + sidebar click handlers + chat file-pill routing. Does not touch: Pulse Inspector, Files Changed, Context tab, Home tab, sidebar tree rendering/structure, no-project fallback (deferred).
Assumptions: The side panel auto-open API works reliably from the bridge message handler. The ~250ms single/double-click debounce is acceptable UX latency.
Acceptance Criteria
Testing Decisions
Extend the existing preview test suite (preview-file-routing, preview-nav-state). Add integration tests for the bridge message flow (sidebar → extension → chat webview). Unit tests for the single/double-click debounce logic in the sidebar webview.
Key Decisions
Click model: single = Preview, double = VS Code
Mirrors VS Code's own preview-tab convention. Single-click is non-committal viewing; double-click commits to a full editor session.
Extension-mediated bridge
Message chain: sidebar webview → extension host → chat webview → SolidJS app. New message kind
preview-file(extension → chat). The existingopen-filefrom sidebar is re-routed at the extension host. Chat file-pillopen-fileis similarly re-routed.Preview state lifted to session layout
selectedFilemoves from a component-local store to a signal at the session-layout level (reachable from the bridge message handler). The per-file store shrinks to mode/scroll/unsaved only.No-project sessions show empty state
The prior fallback mode (listing session-touched files) is deferred — not part of this design.
Data Contracts
New bridge message (extension → chat webview):
New sidebar message (sidebar webview → extension host):
Existing messages re-routed:
{ kind: "open-file", path }— extension host forwards aspreview-fileinstead of callingshowTextDocument.{ source: "amicode", kind: "open-file", url }— extension host forwards aspreview-fileinstead of callingvscode.open.Constraints & Invariants
preview-filebridge message.Prior Art
open-filehandler pattern.Source
Notes