Skip to content

fix(dispatch): reduce idle observer polling - #3427

Merged
kev1n77 merged 1 commit into
GCWing:mainfrom
kev1n77:fmy/bugfix
Oct 16, 2026
Merged

kev1n77 merged 1 commit into
GCWing:mainfrom
kev1n77:fmy/bugfix

Conversation

@kev1n77

@kev1n77 kev1n77 commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator

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:web was 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

  • Tests use simulated clocks and host/target APIs. Live SSH remote workspaces, remote control, account-device/Peer Device connections, and Detached Dispatch end-to-end execution were not exercised. Native CPU usage and OS notification display were not measured.
  • Existing Peer Device Mode controller-polling suppression remains in place. No persisted record shapes or wire contracts change.
  • AI-assisted implementation and verification. Scope is limited to the dispatch observer, its tests, and its local verification guide.

Checklist

  • This PR is focused and does not include secrets, temporary prompts, generated scratch files, or unrelated artifacts.
  • Relevant verification is recorded above, or skipped checks are explained.
  • User-facing strings, docs, and locales are updated where applicable.

@kev1n77
kev1n77 merged commit 20e6a73 into GCWing:main Oct 16, 2026
9 checks passed
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