Skip to content

feat(preview): add browser viewport and tab controls - #872

Merged
nixuuu merged 1 commit into
devfrom
fix/decouple-viewport-sidebar-resize
Nov 16, 2026
Merged

nixuuu merged 1 commit into
devfrom
fix/decouple-viewport-sidebar-resize

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 16, 2026

Copy link
Copy Markdown
Member

Summary

Browser Preview now keeps the agent's viewport independent from the sidebar width. Users can set width and height explicitly, resize from any edge, and select another tab from the browser session.

The worker forwards the session tab list, switches tabs through agent-browser tab <tabId>, and refreshes the active frame and metadata. The compact viewport controls share the interaction status row and support four-digit dimensions.

Validation

  • bun run check:tmp ./apps/worker/src/agent-preview/browser.test.ts — 7 tests passed
  • bun run --filter @canopy/web typecheck — passed
  • bun run --filter @canopy/worker typecheck — passed
  • bun run --filter @canopy/gateway typecheck — passed
  • bunx oxlint on edited preview, shared UI, worker, and gateway files — passed
  • bun run gen:check — passed
  • git diff --check — passed

Copy audit

  • Browser tab, Choose a tab, Viewport, Viewport width, Viewport height, and edge resize labels use sentence case, direct actions, and explicit accessible names.
  • Changed Browser previews follow the active tab to Browser previews use the session tabs so the error matches tab selection in Preview.
  • Checked the compact controls with four-digit viewport values and the multi-tab picker at desktop width; no new glossary terms or colour-only cues were introduced.

@nixuuu
nixuuu enabled auto-merge (squash) November 16, 2026 13:36
@nixuuu
nixuuu merged commit f9cc860 into dev Nov 16, 2026
15 checks passed
@nixuuu
nixuuu deleted the fix/decouple-viewport-sidebar-resize branch November 16, 2026 13:42
nixuuu added a commit that referenced this pull request Nov 16, 2026
## Change

A tall Browser Preview could extend past the bottom of a wide sidebar
because its intermediate container did not constrain the canvas height.
Fit mode now measures the available surface and uses the smaller
width/height scale, preserving the image proportions and keeping the
entire viewport visible when the panel changes size.

The surface reserves space for all four resize handles. Actual-size mode
keeps the frame at 1:1 with scroll access to every edge. Updated the
automation tools documentation and implementation status.

Fixes: #872

## Verification

- `bun run --filter @canopy/web typecheck` — passed, no errors or
warnings.
- `bun run lint --
apps/web/src/lib/features/preview/AgentPreviewCanvas.svelte` — passed.
- `bun run format --
apps/web/src/lib/features/preview/AgentPreviewCanvas.svelte` —
completed.
- `git diff --check` — passed.
- Manually inspected the real preview component in a browser at desktop
and phone panel widths, in light and dark themes, with
portrait/landscape frames and a frame smaller than the panel. Confirmed
preserved proportions, visible resize handles, and no scrolling in fit
mode.
- Checked live panel resizing, normalized pointer coordinates, keyboard
resizing, and scroll access at 1:1. Panel resizing sends no remote
viewport resize commands.
- Copy audit: no UI text changes.

The full repository verification gate remains with GitHub CI.
nixuuu added a commit that referenced this pull request Nov 16, 2026
## Change

Returning to a thread restores its mini preview and minimization state.
Each thread also remembers whether its side panel is open, whether Files
or Preview is selected, and which preview tool is active. Panel metadata
survives reloads in local workspace storage; preview targets remain in
scoped session memory and frames are discarded when a watch closes.

The mini preview uses one fixed icon button for minimize/restore, with
accessible labels, tooltips and keyboard focus preserved. Viewport
width, height and Apply remain visible in narrow panels: the toolbar
wraps and these numeric fields omit the +/− buttons. Other numeric
controls retain their existing steppers.

Documented the implemented behavior and its persistence boundaries in
the workspace and automation docs.

## Verification

- Passed web typecheck with zero errors or warnings, lint on edited
source files, formatting and diff whitespace checks.
- Checked real components in a browser with a temporary fixture and
simulated preview streams: separate A/B/C panel states, reload
persistence, mini preview restore/minimization, stream cleanup and
sidebar handoff. Confirmed no transient mini watch starts for the wrong
thread.
- Checked light/dark themes, desktop and a 390 px phone viewport.
Viewport fields and Apply remain visible at panel widths 320, 390, 468,
520 and 1100 px. Verified resize submission, keyboard increments,
empty-field validation and disabled controls.
- Copy audit (§8): passed. Existing labels are retained as
tooltips/accessibility names; short, typical and long titles were
checked at desktop and phone widths. Icon-only restore replaces the
inconsistent text button without losing its accessible action name.
- Passed integration-tests package typecheck and all four device-view
persistence tests through `check:tmp`, with no temporary files left
behind.
- Remaining repository checks, integration tests and builds run in CI.
No web UI test suite or verification artifacts were added.

Fixes: #846
Fixes: #872
nixuuu added a commit that referenced this pull request Nov 16, 2026
## Change

Dragging a browser viewport handle previously resized the remote browser
every 120 ms, making it difficult to match a visible rectangle. Dragging
now shows a local outline and target dimensions while the live image
keeps its size; releasing sends one resize. This works when shrinking or
expanding from all four edges.

Thin, muted handles sit outside the image. The outline lives outside the
scroll surface so it cannot introduce scrollbars or change the image
scale. Escape, window blur, pointer cancellation and lost capture
discard the draft. Keyboard resizing remains available. Updated the
automation tools documentation and implementation status.

Fixes: #872

## Verification

- Web typecheck: 0 errors and 0 warnings.
- Lint and formatting of both changed Svelte files; diff whitespace
check passed.
- Agent Browser with the real Preview component in an isolated local
harness: exercised synthetic pointer gestures for shrinking and
expanding each edge, verified no resize during the gesture, unchanged
canvas geometry and exactly one resize on release. Verified all four
cancellation paths.
- Visually checked light and dark themes on desktop and at 390 px phone
width; checked 320 px wrapping and actual-size scrolling without handle
overlap on the toolbar. Screenshots reviewed by the user.
- Full repository checks and builds remain with CI. No persistent UI
test suite added, per repository policy.

Copy audit (§8): passed for the new “Release to apply · Esc to cancel”
hint. Previously there was no drag guidance; the hint explains when the
size applies and how to cancel. Labels remain unchanged. Sentence case,
plain language, glossary, accessibility, duplication and narrow-width
checks passed; error, empty-state and humour checks are not applicable.
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.

1 participant