[codex] Preview workspace image files#3259
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
ApprovabilityVerdict: 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. |
e27816d to
7909197
Compare
7909197 to
01b1b93
Compare
01b1b93 to
9214cdf
Compare
e6a4567 to
7ef6bc2
Compare
b74fe0b to
1824661
Compare
3c55746 to
48e11f6
Compare
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>
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>
48e11f6 to
881936d
Compare
Co-authored-by: codex <codex@users.noreply.github.com>
| browserPreviewAbortControllerRef.current?.abort(); | ||
| }, | ||
| [], | ||
| ); |
There was a problem hiding this comment.
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.
Reviewed by Cursor Bugbot for commit 0078748. Configure here.


Summary
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.tsvp checkvp run typecheckpython3 /home/t3code/.codex/skills/.system/skill-creator/scripts/quick_validate.py /home/t3code/.codex/skills/t3-contributevp checkreports the repository's existing unrelated warnings and no errors.Closes #3140
Note
Add image file preview in the integrated browser panel for workspace files
beginPreviewRequestso that newer preview requests supersede older in-flight ones, preventing stale results from being applied.BrowserPreviewUnavailableError,BrowserPreviewAssetUrlInvalidError,BrowserPreviewEnvironmentDisconnectedError,BrowserPreviewThreadContextUnavailableError) with structured context fields replacing ad-hoc message strings.isWorkspaceImagePreviewPath,isWorkspacePreviewEntryPath) from@t3tools/shared/filePreview.FilePreviewPaneleligibility 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/filePreviewhelpers, adds per-thread request coalescing so a newer open wins over an older in-flight preview, and accepts an optionalAbortSignal. Preview failures are modeled withSchema.TaggedErrorClasserrors (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:
ChatViewfile surfaces andDiffPaneldiff 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.FilePreviewPanellabels 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.