|
1 | 1 | import { Button } from "../../components/ui/Button"; |
| 2 | +import { useMessageTimeFormatter } from "./useMessageTimeFormatter"; |
2 | 3 | import * as Dialog from "../../components/ui/Dialog"; |
3 | 4 | import { useOpenPullRequest } from "../../native/useOpenPullRequest"; |
4 | 5 | import { useWorkspaceSettledContentWidth } from "../layout/workspace-content-width"; |
@@ -294,18 +295,6 @@ const WIDE_MARKDOWN_BLOCK_OPTIONS = { |
294 | 295 | includeOrderedLists: Platform.OS === "android", |
295 | 296 | } as const; |
296 | 297 |
|
297 | | -const MESSAGE_TIME_FORMATTER = new Intl.DateTimeFormat(undefined, { |
298 | | - hour: "numeric", |
299 | | - minute: "2-digit", |
300 | | -}); |
301 | | -function formatMessageTime(input: string): string { |
302 | | - const timestamp = Date.parse(input); |
303 | | - if (Number.isNaN(timestamp)) { |
304 | | - return ""; |
305 | | - } |
306 | | - return MESSAGE_TIME_FORMATTER.format(timestamp); |
307 | | -} |
308 | | - |
309 | 298 | const TURN_FOLD_HEIGHT = 42; |
310 | 299 | const FEED_PADDING_TOP = 12; |
311 | 300 | // Rows re-measure within a commit or two of a width change. LegendList also defers imperative |
@@ -1660,6 +1649,7 @@ function renderFeedEntry( |
1660 | 1649 | | "threadId" |
1661 | 1650 | | "workspaceRoot" |
1662 | 1651 | > & { |
| 1652 | + readonly formatMessageTime: (input: string) => string; |
1663 | 1653 | readonly copiedRowId: string | null; |
1664 | 1654 | readonly expandedWorkRows: Record<string, boolean>; |
1665 | 1655 | readonly workRowSizing: ReturnType<typeof deriveThreadWorkLogSizing>; |
@@ -1873,7 +1863,7 @@ function renderFeedEntry( |
1873 | 1863 | const presentation = resolveUserMessagePresentation(message); |
1874 | 1864 | const renderedText = renderAssistantCitationsAsText(presentation.text); |
1875 | 1865 | const styles = isUser ? markdownStyles.user : markdownStyles.assistant; |
1876 | | - const timestampLabel = formatMessageTime(isUser ? message.createdAt : message.updatedAt); |
| 1866 | + const timestampLabel = props.formatMessageTime(isUser ? message.createdAt : message.updatedAt); |
1877 | 1867 | const attachments = message.attachments ?? []; |
1878 | 1868 | const hasReviewCommentContext = presentation.text.includes("<review_comment"); |
1879 | 1869 | // Android does not reposition children after maxWidth clamps bubbles; definite width prevents wide-block overlap. |
@@ -2658,6 +2648,7 @@ export const ThreadFeed = memo(function ThreadFeed({ |
2658 | 2648 | ref, |
2659 | 2649 | ...props |
2660 | 2650 | }: ThreadFeedProps & { readonly ref?: Ref<ThreadFeedHandle> }) { |
| 2651 | + const formatMessageTime = useMessageTimeFormatter(); |
2661 | 2652 | const { listRef, onEndFollowEnabledChange, onHeaderMaterialVisibilityChange } = props; |
2662 | 2653 | const workflowOpening = useWorkflowOpening(props.detailRef); |
2663 | 2654 | const guestShare = useThreadGuestShare(props.detailRef); |
@@ -3218,6 +3209,7 @@ export const ThreadFeed = memo(function ThreadFeed({ |
3218 | 3209 | const listAppearanceData = { |
3219 | 3210 | disclosureLayout, |
3220 | 3211 | reduceMotion, |
| 3212 | + formatMessageTime, |
3221 | 3213 | worktreeSetup: props.worktreeSetup, |
3222 | 3214 | setupWorkingStartedAt: props.setupWorkingStartedAt, |
3223 | 3215 | dispatchingMessageId: props.dispatchingMessageId, |
@@ -3755,6 +3747,7 @@ export const ThreadFeed = memo(function ThreadFeed({ |
3755 | 3747 | ) : null} |
3756 | 3748 | {renderFeedEntry(info, { |
3757 | 3749 | userMessageGrouping: info.item.userMessageGrouping, |
| 3750 | + formatMessageTime, |
3758 | 3751 | environmentId: props.environmentId, |
3759 | 3752 | dispatchingMessageId: props.dispatchingMessageId, |
3760 | 3753 | onEditPendingMessage: props.onEditPendingMessage, |
|
0 commit comments