Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Jan 14, 2026

This PR attempts to address Issue #10539, which requested an option to swap between 12-hour (AM/PM) and 24-hour time formats for chat message timestamps.

Changes

  • Added timestampFormat setting to global-settings.ts with enum type ("12hour" | "24hour")
  • Updated formatTimestamp.ts to accept a format parameter and properly handle 12-hour format with AM/PM display
  • Added comprehensive tests for 12-hour format (midnight displays as 12:00 AM, noon as 12:00 PM, etc.)
  • Added time format dropdown in UI Settings (only visible when timestamps are enabled)
  • Updated i18n translations for the new setting

How it Works

When the "Show timestamps on messages" option is enabled in Settings > UI, a new "Time format" dropdown appears below it, allowing users to choose between:

  • 12-hour (2:34 PM) - Displays times in 12-hour format with AM/PM suffix
  • 24-hour (14:34) - Displays times in 24-hour format (default)

Feedback and guidance are welcome!


Important

Adds a feature to toggle between 12-hour and 24-hour timestamp formats for chat messages, with UI settings and tests.

  • Behavior:
    • Adds timestampFormat setting in global-settings.ts with options for "12hour" and "24hour".
    • Updates formatTimestamp.ts to handle both 12-hour and 24-hour formats, including AM/PM for 12-hour.
    • Displays a dropdown in UI settings to toggle timestamp format when timestamps are enabled.
  • UI Components:
    • Modifies ChatRow.tsx to display timestamps based on the selected format.
    • Updates SettingsView.tsx and UISettings.tsx to include timestamp format options.
  • Tests:
    • Adds tests in formatTimestamp.spec.ts for both 12-hour and 24-hour formats.
    • Updates UISettings.spec.tsx to test the new timestamp format setting.

This description was created by Ellipsis for 8c81d0c. You can customize this summary. It will automatically update as commits are pushed.

Implements Issue #10539 - Adds the ability to display timestamps on chat messages.

Features:
- 24-hour format (14:34)
- Full date for messages from previous days (e.g., "Jan 7, 14:34")
- Configurable on/off toggle in UI Settings
- Timestamps appear on the right side of header rows
- Same styling as other header elements

Files changed:
- packages/types/src/global-settings.ts: Add showTimestamps setting
- src/shared/ExtensionMessage.ts: Add to ExtensionState
- webview-ui/src/context/ExtensionStateContext.tsx: Add state and setter
- webview-ui/src/utils/formatTimestamp.ts: New timestamp formatting utility
- webview-ui/src/components/settings/UISettings.tsx: Add toggle
- webview-ui/src/components/settings/SettingsView.tsx: Pass prop
- webview-ui/src/components/chat/ChatRow.tsx: Display timestamps
- webview-ui/src/i18n/locales/en/settings.json: Translation strings
- webview-ui/src/utils/__tests__/formatTimestamp.spec.ts: Tests
- webview-ui/src/components/settings/__tests__/UISettings.spec.tsx: Update tests
- Add timestampFormat setting to global-settings.ts with enum type
- Update formatTimestamp.ts to accept format parameter (12hour/24hour)
- Add comprehensive tests for 12-hour format (AM/PM display)
- Add time format dropdown in UI Settings when timestamps are enabled
- Update i18n translations for the new setting

Resolves: Issue #10539 - Request for 12hr/24hr time format toggle
@roomote
Copy link
Contributor Author

roomote bot commented Jan 14, 2026

Rooviewer Clock   See task on Roo Cloud

Review complete. The implementation is well-structured with proper type definitions, state management, and UI integration. One minor test issue flagged:

  • Fix timezone-dependent test assertions in formatTimestamp.spec.ts

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

Comment on lines +16 to +20
it("formats today's time in 24-hour format", () => {
// Same day at 10:15
const timestamp = new Date("2026-01-09T10:15:00.000Z").getTime()
expect(formatTimestamp(timestamp)).toBe("10:15")
})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These tests use UTC timestamp strings (e.g., 2026-01-09T10:15:00.000Z) but expect local time values. The formatTimestamp function correctly uses date.getHours() which returns local time, but the test assertions assume UTC equals local time. Tests will pass in UTC timezone but fail in other timezones.

For timezone-independent tests, use the local time constructor instead:

Suggested change
it("formats today's time in 24-hour format", () => {
// Same day at 10:15
const timestamp = new Date("2026-01-09T10:15:00.000Z").getTime()
expect(formatTimestamp(timestamp)).toBe("10:15")
})
it("formats today's time in 24-hour format", () => {
// Same day at 10:15 local time
const timestamp = new Date(2026, 0, 9, 10, 15, 0).getTime()
expect(formatTimestamp(timestamp)).toBe("10:15")
})

Fix it with Roo Code or mention @roomote and request a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

2 participants