Skip to content

fix(native-chat): paste images in structured Codex chat - #17498

Merged
brennanb2025 merged 1 commit into
mainfrom
brennanb2025/native-chat-paste-image
Aug 31, 2026
Merged

brennanb2025 merged 1 commit into
mainfrom
brennanb2025/native-chat-paste-image

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • route app-menu Cmd/Ctrl+V through the structured native-chat composer
  • enable clipboard image attachments in the Codex app-server chat surface
  • add regression coverage for the app-menu paste bridge

Verification

  • pnpm test src/renderer/src/components/native-chat/NativeChatStructuredSession.test.tsx src/renderer/src/components/native-chat/use-native-chat-composer-paste.test.tsx (18 passing)
  • pnpm tc
  • pnpm run check:code-quality:changed
  • Real Electron + Playwright CDP: pasted an OS clipboard PNG via Cmd+V into a fresh Codex native chat, observed the Pasted image chip, sent the turn, and received Codex confirmation that it received the image.

Visual proof

Before paste:
native-chat-before.png

After paste:
native-chat-after.png

@greptile-apps

greptile-apps Bot commented Aug 30, 2026

Copy link
Copy Markdown

Greptile Summary

The PR connects structured native-chat sessions to the existing paste bridge so app-menu paste can reach the composer and adds regression coverage for that routing.

  • Adds root and composer refs to NativeChatStructuredSession.
  • Registers the existing native-chat paste bridge for structured sessions.
  • Tests that an app-menu paste event invokes the structured composer's clipboard paste handler.

Confidence Score: 5/5

The PR appears safe to merge with no concrete blocking or independently actionable non-blocking issue identified.

The structured chat surface delegates paste handling to the existing bridge, whose focus ownership and unavailable-composer behavior prevent hidden sessions or prompt states from incorrectly claiming app-menu paste.

Important Files Changed

Filename Overview
src/renderer/src/components/native-chat/NativeChatStructuredSession.tsx Wires the structured composer into the existing focus-aware paste bridge without an accepted correctness or security issue.
src/renderer/src/components/native-chat/NativeChatStructuredSession.test.tsx Extends the composer mock with its imperative paste API and verifies app-menu paste routing.

Reviews (1): Last reviewed commit: "fix(native-chat): route app menu image p..." | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 61f5ba74-f54e-4139-a900-433004e6bfd4

📥 Commits

Reviewing files that changed from the base of the PR and between b8d5b04 and 7db9181.

📒 Files selected for processing (2)
  • src/renderer/src/components/native-chat/NativeChatStructuredSession.test.tsx
  • src/renderer/src/components/native-chat/NativeChatStructuredSession.tsx

Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

Native chat now connects the chat root and composer handle to useNativeChatPasteBridge. The composer mock forwards refs and exposes paste-related methods. Tests reset the new mocks and verify that an orca-app-menu-paste event invokes pasteFromClipboard.

Merge Risk: ⚪ Minimal · up to 7db91

This change enables image paste in the structured chat composer through the existing clipboard and attachment flow, with no actionable merge-blocking risk remaining after normal checks and review.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description explains the main changes, includes verification details, and provides visual proof. However, it does not follow the required template and omits the required Linked Issue, ELI5, Why, A… Update the description to use the repository template. Add an issue reference after Fixes #, an ELI5 explanation, the reason for the approach, testing checklist status, AI disclosure if applicable, review notes, cross-platform and compati…
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly describes the primary change: adding image paste support to the structured native Codex chat.
Full details: Description check

Explanation

The description explains the main changes, includes verification details, and provides visual proof. However, it does not follow the required template and omits the required Linked Issue, ELI5, Why, AI Disclosure, Review, Notes, and Checklist sections.

Resolution

Update the description to use the repository template. Add an issue reference after Fixes #, an ELI5 explanation, the reason for the approach, testing checklist status, AI disclosure if applicable, review notes, cross-platform and compatibility considerations, and the remaining checklist items.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

@pullfrog pullfrog Bot left a comment

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.

ℹ️ No critical issues — one minor parity suggestion inline.

