feat(tasks): show upgrade prompt for over-limit cloud task creation#2523
Merged
Conversation
Contributor
Prompt To Fix All With AIFix the following 2 code review issues. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 2
apps/code/src/renderer/features/billing/preflightCloudUsage.test.ts:59-101
The four test cases for `assertCloudUsageAvailable` are written as standalone `it` blocks but share the same function under test and differ only in the usage snapshot input and expected output/side-effects. The team standard is to always prefer parameterised tests. Collapsing the "allows / blocks / falls back / fails open" cases into a `it.each` table would make future scenarios trivial to add.
### Issue 2 of 2
apps/code/src/renderer/features/billing/preflightCloudUsage.ts:57-67
`isUsageExceeded` gates on `usage.is_rate_limited || burst.exceeded || sustained.exceeded`, but `usageLimitArgs` only inspects the two bucket flags. If the backend ever sets `is_rate_limited: true` with both bucket `exceeded` flags still false (e.g. a server-side safety valve), `usageLimitArgs` returns `undefined` and `show()` is called with no args — the modal opens with `bucket: null, resetAt: null`. The user sees the generic "Usage limit reached" title with no reset countdown. The `isPro` gap is covered by `useSeat()` in the modal, but the missing reset time could be confusing.
Reviews (1): Last reviewed commit: "feat(tasks): show upgrade prompt for ove..." | Re-trigger Greptile |
a620449 to
624adcf
Compare
Contributor
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
apps/code/src/renderer/features/task-detail/service/service.ts:62-74
**Inbox callers show error toast alongside the usage-limit modal**
The backstop calls `assertCloudUsageAvailable()`, which already shows the modal, then returns `{ success: false, error: "Usage limit reached" }`. Any caller that doesn't recognise this sentinel will also show an error toast, so the user sees both. Concretely, `useDiscussReport.ts` shows `toast.error("Failed to start discussion", { description: "Usage limit reached" })` and `useCreatePrReport.ts` shows `toast.error("Failed to start PR task", ...)` in the same case — neither currently checks for `failedStep === "usage_limit"` or the error string.
Using `CLOUD_USAGE_LIMIT_ERROR_MESSAGE` as the backstop's `error` value (matching what `useTaskCreation.ts` already guards against) would let inbox callers apply the same suppression check.
Reviews (2): Last reviewed commit: "feat(tasks): show upgrade prompt for ove..." | Re-trigger Greptile |
k11kirky
approved these changes
Jun 8, 2026
624adcf to
ef91239
Compare
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
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.
Problem
creating a cloud task while over the usage limit showed a raw rate-limit error instead of an upgrade prompt, and the task was created anyway (orphaned state)
cloud_task_rate_limit_gating.mp4
Closes #2511
Changes
UsageLimitModaland block creation (no task/run created)CLOUD_TASK_USAGE_BLOCKEDevent (bucket + is_pro) emitted when the pre-flight blockswithCloudUsageLimitCheckwrapper for the three cloud-run callsDepends on BE's posthog#62110