Skip to content

[codex] Preview workspace image files#3259

Open
StiensWout wants to merge 10 commits into
pingdotgg:mainfrom
StiensWout:fix/workspace-image-preview
Open

[codex] Preview workspace image files#3259
StiensWout wants to merge 10 commits into
pingdotgg:mainfrom
StiensWout:fix/workspace-image-preview

Conversation

@StiensWout

@StiensWout StiensWout commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • route workspace image files into the existing integrated preview flow
  • expose image preview actions from file links and file surfaces
  • keep non-image file opening behavior unchanged

Root cause

The asset server already supports signed workspace image preview URLs, but the web client only treated HTML and PDF paths as previewable entry files.

Impact

Screenshots and other workspace image files can be viewed in-app from file explorer, markdown links, and diff file headers. If preview opening fails, the UI falls back to the existing file surface behavior.

Validation

  • vp test packages/shared/src/filePreview.test.ts apps/web/src/diffFileActions.test.ts
  • vp check
  • vp run typecheck
  • python3 /home/t3code/.codex/skills/.system/skill-creator/scripts/quick_validate.py /home/t3code/.codex/skills/t3-contribute

vp check reports the repository's existing unrelated warnings and no errors.

Closes #3140

Note

Add image file preview in the integrated browser panel for workspace files

  • Image files clicked in the files panel, diff panel, and chat markdown links now open in the integrated browser preview when runtime support is available, falling back to the file/editor surface with a warning toast on failure or interruption.
  • Introduces request scoping via beginPreviewRequest so that newer preview requests supersede older in-flight ones, preventing stale results from being applied.
  • Adds typed errors (BrowserPreviewUnavailableError, BrowserPreviewAssetUrlInvalidError, BrowserPreviewEnvironmentDisconnectedError, BrowserPreviewThreadContextUnavailableError) with structured context fields replacing ad-hoc message strings.
  • Replaces the local regex file-type check with shared helpers (isWorkspaceImagePreviewPath, isWorkspacePreviewEntryPath) from @t3tools/shared/filePreview.
  • Behavioral Change: FilePreviewPanel eligibility and UI labels now use the shared workspace preview rule and say "Open file in preview" instead of "Open file in browser".

Macroscope summarized 66c94ff.


Note

Medium Risk
Touches signed asset URL assembly and preview state; changes are bounded to preview UI with fallbacks, but concurrent preview requests and URL error handling warrant careful review.

Overview
Workspace image files (png, jpeg, gif, svg, webp, avif, etc.) now use the same integrated preview flow as HTML/PDF, instead of only opening in the file editor.

Preview pipeline (openFileInPreview) delegates file-type checks to shared @t3tools/shared/filePreview helpers, adds per-thread request coalescing so a newer open wins over an older in-flight preview, and accepts an optional AbortSignal. Preview failures are modeled with Schema.TaggedErrorClass errors (thread/environment context, separate tags for disconnected env, missing thread, invalid asset URL). Invalid asset URLs record lengths and metadata only—not signed paths or base URLs.

UI entry points: ChatView file surfaces and DiffPanel diff file opens try image preview when the runtime supports it, then fall back to the existing file/editor path with a warning toast. Chat markdown file links use the broader preview eligibility, pass abort signals, and on preview failure or interruption open the file surface instead of only showing an error. FilePreviewPanel labels and eligibility align with “preview” wording and shared rules.

New unit tests cover unavailable runtime, safe invalid-URL errors, and stale preview responses.

Reviewed by Cursor Bugbot for commit 66c94ff. Bugbot is set up for automated code reviews on this repo. Configure here.

@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 7b871c68-1f28-46f4-a05a-84021b3e678b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Jun 20, 2026
@StiensWout StiensWout marked this pull request as ready for review June 20, 2026 10:00
Comment thread apps/web/src/components/ChatMarkdown.tsx
@macroscopeapp

macroscopeapp Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

This PR introduces a new image preview feature with new error types, async request tracking, and integration across multiple UI components. The scope of new runtime behavior plus an unresolved bug comment about thread handling warrants human review.

You can customize Macroscope's approvability policy. Learn more.

@StiensWout StiensWout marked this pull request as draft June 20, 2026 10:12
Comment thread apps/web/src/components/ChatMarkdown.tsx Outdated
@StiensWout StiensWout marked this pull request as ready for review June 20, 2026 16:23
@StiensWout StiensWout force-pushed the fix/workspace-image-preview branch from e27816d to 7909197 Compare June 20, 2026 16:25
@juliusmarminge juliusmarminge force-pushed the fix/workspace-image-preview branch from 7909197 to 01b1b93 Compare June 21, 2026 00:18
Comment thread apps/web/src/components/ChatView.tsx
@juliusmarminge juliusmarminge force-pushed the fix/workspace-image-preview branch from 01b1b93 to 9214cdf Compare June 21, 2026 00:26
Comment thread apps/web/src/components/ChatMarkdown.tsx
@juliusmarminge juliusmarminge force-pushed the fix/workspace-image-preview branch 4 times, most recently from e6a4567 to 7ef6bc2 Compare June 21, 2026 01:11
Comment thread apps/web/src/components/ChatView.tsx
@juliusmarminge juliusmarminge force-pushed the fix/workspace-image-preview branch 2 times, most recently from b74fe0b to 1824661 Compare June 21, 2026 01:39
Comment thread apps/web/src/components/ChatView.tsx
@juliusmarminge juliusmarminge force-pushed the fix/workspace-image-preview branch 2 times, most recently from 3c55746 to 48e11f6 Compare June 21, 2026 02:02
StiensWout and others added 5 commits June 20, 2026 19:33
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
juliusmarminge and others added 3 commits June 20, 2026 19:33
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
@juliusmarminge juliusmarminge force-pushed the fix/workspace-image-preview branch from 48e11f6 to 881936d Compare June 21, 2026 02:34
Comment thread apps/web/src/components/ChatMarkdown.tsx
Co-authored-by: codex <codex@users.noreply.github.com>
browserPreviewAbortControllerRef.current?.abort();
},
[],
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Preview abort omits thread change

Medium Severity

MarkdownFileLink aborts in-flight integrated preview only on unmount, not when threadRef changes. After switching threads while a plan or message link preview is still pending, completion or the new interrupt fallback can still run with the previous thread’s callbacks and open the browser or file panel on the wrong thread.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 0078748. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Image preview/render

2 participants