Clean up terminal state when threads are archived#1702
Conversation
- close thread terminals after successful archive commands - ignore archived threads in terminal retention and event cleanup - add coverage for archive and unarchive lifecycle handling
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
ApprovabilityVerdict: Approved Extends existing terminal cleanup logic to handle archived threads, following the same pattern already used for deleted threads. Changes are self-contained with graceful error handling and comprehensive test coverage. You can customize Macroscope's approvability policy. Learn more. |
Summary
thread.archivedispatch on the server.thread.archivedandthread.unarchivedso terminal cleanup follows the latest thread state within a batch.Testing
Note
Medium Risk
Adds new side effects to the orchestration
dispatchCommandWebSocket path and changes client-side terminal retention rules; mistakes could close active terminals or drop terminal events for threads unexpectedly. Scope is limited to archive/unarchive handling and is covered by new unit tests.Overview
Ensures terminal resources are cleaned up when threads are archived.
On the server,
ORCHESTRATION_WS_METHODS.dispatchCommandnow closes the thread’s terminals after a successfulthread.archivedispatch (with failures only logged), and a new test asserts the close call occurs.On the web client, terminal state retention now treats
archivedAtthreads as inactive (including draft-linked state), orchestration batch effects now remove terminal state onthread.archivedbut not if a laterthread.unarchivedappears in the same batch, and terminal events for archived threads are ignored; tests were updated/added for these cases.Written by Cursor Bugbot for commit c6d000d. This will update automatically on new commits. Configure here.
Note
Clean up terminal state when threads are archived
thread.archivecommand is dispatched via the WebSocket RPC, the server now callsterminalManager.closefor that thread after a successful dispatch; failures are logged as warnings and do not affect the RPC result.collectActiveTerminalThreadIdsnow excludes archived threads from the active terminal set, and draft-linked terminal state is no longer retained for archived or deleted server threads.deriveOrchestrationBatchEffectsaddsthread.archivedandthread.unarchivedhandling: archived threads are added toremoveTerminalStateThreadIds, and a subsequentthread.unarchivedin the same batch cancels that cleanup.Macroscope summarized c6d000d.