Repository navigation
Conversation
|
The following comment was made by an LLM, it may be inaccurate: |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Reset formatting accepts malformed values and can produce impossible durations such as “60 minutes.”
Review effort: Balanced
Findings: 2
Open (2)
What changed in this PR
Adds reset-time details to free-tier usage-limit messages while preserving the static fallback.
Changes:
- Reuses reset-time formatting for free and Go limits.
- Adds free-limit reset and fallback tests.
| File | Description |
|---|---|
packages/opencode/src/session/retry.ts |
Formats reset times in free-limit messages. |
packages/opencode/test/session/retry.test.ts |
Tests reset and fallback behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| const retryAfter = num(value) | ||
| if (retryAfter === undefined) return "" |
There was a problem hiding this comment.
Done - resetText now requires the header to match /^\d+$/ so malformed or negative values fall back to the static message.
| const seconds = Math.max(0, Math.ceil(retryAfter)) | ||
| const days = Math.floor(seconds / 86_400) | ||
| const hours = Math.floor((seconds % 86_400) / 3_600) | ||
| const minutes = Math.ceil((seconds % 3_600) / 60) | ||
| const unit = (count: number, name: string) => `${count} ${name}${count === 1 ? "" : "s"}` | ||
| if (days > 0) return hours > 0 ? `${unit(days, "day")} ${unit(hours, "hour")}` : unit(days, "day") | ||
| if (hours > 0) return minutes > 0 ? `${unit(hours, "hour")} ${unit(minutes, "minute")}` : unit(hours, "hour") | ||
| return minutes > 0 ? unit(minutes, "minute") : "less than a minute" |
There was a problem hiding this comment.
Done - rounds to total minutes first, so 3599s renders as 1 hour instead of 60 minutes. Covered by a new regression test.
|
This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2. — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊 |

Issue for this PR
Fixes #52894
Type of change
What does this PR do?
Free 429s showed a static message with no reset time while Go limits render "It will reset in X" from retry-after. This reuses the same formatting for FreeUsageLimitError, falling back to the static message when the header is absent or malformed. Go output is unchanged for valid headers (same helper, same tests).
Follow-up fixes review findings: strict non-negative-integer validation and total-minutes rounding (3599s renders as 1 hour, not 60 minutes).
How did you verify your code works?
Screenshots / recordings
N/A - non-UI change.
Checklist