You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(agent-status): preserve Codex turn state across compaction - #31947
After Codex compacts a conversation, a task that already finished can start spinning again in Orca. A task still running can also lose the information Orca needs to recognize its eventual finish. This change leaves the current task alone when Codex reports compaction, so completed tasks stay Done and running tasks can finish normally.
What Changed
Ignore Codex SessionStart events whose source is compact, before the provider event adapter can reset a session or relabel an ended turn.
Preserve the lead turn ID, transcript cursor, subagent roster, prompt, and pending human question. Other startup/resume events retain their existing behavior.
Add deterministic regressions for finished turns with and without a compact hook turn ID, the next real prompt, a live turn completing from its transcript after compaction, and a pending question.
Extend the existing review-completion integration test to assert that compaction preserves Done, both locally and through the relay.
Why
Compaction is not a new user turn or a new Codex process. Processing it as startup can reopen a completed task and discard the turn ID used by the completion fallback from #28860. Ignoring that exact event preserves the existing facts without adding polling, timeouts, stored flags, or a protocol change. Closed#22753 described the same compact-event guard, but current main still lacks it.
Open PRs were checked before starting a separate contribution:
The same synthetic UserPromptSubmit → Stop → SessionStart(source=compact) sequence was sent through the real authenticated hook endpoint in isolated hidden Electron instances, using Playwright. Every test window was asserted hidden. These captures show the normal host listener → IPC → store → sidebar path; no real Codex model request was made and no user session was modified.
Before: compact reopens a finished task
After: the completed task stays Done
Testing
I manually tested these changes locally. Validation used automated hidden Electron replay rather than a live interactive Codex run.
Automated tests added/updated.
On macOS arm64, based on main ea60ec5d7c:
The four new shared-listener regressions fail with the compact guard removed and pass with it present.
Five focused test files: 65 tests passed, including the real local/relay HTTP completion flow.
Hidden Electron before/after replay: one passing run against unmodified main and one passing run against the fix, asserting the expected rendered Working/Done states and hidden-window policy.
pnpm lint passed; pnpm tc passed all four projects; final pnpm tc:node and changed-code quality gate passed.
Full pnpm test --maxWorkers=2 --bail=1 stopped at an unrelated /var versus /private/var assertion in src/main/runtime/orca-runtime-tests/repository-project-operations.spec.ts:190. The same individual test fails with the production compact guard removed, against the unchanged main implementation.
Full pnpm build completed the desktop and web bundles and built-skill verification, then failed in mobile-web compilation because this checkout lacks mobile dependencies including react-native-web and expo-router. Both before/after Electron E2E bundles built successfully.
Physical Linux/Windows and a real SSH host were not exercised. The relay integration test exercises the shared execution-host normalization and forwarding path.
AI Disclosure
OpenAI Codex (GPT-6) assisted with investigation, implementation, regression coverage, hidden Electron evidence, and self-review.
Review
Self-review covered cross-platform behavior, local/SSH/remote normalization, other agent integrations, performance, UI behavior, and security. The provider-specific guard uses existing source parsing, performs no I/O or process work, and changes no schema, IPC channel, credentials, or dependencies. Other providers and real Codex startup/resume events are unchanged. Mobile and mixed-version clients continue receiving the existing host-owned status vocabulary. No Git assumptions are introduced, so folder workspaces follow the same path.
Agent skill upstream boundary
Not applicable; this change copies no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
This prevents future compaction events from corrupting status; it does not migrate already-corrupted in-memory rows. Wrong-project attribution is tracked by the existing PRs cited above and is outside this fix.
I explained what changed and why, including the user-facing before/after and mechanism.
Before/after screenshots attached for the behavior change.
Self-reviewed for correctness, security, and performance.
Cross-platform, SSH/remote, folder-workspace, and mobile impact considered.
Full pnpm lint, pnpm typecheck, pnpm test, and pnpm build are all green. Lint and typechecks passed; full-test and mobile-build limitations are documented above for CI/reviewer follow-up.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
Compact Codex SessionStart hooks now return no event before turn ID or transcript-end checks. New listener tests cover completed turns, live turns, and pending human questions. Review-turn tests cover compaction with and without the relay, including delayed hooks from ended turns.
Priority: ➖ Normal
Severity of issue fixed: Medium
Merge Risk:⚪ Minimal · up to 63ee6
The change is mergeable after normal checks; no actionable defect was established.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 3 files.
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Title check
The title clearly and concisely describes the main change: preserving Codex turn state during compaction.
Description check
The description follows the repository template and explains the user impact, implementation, rationale, linked issue, visual evidence, tests, limitations, AI usage, review scope, and checklist status…
Linked Issues check
The PR satisfies the active coding requirements in #31944. codexHookEventForEndedTurn drops Codex SessionStart events when source is compact, before ended-turn processing. The added tests veri…
Out of Scope Changes check
The changed production code is limited to the Codex compact-event guard. The new and updated tests directly cover the behavior required by #31944, including local and relay paths. No unrelated feature…
Full details: Description check
Explanation
The description follows the repository template and explains the user impact, implementation, rationale, linked issue, visual evidence, tests, limitations, AI usage, review scope, and checklist status. Known full-test and mobile-build failures are documented with their reported causes.
Full details: Linked Issues check
Explanation
The PR satisfies the active coding requirements in #31944. codexHookEventForEndedTurn drops Codex SessionStart events when source is compact, before ended-turn processing. The added tests verify that a finished turn remains Done, a live turn retains its turn and subagent state and settles from transcript completion, and a pending human question remains waiting. The tests also verify that a later prompt still starts normally and that local and relay completion paths preserve Done. The PR does not change unrelated startup/resume behavior or add a status protocol. Closed #22753 is historical context only.
Full details: Out of Scope Changes check
Explanation
The changed production code is limited to the Codex compact-event guard. The new and updated tests directly cover the behavior required by #31944, including local and relay paths. No unrelated feature, provider, protocol, dependency, or attribution change is present in the reviewed diff.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
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
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.
ELI5
After Codex compacts a conversation, a task that already finished can start spinning again in Orca. A task still running can also lose the information Orca needs to recognize its eventual finish. This change leaves the current task alone when Codex reports compaction, so completed tasks stay Done and running tasks can finish normally.
What Changed
SessionStartevents whosesourceiscompact, before the provider event adapter can reset a session or relabel an ended turn.Why
Compaction is not a new user turn or a new Codex process. Processing it as startup can reopen a completed task and discard the turn ID used by the completion fallback from #28860. Ignoring that exact event preserves the existing facts without adding polling, timeouts, stored flags, or a protocol change. Closed #22753 described the same compact-event guard, but current main still lacks it.
Open PRs were checked before starting a separate contribution:
Linked Issue
Fixes #31944.
Visual Proof
The same synthetic
UserPromptSubmit→Stop→SessionStart(source=compact)sequence was sent through the real authenticated hook endpoint in isolated hidden Electron instances, using Playwright. Every test window was asserted hidden. These captures show the normal host listener → IPC → store → sidebar path; no real Codex model request was made and no user session was modified.Testing
On macOS arm64, based on main
ea60ec5d7c:pnpm lintpassed;pnpm tcpassed all four projects; finalpnpm tc:nodeand changed-code quality gate passed.pnpm test --maxWorkers=2 --bail=1stopped at an unrelated/varversus/private/varassertion insrc/main/runtime/orca-runtime-tests/repository-project-operations.spec.ts:190. The same individual test fails with the production compact guard removed, against the unchanged main implementation.pnpm buildcompleted the desktop and web bundles and built-skill verification, then failed in mobile-web compilation because this checkout lacks mobile dependencies includingreact-native-webandexpo-router. Both before/after Electron E2E bundles built successfully.Physical Linux/Windows and a real SSH host were not exercised. The relay integration test exercises the shared execution-host normalization and forwarding path.
AI Disclosure
OpenAI Codex (GPT-6) assisted with investigation, implementation, regression coverage, hidden Electron evidence, and self-review.
Review
Self-review covered cross-platform behavior, local/SSH/remote normalization, other agent integrations, performance, UI behavior, and security. The provider-specific guard uses existing source parsing, performs no I/O or process work, and changes no schema, IPC channel, credentials, or dependencies. Other providers and real Codex startup/resume events are unchanged. Mobile and mixed-version clients continue receiving the existing host-owned status vocabulary. No Git assumptions are introduced, so folder workspaces follow the same path.
Agent skill upstream boundary
Notes
This prevents future compaction events from corrupting status; it does not migrate already-corrupted in-memory rows. Wrong-project attribution is tracked by the existing PRs cited above and is outside this fix.
Author
GitHub: @tigerlaibao. X/Twitter: not provided.
Checklist
pnpm lint,pnpm typecheck,pnpm test, andpnpm buildare all green. Lint and typechecks passed; full-test and mobile-build limitations are documented above for CI/reviewer follow-up.