Skip to content

Fix paginated Codex metadata and native-chat RPC image bounds - #13573

Merged
nwparker merged 1 commit into
mainfrom
nwparker/fix-codex-paginated-metadata
Aug 10, 2026
Merged

Fix paginated Codex metadata and native-chat RPC image bounds#13573
nwparker merged 1 commit into
mainfrom
nwparker/fix-codex-paginated-metadata

Conversation

@nwparker

@nwparker nwparker commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Why this follow-up is needed

#13393 restored native-chat history across the three Codex transcript formats, but the readiness review found two related consumers outside that decoder:

  1. Paginated session metadata was still derived from the wrong records. Codex paginated logs contain canonical completed items plus response_item message copies used for model context. The AI Vault session scanner is separate from the native-chat transcript reader and still consumed those copies. That could double-count messages and use model-only prompt text for the tab title, preview, or last-user-prompt metadata.
  2. Restored inline images could exceed RPC transport limits. Transcript image blocks can contain full data: URLs. The local Electron IPC path can render those bytes directly, but native-chat RPC also publishes the same blocks to mobile, web/runtime, SSH, and relay clients. One inline image could therefore turn a small history response into a multi-megabyte RPC frame.

This PR closes those gaps so #13393 can be cherry-picked without leaving incorrect metadata or an unbounded remote payload path.

What changed

  • record the Codex history_mode while scanning session metadata
  • for paginated sessions, derive titles, previews, message counts, and the last user prompt only from canonical item_completed records
  • ignore paginated response_item message copies while preserving unwrapped-response and wrapped-event legacy formats
  • sanitize image references at the native-chat RPC boundary for every RPC client kind
  • omit inline data: bodies, including URL-parser whitespace/control-prefixed forms
  • cap image path, URL, and alt metadata at 512 characters while preserving ordinary external references

User impact

  • paginated Codex sessions show the real user prompt in tab titles and previews
  • session message counts no longer include duplicate model-context copies
  • mobile, web/runtime, SSH, and relay history reads stay within bounded RPC payloads
  • external image references continue to work; omitted inline references remain valid fieldless image placeholders

Compatibility

This is an additive hardening follow-up with no persisted-schema, route, RPC field, stream opcode, dependency, or protocol-version change. Existing image-ref fields are optional, and older clients already tolerate a fieldless image placeholder. Legacy Codex transcript modes retain their prior behavior.

Cherry-pick order

This PR is one commit intended to follow merged PR #13393:

git cherry-pick 1d3decdbc47c395c645e8b80f9e5436d55a2ebc9
git cherry-pick 47128dfa168fd9db7186568fe5bef2bfa091477f

If #13393 is already present, only cherry-pick 47128dfa168fd9db7186568fe5bef2bfa091477f.

Validation

  • affected desktop suites: 583 passed
  • mobile native-chat consumer suites: 33 passed
  • final image-sanitizer regression suite: 26 passed
  • root and mobile typechecks passed
  • full lint, reliability gates, formatting, max-lines ratchet, and git diff --check passed
  • PR CI: 43 checks passed, including Node 24/26 shards, cross-version wire compatibility, macOS packaging, Windows packaging, static analysis, and final verify
  • CodeRabbit verified the whitespace-prefixed data: regression and resolved the review thread

Readiness review

  • no new network destination, dependency, binary, install hook, shell execution, or secret handling
  • no platform-specific path or shell behavior
  • no local-only assumption; sanitization occurs at the shared RPC publishing boundary
  • metadata parsing remains linear, and image metadata inspection is bounded before scheme detection
  • no visual layout or styling change

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Codex parsing now uses dedicated consumers for response, completed-item, and legacy-event formats. Paginated histories record history_mode, ignore ordinary response_item messages, and process completed items. Native chat RPC responses now sanitize image references for all clients. Sanitization removes data URLs and oversized metadata while preserving safe URLs and alternative text. Mobile-specific truncation remains unchanged. Tests cover paginated Codex sessions and image sanitization across client kinds.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 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 summarizes both primary changes: paginated Codex metadata fixes and native-chat RPC image bounds.
Description check ✅ Passed The description explains the changes, user impact, compatibility, testing, security review, platform risks, and lack of visual changes.
✨ 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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d1470b06-755e-409e-be52-971524c5be04

📥 Commits

Reviewing files that changed from the base of the PR and between a63df91 and d3e5792.

📒 Files selected for processing (6)
  • src/main/ai-vault/session-scanner-codex-message-records.ts
  • src/main/ai-vault/session-scanner-codex-parser.test.ts
  • src/main/ai-vault/session-scanner-codex-parser.ts
  • src/main/runtime/rpc/methods/native-chat-rpc-image-block.ts
  • src/main/runtime/rpc/methods/native-chat.test.ts
  • src/main/runtime/rpc/methods/native-chat.ts

Comment thread src/main/runtime/rpc/methods/native-chat-rpc-image-block.ts Outdated
@nwparker
nwparker force-pushed the nwparker/fix-codex-paginated-metadata branch from d3e5792 to e834179 Compare August 10, 2026 09:51
@nwparker
nwparker force-pushed the nwparker/fix-codex-paginated-metadata branch from e834179 to 47128df Compare August 10, 2026 09:51
@nwparker

Copy link
Copy Markdown
Contributor Author

Built-app proof

Validated exact head 47128dfa.

  • pnpm run build:unpack completed, the packaged macOS app passed strict deep code-signature verification, and the app stayed healthy in an isolated smoke launch.
  • The recorded proof launches the real built Electron app, discovers a seeded paginated Codex session through AI Vault, then pairs a real web/runtime client and reads that same session over the native-chat RPC boundary.
  • Paginated metadata: the source includes a model-context-only response_item copy, but the UI shows the canonical prompt, exactly 2 msgs, and the canonical assistant response. The model-only copy is absent.
  • Bounded remote history: a 251,001-byte transcript containing a 250 KB direct data: image, a whitespace-prefixed data: image, and an external image URL becomes a 773-byte RPC payload (99.69% smaller). Both inline bodies become fieldless image placeholders; https://example.com/reference.png is preserved.
  • The recorded scenario passed 3/3 consecutive runs with one worker. The temporary proof harness and assets are not part of the PR diff.

Paginated session shown correctly in the built app

Representative passing run:

page@3925c940fc4637d830bfb9ea742540f6.webm

@nwparker
nwparker merged commit 6206945 into main Aug 10, 2026
44 checks passed
zpyoung pushed a commit to zpyoung/orca that referenced this pull request Aug 11, 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