Skip to content

Count source updates from the running commit, not the checkout HEAD - #6513

Merged
ymichael merged 1 commit into
mainfrom
bb/check-update-frequency-thr_33ezzpsh5y
Oct 29, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/check-update-frequency-thr_33ezzpsh5y

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

When a pnpm start source checkout is pulled (git pull) while bb keeps running, there are three commits in play: the commit bb is running, the checkout HEAD, and origin/main. The source update check counted and listed incoming commits from the checkout HEAD, while Settings shows the running commit on the left. So a server running f8c0701 with a checkout pulled to 055e758 showed f8c0701 → 0950d00 (+2 commits) when it was 32 commits behind. A checkout pulled all the way to origin/main reported "up to date" while bb still ran old code.

Applying the update in that state also went wrong. The source shim only fast-forwarded when HEAD still equalled the running commit recorded in the pending update. A pulled HEAD failed that check, so the shim skipped the fast-forward, install and rebuild, relaunched on the pulled HEAD, and recorded "bb started 055e758 instead of 0950d00".

What changed

  • packages/bb-app/src/app-update/source-checkout.ts: inspectSourceCheckout takes the running commit and counts and lists incoming commits as running..origin/main. The diverged check still uses HEAD (origin/main..HEAD).
  • fastForwardSource no longer needs HEAD to equal a from commit. It requires the target to contain HEAD, so a partly or fully pulled checkout fast-forwards (or no-ops) to the target. A checkout with commits the target lacks is refused with a clear message.
  • packages/bb-app/src/app-update/source-shim.ts: the shim applies any pending source update through fastForwardSource, so a mismatch is recorded as a failed result instead of silently skipped. Install and rebuild always run, which a pulled-but-unbuilt checkout needs. Removed the now-unused readHead argument and its wiring in launcher.ts.
  • launcher-controller.ts passes args.current.commit for both the check-source request and the apply-time recheck.

The launcher and server share the existing SourceUpdateCheck shape, so nothing on the wire changes and there's no daemon protocol bump.

How you verified

  • pnpm exec turbo run typecheck test --filter=bb-app: 223 tests pass. New tests on real git fixtures:
    • a checkout pulled partway counts from the running commit (+2, where HEAD-based counting gives +1)
    • a checkout pulled to origin/main still offers the update (previously reported up to date)
    • fastForwardSource completes from a partly pulled checkout and refuses one with commits the target lacks
    • the shim reinstalls, rebuilds and relaunches on the target when the checkout was already pulled to it before the restart (previously skipped)
  • End to end with a real pnpm start: built a fresh clone of this branch against a local bare upstream, with its own data dir and ports. Published 3 commits upstream and pulled the checkout forward by 1 without restarting.
    • Settings → Updates showed 04e5411 → e4a5168 (+3 commits) with all three subjects.
    • Clicking Update fast-forwarded, ran pnpm install and the rebuild, and relaunched.
    • GET /api/v1/system/app-update then reported current = e4a5168 and lastResult.outcome: "updated", and Settings showed "Up to date".

AGENT GENERATED

🤖 Generated with Claude Code

When the source checkout was pulled without restarting bb, the update
check counted and listed commits from the pulled HEAD, so Settings showed
'+2 commits' for a server 32 commits behind. Updating then restarted on
the pulled HEAD instead of origin/main because the shim required HEAD to
still equal the running commit.

Count and list incoming commits from the running commit, and let the
shim fast-forward any checkout whose HEAD the target contains.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit 8c18432 into main Oct 29, 2026
26 checks passed
@ymichael
ymichael deleted the bb/check-update-frequency-thr_33ezzpsh5y branch October 29, 2026 03:07
mistakeknot added a commit to mistakeknot/aleph that referenced this pull request Nov 3, 2026
Sync Aleph to upstream bb 8c184323a0 (get-bb#6513, resolves launcher-controller.ts)
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