Repository navigation
Hold new sends while bb restarts into an update (updateWhenIdle) - #7003
Merged
Merged
Conversation
ymichael
force-pushed
the
update-when-idle-hold-sends
branch
from
November 4, 2026 18:54
1620753 to
b42b181
Compare
With the updateWhenIdle experiment on, the server arms a send hold when it decides to restart into an update: at the launcher's ready decision, or once the desktop download finishes. Until bb stops, every dispatch attempt, including Send now and retries, queues its message as an `app-update` wait instead of starting a turn the restart would cut. The flag lives in app_settings, so the next boot clears it and re-attempts the held rows before the daemons reconnect; a reconnect that cuts a running thread queues its resume first and the held rows follow it in order. A deferred, cancelled or failed update releases them at once. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
force-pushed
the
update-when-idle-hold-sends
branch
from
November 4, 2026 19:01
b42b181 to
63316ff
Compare
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, bb restarts once no thread is running, but nothing stopped a new send from starting a turn in the gap between that decision and the process exiting. The launcher's restart decision (app-update.ts) counts running threads once and answersrestart. The launcher then waits 1.5 s and shuts bb down, and the desktop path waits 1.5 s and installs. A message sent in that window starts a turn, and the restart cuts it straight away. The same applies to Update now. This is one of the follow-ups to #6203 and #6955 in #6127.What changed
Behind
updateWhenIdle(on for early adopters):Send hold.
apps/server/src/services/system/app-update-send-hold.tsarms a hold flag inapp_settings(appUpdateSendHold). The launcher service arms it indecideRestartbefore it counts running threads. The desktop service arms it once the download finishes, also before counting. The flag is in the database, so a crash or restart can't leave it set in a later process.Dispatch checkpoint.
dispatch-attempt.tsqueues every dispatch attempt as a newapp-updatewait while the flag is set. That covers sends, Send now, retries, new threads' first messages and child notices. The turn doesn't start.Release. The flag clears in these cases:
deferorcancel.restartrequest, or returns to idle afterwards.Clearing the flag sends a new
app-update-releasedqueue wake. Likehost-connected, it re-attempts each held row in order, and the normal checkpoint routes it.Ordering. At boot the release runs before the startup sweep and before daemons reconnect. A held row on a thread the restart cut waits as
thread-busyorhost-offline. On reconnect, Resume threads a restart cut off (resumeThreadsAfterRestart experiment) #6955 queues the resume at the front, and the held rows go out after the resumed turn, in order.Wording.
bb thread queue list: "sending after bb restarts to update".Domain:
app-updateadded toqueuedMessageWaitingOnSchema.Docs:
docs/configuration.md(updateWhenIdle) andbb guide machines.No daemon wire change, so
HOST_DAEMON_PROTOCOL_VERSIONstays the same. No plugin SDK surface file changed.What users see differently: with the experiment on, a message sent in the second or two between "Restarting" and bb going down no longer starts a turn that gets cut. It shows in the queue as "Sending after bb restarts to update", and goes out once bb is back, after the thread's resume. If the update doesn't happen, it goes out at once.
How you verified
Tests (
apps/server):test/threads/restart-resume.test.ts→ "holding sends while bb restarts to update" (real server harness):The first and third fail with the checkpoint disabled (checked).
test/system/app-update.test.ts: the launcher service holds before it counts threads. It keeps the hold throughrestart, and releases it when the launcher returns to idle, oncancel, ondefer, and when therestartrequest is rejected.test/system/desktop-app-update.test.ts: hold on install; hold then release on a refuse failure or a defer.pnpm exec turbo run lint typecheckfor server, app, cli, db, domain, templates and integration-tests passes. Targeted tests forapp-update,desktop-app-update,restart-resume,public-system-app-updateand the app'squeued-message-waitpass.Live: a real source-mode install (
pnpm startfrom a clone of a local bare origin), with marker commits pushed to the origin and real Codex agent threads. A script polled/system/app-updateand posted/threads/:id/sendas soon as the activity readrestarting.{"delivery":"queued","waitingOn":{"kind":"app-update"}}and the log showed "Holding new sends until bb restarts to update". bb came back on marker 1 about 10 s later, and the thread answered the held message.--yes) with a thread running a 100 s shell loop andresumeThreadsAfterRestarton: sends to the running thread and an idle thread were both held. After the restart:Refs #6127
🤖 Generated with Claude Code