Repository navigation
fix(dispatch): reduce idle observer polling - #3427
Merged
Merged
Conversation
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.
Summary
Reduce dispatch observer polling to every 30 seconds when there are no jobs or all terminal jobs have drained their events. Keep the existing 1.8-second polling cadence for unfinished jobs and terminal jobs awaiting event replay, including when the window is hidden.
Local idle-to-active transitions and explicit refreshes wake the observer immediately. Preserve and coalesce refresh requests during slow reconciliation so approval refreshes are not lost. Add focused scheduling regression coverage and an owner-local verification guide.
Type and Areas
Type: Bug fix / performance / test
Areas: Web UI; Detached Dispatch job observer
Motivation / Impact
An idle observer currently reads dispatch records every 1.8 seconds even when nothing needs reconciliation. Simulated 60-second idle coverage reduces these reads from 34 to 3, including the initial read.
Periodic discovery stays enabled in hidden windows so jobs submitted by another process are still discovered. The idle discovery interval becomes 30 seconds; running jobs, pending approvals, and completion-event draining retain the fast cadence. Local submissions and explicit refreshes bypass the idle interval.
Verification
Passed after rebasing onto upstream/main:
pnpm --dir src/web-ui run test:run src/features/dispatch/DispatchJobObserver.test.ts src/features/dispatch/dispatchJobStore.test.ts src/features/dispatch/dispatchApi.test.ts src/features/dispatch/dispatch.contract.test.ts src/flow_chat/services/flow-chat-manager/MessageModule.test.ts- 135 tests across 5 files passed.pnpm --dir src/web-ui exec tsc --noEmit- passed when run after the test prerequisite UI package build completed.pnpm --dir src/web-ui exec eslint src/features/dispatch/DispatchJobObserver.ts- passed.git diff --check upstream/main...HEAD- passed.Regression coverage includes idle/active/hidden scheduling, discovery of externally submitted jobs, progress and approval projection, completion draining, queued refreshes, single-flight reconciliation, observer teardown, and existing persistence/contract behavior.
Before the rebase,
pnpm run check:webwas blocked by 25 pre-existing typography violations in unchanged design-system files. Those files were unchanged by the upstream update; the broader check was not rerun.Reviewer Notes
Checklist