opencode
opencode copied to clipboard
fix(tui): display human-readable duration for rate limit retry
Summary
- Fix rate limit retry message to display human-readable durations (e.g.,
45m 0sinstead of2700s) - Add
decimalSecondsoption toLocale.duration()to control whether seconds show decimals - Fix latent bug in days/hours calculation that would show
0d 25hinstead of1d 1h
Problem
When rate limits are hit, the retry message displays raw seconds which is hard to read for large values:
Solution
- Use
Locale.duration()for rate limit retry display with{ decimalSeconds: false } - Keep decimal seconds for message duration display (existing behavior)
- Examples:
-
2700s→45m 0s -
7140s→1h 59m
-
Changes
| File | Change |
|---|---|
packages/opencode/src/util/locale.ts |
Add decimalSeconds option, fix days/hours bug |
packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx |
Use Locale.duration() for retry message |
packages/opencode/test/util/locale.test.ts |
Add tests for duration formatting |