Repository navigation
Conversation
39e9512 to
a7b40f5
Compare
When tools emit MEDIA: paths (e.g. image_generate), render images inline on terminals that support Kitty or iTerm2 graphics protocols. Falls back to existing [image/png] text placeholders on other terminals. Architecture: all file I/O happens in setResult() (data layer), cached once, and reused across refreshes. refresh() is a pure function of cached state with zero I/O. Image components are stable instances that attach/detach without recreation.
a7b40f5 to
4e42316
Compare
Tools emit images as [TEXT with MEDIA:path, IMAGE with base64] pairs. When a MEDIA text block is rendered from file, the immediately following image block (base64 duplicate) is now skipped via lastMediaRenderedFromFile flag. Orphan image blocks without a preceding MEDIA path still render from base64. This dedup logic is from the original PR openclaw#36740. Also restores data field on ToolResultContent type so image content blocks with inline base64 can be rendered as a fallback when no preceding MEDIA path exists.
Skills (e.g. grok-imagine) emit a tool call for exec + a follow-up media delivery event for the same image file. Both produce separate ToolExecutionComponent instances that render the same path. Fix: ChatLog passes a shared renderedImagePaths Set to all tool components. When processResult loads a MEDIA: path, it checks and adds to the global set. Second tool call for the same path skips rendering, preventing duplicate images in the TUI.
The TUI client runs on the host but connects to a Docker gateway. MEDIA: paths like /home/node/.openclaw/... don't exist on the host, so readMediaImageAsBase64 fails silently and images render from base64 content blocks instead. The file-path-based globalSeenPaths dedup never fired because no path succeeded. Fix: track a 128-char base64 fingerprint (covers image header + enough pixel data to distinguish different images) in the shared globalRendered set. Both file-loaded and base64-loaded images register their fingerprint. Second tool call with identical image data gets skipped regardless of whether it came via MEDIA: path or orphan image block.
TurboTheTurtle
left a comment
There was a problem hiding this comment.
I found one issue in the inline image state handling.
| if (seenPaths.has(mediaPath) || globalRendered?.has(mediaPath)) { | ||
| continue; | ||
| } | ||
| seenPaths.add(mediaPath); |
There was a problem hiding this comment.
[P2] Keep image dedupe scoped to live cached images
The shared globalRendered set is append-only for the lifetime of the ChatLog, but setPartialResult()/setResult() can detach and clear this component's cached images, and old tool components can be pruned. After a path or fingerprint is added here, a retry or updated final result for the same tool/path skips loading it, so supported terminals can fall back to showing the MEDIA: line or no image even though the current result should render it. Please make the dedupe ownership reversible when cached images are detached/pruned, or scope it to a single processed result instead of the whole chat log.
There was a problem hiding this comment.
You're right, thanks for the careful read. globalRendered is append-only for the ChatLog's lifetime, so once a path or fingerprint is recorded, a later detach or prune of that component's cached images leaves the dedupe entry stale; a retry or updated final result for the same tool/path then skips re-loading and supported terminals fall back to the MEDIA: line. I'll scope the dedupe to a single processed result (or make the entry reversible when its cached image is detached/pruned) instead of keying off the whole chat log. This PR is a stale draft that needs a rebase onto current main first, so I'll fold the fix into that pass.
|
Codex review: needs real behavior proof before merge. Reviewed July 5, 2026, 1:32 PM ET / 17:32 UTC. Summary PR surface: Source +260, Tests +354, Docs +1. Total +615 across 6 files. Reproducibility: yes. source-level: current main renders image tool result content as text placeholders in the TUI, and the PR-head blockers are directly visible in the changed source. I did not run a live Kitty or iTerm2 terminal session in this read-only review. Review metrics: 2 noteworthy metrics.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Proof path suggestion Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review findings
Review detailsBest possible solution: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review. Do we have a high-confidence way to reproduce the issue? Yes, source-level: current main renders image tool result content as text placeholders in the TUI, and the PR-head blockers are directly visible in the changed source. I did not run a live Kitty or iTerm2 terminal session in this read-only review. Is this the best way to solve the issue? No, not as currently submitted. TUI rendering is the right surface, but this branch must be rebased to current main, target current structured media output, repair dedupe ownership, and resolve the local file-read boundary before it is the best maintainable fix. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e09aba147678. Label changesLabel justifications:
Evidence reviewedPR surface: Source +260, Tests +354, Docs +1. Total +615 across 6 files. View PR surface stats
Security concerns:
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
ClawSweeper PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
|
thanks @ademczuk for the substantial exploration and follow-up here. i’m closing this draft unmerged and keeping #57592 as the canonical tracker. current this also needs a fresh security and ownership design rather than a rebase. tool-result text can currently select an arbitrary absolute image-extension path visible to the host TUI process, and the chat-lifetime fingerprint set can suppress legitimate retries or rerenders after a component detaches. the useful direction remains capability-gated pi-tui image rendering with a text fallback. a future implementation should consume a trusted structured media reference, keep dedupe ownership reversible, and include real capable-terminal plus unsupported-terminal proof. any future implementation that reuses code or nontrivial design from this PR should credit @ademczuk and link this PR. |
Summary
image_generate), the TUI shows[image/png 800kb]text placeholders. Users can't see images without switching to another app.image_generatetool landed recently (3a456678ee,21c2ba480a) but there's no rendering surface for it in the TUI.Imagecomponent. All file I/O happens once insetResult()and is cached -refresh()does zero I/O.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
3a456678eefeat(image-generation): add image_generate tool21c2ba480aImage generation: native provider migration (Image generation: native provider migration and explicit capabilities #49551)User-visible / Behavior Changes
On terminals with Kitty or iTerm2 graphics support (Kitty, WezTerm, iTerm2): tool results containing
MEDIA:image paths now render the image inline inside the tool result box.MEDIA:path text is stripped when the image renders visually.On all other terminals (VS Code, Windows Terminal, Apple Terminal): no change. Existing
[image/png 800kb]text placeholders are preserved.Security Impact (required)
lstatSyncsymlink rejection, image extension whitelist, 6MB size bound with TOCTOU guard,path.normalizebefore all checks.Repro + Verification
Environment
image_generateconfigured (Google, OpenAI, fal, xAI)agents.defaults.imageGenerationModelset (or auto-inferred since0aff1c7630)Steps
image_generatetool to completeExpected
MEDIA:path text is not visible (replaced by the visual image)Actual
[image/png]text placeholder shown, no visual renderingEvidence
63 tests pass across 5 test files (24 inline-image security/capability tests + 14 tool-execution lifecycle tests + 25 existing TUI component tests).
pnpm checkpasses all 15 linters.Human Verification (required)
image_generateon upstream/main, ranpnpm check(all pass), ranvitest run src/tui/components/(63/63 pass), verifiedcanRenderInlineImages()detects WezTerm Kitty protocol support...traversal normalization,setPartialResultaftersetResult(stale cache clearing), doublesetResult(replacement).Review Conversations
No bot comments received yet (draft PR).
Compatibility / Migration
Failure Recovery (if this breaks)
src/tui/components/tool-execution.ts. ThecanRenderInlineImages()gate means non-image terminals are never affected.src/tui/components/tool-execution.ts(restore to upstream version). Deletesrc/tui/components/inline-image.tsand test files.Risks and Mitigations
getCapabilities()falsely detects image support on a terminal that doesn't actually render Kitty/iTerm2 protocol, producing garbled escape sequences.Imagecomponent already has a text fallback path. Any detection bug would affect all pi-tui image users, not just this feature.