fix: respect time format preference in UI
Add shared time formatting helpers that apply the Appearance time format preference consistently. Update visible time labels across chat, quota usage, scheduled tasks, tunnels, context details, git views, PR metadata, and passkey settings to use the selected 12-hour, 24-hour, or automatic format. Leave date-only and non-UI formatting untouched so unrelated behavior does not change.
This commit is contained in:
@@ -1038,6 +1038,7 @@ const AssistantMessageBody = React.memo(({
|
||||
const collapsibleThinkingBlocks = useUIStore((state) => state.collapsibleThinkingBlocks);
|
||||
const groupReasoningBlocks = useUIStore((state) => state.groupReasoningBlocks);
|
||||
const showSplitAssistantMessageActions = useUIStore((state) => state.showSplitAssistantMessageActions);
|
||||
const timeFormatPreference = useUIStore((state) => state.timeFormatPreference);
|
||||
const vscodeApi = useRuntimeAPIs().vscode;
|
||||
const isSortedRenderMode = chatRenderMode === 'sorted';
|
||||
const collapsedPreviewCount = 7;
|
||||
@@ -1757,9 +1758,9 @@ const AssistantMessageBody = React.memo(({
|
||||
: (typeof messageCreatedAt === 'number' && messageCreatedAt > 0 ? messageCreatedAt : null);
|
||||
if (timestamp === null) return null;
|
||||
|
||||
const formatted = formatTimestampForDisplay(timestamp);
|
||||
const formatted = formatTimestampForDisplay(timestamp, timeFormatPreference);
|
||||
return formatted.length > 0 ? formatted : null;
|
||||
}, [messageCompletedAt, messageCreatedAt]);
|
||||
}, [messageCompletedAt, messageCreatedAt, timeFormatPreference]);
|
||||
|
||||
const footerTimestampClassName = 'text-sm text-muted-foreground/60 tabular-nums flex items-center gap-1';
|
||||
const canOpenMessagePreview = !isMiniChatSurface && !isMobile && !isVSCode;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const pad2 = (value: number): string => String(value).padStart(2, '0');
|
||||
import { formatTimeForPreference } from '@/lib/timeFormat';
|
||||
import type { TimeFormatPreference } from '@/stores/useUIStore';
|
||||
|
||||
const isSameDay = (left: Date, right: Date): boolean => {
|
||||
return (
|
||||
@@ -18,7 +19,7 @@ const isValidTimestamp = (timestamp: number): boolean => {
|
||||
return Number.isFinite(timestamp) && !Number.isNaN(new Date(timestamp).getTime());
|
||||
};
|
||||
|
||||
export const formatTimestampForDisplay = (timestamp: number): string => {
|
||||
export const formatTimestampForDisplay = (timestamp: number, timeFormatPreference: TimeFormatPreference): string => {
|
||||
if (!isValidTimestamp(timestamp)) {
|
||||
return '';
|
||||
}
|
||||
@@ -26,7 +27,7 @@ export const formatTimestampForDisplay = (timestamp: number): string => {
|
||||
const date = new Date(timestamp);
|
||||
const now = new Date();
|
||||
|
||||
const timePart = `${pad2(date.getHours())}:${pad2(date.getMinutes())}`;
|
||||
const timePart = formatTimeForPreference(date, timeFormatPreference);
|
||||
|
||||
if (isSameDay(date, now)) {
|
||||
return timePart;
|
||||
|
||||
Reference in New Issue
Block a user