Repository navigation
feat: support Codex generated image attachments - #721
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds end-to-end support for persisting Codex-generated images as assistant attachments (server contracts, provider mapping, attachment persistence, turn buffering, idempotent message writes, and web rendering) and replaces inline shell env-edit hook logic with a shared Node ESM script and tests. ChangesGenerated Image Attachment Support
Hook Infrastructure Refactoring
Sequence Diagram(s)sequenceDiagram
participant CodexProvider
participant AttachmentService
participant AgentService
participant TurnFinalizer
participant MessageRepo
participant WebClient
CodexProvider->>AttachmentService: persistGeneratedImageFromPath(savedPath)
AttachmentService-->>CodexProvider: StoredAttachment
CodexProvider->>AgentService: emit GeneratedAttachment(attachment)
AgentService->>TurnFinalizer: bufferAssistantAttachments(threadId, attachment)
TurnFinalizer->>MessageRepo: createAssistantIdempotent(..., attachments)
MessageRepo-->>TurnFinalizer: Message row with attachments
WebClient->>AgentService: receives session.message with attachments
WebClient-->>WebClient: render image thumbnail / open lightbox
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Comment |
What
Adds Codex generated image handling to chat threads. When Codex app-server emits
imageGeneration.savedPath, Mcode copies the image into attachment storage, persists it on the assistant message, and renders it with the existing thumbnail and lightbox UI.Also moves the agent
.envedit guard into a shared Node hook used by Codex, Claude, and Cursor.Why
Codex image generation uses the local Codex session and returns a saved image path through the app-server protocol. Mcode preserves that artifact through turn finalization and thread reloads.
The old inline
.envhook regex missed JSON tool input such as{"path":".env"}.Key Changes
generatedAttachmentagent event and assistant message attachment support..envhook regexes withscripts/agent/hooks/block-env-edits.mjs.Verification
bun run test:scripts: 32 passed.node scripts/agent/hooks/codex-stop.mjs:{"decision":"approve"}..envguard with Codex mode:{"decision":"block","reason":"Do not edit .env files directly. Update .env.example instead."}.bun run e2e -- e2e/generated-image-message.spec.ts: 1 passed.bun run verify: typecheck and lint passed. The full web unit suite failed insidebar-settings-button.test.tsx,sidebar-usage-panel-tokens.test.tsx,MermaidBlock.test.tsx, andPlanDocument.test.tsx. Those files passed when rerun narrowly, except the first pairedPlanDocument.test.tsxrun timed out once before passing alone.Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Summary by CodeRabbit
New Features
Tests
Chores