Skip to content

feat: preview bridge — live dev server proxy with element selection#11

Draft
Blaise1030 wants to merge 18 commits into
mainfrom
browser-sidecar
Draft

feat: preview bridge — live dev server proxy with element selection#11
Blaise1030 wants to merge 18 commits into
mainfrom
browser-sidecar

Conversation

@Blaise1030

Copy link
Copy Markdown
Owner

Summary

Adds a preview bridge that connects the IDE terminal to a proxied dev-server tab, inspired by Cursor's browser panel but implemented across two browser tabs.

  • Terminal URL detection — parses localhost URLs in terminal output; normal click opens the raw server, Cmd+click opens /sidecar/proxy?target=…
  • sidecar-client package — injected script (VanJS pill UI, WebSocket client, CSS selector capture, element screenshot)
  • Go sidecar backend — reverse proxy with HTML injection, embedded client.js, WebSocket hub, screenshot persistence to .workbench/files, and refresh broadcast on file write
  • Frontend wiringuseSidecarWs composable, terminal URL link provider, element-selected paste into terminal

Design spec: docs/specs/2026-06-06-preview-bridge-design.md

Test plan

  • Start a dev server (e.g. Vite) and confirm terminal shows clickable localhost URLs
  • Normal click opens raw dev server in new tab
  • Cmd+click opens sidecar proxy tab with injected client script
  • Save a file in the IDE → preview tab auto-refreshes
  • Enable selection mode in preview → click element → selector + screenshot path pasted in terminal
  • Run pnpm -r build and Go tests (go test ./server-go/internal/sidecar/...)
  • Verify sidecar-client build is wired into Go embed pipeline

Notes

This PR includes only committed changes on browser-sidecar. There are unstaged local edits (vite config, WorkspaceView, rebuilt client.js, landing page) not included — commit separately if needed.

Made with Cursor

Blaise1030 and others added 18 commits June 6, 2026 13:06
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implements buildSelector utility with TDD. Adds local vitest.config.ts with jsdom environment and installs jsdom dev dependency. Refines dynamic class regex to require at least one digit in the suffix so semantic compound names like card-header are preserved.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add explicit guard for document.body input returning "body"
- Add browser-only comment and export DYNAMIC_CLASS_RE for unit testing
- Fix misleading test comment to reflect actual digit-lookahead regex
- Add tests for detached bare element and document.body edge case
- Add DYNAMIC_CLASS_RE describe block with direct unit tests
- Extract magic number 2 into MAX_CLASSES constant
- Remove unused beforeEach import from selector.test.ts

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Wires pill, selector, and screenshot modules into the IIFE entry point
injected into proxied pages; connects to /sidecar/ws with 2s reconnect.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implements a reverse proxy handler that injects the sidecar client.js script
into HTML responses and rewrites absolute asset paths to stay under /sidecar/proxy/.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ile write

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implements extractURLs (pure, tested in isolation) and createURLLinkProvider
(xterm ILinkProvider) for detecting and activating localhost/127.0.0.1 URLs
in terminal output.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment on lines +38 to +43
http.SetCookie(w, &http.Cookie{
Name: cookieName,
Value: target,
Path: cookiePath,
SameSite: http.SameSiteStrictMode,
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants