fix(ccusage): add auto-refresh polling to CLI hooks using usageLimitsRefreshInterval preference#27281
Conversation
…tsRefreshInterval preference
|
Thank you for your contribution! 🎉 🔔 @nyatinte @zhuravel @GarrickZ2 @raulgg you might want to have a look. You can use this guide to learn how to check out the Pull Request locally in order to test it. 📋 Quick checkout commandsBRANCH="fix/ccusage-cli-auto-refresh"
FORK_URL="https://github.com/kud/raycast-extensions.git"
EXTENSION_NAME="ccusage"
REPO_NAME="raycast-extensions"
git clone -n --depth=1 --filter=tree:0 -b $BRANCH $FORK_URL
cd $REPO_NAME
git sparse-checkout set --no-cone "extensions/$EXTENSION_NAME"
git checkout
cd "extensions/$EXTENSION_NAME"
npm install && npm run devWe're currently experiencing a high volume of incoming requests. As a result, the initial review may take up to 10-15 business days. |
Greptile SummaryThis PR wires up the pre-existing Confidence Score: 5/5Safe to merge; all findings are minor P2 style/completeness suggestions that do not affect correctness. The polling logic is correct, the cleanup via clearInterval on unmount is present, and useExec's stable revalidate reference makes the stale-closure concern benign in practice. The missing useCCUsageBlocksCli update and the dependency-array style issue are both P2. No files require special attention; minor polish suggestions exist across all four updated hooks. Important Files Changed
|
…cluding result.revalidate in dependency arrays
0xdhrv
left a comment
There was a problem hiding this comment.
Looks good to me, approved ✅
|
Published to the Raycast Store: |
|
🎉 🎉 🎉 We've rewarded your Raycast account with some credits. You will soon be able to exchange them for some swag. |
Description
The four CLI hooks in the
ccusageextension (useCCUsageDailyCli,useCCUsageMonthlyCli,useCCUsageTotalCli,useCCUsageSessionCli) were not auto-refreshing.useExecfrom@raycast/utilsis a one-shot hook — it fetches once on mount and never polls again. As a result, usage data (today's cost, monthly total, session list) would only update when the user triggered a manual revalidation.The fix adds a
setIntervalinside each CLI hook that callsresult.revalidate()on the interval configured by the existingusageLimitsRefreshIntervalpreference (default 60 s). This wires up the refresh cadence that was already exposed as a user preference but had no effect on the CLI hooks.Screencast
No visual changes — this is a background data-refresh fix. The displayed figures now update automatically at the configured interval instead of remaining stale until a manual refresh.
Checklist
npm run buildand tested this distribution build in Raycastassetsfolder are used by the extension itselfREADMEare located outside the metadata folder if they were not generated with our metadata tool