Skip to content

feat(ai): render generate_image tool calls inline, no accordion - #2019

Merged
2witstudios merged 2 commits into
masterfrom
pu/image-gen-view
Jul 12, 2026
Merged

feat(ai): render generate_image tool calls inline, no accordion#2019
2witstudios merged 2 commits into
masterfrom
pu/image-gen-view

Conversation

@2witstudios

Copy link
Copy Markdown
Owner

Summary

  • generate_image tool calls now bypass the generic accordion shell entirely (same dispatch path as task/agent/question tools) and always render inline — a loading placeholder while generating, an inline error row on failure, or the finished image.
  • Clicking the finished image navigates to where it's saved in the user's Home drive (usePageNavigation), replacing the previous click-to-open-lightbox behavior.
  • image-generation-tools.ts now returns driveId in the tool result (already computed by createImageFilePage, previously dropped) so the click can navigate without an extra lookup.

Test plan

  • bunx tsc --noEmit clean in apps/web
  • bunx eslint clean on all changed files
  • vitest run — 118 tests pass in src/components/ai/shared/chat/, 24 pass in src/lib/ai/tools/__tests__/image-generation-tools.test.ts (including new driveId assertion and new dispatchToolCall image-kind test)
  • Manual smoke test in browser (admin account, generate_image is currently admin-gated): generate an image, confirm no accordion header appears, confirm click navigates to /dashboard/<homeDriveId>/<pageId>, confirm a forced failure still renders inline without a raw JSON dump

🤖 Generated with Claude Code

https://claude.ai/code/session_01RoFf2J7TjkpBRif7rwHhdR

generate_image tool calls now bypass the generic accordion shell
entirely (same dispatch path as task/agent/question tools) and
always render the image inline — loading placeholder, inline error
row, or the finished image. Clicking the image navigates to where
it's saved in the user's Home drive instead of opening a lightbox.

- tool-call-dispatch.ts gains an 'image' dispatch kind for
  generate_image, handled before the generic renderer/registry.
- registry.tsx moves generate_image from toolRenderers into
  SPECIAL_HANDLED_TOOLS, which also makes it a standalone tool call
  (never folded into a batched ToolRunGroup).
- GeneratedImageRenderer now owns all three tool-call states and
  navigates via usePageNavigation(pageId, driveId) on click.
- image-generation-tools.ts returns driveId (already computed, was
  previously dropped) so the click can navigate without a lookup.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RoFf2J7TjkpBRif7rwHhdR
@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@2witstudios, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 34 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d6838399-fe51-417b-9299-4ae32fcfda36

📥 Commits

Reviewing files that changed from the base of the PR and between 7b0d4d1 and ee5c6eb.

📒 Files selected for processing (9)
  • apps/web/src/components/ai/shared/chat/tool-calls/CompactToolCallRenderer.tsx
  • apps/web/src/components/ai/shared/chat/tool-calls/GeneratedImageRenderer.tsx
  • apps/web/src/components/ai/shared/chat/tool-calls/ToolCallRenderer.tsx
  • apps/web/src/components/ai/shared/chat/tool-calls/__tests__/GeneratedImageRenderer.test.tsx
  • apps/web/src/components/ai/shared/chat/tool-calls/__tests__/tool-call-dispatch.test.ts
  • apps/web/src/components/ai/shared/chat/tool-calls/registry.tsx
  • apps/web/src/components/ai/shared/chat/tool-calls/tool-call-dispatch.ts
  • apps/web/src/lib/ai/tools/__tests__/image-generation-tools.test.ts
  • apps/web/src/lib/ai/tools/image-generation-tools.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pu/image-gen-view

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.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dc8c5da8f8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +56 to +57
const failed = state === 'output-error' || parsedOutput?.success === false || loadError;
const isLoading = !failed && !parsedOutput?.viewUrl;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Treat error-only image outputs as failures

In contexts where generate_image is invoked through execute_tool (for example Global Assistant/search-mode), wrapper failures such as invalid parameters return an output object containing error without success: false. Because failed ignores parsedOutput.error and isLoading only checks for a missing viewUrl, those completed failed calls render the loading spinner forever instead of the error message already handled below.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Confirmed and fixed in ee5c6eb. Traced the exact path: execute_tool's safeParse-failure branch (execute-tool.ts) returns { error: string } with no success field at all, and dispatchToolCall resolves the effective tool name to generate_image from the input (tool_name), not the output — so GeneratedImageRenderer received that bare-error output verbatim. failed only checked success === false, and isLoading only checked for a missing viewUrl, so a completed-but-errored call spun forever instead of hitting the error row.

Fix: isLoading is now derived from whether output has arrived at all (not from viewUrl specifically), and failed now also triggers whenever output has arrived without a viewUrl (covers a bare error field or any other unexpected completed shape), in addition to the existing success === false and output-error checks.

Added regression tests in GeneratedImageRenderer.test.tsx covering: the execute_tool-shaped bare-error case, explicit success: false, the loading state, and the success/image-render state — all 4 pass. Leaving this thread open for your verification rather than auto-resolving it.

A generate_image call routed through the execute_tool wrapper (used by
search-mode/Global Assistant agents) can complete with an error-shaped
output — { error: string } — that carries no success: false field (see
execute-tool.ts's safeParse-failure and permission-denied branches).
GeneratedImageRenderer treated "no viewUrl yet" as the only loading
signal, so a completed-but-errored call spun its loading placeholder
forever instead of showing the error row.

failed now also triggers when output has arrived but has no viewUrl
(covers a bare `error` field, or any other unexpected completed shape),
and isLoading is derived from "no output yet" instead of "no viewUrl
yet". Adds regression coverage for the execute_tool-shaped error case,
the explicit success:false case, and the success/loading cases.

Addresses review feedback from PR #2019 (chatgpt-codex-connector).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RoFf2J7TjkpBRif7rwHhdR
@2witstudios
2witstudios merged commit 02bed8e into master Jul 12, 2026
3 checks passed
@2witstudios
2witstudios deleted the pu/image-gen-view branch July 12, 2026 17:47
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