opencode icon indicating copy to clipboard operation
opencode copied to clipboard

feat(tui): add 24-hour time format option for session view

Open Octane0411 opened this issue 3 months ago • 3 comments

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)

7bc66c04-e643-433e-bd20-f4b7f35de2e5

After (24-hour format)

52a1a39e-fc0e-4fc5-8a66-46cb8c9f9113

Changes

  • Added time_format configuration 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

Octane0411 avatar Jan 07 '26 17:01 Octane0411

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.

github-actions[bot] avatar Jan 07 '26 17:01 github-actions[bot]

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.

Octane0411 avatar Jan 07 '26 17:01 Octane0411

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!

Octane0411 avatar Jan 08 '26 08:01 Octane0411