Repository navigation
fix(native-chat): show images in Codex structured chat - #18266
Conversation
778c8a2 to
be00c8b
Compare
There was a problem hiding this comment.
Important
One stability bug to fix before merge: the resolved image runtime context is recreated on every parent render, so every visible image is released and re-read during streaming.
Reviewed changes
- Preview cache hardening —
local-image-src-cache.tsextracts the existing preview blob cache into its own module and adds byte-budgeted, lease-versioned eviction with pinning and deferred blob revocation. - Structured transcript image thumbnails —
NativeChatTranscriptChrome.tsxrendersimage-refblocks as IntersectionObserver-gated thumbnails with a full-size dialog and textual fallback; legacy terminal chips keep their existing behavior. - Runtime ownership derivation —
native-chat-image-runtime-context.tsresolves the owning local/folder/runtime/SSH execution host into aRuntimeFileOperationArgs, failing closed while unresolved, with a folder-workspace path fallback innative-chat-file-link.ts. - Typing indicator extraction —
TypingIndicatorRowis moved toNativeChatTypingIndicatorRow.tsx.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (7)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe change adds runtime-aware local image loading with a bounded blob URL cache, lease validation, invalidation, eviction, and URL cleanup. Native chat resolves image ownership from tab and workspace state, passes runtime context through message rendering, and displays lazy local image previews with dialog support. Folder workspace paths use a fallback resolver. Typing indicators use a shared component. Tests cover cache limits, release behavior, runtime context stability, visibility observation, and owner changes. Merge Risk: ⚪ Minimal · up to Native structured chat now renders locally resolved image references as accessible thumbnails with full-size dialog support while preserving chip fallbacks when resolution is unavailable. Cache and lifecycle regressions identified during development are covered by focused tests, and no current merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description includes a useful summary and validation notes, but it does not follow the required template. It omits the ELI5, What Changed, Why, Linked Issue, Visual Proof, AI Disclosure, Review, boundary, Notes, and Checklist sections. Resolution Complete the required template sections. Add the issue reference after "Fixes #", provide visual proof or write "N/A" with a reason, document testing and platform coverage, complete the required checklist items, and include any applicable AI disclosure and review notes.
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: 6f9c9b4d-eb01-417a-a6bd-18cfbe6dedf3
📥 Commits
Reviewing files that changed from the base of the PR and between 4b2d9b5 and 778c8a253892664685992467369f08666f92b6d9.
📒 Files selected for processing (13)
src/renderer/src/components/editor/local-image-src-cache.tssrc/renderer/src/components/editor/local-image-src-reader.tssrc/renderer/src/components/editor/useLocalImageSrc.test.tssrc/renderer/src/components/editor/useLocalImageSrc.tssrc/renderer/src/components/native-chat/NativeChatMessageList.tsxsrc/renderer/src/components/native-chat/NativeChatStructuredSession.tsxsrc/renderer/src/components/native-chat/NativeChatTranscriptChrome.test.tsxsrc/renderer/src/components/native-chat/NativeChatTranscriptChrome.tsxsrc/renderer/src/components/native-chat/NativeChatTypingIndicatorRow.tsxsrc/renderer/src/components/native-chat/native-chat-file-link.test.tssrc/renderer/src/components/native-chat/native-chat-file-link.tssrc/renderer/src/components/native-chat/native-chat-image-runtime-context.test.tssrc/renderer/src/components/native-chat/native-chat-image-runtime-context.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Memoized image runtime owner —
useNativeChatImageRuntimeContextnow wrapsresolveNativeChatImageRuntimeContextinuseMemokeyed on the shallow-stableownerStateandtabId, so the derivedRuntimeFileOperationArgskeeps referential identity across unrelated re-renders. This resolves the prior release/re-read churn finding and the corresponding test was updated to reflect the stabilized identity.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ No critical issues — one test-quality suggestion inline. The production fix is correct.
Reviewed changes
- Scoped image preview to the Codex lane —
NativeChatStructuredSessionnow passesruntimeContextonly whenprops.agent === 'codex', so legacy terminal sessions keep their chip rendering (enablePreviewstaysfalse). - Stabilized the observed element —
TranscriptImagePreviewdrops the fragment wrapper and always returns a singlediv, so theIntersectionObservertarget keeps DOM identity when the fallback swaps to the thumbnail.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
| const observedElement = container.firstElementChild | ||
| expect(observedElement).not.toBeNull() | ||
| if (!observedElement || !callback) { | ||
| throw new Error('image preview did not register visibility observation') | ||
| } | ||
| const notifyVisibility = callback | ||
| await act(async () => { | ||
| notifyVisibility( | ||
| [{ target: observedElement, isIntersecting: true } as IntersectionObserverEntry], | ||
| {} as IntersectionObserver | ||
| ) | ||
| await flushPromises() | ||
| }) | ||
|
|
||
| expect(container.firstElementChild).toBe(observedElement) |
There was a problem hiding this comment.
observedElement is NativeChatImageAttachments' outer mb-2 flex flex-wrap wrapper, but observeTranscriptVisibility registers the listener keyed on the inner TranscriptImagePreview ref div. Firing the callback with the wrapper as target never matches the visibilityListeners map, so setNear never fires, the preview never materializes, and the assertion is trivially true. This test would still pass with the fragment regression reintroduced.
Technical details
# Regression test doesn't exercise the observed-element fix
## Affected sites
- src/renderer/src/components/native-chat/NativeChatTranscriptChrome.test.tsx:161 — captures `container.firstElementChild` (the wrapper).
- src/renderer/src/components/native-chat/NativeChatTranscriptChrome.test.tsx:169 — fires the callback with that wrapper as `entry.target`.
- src/renderer/src/components/native-chat/NativeChatTranscriptChrome.tsx:37 — `visibilityListeners.set(element, listener)` where `element` is the inner ref div, not the wrapper.
## Required outcome
- The test must actually drive `setNear` on the observed element and assert the ref div's
identity is preserved across materialization (e.g. assert a thumbnail `<img>` appears AND
the ref div node is unchanged).
## Suggested approach (optional)
- Use the element the fake observer was asked to observe as the target, e.g.
`const target = vi.mocked(FakeIntersectionObserver.observe).mock.calls[0]?.[0]`,
or `observedElement.firstElementChild`, then fire `notifyVisibility` with that `target`
and assert on the ref div identity rather than the wrapper.There was a problem hiding this comment.
ℹ️ The runtime-owner fallback in this delta is correct and backed by a genuine regression test — no new issues in these commits. Approval is withheld only because the prior test-quality thread on the transcript visibility-observation test remains open and is untouched by this delta.
Reviewed changes
- Resolved runtime-only image owners —
resolveNativeChatImageRuntimeContextnow derives the execution host fromroute.runtimeEnvironmentIdviatoRuntimeExecutionHostIdwhen a route carries only a runtime owner (noexecutionHostId), so owner-only worktrees resolve an image read context during paired hydration instead of failing closed withnull.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
Review complete at exact head f136efb. Verdict: clean for the requested scope. PR1 remains limited to Codex structured-session image-ref previews and the shared runtime-owner/preview plumbing; terminal transcript rows are not upgraded, paired-web thumbnail behavior is preserved, and observer/cache cleanup plus runtime-only owner routing are covered. Verification:
Residual validation gaps: no Electron/CDP visible-proof run was possible against these exact heads, and the full SSH/network/mobile matrix was not run (mobile-facing code is untouched). The stale attachment-cache/SSH-save owner-migration concern remains an adjacent pre-existing follow-up, not introduced by this PR. |
Visual QA — structured Codex chat image previewExercised on an isolated Orca dev instance from this worktree ( 1. Empty structured Codex Chat2. Composer pasted-image thumbnail3. Composer full-size preview dialog4. Transcript thumbnail after send (PR change)5. Transcript full-size preview dialogGaps: legacy terminal transcript chips, SSH/folder/unresolved-owner fallbacks, and runtime-owner switches were not exercised. Screenshots are uncropped full-window captures; they are not committed to the branch. |
|
Review complete at Verdict: land after fixes. The same-model adversarial review completed two passes, grounded the implementation against established attachment/ownership/lifecycle patterns, and fixed three proven regressions without expanding scope:
Validation:
Residual gaps: live SSH/paired-runtime and Windows variants were not exercised in this macOS run; the changed structured-chat path is gated away from those hosts, and routing/ownership tests cover the relevant branches. Legacy terminal-chip rendering remains intentionally unchanged in this PR. |
There was a problem hiding this comment.
ℹ️ No new issues in this cache-lease delta — the version-bump move from acquire to release is correct and backed by genuine regression tests. Approval remains withheld only because the prior test-quality thread on the transcript visibility-observation test is still open and untouched by these commits.
Reviewed changes
-
Retained image preview cache leases across surfaces — lease acquisition now pins without bumping the cache-key version, and release is what invalidates stale in-flight reads, so a mounted preview adopts an in-flight prewarm read and one surface's
releaseLocalImageSrcno longer evicts a blob another surface still leases. -
Extended lease acquisition to the rich-markdown image nodeView — the ProseMirror image node now holds a pin for its lifetime and releases it on destroy or reload.
-
Scoped thumbnail and dialog error state to the offending src —
TranscriptImagePreviewtracks the failed blob URL rather than a boolean, so a cache refresh produces a fresh URL and retries a previously failed thumbnail.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
…s Codex (#18743) * fix(native-chat): render Claude structured chat through the same UI as Codex Structured native chat is one shared, agent-agnostic component tree, but three Codex-hardcoded terms on that path made a Claude session render differently. - `showTurnStatus` was `agent === 'codex'`, which gated the whole structured presentation: the live tool-progress row, the completion check and activity grouping (`structuredActivityUi`), and the Thinking / Working for N / Worked for N status rows. Claude fell back to the legacy compact chrome. - `runtimeContext` was likewise Codex-only, so a Claude transcript rendered images as filename chips instead of previews. - The composer's structured slash menu always served the Codex catalog, ignoring `agent`. That disagreed with the dispatcher, which does branch per agent: Codex-only tokens offered to Claude missed the command guard and were sent to the model as literal prompt text, where Codex shows an error. The first two gates landed Codex-first (#17597, #18266) before the Claude structured lane existed; they were rollout scoping, not capability limits. Neither `useNativeChatTurnStatus` nor `useNativeChatImageRuntimeContext` has any agent-specific logic. The menu now reads `structuredSlashCommands(agent)`, the function the dispatcher already used, so both read one list. No new rendering logic: two gates removed and one existing shared function reused. There are now zero `agent === 'codex' | 'claude'` branches in any native-chat component. * docs(native-chat): update structured turn status contract --------- Co-authored-by: Merge Sim <sim@local>
* fix(native-chat): render structured image refs from their runtime owner * fix(native-chat): keep transcript image keys stable * fix(native-chat): memoize the image runtime owner * fix(native-chat): keep image preview observation scoped * fix(native-chat): resolve runtime-only image owners * fix(native-chat): retain image preview cache leases --------- Co-authored-by: Merge Sim <sim@local>
…s Codex (stablyai#18743) * fix(native-chat): render Claude structured chat through the same UI as Codex Structured native chat is one shared, agent-agnostic component tree, but three Codex-hardcoded terms on that path made a Claude session render differently. - `showTurnStatus` was `agent === 'codex'`, which gated the whole structured presentation: the live tool-progress row, the completion check and activity grouping (`structuredActivityUi`), and the Thinking / Working for N / Worked for N status rows. Claude fell back to the legacy compact chrome. - `runtimeContext` was likewise Codex-only, so a Claude transcript rendered images as filename chips instead of previews. - The composer's structured slash menu always served the Codex catalog, ignoring `agent`. That disagreed with the dispatcher, which does branch per agent: Codex-only tokens offered to Claude missed the command guard and were sent to the model as literal prompt text, where Codex shows an error. The first two gates landed Codex-first (stablyai#17597, stablyai#18266) before the Claude structured lane existed; they were rollout scoping, not capability limits. Neither `useNativeChatTurnStatus` nor `useNativeChatImageRuntimeContext` has any agent-specific logic. The menu now reads `structuredSlashCommands(agent)`, the function the dispatcher already used, so both read one list. No new rendering logic: two gates removed and one existing shared function reused. There are now zero `agent === 'codex' | 'claude'` branches in any native-chat component. * docs(native-chat): update structured turn status contract --------- Co-authored-by: Merge Sim <sim@local>






Summary
image-refblocks in Codex structured-session transcripts as accessible thumbnailsValidation
pnpm tc:webThis PR intentionally leaves legacy terminal transcript rows on their existing chip behavior; the terminal optimistic-echo lane is in the stacked follow-up PR.