Skip to content

feat(preview): closable right slot with file preview pane - #7

Merged
SPhillips1337 merged 18 commits into
mainfrom
feat/preview-pane
Nov 30, 2026
Merged

SPhillips1337 merged 18 commits into
mainfrom
feat/preview-pane

Conversation

@SPhillips1337

Copy link
Copy Markdown
Contributor

Summary

  • Right workspace slot is now browse | preview | closed, persisted with the layout; closing collapses the grid to one pane, and Split/Preview reopen it. maximized is kept consistent so a closed slot never leaves a ghost.
  • One bounded IPC channel fs:preview classifies, validates and reads in main: images (32 MiB, 4096 px display edge, 40 MP pre-decode header probe on the synchronous fallback), UTF-8 text (1 MiB cap with byte-accurate truncation flag), NUL-byte binary sniff, BOM strip; regular files only, folders/symlinks/devices refused, ENOENT → not-found.
  • New PreviewPane renders images, text, Markdown (react-markdown + remark-gfm, no raw HTML) and source code; HTML shows as source. http(s)-only links open through shell:openUrl → safeExternalUrl; CSP keeps remote images inactive.
  • Preview follows the left selection (180 ms debounce, re-reads when size/mtime change); explicit "Preview in Pane" on a right-pane file pins that file; an empty selection opens the empty state.
  • F5/F6, Copy→/Move→, cross-pane drops and context-menu transfer items disable with a transcript hint when the peer is not a listing.
  • Docs: ADR-0006, SPEC M11–M13, ROADMAP D18/P3.7, PROGRESS delivered entry; version bumped to 0.3.1.

Test plan

  • npm run ci — typecheck clean, 36 test files / 260 passed / 1 skipped (Windows symlink privilege), production build OK
  • Installed 0.3.1 build smoke: toolbar Preview, selection-following, ×/Split round-trip, F5 greying, right-click Preview in Pane, Markdown/HTML rendering

Notes

Deferred minors are recorded in the session ledger (slot-pill lit state, some listing-only toolbar buttons still no-op without a listing pane, no renderer test harness, link-click failure replaces the document). PDF/audio/video/SVG preview intentionally deferred per ADR-0006.

Scopes a preview mode for the right workspace slot: images, text,
Markdown and code read through bounded main-process IPC, follow-selection,
and disabled cross-pane ops when the peer is not a listing.
…isting pane

item:preview now seeds the recommended target through setSlot('preview', target),
so the follow-selection effect must not re-seed from the left listing on slot
entry; a signature ref gates it to later left selection changes. F5/Copy-> and
F6/Move-> also go dead-disabled with a log when no listing pane is active,
instead of resolving to a null command set and silently doing nothing.
Real JPEGs carry 100 KB+ of ICC/EXIF/XMP APPn segments before the SOF
marker, so the 64 KiB probe window from 9a44c9c rejected files the
synchronous createFromPath fallback had always decoded, losing preview
and listing thumbnails. Raise the window to 1 MiB and cover the layout
with a crafted SOF-beyond-64-KiB JPEG in both the decode and probe tests.
@amazon-q-developer

Copy link
Copy Markdown

Warning

Amazon Q Developer for GitHub: end of support

On January 30, 2027, AWS will discontinue support for the Amazon Q Developer for GitHub App. New app installations will no longer be available starting November 18, 2026.

For capabilities similar to the Amazon Q Developer for GitHub App, explore Kiro and the Kiro GitHub App. For more information about the end of support, see Amazon Q Developer end-of-support announcement on the AWS DevOps Blog.

@amazon-q-developer amazon-q-developer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

This PR introduces a well-structured preview pane with IPC-bounded file reading, Markdown rendering via react-markdown, and a closable right workspace slot. The security model — resolveLocalPath path validation, safeExternalUrl protocol/credential gating, and renderer-side shell:openUrl routing — is sound. The read loop in readText correctly handles short reads and truncation. The sequence counter in PreviewPane correctly prevents stale IPC replies from repopulating closed state.

One logic defect found: The "Open" button in the unsupported-reason UI incorrectly appears for symlink results. The backend deliberately refuses symlinks (using lstat specifically to avoid following links), but the renderer does not exclude 'symlink' from the button condition, so the UI offers to open a path that was intentionally rejected. See the inline comment for the one-line fix.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.


⚠️ This PR contains more than 30 files. Amazon Q is better at reviewing smaller PRs, and may miss issues in larger changesets.

Comment thread src/renderer/preview-pane.tsx Outdated
body = (
<div className="preview-error">
<p>{REASONS[result.reason]}</p>
{result.reason !== 'folder' && result.reason !== 'not-found' ? (

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Logic Error: The symlink reason is not excluded from showing the "Open" button, but this is inconsistent and potentially wrong — a symlink was refused specifically because following it was not allowed. Presenting an "Open" button for a symlink result will call onOpen(result.path) with the symlink path, which then calls shell.openPath on the symlink itself; on some platforms the OS follows the link, on others it fails silently. The intent of refusing symlinks in the backend was to avoid indirection, so the UI should not offer to open them either. Add 'symlink' to the exclusion condition.

Suggested change
{result.reason !== 'folder' && result.reason !== 'not-found' ? (
{result.reason !== 'folder' && result.reason !== 'not-found' && result.reason !== 'symlink' ? (

@SPhillips1337
SPhillips1337 merged commit c96fa5a into main Nov 30, 2026
@SPhillips1337
SPhillips1337 deleted the feat/preview-pane branch November 30, 2026 17:02
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