Skip to content

Say running threads resume when Update now restarts bb (resumeThreadsAfterRestart) - #7007

Merged
ymichael merged 1 commit into
mainfrom
update-now-resume-wording
Nov 4, 2026
Merged

ymichael merged 1 commit into
mainfrom
update-now-resume-wording

Conversation

@ymichael

@ymichael ymichael commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

With resumeThreadsAfterRestart on (#6955), an update restart already resumes the threads it cuts. The source, npm and desktop updates stop the server and its local daemon, the daemon comes back as a new instance, and handleHostSessionOpened queues a "bb restarted" resume for each cut turn. Nothing was missing in that path. But the confirmation still said "N threads are running. Updating restarts bb and interrupts them." in three places: the Update now dialog (runningThreadsWarning), the CLI prompt and non-interactive error in bb updates app apply, and the server's threads_running error (runningThreadsError). So users were warned about losing work that bb now resumes. Follow-up to #6203 and #6955 in #6127.

What changed

  • runningThreadsError(count, threadsResume) (server), runningThreadsWarning(count, threadsResume) (app) and the CLI warning take whether restarts resume threads. With the experiment on they read "N threads are running. Updating restarts bb, and they resume after the update." (singular: "1 thread is running. Updating restarts bb, and it resumes after the update.").
  • The launcher and desktop update services get a threadsResumeAfterRestart callback, which reads the experiment, for the threads_running message. Settings → Updates reads it from the system config's experiments. The CLI reads it from system.config, which it already fetched for updateWhenIdle.
  • Without a terminal, the CLI hint now ends "or --yes to update now" instead of "or --yes to interrupt them" when threads resume. The --yes help is now "Update without asking about running threads".
  • Docs: docs/configuration.md (resumeThreadsAfterRestart) and bb guide machines.
  • With the experiment off, every message is unchanged. No API shape, daemon wire or plugin SDK change.

What users see differently: with "Resume interrupted threads after a restart" on, the Update now dialog, bb updates app apply and the API's 409 say running threads resume after the update instead of being interrupted. And they do resume (verified live below).

How you verified

Tests:

  • apps/server/test/system/app-update.test.ts: the threads_running message is checked with the experiment off ("interrupts them") and on ("it resumes after the update").
  • apps/app/.../app-update-presentation.test.ts: both wordings, singular and plural. UpdatesSettingsSection.test.tsx: with the experiment on, the Update now dialog shows the resume wording.
  • apps/cli/src/__tests__/command-output/updates.test.ts: non-interactive apply with two running threads and the experiment on prints the resume wording and the "--yes to update now" hint.
  • pnpm exec turbo run lint typecheck for server, app, cli, templates and integration-tests passes, and so do the targeted test files above.

Live: a real source-mode install (pnpm start from a clone of a local bare origin), with a marker commit pushed to the origin. A real Codex agent thread was running a 100 s foreground shell loop. Both experiments were on.

  • bb updates app apply without a terminal printed: Error: 1 thread is running. Updating restarts bb, and it resumes after the update. Re-run with --when-idle to update once they finish, or --yes to update now.

  • POST /system/app-update/apply returned: {"code":"threads_running","message":"1 thread is running. Updating restarts bb, and it resumes after the update.","details":{"runningThreadCount":1}}

  • With the experiment turned off, the CLI went back to "...interrupts it. ... or --yes to interrupt them."

  • In Settings → Updates, Update when idle ▾ → Update now opened "Update bb now? 1 thread is running. Updating restarts bb, and it resumes after the update."

    I clicked Update and restart. bb came back on the marker commit about 10 s later. The thread showed "Thread interrupted because bb restarted / bb will resume the thread shortly", resumed ("I'll check the running command and wait for it to finish."), and finished with A-FINISHED.

Refs #6127

🤖 Generated with Claude Code

AGENT GENERATED

With resumeThreadsAfterRestart on, a restart for an update resumes the
threads it cuts, the same as any other restart. The Update now dialog, the
CLI prompt and the server's threads_running error now say "Updating restarts
bb, and they resume after the update" instead of "interrupts them", and the
non-interactive CLI hint offers --yes to update now. The update services read
the experiment through a threadsResumeAfterRestart callback.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit 0d83bee into main Nov 4, 2026
51 checks passed
@ymichael
ymichael deleted the update-now-resume-wording branch November 4, 2026 18:52
ymichael added a commit that referenced this pull request Nov 4, 2026
…sh (updateWhenIdle) (#7011)

## Human comments

## What was wrong

With `updateWhenIdle` on (#6203), bb could only wait for threads before
updating when someone asked it to, by clicking Update when idle in
Settings or running `bb updates app apply --when-idle`. Nothing checked
for updates on its own, so a bb nobody watched never updated. This PR's
first version ran that check for everyone who had the experiment on.
That quietly changed the deal with those users from "bb updates when I
say so" to "bb updates itself", without anyone opting in. This rework
makes automatic updating a setting each user turns on. It is the "check
and update automatically" part of #6127.

## What changed

**Settings → Updates**
- **New switch: "Restart and update bb automatically"**, described as
"Checks every hour and restarts bb into a new version once no threads
are running." It is off by default and only shown while `updateWhenIdle`
is on. When the desktop app talks to a separate server, the label is
"Restart and update the server automatically". The name leads with
"Restart" because the packaged desktop app already installs downloaded
updates when you quit; what this switch adds is bb restarting itself,
without waiting for you.
- **The "Update when idle" split button is gone.** The Server row has a
plain **Update** button. When threads are running it asks first, using
#7007's wording about running threads resuming.
- **Waiting update.** The row reads "Updates when all threads are idle
(N running)". Its button is **Update now**, with **Skip this version**
in the menu.
- **Skipped version.** The row reads "Skipped until a newer version",
and **Update** still installs that version by hand.
- **Row order.** The Desktop row (shown when the desktop app has its own
update to relaunch into) now sits above Server, so the switch is
directly under the row it controls.

**Server** (`app-update-schedule.ts`)
- **Saved setting.** The switch is stored as the new `autoAppUpdate` app
setting.
- **Automatic check.** While the setting and the experiment are both on,
the server checks right away, 30 s after boot, and every hour. Hourly
matches the existing hour-long caches for the npm and source checks and
the desktop app's hourly check. bb waits for threads to finish anyway,
so checking more often would barely change when an update installs. It
uses `forceRefresh` (a `git fetch` in source mode, the npm registry, or
the desktop updater) and schedules what it finds through the existing
when-idle path.
- **Turning it off** stops the checks and drops a waiting update.
- **Versions the check leaves alone:**
  - one the user skipped (the `skippedAppUpdate` app setting);
- one whose last update attempt failed, read from the persisted
`lastResult`.

  Both last until a newer version appears.

**API, SDK and CLI**
- **Status fields.** The status gains `autoUpdate` and
`availableSkipped`.
- **New route.** `POST /system/app-update/auto { enabled }`, exposed in
the SDK as `system.experimental_setAppUpdateAuto`. Like the schedule
routes, it returns 403 while the experiment is off and refuses machine
credentials.
- **New CLI command.** `bb updates app auto [on|off]`.
- **`cancel`** now says it skips the version.
- **`apply --when-idle` stays** as a one-off wait that doesn't touch the
setting, so an agent can update bb from its own thread.

**Other**
- Docs updated: `docs/configuration.md`, `docs/api_to_audit.md`, the
`machines` and `customization` guides, the bb-cli command index, and the
Settings → Experiments description.
- The plugin SDK is bumped to 0.6.123 because its bundle includes the
status schema.
- No daemon wire change.

**What users see differently:** with the experiment on, nothing updates
by itself until you turn on "Restart and update bb automatically" (or
run `bb updates app auto on`). Once it's on, bb checks every hour and
installs new versions when threads finish. Skip this version holds a
version back until a newer one comes out.

## How you verified

Tests:
- **`apps/server/test/system/app-update.test.ts`, "checking for bb
updates automatically"** (real launcher service, fake timers):
- the 30 s and hourly checks (the real `AUTO_UPDATE_CHECK_MS`) schedule
an update and apply it after threads settle;
  - nothing is checked while the experiment is off;
- nothing is checked while the setting is off; turning it on checks at
once; turning it off drops the waiting update and nothing installs;
  - a failed version is skipped until a newer one appears;
  - a skipped version is skipped until a newer one appears.
- **`public-system-app-update.test.ts`:** the auto route returns 403
while the experiment is off, the setting persists into later status
reads, and machine credentials are refused.
- **`UpdatesSettingsSection.test.tsx`:**
  - a single Update button while threads run;
  - the switch appears only with the experiment on;
  - turning it on calls the SDK and shows the waiting row;
- Skip this version shows "Skipped until a newer version · 2 threads
running" and keeps Update;
  - Update now on a waiting update asks first;
- the Desktop row sits above Server, with "Restart and update the server
automatically".
- **CLI `updates.test.ts`:** `auto on`, `auto off` and `auto` output.

`pnpm exec turbo run typecheck lint` passes for server, app, cli, sdk,
db, server-contract, templates and integration-tests, and the targeted
tests pass.

Live: a real source-mode install (`pnpm start` from a clone of a local
bare origin), with marker commits pushed to that origin and a real Codex
thread running a 20-minute loop.

1. **Off means off.** I ran `bb updates app auto off` right after boot.
With marker 13 available and the thread running, nothing was scheduled
40 s later (past the 30 s check).
2. **On installs once idle.**
- `bb updates app auto on` scheduled marker 13 immediately. `bb updates
app` printed "bb will update to 628e88a37c when all threads are idle (1
running)" and "…or bb updates app cancel to skip this version."
- I stopped the thread at 11:53:44. bb restarted at 11:53:50 and was on
marker 13 at 11:53:59.
- `bb updates app` then printed "Updated bb to source checkout
628e88a37c", and `auto` was still on after the restart.
3. **Turning it off drops a waiting update.** With marker 14 waiting for
a running thread, `auto off` cleared the schedule. Fifteen seconds after
the thread went idle, bb was still on marker 13.
4. **UI.** I took screenshots of every state from the same install:
   - switch off;
   - switch on and waiting;
   - the Skip this version menu;
   - skipped;
   - the Update dialog;
- two rows, using a stand-in for the desktop app's update info pointed
at the real server, with Desktop first and "Restart and update the
server automatically".

The earlier version of this PR also verified the check intervals,
cancel-skip and failed-skip end to end, and that logic is unchanged. The
live runs above used the 5-minute interval from before. The hourly
change only changes that constant, and the tests now run against the
real constant.

Refs #6127

🤖 Generated with [Claude Code](https://claude.com/claude-code)

> AGENT GENERATED

Co-authored-by: Claude Opus 5.5 <[email protected]>
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