Skip to content

fix(coding-agent): keep saved draft and archived sessions out of the agents view - #1919

Closed
artgas1 wants to merge 1 commit into
PrimeIntellect-ai:mainfrom
artgas1:fix/agents-view-hidden-draft-rows
Closed

fix(coding-agent): keep saved draft and archived sessions out of the agents view#1919
artgas1 wants to merge 1 commit into
PrimeIntellect-ai:mainfrom
artgas1:fix/agents-view-hidden-draft-rows

Conversation

@artgas1

@artgas1 artgas1 commented Aug 31, 2026

Copy link
Copy Markdown

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. activeLifecycleForSession marks the resident session draft and shouldShowAgentsViewSession drops it, but reconcileCatalogs passes the saved-session catalog through unfiltered, so the same file returns as an inactive row titled (no messages).

That row cannot be removed:

  • Ctrl+X twice hits resolveAgentsViewActiveSummaryForPath against the unfiltered daemon list, finds the hidden draft, and reports Session became active; stop it before deleting.
  • delete_saved_session would refuse anyway with Cannot delete the currently active session.
  • The session cannot be stopped from the UI, because its only row is the hidden one.

Every abandoned new session leaves one such row: the startup model_change, thinking_level_change, and service_tier_change entries make hasUserContent() 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 inactiveLifecycleForSession so 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 deactivatePendingAgent already 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' ]).
  • Also green: 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 check clean.

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-state

  • Adds shouldShowAgentsViewSavedSession which delegates to inactiveLifecycleForSession and returns true only for sessions with a "live" lifecycle (message count > 0 and not archived/crashed)
  • Updates reconcileUnifiedSessions to skip creating inactive UnifiedSessionRecord entries for saved sessions that are drafts (no messages) or archived/crashed; those sessions still merge into a matching daemon-backed record if identities align
  • Narrows inactiveLifecycleForSession parameter type from SessionInfo to Pick<SessionInfo, "state" | "messageCount"> to allow calls with partial shapes
  • Behavioral Change: saved-only draft and archived sessions no longer appear as standalone rows in the agents view, fixing rows that could not be deleted via Ctrl+X

Macroscope summarized 57a8f8c.

…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.
@github-actions

Copy link
Copy Markdown

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.

@github-actions github-actions Bot closed this Aug 31, 2026
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