Skip to content

Test: Automatic cleanup settings for merged agent sessions #335536

Description

Refs: #334341, #334334, #334352, #335374

Complexity: 4

Authors: Megan Rogge (@meganrogge)


This test covers the Preview settings that opt agent sessions with merged pull requests into automatic archival and later permanent deletion. Note this requires testing for over a day.

For this lifecycle, a session is inactive when it is not currently in progress and its provider-reported last-modified time is at least the configured number of days old. The separate deletion grace period starts when the lifecycle automatically archives the session, not at the session's last-modified time.

Setup

  • Use Insiders with an Agent Host harness and the Agents Window enabled.
  • Use disposable sessions and repositories. Permanent deletion cannot be undone.
  • Have:
    • an inactive session with at least one merged pull request and no open related pull requests;
    • a session with an open related pull request;
    • a manually archived session;
    • if practical, both a clean worktree that tracks an upstream and a worktree with uncommitted or outgoing changes.

Verify the settings

  • Open Settings and search for archive.
  • Verify exactly these two application-scoped Preview settings are shown:
    • chat.agentSessions.autoArchiveMergedSessionsAfterDays
    • chat.agentSessions.autoDeleteArchivedMergedSessionsAfterDays
  • Verify both default to 0, explain that zero disables the behavior, recommend 15 days, and link to each other.
  • Verify the archive setting describes inactivity before archival and safe cleanup of eligible worktrees.
  • Verify the delete setting describes a separate grace period after automatic archival, permanent deletion, and safe cleanup of retained eligible worktrees.
  • Enter positive whole-number values and verify they are accepted. Verify negative and fractional values are rejected.
  • Set both settings to 0 and reload VS Code. Verify existing sessions are neither automatically archived nor deleted.
  • Set only the archive setting to a positive value and verify permanent deletion remains disabled.
  • Set only the delete setting to a positive value and verify startup/hourly lifecycle evaluation remains enabled, but sessions that were not automatically archived are not made deletion-eligible.
  • If the Configure Automatic Cleanup or Open Settings action is available from a merged-PR session suggestion, activate it and verify Settings opens filtered to only these two settings.

Verify automatic archival

  • Set the archive threshold so an inactive merged-PR session is eligible. Reload VS Code or wait for the next lifecycle evaluation.
  • Verify the eligible session is archived through the normal Archive/Mark as Done lifecycle.
  • Verify sessions are not archived when they are active, external, have any open related pull request, or have no merged pull request.
  • Verify a clean tracked worktree with no outgoing or uncommitted changes is safely removed during archival.
  • Verify a worktree is retained when it has outgoing commits, uncommitted changes, no branch, no upstream, or unknown Git state.
  • Restore/unarchive the automatically archived session and verify its checkout can be recreated and it is no longer eligible for automatic deletion based on the previous archive.

Verify automatic deletion

  • Configure both settings so an automatically archived merged-PR session is eligible for deletion after the separate post-archive grace period. Reload VS Code or wait for the next lifecycle evaluation.
  • Verify only automatically archived sessions are permanently deleted.
  • Verify manually archived sessions are retained.
  • Verify reopening a related pull request before archival or deletion blocks the operation.
  • If an eligible retained worktree is still present, verify deletion applies the same safe cleanup checks and does not force-remove a dirty or otherwise unsafe worktree.

Verify the opt-in notification

  • With both settings at 0, use an eligible merged-PR session that has been inactive for at least 15 days.
  • Verify the one-time notification offers Turn On Session Cleanup and Open Settings.
  • Choose Open Settings and verify only the two automatic cleanup settings are shown.
  • Choose Turn On Session Cleanup and verify both settings are set to 15.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions