fix(orchestrator): open most recently active session, not newest-created#3041
Open
AllBeingsFuture wants to merge 1 commit into
Open
Conversation
When multiple live orchestrators overlap, ranking by createdAt sent Open Orchestrator / ensure-reuse to a brand-new empty session while conversation history still lived on an older still-active orchestrator. Prefer agent activity (then updatedAt, createdAt, id) so casual open reuses the session the user was actually using. clean=true relaunch and single-orchestrator ensure paths are unchanged.
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.
Problem
Clicking Orchestrator (sidebar / topbar / board / command palette) sometimes opened an empty conversation as if history had been wiped. History was still on another live orchestrator session; the UI/daemon had attached to a different, newer empty one.
Root cause
When more than one non-terminated orchestrator existed for a project (overlap during replacement, accidental duplicates, etc.), both the frontend picker (
newestActiveOrchestrator) and the daemon ensure path (SpawnOrchestratorclean=false →newestSession) ranked by createdAt first.That preferred a brand-new empty spawn over an older still-active orchestrator that held the real conversation — matching the “wrong session / empty history on open” report and the recency intent of #1362 (most recently used/active, not lex-smallest or newest-created).
Fix
Rank live orchestrators by:
activity.lastActivityAt(most recently used)updatedAtcreatedAtApplied in both:
frontend/.../workspace.ts(newestActiveOrchestrator— all open entry points already use this)backend/.../service/session/service.go(sessionNewer— ensure/reuse when clean=false)What was deliberately not changed
SpawnOrchestrator(clean=false)with one active orchestratorSpawnOrchestrator(clean=true)/ restart / settings / restore-dialogTests
cd frontend && npm test -- --run src/renderer/types/workspace.test.ts— prefers recently-active over newer empty spawncd backend && go test ./internal/service/session/ -count=1— ensure returns most recently active among duplicates; existing clean=false/true tests still passResidual risks / follow-ups
Closes nothing automatically; addresses the open-path half of the “click Orchestrator clears history” report and improves #1362 targeting.