Skip to content

COD-166 feat(attachments): surface Codex generated-artifact files as attachment cards#150

Merged
Ark0N merged 3 commits into
Ark0N:masterfrom
aakhter:cod-166-codex-generated-artifact-attachments
Jul 12, 2026
Merged

COD-166 feat(attachments): surface Codex generated-artifact files as attachment cards#150
Ark0N merged 3 commits into
Ark0N:masterfrom
aakhter:cod-166-codex-generated-artifact-attachments

Conversation

@aakhter

@aakhter aakhter commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Parses Codex Saved to: file://... terminal output alongside existing codeman://attach?... magic links, registering matching images/documents as attachment cards in real time
  • Adds parseTerminalAttachmentRequests() in attachment-magic.ts — wraps the existing magic-link parser and adds a new parseCodexGeneratedArtifactRequests() scanner; old parseAttachmentMagicLinks() is preserved as a thin alias returning paths only
  • Introduces src/generated-artifact-attachments.ts (net-new): registerGeneratedArtifactAttachment() routes Codex-sourced files through a relaxed path policy — workspace-confined by default, but bypassed for known Codex generated-image directories (~/.codex/generated_images/, ~/.codex-personal/generated_images/, and the generated_artifacts/ variants)
  • Expands SUPPORTED_ATTACHMENT_EXTENSIONS to include jpg/jpeg/gif/webp (Codex primarily generates PNGs and JPEGs)
  • Threads source: 'external' | 'codex-generated' through the attachmentRequested event → session-listener-wiringregisterAttachment so the server can apply per-source trust policies

Files changed

File Change
src/attachment-magic.ts Adds parseTerminalAttachmentRequests, TerminalAttachmentRequest, parseCodexGeneratedArtifactRequests; refactors internals
src/attachment-registry.ts Expands image extension support (jpg/jpeg/gif/webp)
src/generated-artifact-attachments.ts Net-new — Codex artifact registration with workspace-confinement bypass
src/session.ts Uses parseTerminalAttachmentRequests; emits source in attachmentRequested event
src/web/server.ts registerAttachment accepts source param; routes to registerGeneratedArtifactAttachment for codex-generated
src/web/session-listener-wiring.ts Adds source to attachmentRequested and registerAttachment interfaces
test/attachment-magic.test.ts Coverage for new scanner and parseTerminalAttachmentRequests
test/generated-artifact-attachments.test.ts Net-newisAllowedGeneratedArtifactPath table tests

Verification

tsc --noEmit: 0 errors
test/attachment-magic.test.ts: 8/8 passed
test/generated-artifact-attachments.test.ts: 1/1 passed
npm run build: clean
prettier: clean

Downstream source: COD-152.

johoja12 and others added 3 commits July 10, 2026 20:54
…rk0N#150)

- Pass the attachment request `source` through the server deps lambda and make
  it a required param on SessionListenerDeps.registerAttachment + the wiring
  event type (the 2-arg lambda silently dropped `source`, force-confining every
  codex-generated artifact — the feature never worked outside the workspace);
  new test/session-listener-wiring.test.ts asserts the pass-through
- Gate the Codex `Saved to: file://` scanner on mode === 'codex' via a
  codexArtifacts option threaded from the session call site; magic links stay
  mode-agnostic; tests assert claude/shell sessions never emit codex-generated
  requests
- Decide the generated-artifact trust policy on the realpath-RESOLVED path
  (unresolvable → force-confined) and anchor the ~/.codex marker dirs to
  os.homedir() prefixes with startsWith instead of substring matching; symlink
  escape + unanchored-marker regression tests added
- Run the Codex scanner on stripAnsi'd data so trailing SGR sequences don't
  ride into the captured URL; styled 'Saved to:' test added
- Extend generateFirstPageThumbnail with jpg/jpeg/gif/webp passthrough and
  per-extension content types (mirrors the png passthrough) so the PR's new
  image formats render real thumbnails instead of 204 letter-tiles

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Ark0N Ark0N merged commit b20c007 into Ark0N:master Jul 12, 2026
2 checks passed
@Ark0N

Ark0N commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Merged — thank you @aakhter! Codex artifact cards round out the attachment pipeline nicely. Review caught one silent killer — the server-side deps lambda dropped the source argument, so every codex artifact got force-confined and the feature never actually fired (it's now a required param end-to-end) — plus codex-mode gating for the scanner, realpath-first trust decisions with homedir-anchored markers, ANSI-stripped scanning, and jpg/gif/webp thumbnail passthrough. 🙏

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.

4 participants