Skip to content

[codex] Skip auto-update probes already in flight#498

Merged
robinebers merged 2 commits into
robinebers:mainfrom
zergzorg:codex/resource-budget-probe-guard
May 25, 2026
Merged

[codex] Skip auto-update probes already in flight#498
robinebers merged 2 commits into
robinebers:mainfrom
zergzorg:codex/resource-budget-probe-guard

Conversation

@zergzorg
Copy link
Copy Markdown
Contributor

@zergzorg zergzorg commented May 23, 2026

Summary

  • skip auto-update probes for providers that are already marked loading
  • keep refreshing idle providers when only part of the enabled set is still in flight
  • keep the next auto-update schedule moving even when every provider is still busy
  • add focused hook coverage and update App integration tests to model initial probe completion before auto-update

Why

This is a small first slice of #487. If a provider probe is slow or stuck, the fixed auto-update interval should not start another probe for that same provider on top of the existing one. The app already uses loading to prevent repeated manual refreshes; this applies the same resource-budget guard to background auto-updates.

The change does not alter the configured refresh interval, provider plugin runtime, or manual refresh behavior. It only avoids redundant auto-update work for providers that are still in flight.

Validation

  • node ./node_modules/vitest/vitest.mjs run src/hooks/app/use-probe-auto-update.test.ts
  • node ./node_modules/vitest/vitest.mjs run src/App.test.tsx -t "auto-update"
  • node ./node_modules/vitest/vitest.mjs run
  • bun run build

The full Vitest run passes. Existing App tests still print Tauri store mock stderr, but the suite exits successfully.

Closes part of #487.


Summary by cubic

Skip auto-update probes already in flight and keep probe state in sync so loading checks are accurate. Only idle providers run; the schedule still advances when all providers are busy. Part of #487.

  • Bug Fixes
    • Only start auto-update batches for idle providers; skip those still loading.
    • If all enabled providers are busy, do not start a batch and reschedule the next run.
    • Keep pluginStatesRef current when setting loading/errors so isPluginLoading reflects changes immediately; wire isPluginLoading into use-probe-auto-update and update tests (App timers, initial batch completion, and new use-probe-state coverage).

Written for commit 6e41496. Summary will update on new commits. Review in cubic

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

Re-trigger cubic

@zergzorg
Copy link
Copy Markdown
Contributor Author

Stack note for maintainers/agents:

Recommended #487 merge order:

  1. [codex] Skip auto-update probes already in flight #498 first: skip auto-update probes for providers already in flight.
  2. [codex] Cap concurrent plugin probes per batch #499 second: cap backend batch fan-out to 4 probe workers.
  3. [codex] Add per-probe runtime deadline #500 third: add a per-provider runtime deadline.

This PR has no hard dependency on #499 or #500 and is the smallest behavioral guard in the stack. It is the best first merge because it prevents redundant background work before the backend-level limits are reviewed.

#490 is separate from this stack and can merge anytime.

@validatedev
Copy link
Copy Markdown
Collaborator

@codex review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the app’s auto-update probe scheduler to avoid launching redundant background probes for providers that are already in-flight (loading), aligning background refresh behavior with the existing manual refresh guardrails and supporting the broader resource-budget work in #487.

Changes:

  • Add an isPluginLoading predicate to the probe hook surface area (useProbeuseProbeAutoUpdate) so the auto-update interval can skip busy providers.
  • Update auto-update scheduling to only start batches for idle providers, while still advancing autoUpdateNextAt even if all providers are busy.
  • Extend hook-level tests and adjust App integration tests to model initial probe completion prior to auto-update.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/hooks/app/use-probe.ts Exposes isPluginLoading based on current probe state for use by auto-update scheduling.
src/hooks/app/use-probe-auto-update.ts Filters enabled provider IDs to idle ones before starting an auto-update batch; keeps schedule advancing when none are idle.
src/hooks/app/use-probe-auto-update.test.ts Adds coverage for skipping loading providers and rescheduling when all are loading.
src/App.test.tsx Updates auto-update integration tests to simulate initial probe completion before interval-driven refresh.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/hooks/app/use-probe.ts
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@zergzorg zergzorg force-pushed the codex/resource-budget-probe-guard branch from dd27e5a to 6e41496 Compare May 24, 2026 07:03
@zergzorg
Copy link
Copy Markdown
Contributor Author

Addressed the review feedback in the latest push:

  • useProbeState now updates pluginStatesRef.current synchronously before publishing React state;
  • added a regression test that confirms setLoadingForPlugins() is immediately visible through the ref, which closes the same-tick race for isPluginLoading.

Verified locally with node ./node_modules/vitest/vitest.mjs run src/hooks/app/use-probe-state.test.ts src/hooks/app/use-probe-auto-update.test.ts using the bundled Node runtime. The updated branch is also rebased on current main, and CI is green.

Copy link
Copy Markdown
Owner

@robinebers robinebers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Clean focused change. The synchronous pluginStatesRef update via updatePluginStates is the right way to make isPluginLoading actually correct on the next interval tick. Tests cover the partial-idle and all-loading branches. Verified all 78 App tests + new hook tests pass locally.

@robinebers robinebers merged commit a291696 into robinebers:main May 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants