Skip to content

[codex] fix AgentGUI cold-start conversation rail race#1267

Open
chovy-ai wants to merge 3 commits into
mainfrom
codex/agent-gui-stable-rail-scope
Open

[codex] fix AgentGUI cold-start conversation rail race#1267
chovy-ai wants to merge 3 commits into
mainfrom
codex/agent-gui-stable-rail-scope

Conversation

@chovy-ai

@chovy-ai chovy-ai commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix AgentGUI project conversation history appearing empty after a cold desktop startup until the user switches Agent filters.

User impact

The conversation database and daemon response were intact, but the initial AgentGUI rail could show only the active project conversation and an empty second project. Switching Agent filters caused a full section request and made the missing history appear, which made the startup race look like data loss.

Root cause

Two startup state flows were allowed to compete:

  1. The controller started the full listSessionSections request that establishes the rail topology (workspace, team-shell, and conversations).
  2. While that request was pending, runtime session hydration changed membership records and triggered a targeted page refresh.

The targeted refresh reused the controller's paging sequence. It invalidated the still-pending full response, then applied only its changed page (in the reproduced case, conversations) to a controller whose full section topology had not been established. Project section templates remained visible, but their canonical memberships were absent, so the UI showed the active overlay in one project and no history in the other.

Switching Agent filters created a new scope and issued another full section request, which is why the history appeared after interaction.

The branch also removes implicit Agent-target fallback behavior and keeps the All scope keyed only by values actually sent in the backend request. Asynchronously hydrated userProjects therefore cannot create a second equivalent query scope.

Fix

  • Defer runtime membership page refreshes while the full first-page request is pending.
  • Merge affected page IDs and the pending search-refresh flag while deferred.
  • Release the merged targeted refresh only after a successful full response has established a non-empty section topology.
  • Never let a failed full request fall back to constructing the rail from partial targeted pages.
  • Keep full section requests and targeted page updates as separate phases with explicit ordering.
  • Keep All rail query identity stable across asynchronous project hydration.
  • Document the startup ordering and scope invariants.

Regression coverage

The new controller test reproduces the race by:

  • holding the full section response unresolved;
  • hydrating a runtime session that requests a targeted conversations refresh;
  • verifying the targeted refresh does not run while the full response is pending;
  • resolving the full response with a project and conversations section;
  • verifying the targeted refresh runs afterward without removing the project topology.

Validation

  • Agent GUI test suite: 187 files passed, 1698 tests passed.
  • Focused controller regression suite: 10 tests passed.
  • Agent GUI typecheck passed.
  • Changed TypeScript files passed oxlint.
  • Agent GUI degradation/file-size guard passed.
  • Pre-push pnpm check:full: 18 tasks passed, including TypeScript tests, Go tests, and lint checks.
  • Production-data dev launch: DEV_GUI_TUTTI_ENV=production make dev-gui.
  • Repeated cold-start verification after confirming the investigation Electron, daemon, and electron-vite process count was zero.
  • On cold startup, without HMR or switching Agent filters, both workspace and team-shell histories were immediately visible.

@chovy-ai chovy-ai changed the title [codex] fix AgentGUI conversation rail scope stability [codex] fix AgentGUI cold-start conversation rail race Jul 16, 2026
@chovy-ai
chovy-ai marked this pull request as ready for review July 17, 2026 03:10

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

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