Skip to content

feat(threads): release thread resources when archived - #882

Merged
nixuuu merged 2 commits into
devfrom
fix/close-background-resources-on-archive
Nov 16, 2026
Merged

nixuuu merged 2 commits into
devfrom
fix/close-background-resources-on-archive

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Change

Archiving a thread now stops its background work and releases its harness, MCP transports, automation sessions, previews, file watches, cursors, image transfers and secret files. It also cancels schedules and CI watches and pauses active goals. Cleanup is scoped to the thread and its archived children, preserving other threads and shared services.

Unarchiving preserves conversation history and permits new messages without restarting stopped work. Durable cleanup survives offline workers and retries, blocks new work until acknowledged, and prevents retention from purging unfinished cleanup (migration 0158). A thread archived before its provider session existed creates that session only when fresh user input arrives.

Verification

  • Targeted check:tmp suites passed for gateway archive/delete/agent-close, retention and schema, Claude/Codex/Grok release, automation teardown and reopen, file/secret/image cleanup, delayed admission, offline reconnect and continued conversation after unarchive.
  • Command redelivery (4 tests), instance switching and archived-turn replay (7 tests), and Codex rewind (2 tests) passed through scoped check:tmp runs.
  • Gateway, worker and integration-test package typechecks passed. Edited-file lint, formatting and git diff --check passed.
  • bun scripts/test-shards.ts --check passed.
  • The full repository verification gate and builds are left to CI; live model-provider tests were not run.

Copy audit

Applicable items in docs/copy.md §8 pass. Cleanup errors state the condition and recovery action: “Thread resources are still closing” → “This thread is still closing. Wait a moment, then try again.” Closed-thread errors explain how to continue. Copy is static, concise and independent of colour or icons. No controls, confirmations, empty states or UI layout changed, so their layout/name-length checks do not apply.

@nixuuu
nixuuu enabled auto-merge (squash) November 16, 2026 19:29
@nixuuu
nixuuu force-pushed the fix/close-background-resources-on-archive branch from a903b36 to 90b3e24 Compare November 16, 2026 19:51
@nixuuu
nixuuu merged commit 5f166ab into dev Nov 16, 2026
15 checks passed
@nixuuu
nixuuu deleted the fix/close-background-resources-on-archive branch November 16, 2026 19:58
nixuuu added a commit that referenced this pull request Nov 21, 2026
## Changes

The Updates panel on phone, web and desktop now counts and installs
Canopy updates only. Check, Update all and Retry no longer perform
incidental work on provider CLIs. Agent CLIs keep their own check and
install controls in Settings, including on linked workers.

The gateway retires CLI steps when reading an older saved run. It
rotates the run ID when indices change so an older Retry cannot select a
different target. New clients send distinct bulk action names, which
also prevent an older gateway from starting a mixed update.

Worker reconnects used to start native session probes for every archived
thread. The observed Linux worker took over three minutes to exit after
the executable was staged and another three minutes to hand over after
reconnect. Its final process applied configuration within a second. The
worker now retains completed archive fences across connections and
shares native session inventories across a batch. It still retries
failed cleanup and closes resources belonging to the archived threads.

Fixes: #882

Related: #1079

## Verification

- 30 focused update planner, scheduler and gateway integration tests
passed. Coverage includes historical mixed runs, stale retry indices,
linked computers, explicit CLI installs and older clients.
- 16 focused worker tests passed, including compiled worker handover and
a 66-thread archived snapshot with a failed cleanup and a reconnect.
Gateway and worker typechecks and edited-file lint passed.
- Verified the panel on an isolated Android emulator. A CLI-only failure
left Canopy up to date, mixed failures counted only Canopy, and Settings
sent the explicit CLI calls. An older gateway rejected bulk update
without a fallback install request.
- Chromium at 375 and 1280 px with controlled API responses covered the
indicator, check, mixed historical results, retry and explicit local and
linked CLI actions.
- The running worker was not restarted for verification. The first
upgrade from an older build still uses that build's shutdown code. Full
repository verification runs in CI.

## Copy audit

Removed the sentence promising CLI updates after Canopy updates. The
phone and web compatibility message directs the user to update Canopy on
the gateway. CLI check errors stay with the CLI controls in Settings.
Checked the status and action labels at both browser widths and in the
Android sheet. No outstanding copy findings.
nixuuu added a commit that referenced this pull request Nov 23, 2026
## Change

Canopy restores the thread's platform state immediately, while the Codex
session log remains archived until the next cold resume. Forking before
that resume could fail with `session … is archived`.

When Codex reports that specific error, the worker restores the source
log and retries the fork once with the same turn boundary and settings.
The source stays unloaded. Rewind uses the same recovery when it forks
an earlier prefix.

Fixes: #882

## Verification

- Reproduced the archived-source error with the app-server fixture
before the fix.
- Passed 17 focused Codex adapter tests via `check:tmp`, including the
regression and the rewind, sandbox profile, and service tier suites.
- Passed worker typecheck, lint and formatting on the edited TypeScript,
and `git diff --check`.
- CI runs the full repository gate. Live provider and MacStudio checks
are pending.
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