Skip to content

fix(native-chat): render compaction notices, plan documents, and images - #19228

Merged
brennanb2025 merged 8 commits into
mainfrom
brennanb2025/nc-notices
Sep 7, 2026
Merged

brennanb2025 merged 8 commits into
mainfrom
brennanb2025/nc-notices

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​531 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​527
Prod 16 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​347 $\color{#cf222e}{\Huge{\mathbf{−}}}$​23 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​324

What this does, in plain terms

Four kinds of thing the agent tells you that the chat was rendering badly or not at all:

  1. Context compaction. When a session gets too long the agent compacts its history. That's a significant event — it's why it might "forget" something — and it was invisible. Now it's a quiet divider.
  2. Warnings vs errors vs deprecation notices. All rendered identically as plain system text, so a serious warning looked like a routine status line. Now they're distinguishable by tone.
  3. Plan documents. When the agent writes out a plan, it was rendering in tiny muted text — smaller than ordinary body copy. A plan is a headline artifact; now it gets a readable card.
  4. Images the agent viewed or generated. Previously fell through to a raw JSON blob.

Before → After

Before After
History gets compacted Nothing shown; unexplained memory gap A quiet "context compacted" divider
A warning arrives Looks like any other status line Visually distinct by severity
Agent writes a plan Tiny grey text, smaller than the answer A readable card
Agent views/generates an image Raw JSON blob A proper image row

One subtlety: newer agent versions announce compaction differently than older ones. Both are handled, and a provider that reports it both ways still produces exactly one divider.


Technical detail

ELI5

Compaction now leaves a quiet divider, warnings show their tone, plan documents get readable cards, and viewed/generated images use the existing previews.

What Changed

  • Publish canonical compaction completion items and legacy notifications as an existing status row, and distinguish warnings, notices, and errors with optional display metadata.
  • Deduplicate compaction within each thread/turn at a stable journal key: canonical items replace a legacy fallback, both event orders render one divider, and a bounded 64-turn map suppresses repeat delivery. History restoration uses the same key.
  • Preserve plan-document identity through streaming and completion, rendering markdown at body size in a card.
  • Translate image items into existing assistant messages with operation text and image attachments; prefer saved paths and fall back to readable text for unavailable or oversized inline outputs.

Why

These events were suppressed, flattened into small status text, or displayed as raw provider frames. Optional open-string fields preserve readable text for older desktop/mobile readers and tolerate future metadata values. Reasoning, checklist updates, token usage, and rate-limit classifications remain unchanged.

Linked Issue

Coordinator-dispatched notice-row task; no issue number supplied.

Visual Proof

Pending centralized Electron validation and before/after screenshots by the coordinator, as agreed during plan review. No desktop UI was activated by this lane.

Testing

  • 2,070 tests passed across 218 suites after merging current main, covering the Codex and provider-wire areas plus focused schemas, projection, notices, message lists, and image behavior.
  • 30 renderer tests passed after correcting duplicate notice text in its diagnostic disclosure.
  • Compaction tests cover modern-only and legacy-only delivery, both event orders, history restoration, turn/thread isolation, bounded retention, and append/publish retries.
  • Changed-code quality, type-aware lint, React checks, root-directory guard, and localization catalog verification passed.
  • Compatibility tests cover unknown metadata strings and old-reader parsing followed by rendering the original text.
  • Tested on macOS; local/remote path preservation covered by automated tests. Central typechecking and rendered Electron validation remain with the coordinator.

Review

Independent same-model review returned clean after fixing repeated notice text and canonical compaction delivery. START and END readiness checklists include mobile compatibility, bounded state, shared projection, and unchanged reasoning contracts. docs/native-chat-notices-plan.md records the implementation and verification.

Agent skill upstream boundary

  • Not applicable.

Checklist

  • Focused on the requested notice rows
  • Automated tests and backward-compatibility coverage added
  • Cross-platform paths, folder workspaces, SSH execution ownership, and mobile considered
  • Central typecheck and Electron visual validation
  • Before/after screenshots attached

@coderabbitai

coderabbitai Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change adds Codex image and plan item translation, canonical compaction handling, provider notice metadata, journal schema support, and native-chat notice rendering. It also adds tests for image validation, compaction deduplication, notice classification, metadata projection, renderer behavior, and compatibility.

Merge Risk: 🟡 Moderate · up to 7598a

This change adds distinct warning rendering, but warning text can be difficult to read in light theme. Use an accessible theme-aware warning color before merge.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 23.53% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 23 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise, specific, and accurately describes the primary native-chat rendering changes.
Description check ✅ Passed The description is substantially complete and explains the changes, rationale, testing, compatibility, and review status. It identifies that no linked issue and no visual proof were supplied, and some…
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 23.53% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 23 files. (1 skipped: 1 unsupported.)

  • 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.

ℹ️ One minor dead-code cleanup inline; otherwise this is a clean, well-tested change.

Reviewed changes

  • Compaction dividers — notification:thread/compacted reclassified to timeline-substantive and journaled as a presentation: 'compaction' status row, with the duplicate item:contextCompaction left suppressed.
  • Notice tones — warnings/guardian/config notices and errors now carry an optional tone (warning/notice/error) and render tinted, with summary+details joined for config/deprecation notices.
  • Plan documents — a plan-only branch (streaming and completion) marks plans presentation: 'plan-document', rendered as a Card with markdown at body size.
  • Images — imageView/imageGeneration translate into assistant messages with operation text plus image-ref blocks, preferring saved paths and bounding inline data.
  • Wire plumbing — optional presentation/tone string fields added to the status/text schemas and types, propagated through the shared projection; old readers strip them and render the plain text (covered by tests).

The forward/backward compatibility story is solid: new fields are optional strings, never enums, and the tests exercise old-reader parsing and unknown metadata values. Image savedPath/path preservation across /- and \-style execution-host paths is covered.

The only remaining gap is the explicitly-deferred Electron visual validation and before/after screenshots (noted as coordinator-owned in the plan and PR checklist); the new NativeChatNoticeRow styling hasn't been exercised under a rendered app yet.

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

handled: true
}
}
if (item.type === 'reasoning' || item.type === 'plan') {

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.

This || item.type === 'plan' is now dead — the plan-only branch added above returns unconditionally, so a plan item never reaches this condition. Removing it also makes explicit a subtle behavior change: plan items now read only text and no longer fall back to summary/content, which the previous combined reasoning || plan branch did.

Suggested change
if (item.type === 'reasoning' || item.type === 'plan') {
if (item.type === 'reasoning') {

@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 new issues in the incremental commits. Approval is held only by one minor, previously-flagged cleanup that these commits did not touch.

Reviewed changes

  • Compaction coalescing — extracted a dedicated CodexJournalCompactions handler that journals both the legacy thread/compacted notification and the canonical item/completed (contextCompaction) form into one presentation: 'compaction' status row per thread/turn, deduplicating by a sha256 of [threadId, turnId] with a 64-entry retention bound and history-restore support.
  • Canonical item reclassification — contextCompaction moved from status-chrome to timeline-substantive in the item-disposition catalog (while item/started stays explicitly suppressed), so the item form now reaches the journal's dedup instead of being dropped.
  • Shared completion predicate — isCodexCompactionComplete now recognizes the canonical item form and is reused by the wire-level StructuredSessionCompaction receipt tracker, so a compaction signaled via item/completed still satisfies completion.
  • Notice disclosure dedup — ProviderFrameRow gained an optional summary prop so a notice's diagnostic disclosure no longer repeats the message text already shown in the row.

The dedup logic handles all delivery orders (item-then-legacy, legacy-then-item, duplicates) and the "canonical replaces legacy" case correctly relies on the journal's identity upsert, so the two events collapse to a single projected row rather than two dividers. The 59 focused tests across the changed suites pass.

The remaining item is the dead || item.type === 'plan' clause at src/main/codex/codex-structured-item-translation.ts:264: the plan branch added above it returns unconditionally, so no plan item reaches that condition, and removing it also makes explicit that plan items now read only text (no summary/content fallback). It predates this delta and is unchanged by it — a one-line cleanup whenever convenient.

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

@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 new issues in the incremental commits — this delta is a clean merge of origin/main.

Reviewed changes

  • Merge of origin/main (subagent roster) — reconciled the branch with the upstream subagent-roster feature: settleOversizedNotification and startTurn now accept typed Extract<CodexStructuredSessionEvent, …> event shapes, the roster dispose() is wired into createCodexJournalTranslator's teardown, and provider-frame disposition comments align with roster rendering.

The merge resolution is clean: the compaction handler still runs before subagent item handling, so item/completed (contextCompaction) keeps coalescing with the legacy notification, and the PR's compaction, notice-tone, plan-document, and image translation paths are otherwise untouched.

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

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Manual UI validation — native chat notices

Ran this branch's dev build in the real Orca Electron app (hidden window, ORCA_BACKGROUND_LAUNCH=1, CDP screenshots only — no window was shown or focused). The rows below are rendered by the real NativeChatMessageList / MessageRow / NativeChatNoticeRow components inside a real Codex Chat tab, fed through the real projectStructuredItemsToNativeChat projection. The journal item bodies are the exact shapes the main-process producers on this branch emit (unhandledProviderFrameJournalItem, codexJournalItem, CodexJournalCompactions), and the "before" shots use the exact shapes main emits for the same frames.

1. Compaction renders as one quiet centered divider

compaction-dark.png
Dark: a context compaction renders as a quiet centered "Context compacted" divider between turns — one divider, role="separator".

compaction-light.png
Light: the same divider, hairline and label both readable on the light canvas.

A DOM count of [role="separator"][aria-label="Context compacted"] returns 1. The "provider reports it twice" case is collapsed upstream of the renderer: the legacy thread/compacted notification and the canonical item/completed(contextCompaction) share one journal identity (codex-compaction:<sha256(threadId,turnId)>), so the second report revises the same row instead of appending a new one. codex-structured-journal-compactions.test.ts covers exactly this (two sends, one row; dedup scoped per thread and per turn) — 22 tests pass across that file and NativeChatNoticeRow.test.tsx.

2–4. Warning, deprecation notice, plan document, image row

before-dark.png
BEFORE (dark), on main: the compaction, the warning, the deprecation notice and both image items all collapse into identical monospace codex · <opcode> fallback rows; the plan is muted gray prose with no container.

after-dark.png
AFTER (dark): the warning gets an amber triangle in a bordered box, the deprecation notice gets a gray info icon in its own box (summary + details, no repeated text), the plan is a titled card at body-copy size, and the image items render a real icon.png chip and an inline preview.

before-light.png
BEFORE (light): same undifferentiated opcode rows.

after-light.png
AFTER (light): tone separation, plan card and image chip all hold up on the light canvas.

Verdict

  • Compaction divider — works, quiet and centered, exactly one row per compaction in both themes.
  • Tone separation — works. Warning (amber + AlertTriangle), deprecation notice (muted + Info) and ordinary system text ("Reading the workspace configuration.", no chrome at all) are three visibly distinct treatments. The Details disclosure still carries the raw frame.
  • Plan document — readable card, and it no longer repeats its own text in the disclosure.
  • Image row — imageView renders a icon.png chip, imageGeneration renders an inline preview, instead of codex · item:imageView / codex · item:imageGeneration.
  • No regression in the surrounding transcript: user bubbles, assistant prose, provider-frame disclosure rows and the composer are unchanged.

Two things worth a look

  1. The plan was never smaller than body copy — it was muted. Measured computed styles on both sides: the plan list text is 14px before and after; what changed is rgb(161,161,161) → rgb(250,250,250) plus the card. CommentMarkdown's own className="text-sm" was already overriding the row's text-xs. The fix is still right (the plan read as a de-emphasized aside), but if the intent was a size bump, that part isn't happening.
  2. The warning tone is not theme-aware. text-[color:var(--warning,#f59e0b)] in NativeChatNoticeRow.tsx — --warning is not defined as a token in main.css (it only ever appears with the same inline fallback), so both themes resolve to the literal #f59e0b. Measured rgb(245, 158, 11) on rgb(255,255,255) in light theme ≈ 2.16:1 contrast, under the 4.5:1 bar for body text; dark theme is fine at ~9:1. Worth either defining a real --warning token per theme or reusing an existing one.

Validated on eb94b8828c. The failing adoption-replay check is pre-existing on main and unrelated.

@brennanb2025

brennanb2025 commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor Author

Status: ready for review

Plan review

Reviewed before any code was written. APPROVE WITH AMENDMENTS, all applied. The critical one prevented a subtle wire hazard: the plan typed the new tone and presentation fields as z.enum. That would have recreated the unknown-kind row-drop one level down — a future host adding a fourth tone would make this build reject the whole row. They are now open strings narrowed in the renderer, with a test proving an unrecognized value still parses and still renders its text.

The find that mattered most

During review the reviewer discovered the compaction divider was wired to a deprecated notification the current provider no longer sends — it now emits a contextCompaction item instead. Shipping as planned would have produced a divider that passed every test and never appeared in a real session. Both delivery paths are now handled, with the item as canonical and bounded deduplication so a provider reporting both still renders exactly one divider.

Code review loop

Same-model subagent review returned clean. readiness-checklist at start and end — both PASS, including mobile compatibility, which is not a formality here: this PR adds optional fields to shared journal bodies that the mobile client consumes, and changes what the host publishes. 2070 tests pass.

Verification

  • Central typecheck: exit 0.
  • Merged with origin/main, two parents verified. The classifier table was merged entry by entry rather than taking a side, preserving both this branch's reclassification and main's new entries.
  • An auto-merge pushed a translator over max-lines; fixed by reusing existing discriminated types in the signatures, emitting identical JavaScript. No max-lines disable was added.

Manual UI validation

Real Orca dev build, hidden renderer over CDP. 6 screenshots attached above, dark and light. Compaction renders as exactly one centred divider (role=separator count is 1); warning, deprecation notice, and plain system text are three visibly distinct treatments; the plan renders as a titled readable card rather than text smaller than body copy; image items render a chip and inline preview.

Process deviations, stated plainly

  • The review loop's $orchestration arm was not used. Nested worker depth is 1 in this install, so a dispatched worker cannot dispatch its own workers (nested_worker_depth_exceeded). The UI validation lane was run directly by the coordinator at depth 0. The substance of the loop — subagent review to clean, readiness bookends, independent UI validation with visual evidence — was carried out in full.
  • readiness-checklist's severity-counsel step was unavailable for the same depth reason, and is recorded as unavailable rather than reported as a verdict.
  • Validation ran on Claude, not the originally-planned agent, which ran out of quota mid-programme.

Known-red, not caused by this PR

structured-agent-session-adoption-replay.test.ts:188 fails on a clean detached origin/main checkout — reproduced independently by two lanes, byte-identical failure. It is a pre-existing break on main and was deliberately not touched.

@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 new issues in this delta — a clean third merge of origin/main.

Reviewed changes

  • Merge of origin/main — reconciled the branch with upstream native-chat work (0b3af9ddbc message timestamps on hover/focus, d0506bf5de execution details / tool row identity, ce4a3a4186 rewind backend) plus unrelated relay/mobile-revert/browser/composer commits.
  • Clean overlapping-file resolution — the PR's optional presentation/tone fields coexist with upstream's ToolMetadata tool annotations in agent-session-journal-schemas.ts and the shared projection, and NativeChatMessageRow.tsx keeps its notice-row detection beside the new NativeChatMessageTimestamp.
  • Compaction ordering preserved — compactions.handle still runs before subagent item handling, so the canonical item/completed (contextCompaction) keeps coalescing with the legacy thread/compacted notification.

The merge is clean and the PR's compaction, notice-tone, plan-document, and image translation paths are unchanged. Approval remains held only by the pre-existing dead || item.type === 'plan' cleanup flagged in the initial review — a one-line removal whenever convenient.

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

@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@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: Team

Run ID: a7a0782c-e44f-4693-a3ab-74ca797d4d95

📥 Commits

Reviewing files that changed from the base of the PR and between d0506bf and 7598ad5.

📒 Files selected for processing (24)
  • src/main/codex/codex-image-item-translation.ts
  • src/main/codex/codex-notice-item-translation.test.ts
  • src/main/codex/codex-structured-item-translation.ts
  • src/main/codex/codex-structured-journal-compactions.test.ts
  • src/main/codex/codex-structured-journal-compactions.ts
  • src/main/codex/codex-structured-journal-items.ts
  • src/main/codex/codex-structured-journal-translation-streams.test.ts
  • src/main/codex/codex-structured-journal-translation.ts
  • src/main/native-chat/agent-session-wire/provider-frame-disposition.test.ts
  • src/main/native-chat/agent-session-wire/provider-frame-disposition.ts
  • src/main/native-chat/agent-session-wire/structured-session-compaction.ts
  • src/main/native-chat/agent-session-wire/unhandled-provider-frame.test.ts
  • src/main/native-chat/agent-session-wire/unhandled-provider-frame.ts
  • src/renderer/src/components/native-chat/NativeChatMessageRow.tsx
  • src/renderer/src/components/native-chat/NativeChatNoticeRow.test.tsx
  • src/renderer/src/components/native-chat/NativeChatNoticeRow.tsx
  • src/renderer/src/components/native-chat/NativeChatTranscriptChrome.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/shared/agent-session-journal-schemas.test.ts
  • src/shared/agent-session-journal-schemas.ts
  • src/shared/agent-session-journal-types.ts
  • src/shared/native-chat-types.ts
  • src/shared/structured-agent-session-projection.test.ts
  • src/shared/structured-agent-session-projection.ts
🚧 Files skipped from review as they are similar to previous changes (16)
  • src/shared/agent-session-journal-schemas.ts
  • src/renderer/src/i18n/locales/en.json
  • src/shared/agent-session-journal-schemas.test.ts
  • src/renderer/src/components/native-chat/NativeChatNoticeRow.tsx
  • src/main/codex/codex-notice-item-translation.test.ts
  • src/shared/native-chat-types.ts
  • src/main/native-chat/agent-session-wire/unhandled-provider-frame.test.ts
  • src/main/native-chat/agent-session-wire/provider-frame-disposition.ts
  • src/shared/structured-agent-session-projection.ts
  • src/main/native-chat/agent-session-wire/provider-frame-disposition.test.ts
  • src/main/codex/codex-structured-journal-translation-streams.test.ts
  • src/renderer/src/components/native-chat/NativeChatMessageRow.tsx
  • src/main/codex/codex-structured-item-translation.ts
  • src/shared/structured-agent-session-projection.test.ts
  • src/shared/agent-session-journal-types.ts
  • src/main/native-chat/agent-session-wire/unhandled-provider-frame.ts

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

).toHaveLength(2)
})
it.each([
['warning', 'text-[color:var(--warning,#f59e0b)]'],

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Use an accessible light-theme warning color.

Line 32 requires #f59e0b for warning text. This color has about 2.15:1 contrast against a white background. It makes warning text difficult to read in light theme. Use a theme-aware warning token with sufficient contrast, then update this expectation.

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