fix: unify session state and lifecycle presentation#2980
Draft
whoisasx wants to merge 13 commits into
Draft
Conversation
…ion-state # Conflicts: # backend/internal/adapters/agent/codex/codex.go # backend/internal/daemon/daemon.go # backend/internal/daemon/lifecycle_wiring.go # backend/internal/sessionguard/guard.go
62 tasks
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
This PR makes AO's session state model consistent from backend facts through every frontend surface.
Closes #2950
Covers the narrower reproduction in #2944.
Supersedes the overlapping implementations in #2924, #2840, and #2841.
Root cause
AO already persisted the necessary facts independently:
The inconsistencies came from two places:
exitedactivity signal into termination.Codex added a third gap: its hooks expose turn boundaries but no reliable session-end event, so the agent process could exit while tmux stayed alive and AO continued showing the last activity state.
Final state precedence
mergedterminatedworkingexitedneeds_inputmergedidlestatusremains derived at service read time and is never persisted. Existing stacked/multi-PR worst-wins aggregation andno_signalbehavior remain intact.Backend changes
Lifecycle and state derivation
exitedas a real derived session status.activity=exited, isTerminated=falsefor an exited agent inside a still-live terminal runtime.Codex process-exit detection
Merged-session policy
terminateOnPrMergesession policy and API endpoints.PR activity timing
stateChangedAtfor normalized PR lifecycle state.Integration with current main
main's new0025:0026_pr_state_changed_at.sql0027_add_session_terminate_on_pr_merge.sql0028_add_session_runtime_launch_id.sqlFrontend changes
One presentation model
session-presentation.ts.session.status.session.activitythrough the same helper.Board and Archive
Idle / Workinglane.Ready to merge / Mergedlane with distinct ready and completed colors.Session lifecycle controls
Activity, colors, and workspace UX
Cleanup
Related PRs
Those PRs can be closed after this consolidated PR is accepted to avoid reviewing and merging overlapping implementations independently.
Validation
cd backend && go test -p 1 ./...- all backend packages passed.cd frontend && npm run typecheck- passed.cd frontend && npm test -- --run --maxWorkers=1- 73 files, 886 tests passed.git diff --check- passed.Screenshots
Visual evidence will be attached in a follow-up PR comment.