Skip to content

Preview as sidebar companion — extension-side changes (#931) - #936

Merged
jeonghun-jj-lee merged 12 commits into
mainfrom
amico/issue-931-preview-companion
Sep 9, 2026
Merged

jeonghun-jj-lee merged 12 commits into
mainfrom
amico/issue-931-preview-companion

Conversation

@jeonghun-jj-lee

Copy link
Copy Markdown
Contributor

Preview as sidebar companion (#931)

Extension-side changes for the Preview companion redesign. Companion to harmoniqs/opencode#315 (app-side changes).

Commits

  1. Sidebar single/double-click split #932 — Sidebar single/double-click split: Debounced click handler on file rows. Single-click (250ms) sends open-file (routed to Preview). Double-click sends open-file-editor (opens native VS Code tab).

  2. Extension → Preview bridge (sidebar routing) #934 — Extension → Preview bridge: Re-routes the sidebar's openFile handler to post { source: 'amicode', kind: 'preview-file', path } to the chat panel webview instead of calling showTextDocument. Fallback to native editor if chat panel not open.

  3. Chat file-pill re-routing to Preview #935 — Chat file-pill re-routing: Re-routes the chat bridge's open-file handler to post preview-file instead of executing markdown.showPreview / vscode.open. Uniform routing: both sidebar clicks and chat file references flow through the same pipeline.

Test delta

  • 8 new tests across sidebar bridge, webview, and chat bridge
  • 2 updated tests (chat bridge: open-file now expects preview-file instead of VS Code commands)
  • All 2991 tests pass, 0 failures

Closes #932, closes #934, closes #935

@jeonghun-jj-lee jeonghun-jj-lee added the afk Implementable without human interaction label Sep 9, 2026
@jeonghun-jj-lee jeonghun-jj-lee self-assigned this Sep 9, 2026
@coderabbitai

coderabbitai Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 1743e6f7-036f-4694-a601-de9bbecd97f7


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jeonghun-jj-lee
jeonghun-jj-lee marked this pull request as ready for review September 9, 2026 18:27
…own (#919)

Match the canonical preprocessMarkdown (newlines + trim) from the opencode
fork's markdown-utils.ts. Updates 4 math-block assertions.
Sidebar entry: single-click → Preview, double-click → VS Code tab.
Preview entry: reactive companion viewer in the side panel.
Add debounced click handling to sidebar file rows:
- Single-click (250ms debounce) → sends 'open-file' (routed to Preview in slice 3)
- Double-click → sends new 'open-file-editor' (opens native VS Code editor tab)

Bridge changes:
- Add OpenFileEditorMessage type (kind: 'open-file-editor')
- Add openFileEditor optional handler to SidebarMessageHandlers
- Add dispatch case in handleSidebarMessage
- sidebar_view.ts implements openFileEditor via showTextDocument

Tests (6 new):
- Bridge: open-file-editor triggers handler, no-op when handler absent
- Webview: debounce timer present, both message kinds emitted, 250ms delay,
  ghost entry guard precedes debounce

All 2989 tests pass, 0 failures.
Closes #932
Re-route the sidebar's openFile handler: instead of calling showTextDocument
directly, it now posts a { source: 'amicode', kind: 'preview-file', path }
message to the chat panel webview. The chat panel's session page listens for
this message and sets previewFile in the layout context (the opencode fork
side of #934).

Fallback: if the chat panel isn't open, falls back to showTextDocument.

Tests (2 new):
- openFile handler references preview-file and ChatPanel
- openFileEditor handler still uses showTextDocument

All 2991 tests pass, 0 failures.
Closes #934
…ion (#935)

Re-route the chat bridge's open-file handler: instead of executing
markdown.showPreview (for .md) or vscode.open (for everything else), it
now posts { source: 'amicode', kind: 'preview-file', path } to the chat
webview. This reuses the same preview-file pipeline built in #934 — the
session page sets previewFile, opens the side panel, and switches to the
Preview tab.

Uniform routing: both sidebar single-clicks (from #932/#934) and chat file
references now flow through the same preview-file bridge message.

Tests (3 updated):
- Markdown files route to preview-file (not markdown.showPreview)
- Non-markdown files route to preview-file (not vscode.open)
- Invalid/missing files: no preview-file posted, no commands executed

All 2991 tests pass, 0 failures.
Closes #935
The outer webview relay script has an explicit allowlist of message kinds
that get forwarded from the extension host to the opencode iframe. The
preview-file message was not in this list, so it was silently dropped —
the sidebar posted the message, but it never reached the app's session
page listener.

Add 'preview-file' to both relay instances (primary panel + adopted panel).

Test (1 new): verifies preview-file appears in both relay allowlists.
… PDFs (#934)

openFileEditor used showTextDocument, which only works for text files.
Binary files (images, PDFs) either showed garbled content or failed
silently. Replace with vscode.commands.executeCommand('vscode.open',
uri) which delegates to VS Code's file-type detection — images open
in the built-in preview, PDFs in a PDF viewer extension, etc.

Test (1 updated): asserts vscode.open, not showTextDocument.
- Zoom pill + edit/preview mode toggle as auto-hiding floating overlays
- 2s idle fade with mouse/pinch reveal; hover pauses timer
- Pinch/wheel zoom on markdown preview (transform: scale)
- Save via serverSDK (auth-aware); autosave removed — Cmd+S only
- .trim() removed from file read handler (fixes phantom git diffs)
- Dirty dot with correct v2 design system tokens
- Overlay nudged right: 14px to clear scrollbar
- Sync overlay with opencode fork (e37f8eb68a)
@jeonghun-jj-lee
jeonghun-jj-lee force-pushed the amico/issue-931-preview-companion branch from 4ff6b2c to 131a477 Compare September 9, 2026 18:40
New files created in the fork for the floating overlay refactor —
needed by session-preview-tab.tsx imports.
…mports

markdown-utils.ts, media.ts, selection-bridge.ts, session-diff.ts,
session-review.tsx — all new in the fork, imported transitively by the
Files Changed floating overlay refactor.
preview-editor.tsx, editor-core.ts, preview-nav-state.ts,
markdown-shiki.worker.ts, and app/package.json (pdfjs-dist dep).
Verified: materialized vite build passes locally.
@jeonghun-jj-lee
jeonghun-jj-lee merged commit bcc8547 into main Sep 9, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

afk Implementable without human interaction

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chat file-pill re-routing to Preview Extension → Preview bridge (sidebar routing) Sidebar single/double-click split

1 participant