Repository navigation
Let users turn on automatic bb updates that install once threads finish (updateWhenIdle) - #7011
Merged
Merged
Conversation
ymichael
force-pushed
the
update-when-idle-auto-check
branch
from
November 4, 2026 19:54
04549c7 to
fa62ce5
Compare
ymichael
force-pushed
the
update-when-idle-auto-check
branch
3 times, most recently
from
November 4, 2026 20:28
a5723c8 to
bcd9912
Compare
Settings → Updates gains a "Restart and update bb automatically" switch (off by default, behind updateWhenIdle) and bb updates app auto on|off. While it is on, bb checks right away, 30 s after boot, and every hour, and restarts into what it finds once no thread is running. The Update when idle split button goes away: the Server row offers Update, and a waiting update offers Update now with Skip this version, which skips that version until a newer one appears. The Desktop row moves above Server so the switch sits under the row it controls, labelled "Restart and update the server automatically" when the server runs separately. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
force-pushed
the
update-when-idle-auto-check
branch
from
November 4, 2026 20:29
bcd9912 to
6b17f1b
Compare
ymichael
added a commit
that referenced
this pull request
Nov 4, 2026
#7011 brought the coalesced-notice code back to its pre-#7028 shape, so the pending lookup takes `now` again and a merge writes `sendAt` rather than `windowEndsAt`. The test for withdrawing a change after its window but before delivery depended on #7028 and is removed with it; main's plugin SDK is now 0.6.123. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
added a commit
that referenced
this pull request
Nov 4, 2026
…eue drawer (#7029) ## Human comments ## What was wrong **Ownership notices were one turn per child.** `thread-ownership.ts` debounced each child separately with an in-memory `WeakMap` + 2 s `setTimeout`, then called `queueParentSystemMessage` once per child. Unassigning N threads together sent the parent N separate notices, each its own steer or turn. In production, thr_bgwkk8ing5 got 6 within one minute on 2026-10-22. A server restart inside the 2 s window lost the notice. Child turn-end notices had the same design until #6728 moved them to one durable coalesced queue row per parent. **Queued bb notices were noisy in the queue drawer and sidebar.** - The drawer rendered their raw prompt text ("[bb system] These threads are now children…") with a "From System" label. - They offered every user-message action (edit, reschedule, drag). - They appeared for their 2 s coalescing window and then vanished. - They turned the sidebar's queued clock on even when nothing of the user's was queued. - The collapsed summary could show a notice's schedule as if it were the user's. - The drawer was capped at 198 px, so a third row sat under a fade. ## What changed **Ownership notices go through the coalesced queue** (`thread-ownership.ts`). The WeakMap/timer path is gone. Each change posts to `postCoalescedSystemNotice` with a `thread-ownership` key and a 2 s window. All changes to one parent become one durable queued row with a typed, zod-parsed `coalesceState`, listing every child assigned or unassigned. The timer's per-child behaviour is kept: - A move undone before the parent is told is withdrawn. If the row ends up empty, it is deleted (`message.cancelled` is emitted to plugins). - An `assigned` entry remembers the parent the child had before the window, so A→B→C notifies only A and C, and A→B→A notifies nobody, even with `parentNotifications` `stuck`/`off`. - Removal notices are still skipped unless `parentNotifications` is `auto`. - Once a row is delivered, the next change starts a new one. - Works with main's current coalescing. #7011 reverted #7028's "merge into rows waiting on the parent", so today a row can only be merged into or withdrawn from during its 2 s window. If #7028 is restored, ownership notices pick that up with no change here. - `postCoalescedSystemNotice`'s `merge` may return `null` to withdraw, using the new `deleteCoalescedQueuedThreadMessageInTransaction`, which only deletes a row that is still waiting to be sent. - A single change renders exactly as before. Two or more use the new `system-message-thread-ownership-batch` template and `ownership-batch` kind with a `thread-batch` subject; the timeline titles it "Ownership changed for N threads". - Deliberate change: the old timer skipped a notice if the child was archived or deleted inside the 2 s window. The row's content is fixed when it is posted, so that narrow case now still notifies. **The queue drawer shows notices usefully.** - `ThreadQueuedMessage` gains `systemNotice`. Notice rows use the timeline's own title and icon ("3 threads updated", "X assigned to you") and show only their wait reason underneath. - Notice rows offer only send-now and delete: no edit, no send-time change, no drag. The server reports them `editable: false` and the update route refuses a rewrite with 409, so the CLI and SDK follow the same rule. - Notices still collecting or being delivered (time wait or no wait) are left out of the drawer, so they no longer flicker. Held, failed and stuck notices still show. - The sidebar's queued-waiting status counts only non-notice rows; a failed notice still shows as failed. - The collapsed header adds "· N from bb" and prefers the user's own wait line over a notice's. - The drawer cap is 30% of the window height, between 198 and 360 px. A short queue still fits its content exactly. **Other** - `@get-bb/plugin-sdk` bumped to 0.6.124. The bundled types inline `SystemMessageKind` and `ThreadQueuedMessage`. - No daemon wire change, no CLI/config surface change. ## How you verified **Tests** - New `thread-ownership-notices.test.ts` replaces the timer-mock debounce test and runs against real queue rows. It covers: - Bulk unassign: one row, one delivered `ownership-batch` turn. This **fails on main** with `expected [] to have a length of 1 but got +0`. With a 2.3 s wait added on main, the same three unassigns produce 1 delivered turn plus 2 more queued notices. - The row is persisted and scheduled before the window elapses. - Same-child flip; intermediate parent never notified; withdrawing one child keeps the others. - Delivered-parent baseline. - `stuck`/`off` handling; single change keeps today's exact text. - Server: queued-work status for notice-only and mixed threads; a notice row reported `editable: false` with `systemNotice`, and a rewrite refused with 409. - App: notice-row title and actions, collapsed summary, transient-notice filter, drawer-cap math. Existing drawer tests that encoded "From System", a system second line and the 198 px cap are updated. - Targeted runs: server 99, app 452; `turbo run test` for domain, server-contract, cli and client-core. `turbo run typecheck` passes across server, app, db, cli, demo-server, plugin-sdk and test-helpers; app lint has no errors. **Live** on `pnpm start:worktree`, with Claude Haiku managers and children, driven with the source CLI: - Ownership: - Three concurrent assigns and three concurrent unassigns: one notice each. - SIGKILL inside the window: the row was on disk and was delivered after the automatic restart. - Assigning then unassigning the same child withdrew the row. - A single change kept the old wording. - Notices held by the concurrency limit (global limit 0): - The drawer shows "Ownership changed for 4 threads · Held by Concurrency limit" next to the user's own scheduled message. That's two unassigns plus two assigns sent 10 s later, merged into the held row. - Hovering a notice offers only Send now and Delete. - Collapsed: "Queue · 1 from bb" with the user's own schedule. - Same at 390 px. - A MutationObserver on an idle manager saw no queue row or card while three children reported, and the notice was delivered as one turn. - With only notices queued, the thread list API reported `queuedWork: none` and the sidebar clock went away. > AGENT GENERATED 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
ymichael
added a commit
that referenced
this pull request
Nov 4, 2026
## Human comments ## What was wrong #7011 (updateWhenIdle settings) reverted two PRs that had merged about 30 minutes before its commit was created: #7028 (merge child notices while the parent is blocked, skip `/compact` turns) and #7030 (count only the latest workflow run in GitHub PR check status). Its body mentions neither, so it looks accidental. - #7011 is a single commit, `6b17f1bc04`, whose parent is #7028's merge commit `920804af63`. Even so, the commit's own diff rewrites 11 files to their earlier content: - In #7028's 9 files it is an exact inverse of #7028, apart from four exports #7011 added to `packages/db/src/data/index.ts`. - #7030's 3 files in `plugins/github-pr-status/host/` went back to their pre-#7030 content. - That pattern fits a branch whose files came from an older checkout and were committed onto a newer base. - CI stayed green because each revert also removed the matching tests. - No other PR was affected. Every file the commit touched was compared with its earlier versions on main; only these two PRs match. What users got back after #7011: - **#7028:** a parent blocked on a question, a starting turn or an offline host collects a separate notice for every child update again (on Nov 3 one parent got ten from one child). `/compact` turns on a child send the parent "No final output was recorded." - **#7030:** bb shows green PRs as failing ("22 passed, 4 failed") when GitHub cancelled a duplicate CI run. ## What changed - Cherry-picks `b0e91c38f8` (#7030) and `920804af63` (#7028) onto current main with `-x`. #7030 applies unchanged. - #7028 conflicted only in `coalesced-system-notices.ts`, because #7029 (merged after #7011) added withdrawing a pending notice there. The result is #7028's version with #7029's withdraw path kept: the pending lookup has no `now` and a merge writes `windowEndsAt`. This is the combination #7029 was tested with before #7011 landed. `child-thread-notifications.ts` resolved to main's existing version, which already guards on a scheduled row. - Restores the #7029 test that depends on #7028: an ownership change undone after its 2 s window but before delivery is withdrawn. Its test helper comes back with it. - `internal/events.ts` and `db/data/events.ts` merged cleanly with the later #7031 and #7033 changes. - No daemon wire, CLI, config or plugin SDK surface change; `check-plugin-sdk-version` reports the surface unchanged. ## How you verified - With main's current code and the restored tests, 7 tests fail. With this branch they pass: - `thread-ownership-notices`: "withdraw a move undone after its window but before delivery" - `system-notice-dispatch`: "merge later outcomes into a row still waiting on the parent" - `child-completion-turn-output`: "does not notify the parent for a turn that only compacted context" - `github-pr-status` `git-host` / `batch`: superseded workflow runs, including on a later checks page and for drafts found through `gh pr view` - Server: ownership notices, notice dispatch, child completion output, notice kinds, child outcomes, parenting, plugin events, queue updates, sidebar status and child notifications all pass (112 tests). - `turbo run test` for the GitHub PR Status plugin, `@bb/db` and `@bb/templates` passes (10/10 tasks). `turbo run typecheck` for server, db, app and the plugin passes (10/10 tasks). > AGENT GENERATED 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
With
updateWhenIdleon (#6203), bb could only wait for threads before updating when someone asked it to, by clicking Update when idle in Settings or runningbb 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
updateWhenIdleis 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.Server (
app-update-schedule.ts)Saved setting. The switch is stored as the new
autoAppUpdateapp 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(agit fetchin 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:
skippedAppUpdateapp setting);lastResult.Both last until a newer version appears.
API, SDK and CLI
autoUpdateandavailableSkipped.POST /system/app-update/auto { enabled }, exposed in the SDK assystem.experimental_setAppUpdateAuto. Like the schedule routes, it returns 403 while the experiment is off and refuses machine credentials.bb updates app auto [on|off].cancelnow says it skips the version.apply --when-idlestays as a one-off wait that doesn't touch the setting, so an agent can update bb from its own thread.Other
docs/configuration.md,docs/api_to_audit.md, themachinesandcustomizationguides, the bb-cli command index, and the Settings → Experiments description.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):AUTO_UPDATE_CHECK_MS) schedule an update and apply it after threads settle;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:updates.test.ts:auto on,auto offandautooutput.pnpm exec turbo run typecheck lintpasses for server, app, cli, sdk, db, server-contract, templates and integration-tests, and the targeted tests pass.Live: a real source-mode install (
pnpm startfrom a clone of a local bare origin), with marker commits pushed to that origin and a real Codex thread running a 20-minute loop.Off means off. I ran
bb updates app auto offright after boot. With marker 13 available and the thread running, nothing was scheduled 40 s later (past the 30 s check).On installs once idle.
bb updates app auto onscheduled marker 13 immediately.bb updates appprinted "bb will update to 628e88a37c when all threads are idle (1 running)" and "…or bb updates app cancel to skip this version."bb updates appthen printed "Updated bb to source checkout 628e88a37c", andautowas still on after the restart.Turning it off drops a waiting update. With marker 14 waiting for a running thread,
auto offcleared the schedule. Fifteen seconds after the thread went idle, bb was still on marker 13.UI. I took screenshots of every state from the same install:
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