fix(coding-agent): keep saved draft and archived sessions out of the agents view - #1919
Closed
artgas1 wants to merge 1 commit into
Closed
fix(coding-agent): keep saved draft and archived sessions out of the agents view#1919artgas1 wants to merge 1 commit into
artgas1 wants to merge 1 commit into
Conversation
…agents view A message-less session file is a draft. The daemon classifies its resident row as draft and the agents view drops it, but the saved-session catalog row for the same file is never classified, so it renders as an inactive "(no messages)" row. That row cannot be removed. The daemon still holds the draft, so delete_saved_session refuses with "Cannot delete the currently active session", the view reports "Session became active; stop it before deleting", and the session cannot be stopped because its own row is hidden. Every abandoned new session leaves one such row behind, since the startup model, thinking level, and service tier entries make hasUserContent() true and keep the file on disk. Apply the live-only rule to catalog rows that have no daemon summary, reusing inactiveLifecycleForSession so on-disk and resident classification stay in sync. Archived and crashed files are covered too, which deactivatePendingAgent already assumes when it writes the archived marker to stop a row from resurfacing.
|
Hi @artgas1, thanks for your interest in contributing! This project requires that pull request authors are vouched, and you are not in the list of vouched users. This PR will be closed automatically. See https://github.com/PrimeIntellect-ai/prime-agent/blob/main/CONTRIBUTING.md for more details. |
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.
Follow-up to discussion #1531, re-diagnosed on current main (c718bf3). Details and the live daemon evidence are in #1531 (comment).
Problem
A message-less session file is a draft.
activeLifecycleForSessionmarks the resident sessiondraftandshouldShowAgentsViewSessiondrops it, butreconcileCatalogspasses the saved-session catalog through unfiltered, so the same file returns as aninactiverow titled(no messages).That row cannot be removed:
resolveAgentsViewActiveSummaryForPathagainst the unfiltered daemon list, finds the hidden draft, and reportsSession became active; stop it before deleting.delete_saved_sessionwould refuse anyway withCannot delete the currently active session.Every abandoned new session leaves one such row: the startup
model_change,thinking_level_change, andservice_tier_changeentries makehasUserContent()true, so the empty-draft discard guard never fires and the file stays on disk.Change
Apply the live-only rule to catalog rows that have no daemon summary, reusing
inactiveLifecycleForSessionso on-disk and resident classification stay in sync. Daemon records are still enriched by their saved twin; only the saved-only row is dropped.Archived and crashed files are covered by the same rule, which
deactivatePendingAgentalready assumes when it writes the archived marker so a row does not resurface on the next scan.Validation
npx tsx ../../node_modules/vitest/dist/cli.js --run test/agents-view-state.test.ts- 67 passed, including two new tests. The row test fails without the guard (expected [ Array(4) ] to deeply equal [ 'live' ]).test/agents-view-mode.test.ts,test/agents-view-inactive-reply.test.ts,test/agents-view-missing-cwd.test.ts,test/session-view-search.test.ts,test/daemon-session-list.test.ts,test/session-manager/session-state.test.ts,test/suite/regressions/502-unified-session-view.test.ts.npm run checkclean.Out of scope
The draft files still accumulate on disk, now invisibly. A sweep for message-less drafts with no resident session, and the
hasUserContent()treatment of the startup config snapshot, are tracked separately in the discussion.Note
Filter out draft and archived sessions from agents view in
agents-view-stateshouldShowAgentsViewSavedSessionwhich delegates toinactiveLifecycleForSessionand returns true only for sessions with a "live" lifecycle (message count > 0 and not archived/crashed)reconcileUnifiedSessionsto skip creating inactiveUnifiedSessionRecordentries for saved sessions that are drafts (no messages) or archived/crashed; those sessions still merge into a matching daemon-backed record if identities aligninactiveLifecycleForSessionparameter type fromSessionInfotoPick<SessionInfo, "state" | "messageCount">to allow calls with partial shapesMacroscope summarized 57a8f8c.