Skip to content

Warn before archiving a thread that has uncommitted work #5952

Open

Description

@brsbl

Archiving a thread removes its worktree a few minutes later. That's expected, but if the worktree still has uncommitted or unpushed changes, the archive dialog doesn't say so, and that work is easy to lose without noticing.

When a thread's worktree has uncommitted or unpushed changes, the archive dialog should say so and offer to:

  • keep the worktree and archive just the thread, or
  • have the thread's agent commit and push first, then archive.

Threads with clean worktrees archive as they do today.

Activity

  1. added theissue type on Oct 21, 2026
  2. added
    threads
    workspaces
    confirmed-repro
    on Oct 21, 2026
  3. bb-slop-cop commented on Oct 21, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · Priority High · Effort Medium. Applied labels: threads, workspaces, confirmed-repro.
    • Report: Reproduction and root-cause analysis.
    • Verdict: REPRODUCED, high root-cause confidence. The regression test exercises the actual archive route, retirement sweep, and worktree provider; it fails on two clean origin/main checkouts. The report includes the complete test. All 58 adjacent existing tests pass.
    • Root cause: Archive schedules retirement without a dirty-worktree guard; cleanup forces Git worktree removal and recursively deletes the directory. Modified tracked files and untracked files disappear. Unpushed commits survive on the local branch in both runs.
    • No PR: A safe repair requires coordinated archive retention and teardown behavior across subsystems, outside the simple-fix gate.
  4. changed the title [-]Archiving a thread can delete uncommitted worktree changes without warning[/-] [+]Warn before archiving a thread that has uncommitted work[/+] on Oct 21, 2026
  5. added
    enhancement
    and removed
    confirmed-repro
    on Oct 21, 2026
  6. xLagerFeuer commented on Nov 16, 2026

    @xLagerFeuer

    Following up on #5952 to request maintainer guidance before preparing another implementation.

    I reviewed the existing issue and PR #5957, which implemented worktree retention and explicit archive options but was automatically closed after two weeks without being merged. I don't interpret that closure as a technical rejection of the approach.

    Questions for maintainers

    1. Is protecting uncommitted, untracked, and unpushed work during thread archival still a desired change?
    2. Should archiving preserve unsafe worktrees by default, or require an explicit choice before cleanup proceeds?
    3. Should the same safety contract apply consistently across the UI, CLI, and SDK, including descendant threads?

    The intended outcome is to avoid silently losing local work while preserving predictable cleanup of safe worktrees.

    Evidence and current status

    This is an AI-assisted investigation and design question. No new implementation or native test results are being claimed here. The proposal originates from this repository's existing issue; it is not claimed as a VSM-derived finding.

    If the direction is approved, we can prepare a focused implementation with source-native regression tests and follow the repository's contributor approval process before opening an upstream PR.

    AGENT GENERATED

  7. appzan commented on Nov 19, 2026

    @appzan

    Could the “keep the worktree and archive just the thread” action proposed here also be available through the CLI and SDK, including for clean managed worktrees?

    We want automation to archive a conversation when its task ends, while a separate cleanup policy checks for active consumers and verifies that the exact commit is on the remote before removing the checkout. On BB 0.50.1 I confirmed that bb thread archive --help has no option for this workflow. The worktree documentation at the base we tested describes archive-triggered teardown.

    A local prototype based on df9619d8e8aac4aff00c0c3ff9b8ef4e2823e4f2 exercises an opt-in bb thread archive <id> --keep-worktrees --json and the equivalent SDK call. It reports the IDs of retained environments, preserves retention during periodic sweeps and repeated archive requests, and leaves ordinary archive and explicit cleanup available. Unarchiving releases that thread's retention. The opt-in refuses a worktree already scheduled for cleanup. A separate route lets an older server reject the request without running ordinary archive. The prototype passed 209 targeted CLI, server, and database tests plus type checking.

    Would maintainers be open to this opt-in CLI and SDK behavior as part of #5952?

    AGENT GENERATED

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementthreadsworkspaces

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions