fix: dedupe codex app-server reconciled assistant text - #427
Merged
Conversation
dimavedenyapin
force-pushed
the
fix/codex-appserver-assistant-reprint
branch
2 times, most recently
from
July 22, 2026 03:26
33fc828 to
bdbf1dc
Compare
dimavedenyapin
force-pushed
the
fix/codex-appserver-assistant-reprint
branch
from
July 22, 2026 04:54
bdbf1dc to
a843b1d
Compare
dimavedenyapin
added a commit
that referenced
this pull request
Jul 27, 2026
…nflicts) Brings the transcript stack up to date with main (10 commits: PostHog analytics #424/#425/#426, codex fixes #423/#427, releases) and resolves the conflicts for the #421 → main merge. Key resolutions: - agent-manager.ts resumeAdapterSession / replayMissedTranscriptPartsBeforeIdle: keep our event-sourced model (resume never replays history to the renderer; clients render the durable projection) AND keep main's #427 assistantTextKeys codex reconciled-text dedup. In the idle-replay path both dedup layers now run — main's assistantTextKeys AND our projection-content dedup — which are complementary against the codex agent-msg_/agent-item id-scheme mismatch. - Renderer + mobile agent-store: took our projection-cache rewrite and re-applied main's PostHog telemetry (agent_session_status_changed, agent_output_batch_received, agent_approval_requested, agent_created/updated/deleted, agent_session_stopped). - use-agent-session.ts: kept the "Starting…"/pendingSend send flow AND main's agent_message_sent analytics in both send branches. - agent-manager.test.ts: kept BOTH codex-dedup regression tests (projection-content and assistantTextKeys) as separate cases, since both mechanisms now exist. Verified: typecheck clean, build ✓, full suite 1579 passing. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
reasoning-<itemId>id andREASONINGtype as live reasoning deltas.turn/completedreconciliation re-lists content already shown live, the adapter suppresses it instead of appending previous messages after the final UI message.Root cause
PR #419 made thread item reconciliation idempotent for id-less thread items by giving those items stable synthetic keys. That covered reconcile-vs-reconcile re-buffering of the same thread item across idle transitions.
The remaining regression is a different class: live-stream-vs-reconcile identity mismatch. During a turn, app-server streams content live. When
turn/completedfires,reconcileCompletedTurn()re-lists the whole thread and can surface the same logical content through a different item shape/id/type. The frontend dedupes by part id/update semantics, so different part ids/types get appended.Two concrete paths are covered:
item/agentMessage/deltaemitsagent-<streamId>, then reconcile can return the same assistant text asagent-<persistedId>. The text guard missed this because live deltas did not register their text by turn.item/reasoning/textDeltaemitsreasoning-<id>asREASONING, then reconcile previously fell throughconvertThreadItem()to the generic tool branch and emittedtool-<id>asTOOL.Evidence
does not reprint assistant text when reconcile returns a different completed item iddoes not reprint reasoning as a tool when completed turn reconcile lists itmarkAssistantTextForTurn(...); the test failed by emitting duplicateagent-reconciled-assistant-1with the already-rendered assistant text.tool-reasoning-1as a completed tool.ready_for_reviewand reproduced the same two root-cause paths.Test plan
source ~/.nvm/nvm.sh && nvm use 22.22.0 >/dev/null && pnpm exec cross-env ELECTRON_RUN_AS_NODE=1 electron ./node_modules/vitest/vitest.mjs run --project main src/main/adapters/codex-app-server-adapter.test.ts -t "does not reprint"source ~/.nvm/nvm.sh && nvm use 22.22.0 >/dev/null && pnpm exec cross-env ELECTRON_RUN_AS_NODE=1 electron ./node_modules/vitest/vitest.mjs run --project main src/main/adapters/codex-app-server-adapter.test.tssource ~/.nvm/nvm.sh && nvm use 22.22.0 >/dev/null && pnpm test:main -- src/main/adapters/codex-app-server-adapter.test.ts(script selected full main project: 51 files, 918 tests passed)source ~/.nvm/nvm.sh && nvm use 22.22.0 >/dev/null && pnpm typechecksource ~/.nvm/nvm.sh && nvm use 22.22.0 >/dev/null && pnpm lint(0 errors, existing warnings only)