perf: eliminate 5 redundant health checks on startup — data in <1 second#423
Merged
perf: eliminate 5 redundant health checks on startup — data in <1 second#423
Conversation
Before: 5 health checks + file reads + process checks before showing data 1. Orchestrator: RefreshPort (file read) 2. Orchestrator: CheckHealth (HTTP) 3. EnsureAgentRunning: GetReadyState (file + HTTP + process) 4. UpdateMonitorToggleButtonStateAsync (file + HTTP + process) 5. CheckApiContractAsync (HTTP) 6. RapidPoll: CheckHealth (HTTP) 7. RapidPoll: GetUsageAsync (HTTP — first actual data fetch) After: 1 port refresh + 1 data fetch, monitor start only if needed 1. RefreshPort (file read) 2. FetchDataAsync (HTTP — data appears immediately) 3. If no data: start monitor, fetch again 4. Contract check in background (non-blocking) Deleted: RapidPollUntilDataAvailableAsync (128 lines), UpdateMonitorToggleButtonStateAsync, orphaned else block. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
Startup went from 7 sequential HTTP calls to 2. Data appears in <1 second when Monitor is already running.
Before: RefreshPort → CheckHealth → EnsureAgentRunning (file+health+process) → UpdateToggle (file+health+process) → CheckContract (health) → RapidPoll CheckHealth → RapidPoll GetUsage
After: RefreshPort → FetchData. If no data: start monitor, fetch again. Contract check runs in background.
Deleted 128 lines: RapidPollUntilDataAvailableAsync, UpdateMonitorToggleButtonStateAsync, dead else block.
Test plan
🤖 Generated with Claude Code