feat(tui): add 24-hour time format option for session view
Description
Adds support for 24-hour time format in the TUI session view, addressing Issue #7208.
Users can now configure whether timestamps in the session view display in 12-hour (AM/PM) or 24-hour format.
Before & After
Before (12-hour format - default)
After (24-hour format)
Changes
- Added
time_formatconfiguration option to TUI settings (supports "12h" and "24h" formats) - Updated time formatting utilities (
Locale.time,Locale.datetime,Locale.todayTimeOrDateTime) to accept format parameter - Applied time format configuration to:
- Session list view
- Fork from timeline dialog
- Timeline view
- Added unit tests for time formatting functions
Configuration Example
Add the following to your opencode.jsonc or .opencode/opencode.jsonc:
{
"tui": {
// Use 24-hour time format (default is 12-hour)
"time_format": "24h"
}
}
Or use 12-hour format explicitly:
{
"tui": {
"time_format": "12h"
}
}
Testing
- Session list displays correct time format based on configuration
- Fork dialog shows correct time format
- Timeline view respects time format setting
- Unit tests pass for both 12h and 24h formats
Related Issue
Closes #7208
The following comment was made by an LLM, it may be inaccurate:
I found a potentially related PR:
PR #1888: Add configurable time format support https://github.com/anomalyco/opencode/pull/1888
This PR appears to be related as it also deals with configurable time format support, though it may be an older or broader implementation. You may want to check if this PR overlaps with the current PR #7236 or if it was already merged/closed.
The other PRs that appeared in the search (OAuth usage display and terminal panel) are not related to time formatting.
Note on Related Work
This PR addresses time format configuration for the current OpenCode 1.0+ TUI
(TypeScript/SolidJS, located in packages/opencode/src/cli/cmd/tui/).
There is a separate PR #1888 that addresses the same feature for the legacy
OpenCode 0.x TUI (Go/BubbleTea, located in packages/tui/), which was replaced
in version 1.0 but is maintained for backward compatibility.
These implementations are independent and target different versions of OpenCode.
Hi @thdxr, just a gentle bump on this PR.
It implements the 24-hour time format option requested in #7208. I've included unit tests and verified the UI changes locally.
Ready for review whenever you have a moment. Thanks!