Repository navigation
fix(agent): report late billing refresh failures [cloud/1.56] - #20951
christian-byrne merged 1 commit into
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
🎨 Storybook: ✅ Built — View Storybook🌾 Fallow: ✅ PassedFallow audits the diff for duplication, complexity and dead code. It gates on new findings only, so when the audit completes, a red is something this PR introduced or moved — never inherited backlog. A red can also mean the audit itself did not finish; the details below say which happened. No new findings in the changed files. Reproduce locally# the base the gate compared against
npx fallow audit --root . --quiet --format json \
--changed-since fc4871b82084fe6190fa5e3499209392aeb4e641
Full docs: ADR-DEVEX-LINT-0015 🎭 Playwright: ✅ 2201 passed, 0 failed · 1 flaky📊 Browser Reports
🧩 Custom Nodes Ecosystem Matrix: ✅ PassedExecutes the frontend JS of every registry pack that ships any, against this change, in both renderers. The eight
On a pin-bump PR, a red gate means the ecosystem moved — not that your diff broke something. That is what the bump PR is for. Outside a pin bump or a cold rebuild of the unpinned tail, a red means the diff. Note the corpus size and the executed count are different numbers, and the verdict is against the executed count: roughly 3,100 of ~5,100 packs ship no extension-shaped JS and are skipped. Reproduce locally# build one shard's fixture, then run it
python3 scripts/registry-census/build_matrix.py --shard 1/4
MATRIX_RENDERER=vue MATRIX_VUE=1 \
npx vitest run --config vitest.matrix.config.mts
Full docs: scripts/registry-census/README.md |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## cloud/1.56 #20951 +/- ##
=============================================
Coverage ? 82.99%
=============================================
Files ? 2381
Lines ? 126601
Branches ? 38617
=============================================
Hits ? 105078
Misses ? 21114
Partials ? 409
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🔍 Cursor Review — Consolidated panel
Triggered by @christian-byrne.
Found 6 finding(s).
| Severity | Count |
|---|---|
| 🟡 Medium | 1 |
| 🟢 Low | 4 |
| ⚪ Nit | 1 |
Panel: 8/8 reviewers contributed findings.
| billingRefreshes.delete(key) | ||
| } | ||
| if (latestBillingRefresh === refresh) latestBillingRefresh = undefined | ||
| billingRefreshCount.value -= 1 |
There was a problem hiding this comment.
🟡 Medium — The decrement runs in pending.finally(...), so billingRefreshPending flips to false a microtask or two before the refresh promise callers actually hold settles — i.e. before refreshTransitionBaseline's .then has run completeCreditTransitionRefresh/observeFreshScopedFunds — yet the new tests at useAgentDockMount.test.ts:283 and :338 gate on it as a refresh-complete barrier. It also reports idle as soon as the 15s timeout resolves while fetchStatus is still outstanding; the onLateError path added here is proof that work continues past that point. Putting the real assertion inside vi.waitFor (or awaiting the refresh promise) avoids depending on a flag that cannot mean "consumers have run". Raised by 2 of 8 reviewers (claude-opus-5-thinking-max edge-case, claude-opus-5-thinking-max adversarial).
| .then(fetchStatus) | ||
| .then(resolve, reject) | ||
| .then(resolve, (error: unknown) => { | ||
| if (timedOut) onLateError?.(error) |
There was a problem hiding this comment.
🟢 Low — onLateError is invoked inside a rejection handler whose chain (.then(...).finally(...)) is never returned or awaited, so a callback that throws becomes an unhandled promise rejection with no catch anywhere — the previous handler was bare reject, which could not throw. Today's only caller is reportError, but this is public store API open to any callback; wrapping the invocation in try/catch keeps the late-error reporting path itself failure-safe. Raised by 5 of 8 reviewers (claude-opus-5-thinking-max adversarial, gemini-3.1-pro adversarial, claude-opus-5-thinking-max edge-case, gemini-3.1-pro edge-case, kimi-k3-max edge-case).
| onLateError?: (error: unknown) => void | ||
| ): Promise<boolean> { | ||
| const existing = billingRefreshes.get(key) | ||
| if (existing) return existing |
There was a problem hiding this comment.
🟢 Low — The dedupe early-return discards a joining caller's onLateError, so only the first caller for a key ever registers one. Combined with the parameter being optional, any call site that omits it — or joins one that did — still silently swallows post-timeout rejections, the exact failure this change set out to fix. Making the parameter required, or defaulting to a store-level reportError, keeps late failures visible regardless of call site. Raised by 2 of 8 reviewers (claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case).
|
|
||
| expect(fetchStatusFresh).toHaveBeenCalledOnce() | ||
| await new Promise((resolve) => setTimeout(resolve, 0)) | ||
| expect(store.billingRefreshPending).toBe(true) |
There was a problem hiding this comment.
🟢 Low — Unlike the other three substitutions, this one replaces the flush with an assertion that the refresh is still pending, so the following claimCreditTransitionNoticeImpression check now runs before the refresh settles rather than after — a different property than the test previously proved — and the fetch chain plus its 15s timeout are left dangling at test end. If the intent is "the notice is not claimable while the refresh is in flight", keep it but assert that explicitly; otherwise wait for completion like the sibling cases. Raised by 1 of 8 reviewers (gemini-3.1-pro edge-case).
| @@ -423,8 +432,10 @@ export const useAgentPanelStore = defineStore('agentPanel', () => { | |||
| billingRefreshes.delete(key) | |||
| } | |||
| if (latestBillingRefresh === refresh) latestBillingRefresh = undefined | |||
There was a problem hiding this comment.
🟢 Low — latestBillingRefresh is cleared only when the settling refresh is the newest one, so if a second refresh starts and finishes before an older one, the pointer is nulled while the older fetch is still in flight and the next afterCurrent: true reopen refresh runs immediately instead of queueing behind it. Pre-existing, but it sits in the bookkeeping this PR is tightening, and the new counter makes "nothing outstanding" cheap to detect. Raised by 1 of 8 reviewers (gemini-3.1-pro edge-case).
| ready: boolean | ||
| } | null>(null) | ||
| const billingRefreshes = new Map<string, Promise<boolean>>() | ||
| const billingRefreshCount = ref(0) |
There was a problem hiding this comment.
⚪ Nit — billingRefreshPending has no production consumer — the only readers are useAgentDockMount.test.ts — so this adds internal refresh bookkeeping to the public store surface purely as a test synchronisation hook, and couples those tests to the counter rather than to observable panel behaviour. Raised by 1 of 8 reviewers (claude-opus-5-thinking-max adversarial).
Summary
Validation
pnpm vitest run src/workbench/extensions/agent/composables/useAgentDockMount.test.ts src/workbench/extensions/agent/stores/agent/agentPanelStore.test.ts(53 passed)pnpm typecheckFollow-up carrier for #20929 after review.