Skip to content

feat(tasks): show upgrade prompt for over-limit cloud task creation#2523

Merged
tatoalo merged 1 commit into
mainfrom
chore/cloud-tasks/rate-limiting-upgrade-comms
Jun 8, 2026
Merged

feat(tasks): show upgrade prompt for over-limit cloud task creation#2523
tatoalo merged 1 commit into
mainfrom
chore/cloud-tasks/rate-limiting-upgrade-comms

Conversation

@tatoalo
Copy link
Copy Markdown
Contributor

@tatoalo tatoalo commented Jun 8, 2026

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

  • pre-flight gate, before cloud task creation, refresh the team's usage and if over limit --> show the existing UsageLimitModal and block creation (no task/run created)
  • graceful 429 handling
  • added also CLOUD_TASK_USAGE_BLOCKED event (bucket + is_pro) emitted when the pre-flight blocks
  • small cleanups w/ a shared withCloudUsageLimitCheck wrapper for the three cloud-run calls

Depends on BE's posthog#62110

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jun 8, 2026

Prompt To Fix All With AI
Fix 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

Comment thread apps/code/src/renderer/features/billing/preflightCloudUsage.test.ts Outdated
Comment thread apps/code/src/renderer/features/billing/preflightCloudUsage.ts
@tatoalo tatoalo force-pushed the chore/cloud-tasks/rate-limiting-upgrade-comms branch from a620449 to 624adcf Compare June 8, 2026 11:08
@tatoalo tatoalo marked this pull request as ready for review June 8, 2026 11:19
@tatoalo tatoalo requested a review from a team June 8, 2026 11:20
@tatoalo tatoalo self-assigned this Jun 8, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jun 8, 2026

Prompt To Fix All With AI
Fix 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

Comment thread apps/code/src/renderer/features/task-detail/service/service.ts
@tatoalo tatoalo force-pushed the chore/cloud-tasks/rate-limiting-upgrade-comms branch from 624adcf to ef91239 Compare June 8, 2026 12:30
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 8, 2026

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit ef91239.

@tatoalo tatoalo merged commit 2436b37 into main Jun 8, 2026
19 checks passed
@tatoalo tatoalo deleted the chore/cloud-tasks/rate-limiting-upgrade-comms branch June 8, 2026 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show upgrade prompt for cloud tasks when out of usage

2 participants