Skip to content

Conversation

@opencode-agent
Copy link
Contributor

The change is complete. Here's a summary of the formatting logic I added:

Duration formatting rules:

  • < 60 seconds: Shows as Xs (e.g., 45s)
  • < 1 hour: Shows minutes + seconds like Xm Ys (e.g., 5m 30s, or 5m if no remaining seconds)
  • < 1 day: Shows hours + minutes like Xh Ym (e.g., 2h 15m, or 2h if no remaining minutes)
  • < 1 week: Shows approximate days like ~X days (e.g., ~3 days)
  • >= 1 week: Shows approximate weeks like ~X weeks (e.g., ~2 weeks)

This addresses the issue where 447+ hours was displayed as raw hours/seconds. Now it would show as ~2 weeks or ~18 days instead, making it much clearer when a quota resets.

Closes #8170

New%20session%20-%202026-01-15T06%3A18%3A05.219Z
opencode session  |  github run

}
}

const formatDuration = (secs: number) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rekram1-node add test cases for it?

@rekram1-node
Copy link
Collaborator

/oc can you make this function testable and then write some unit tests for it?

@opencode-agent
Copy link
Contributor Author

Done! Here's a summary of the changes:

Changes made:

  1. Created /packages/opencode/src/util/format.ts - Extracted the formatDuration function to a reusable utility module, making it testable and available for use elsewhere in the codebase.

  2. Updated /packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx - Added import for formatDuration from the new utility module and removed the inline function definition.

  3. Created /packages/opencode/test/util/format.test.ts - Comprehensive unit tests covering:

    • Zero and negative values
    • Seconds under a minute
    • Minutes under an hour (with and without remaining seconds)
    • Hours under a day (with and without remaining minutes)
    • Days under a week (singular and plural)
    • Weeks (singular and plural)
    • Boundary values at each threshold

New%20session%20-%202026-01-15T17%3A12%3A34.436Z
opencode session  |  github run

@rekram1-node
Copy link
Collaborator

/review

@github-actions
Copy link
Contributor

lgtm

@rekram1-node rekram1-node merged commit ebc194c into dev Jan 15, 2026
4 checks passed
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.

feat: prettify retry message so it is more clear when quota resets

3 participants