fix(compute): show queued jobs on the notebook bar and drain them on restart - #371
Draft
wen2zhou wants to merge 4 commits into
Draft
fix(compute): show queued jobs on the notebook bar and drain them on restart#371wen2zhou wants to merge 4 commits into
wen2zhou wants to merge 4 commits into
Conversation
When jobs exceed concurrency limits and enter queued status, they were invisible on the notebook bar badge. Root cause had two layers: 1. Main process: submitJob only broadcast job-updated for submitted jobs (via dispatchJob), while queued jobs were written to DB but never broadcast. The renderer store relies purely on broadcasts after initial hydrate, so queued jobs never reached the UI. 2. Renderer: RemoteJobBadge only counted running+submitted, ignoring queued. Fixes: - Broadcast job-updated immediately after creating any job (queued or submitted) so the renderer store sees it instantly - Badge now displays 'N running · M queued' when queued jobs exist, stays amber (not gray idle), and tooltip shows queued rows with 'queued' label - Subscribe to jobsById map (not stable fn ref) so badge re-renders on any job status change, not just the 1s elapsed-time tick Tests: 16 badge render tests + 1 integration test for queued broadcast. All compute-service/concurrency suites pass (138 tests, no regressions). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… queued tasks - Add drainOnStartup() to ConcurrencyManager (delegates to tryDispatchNext) - Add drainQueuedJobs() facade on ComputeService - Wire void computeService.drainQueuedJobs() in ipc.ts after jobPoller.start() - Tests: drainOnStartup unit test + integration test for restart scenario
Subscribe to only the active session's job slice via useShallow instead of the whole jobsById map. applyUpdate swaps the map on every broadcast, so a job update in another session no longer re-renders this badge — only this session's own add/status changes do. The 1s elapsed-time tick still drives fresh durations independently. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Replace the fixed 200ms setTimeout wait in the drainOnStartup integration test with a polling waitFor helper so it does not flake under CI load. - Add a multi-job drainOnStartup unit test asserting it drains every queued job up to the provider ceiling and leaves the remainder queued, making the drain contract explicit. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
wen2zhou
marked this pull request as draft
July 27, 2026 10:27
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.
Problem
When compute jobs exceed a concurrency limit (session limit or provider ceiling) they enter a
queuedstatus while waiting for a slot. Two gaps made queued jobs invisible and fragile:submitJobonly broadcastjob-updatedfor dispatched(submitted) jobs; a queued job was written to the DB but never broadcast, so the renderer store
— which hydrates once then lives entirely off broadcasts — never learned about it. On top of
that,
RemoteJobBadgeonly countedrunning/submittedjobs and subscribed to a stableselector reference, so it did not re-render on status changes anyway.
start, so they sat in
queuedforever even after capacity freed up.Proposed change
submitJobnow broadcastsjob-updatedimmediately after creating anyjob (queued or submitted), so the renderer sees it instantly. This also closes a brief invisible
window for submitted jobs before the async dispatcher emits its first transition.
RemoteJobBadgenow displaysN running · M queuedwhile jobs are queued,stays amber (not gray idle), lists queued rows in the tooltip with a literal "queued" label
(instead of a misleading elapsed time), and carries an accurate
aria-label.useShallow, soa job update in another session no longer re-renders it.
drainQueuedJobs()/drainOnStartup()dispatch queued jobs that cannow fill free capacity after a restart; wired in
ipc.tsright after the poller starts.Scope and non-goals
model (session limit + provider ceiling). No schema changes.
surfaces (e.g. a full job-list page).
Acceptance criteria and validation
segment once dispatched to running, and the badge returns to gray "N jobs" once every job is
terminal.
npm run typecheck,npm run lint,npm run testall pass (full suite: 5795 passed, 0 failed).RemoteJobBadgerender tests, a queued-broadcast integration test, adrainOnStartupunit test + a multi-job "drain up to ceiling" unit test, and a restart-drain integration test
(the latter now polls instead of a fixed delay to avoid CI flake).
Review focus
compute-service.ts— broadcast-on-create placement and thedrainQueuedJobsfacade.RemoteJobBadge.tsx—useShallowsession scoping and the segments /aria-labellogic.concurrency-manager.ts—drainOnStartup(delegates totryDispatchNext, which alreadyiterates the whole queue under the shared admit lock).