Skip to content

CLI: Throttle dependency update checks to once per 24h - #3100

Merged
bcotrim merged 6 commits into
trunkfrom
stu-1455-throttle-dependency-update-checks
Apr 16, 2026
Merged

CLI: Throttle dependency update checks to once per 24h#3100
bcotrim merged 6 commits into
trunkfrom
stu-1455-throttle-dependency-update-checks

Conversation

@bcotrim

@bcotrim bcotrim commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

Related issues

How AI was used in this PR

Implementation drafted with Claude Code from the Linear issue. I reviewed the diff, ran the test suite, and validated the throttle logic (missing timestamp, stale timestamp, future/clock-skew timestamp, happy path) before pushing.

Proposed Changes

  • Add an optional lastDependencyCheckTime field to the CLI config schema (cli.json).
  • Add shouldCheckDependencyUpdates() / markDependencyCheckTime() helpers in dependency-management/setup.ts. The throttle treats missing, >24h-old, and future (clock-skew) timestamps as stale, and swallows read/write errors so a broken cli.json never blocks site create.
  • Gate the updateServerFiles() call in site create behind the throttle, so back-to-back site creations don't re-run the network check.
  • Unit tests for the helpers and for the create-command gating paths (runs when expired, skips when fresh, skips when offline).

Testing Instructions

  1. npm run cli:build
  2. node apps/cli/dist/cli/main.mjs site create ~/Studio/throttle-test-1 — should show "Checking for dependency updates…" and succeed.
  3. node apps/cli/dist/cli/main.mjs site create ~/Studio/throttle-test-2 immediately after — should skip the dependency check entirely and feel faster.
  4. Edit ~/.studio/cli.json and set lastDependencyCheckTime to 1 (or delete the field), then re-run site create — the check should run again.
  5. Run the unit tests:
    • npm test -- apps/cli/lib/dependency-management/tests/setup.test.ts
    • npm test -- apps/cli/commands/site/tests/create.test.ts

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?
  • Unit tests added / updated
  • npm run typecheck passes
@bcotrim bcotrim self-assigned this Apr 15, 2026
@bcotrim
bcotrim requested a review from a team April 15, 2026 13:28
@wpmobilebot

wpmobilebot commented Apr 15, 2026

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing e2426a9 vs trunk

app-size

Metric trunk e2426a9 Diff Change
App Size (Mac) 1282.23 MB 1282.23 MB +0.00 MB ⚪ 0.0%

site-editor

Metric trunk e2426a9 Diff Change
load 1528 ms 1909 ms +381 ms 🔴 24.9%

site-startup

Metric trunk e2426a9 Diff Change
siteCreation 8118 ms 8118 ms 0 ms ⚪ 0.0%
siteStartup 4164 ms 4327 ms +163 ms 🔴 3.9%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

@sejas sejas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Works as expected! 👌
I left a suggestion but it's not a strong opinion.

Comment on lines +266 to +272
* Fetches the latest WordPress version from the network.
*
* This performs a network request, so callers should gate it behind
* `shouldCheckDependencyUpdates()` and follow a successful call with
* `markDependencyCheckTime()` to avoid hitting the network on every
* invocation (see STU-1455).
*/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder if we could enforce this with code instead of a comment.

@katinthehatsite katinthehatsite left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The changes look good 👍

@bcotrim
bcotrim merged commit 38792ef into trunk Apr 16, 2026
10 checks passed
@bcotrim
bcotrim deleted the stu-1455-throttle-dependency-update-checks branch April 16, 2026 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants