Repository navigation
Description
Needs your OK: this changes the wait shown on the two OAuth "too many requests" pages from seconds to minutes for waits under two minutes. Swap pipeline:proposed for pipeline:ready to have it built.
What happens
When someone hits a rate limit, the page tells them how long to wait. That wording is worked out in three places:
- Participant sign-up errors:
rateLimitMessageinsrc/app/s/[slug]/rate-limit-message.ts. It rounds up to whole minutes, never under one: "Try again in about 2 minutes." - The new-signup form:
createSignupActioninsrc/app/app/(chrome)/signups/new/actions.ts. It has the same rule, copied by hand (Math.max(1, Math.ceil(retryAfter / 60))and the same plural). - OAuth:
describeWaitinsrc/oauth/provider.ts, used bysrc/oauth/handler.tsandsrc/app/oauth/consent/[uid]/decision/route.ts. It gives seconds under 120 and minutes from 120 on.
The verifier called the real functions:
| wait (s) | participant page | new-signup form | OAuth pages |
|---|---|---|---|
| 1 | 1 minute | 1 minute | 1 seconds |
| 60 | 1 minute | 1 minute | 60 seconds |
| 90 | 2 minutes | 2 minutes | 90 seconds |
| 119 | 2 minutes | 2 minutes | 119 seconds |
| 120 | 2 minutes | 2 minutes | 2 minutes |
| 3412 | 57 minutes | 57 minutes | 57 minutes |
"1 seconds" really happens. chargeRateLimit returns at least 1 second, and exactly 1 in the last second of a window. The OAuth authorize limit (600 s window) and the consent limit (3600 s window) are long enough to land there. A person reads these pages: the handler renders HTML only for a browser, and API clients get JSON.
Open PR #572 adds a fourth copy for Magic Compose (minutesToWait in src/components/magic-compose/draft-errors.ts).
Fix, in outline
- Add one helper next to
formatDurationinsrc/lib/format-duration.ts, which already has a privatepluralize. For examplewaitInMinutes(seconds), giving "1 minute", "2 minutes" and so on, rounded up and never under one. - Use it in
rateLimitMessage(keep its "a few minutes" fallback for a missing wait), increateSignupAction, and in both OAuth callers. DeletedescribeWait. - Once Say when the hour's AI drafts are used up, in plain words #572 has merged, have
minutesToWaitindraft-errors.tsuse the same rounding: either the helper, or one shared minutes function the helper is built on. Its "missing wait" fallbacks (60 for the hourly limit, 1 for the provider) stay as they are.
Watch for
- Tests that pin the current text:
src/oauth/provider.test.tstestsdescribeWait(7 → "7 seconds", 119 → "119 seconds"). Replace it with awaitInMinutestest insrc/lib/format-duration.test.tsthat covers 1, 60, 61 and 3412.src/app/oauth/consent/[uid]/decision/route.test.tsmocksdescribeWaitand expects "Wait 600 seconds". Expect "Wait 10 minutes" instead.handler.test.ts,rate-limit-message.test.ts,commit-dialog.test.tsxandactions.db.test.tsshould pass unchanged.
src/oauth/is on the high-risk list, so the PR stops for the owner anyway. Only the wording changes, nothing about tokens or auth.src/app/api/signups/magic-compose/errors.tsprints the AI provider's ownretryAfterSecondsas "30s". That's the provider's wait, not ours, and Say when the hour's AI drafts are used up, in plain words #572 rewords it for the page. Leave it out.- Add a CHANGELOG line under Changed for the OAuth wording.
Choices this makes
- Minutes everywhere, rounded up. The OAuth pages change: waits of 1 to 60 seconds read "1 minute", and 61 to 119 seconds read "2 minutes". Rounding up never tells someone to come back too early, and the participant page already reads this way. The other choice is to keep seconds under two minutes on OAuth and only fix "1 seconds"; that would leave two rules.
- The OAuth sentences keep their shape: "Too many requests. Wait 2 minutes and try again." Only the wait changes, not "about" as the participant page has.
Order
After #572, because it adds the Magic Compose copy this should fold in.
Done when
- One helper words the wait, and
rateLimitMessage,createSignupAction, both OAuth callers and Say when the hour's AI drafts are used up, in plain words #572'sminutesToWaituse it (or its rounding).describeWaitis gone. - A unit test pins 1 → "1 minute", 60 → "1 minute", 61 → "2 minutes" and 3412 → "57 minutes".
pnpm lint && pnpm typecheck && pnpm knip && pnpm testandpnpm test:dbpass (src/oauthchanges).
Found by the pipeline's refactor scout in the rate-limit callers (src/lib/rate-limit.ts, src/oauth, src/app/s/[slug], the new-signup form), at a1861fb. Checked by an independent vitest run calling the real rateLimitMessage, createSignupAction and describeWait with waits from 1 to 3412 seconds. https://claude.ai/code/session_01VDxNQieDU78WZq9ygPpF7h
Activity
Merge main into claude/issue-679-wait-in-minutes