Reviewed changes

  • Paste bridge wiring — NativeChatStructuredSession now calls useNativeChatPasteBridge with a root and composer ref, routing app-menu paste into the structured composer's pasteFromClipboard (image attachment path) and pane-level DOM paste into handlePasteEvent.
  • Regression coverage — the test mocks NativeChatComposer as a forwardRef exposing the imperative handle and asserts the app-menu paste event reaches pasteFromClipboard exactly once.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

)
const rootRef = useRef<HTMLDivElement>(null)
const composerRef = useRef<NativeChatComposerHandle>(null)
useNativeChatPasteBridge({ rootRef, composerRef })

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.

useNativeChatPasteBridge is called without questionAnswerInputRef, so while the question card owns the input region (composer unmounted), app-menu paste only reaches the free-text answer when that input happens to be focused. NativeChatResolvedView wires the same ref through NativeChatQuestionCard.answerInputRef for exactly this case; doing the same here keeps paste working while the card is shown.

Technical details
# Wire the question card answer input into the paste bridge

## Affected sites
- src/renderer/src/components/native-chat/NativeChatStructuredSession.tsx:51 — `useNativeChatPasteBridge({ rootRef, composerRef })` omits the optional `questionAnswerInputRef`.
- src/renderer/src/components/native-chat/NativeChatStructuredSession.tsx:162-193 — `NativeChatQuestionCard` is rendered without `answerInputRef`.

## Required outcome
- Add a `useRef<HTMLInputElement>(null)` and pass it as both the bridge's `questionAnswerInputRef` and `NativeChatQuestionCard`'s `answerInputRef`, matching `NativeChatResolvedView` (use-native-chat-paste-bridge.ts:10-12 documents this as the paste target while the card owns the input region).

## Suggested approach (optional)
- Text-only is expected here; the bridge already routes the answer input through `pasteTextIntoTextControl` with no image attachment.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron validation evidence (real app-server flow):

  • Cmd+V in a fresh Codex native-chat composer created a visible Pasted image attachment.
  • Sent turn rendered as [Image #1] Please confirm you received the pasted image and describe what you can see.
  • Codex replied: “I received the pasted image. It appears to be a 1×1-pixel image consisting entirely of black.”
  • The backing Codex session event recorded the user item as local_image with the generated /var/folders/.../orca-paste-....png path.

Visual proof:
Before: https://github.com/user-attachments/assets/cf3f9a42-a06d-4aa5-ac53-14e6212e2d44
After: https://github.com/user-attachments/assets/65f85257-c085-49fc-8486-bc54dd86f418

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status: PASS — no proven P0/P1/P2 issues found, and no in-scope code changes were needed.

Checks completed:

  • Focused native-chat/app-menu paste tests: 18 passed
  • pnpm tc passed
  • Changed-code quality gate: 0 findings
  • git diff --check clean
  • Final readiness checklist rerun clean across reliability, security, performance, functional correctness, compatibility, remoting, and organization

The bridge wiring follows the existing pane-scoped paste ownership pattern and preserves text/image async handling without introducing new polling, persistence, subprocess, or mobile-facing behavior.

Electron validation was attempted through an orchestrated Grok worker. The exact PR worktree launched with an isolated profile; identity and Dock label matched killifish @ brennanb2025/native-chat-paste-image. However, CDP on port 9335 accepted TCP connections while /json, /json/list, and /json/version returned zero bytes until timeout, so Playwright could not attach. The structured Codex chat app-menu paste flow was therefore not exercised and no screenshots could be captured or attached. Validation processes were cleaned up afterward.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Follow-up: I retried the orchestrated Grok Electron validation with a fresh dispatch. That retry terminal exited back to a shell before producing a second worker report, so it did not add new evidence. The PR now contains independent successful real-Electron evidence and before/after screenshots: Cmd+V created a visible Pasted image chip in a fresh Codex native-chat composer, the turn was sent, and Codex confirmed receipt of the 1×1 image. The existing visual proof remains attached in the PR description and prior validation comment.

@brennanb2025
brennanb2025 merged commit b2eec59 into main Aug 31, 2026
30 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
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