feat(chat): align activity timing UI with hover-only end timestamps (#557)
* feat(chat): add shared activity timestamp formatter * feat(chat): pass assistant created timestamp to message body * feat(chat): render footer timestamp beside elapsed time * feat(chat): pass timing metadata in reasoning text blocks * feat(chat): propagate justification timing to timeline block * feat(chat): show thinking duration with hover end time * feat(chat): reveal tool end time on activity hover
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
const pad2 = (value: number): string => String(value).padStart(2, '0');
|
||||
|
||||
const isSameDay = (left: Date, right: Date): boolean => {
|
||||
return (
|
||||
left.getFullYear() === right.getFullYear() &&
|
||||
left.getMonth() === right.getMonth() &&
|
||||
left.getDate() === right.getDate()
|
||||
);
|
||||
};
|
||||
|
||||
const isValidTimestamp = (timestamp: number): boolean => {
|
||||
return Number.isFinite(timestamp) && !Number.isNaN(new Date(timestamp).getTime());
|
||||
};
|
||||
|
||||
export const formatTimestampForDisplay = (timestamp: number): string => {
|
||||
if (!isValidTimestamp(timestamp)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const date = new Date(timestamp);
|
||||
const now = new Date();
|
||||
|
||||
const timePart = `${pad2(date.getHours())}:${pad2(date.getMinutes())}:${pad2(date.getSeconds())}`;
|
||||
|
||||
if (isSameDay(date, now)) {
|
||||
return timePart;
|
||||
}
|
||||
|
||||
const yearPart = String(date.getFullYear()).slice(-2);
|
||||
const monthPart = pad2(date.getMonth() + 1);
|
||||
const dayPart = pad2(date.getDate());
|
||||
|
||||
return `${yearPart}-${monthPart}-${dayPart} ${timePart}`;
|
||||
};
|
||||
Reference in New Issue
Block a user