Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix[channels]: grouped message timestamps (#2648)
Peter Chinmanc35e8a177952
diff --git a/js/app/packages/channel/Message/ChannelMessage.tsx b/js/app/packages/channel/Message/ChannelMessage.tsxindex 41713e4e7e..b21ad6fa4d 100644--- a/js/app/packages/channel/Message/ChannelMessage.tsx+++ b/js/app/packages/channel/Message/ChannelMessage.tsx@@ -9,6 +9,7 @@ import { useMessageActionDrawer } from '@channel/Mobile/message-action-drawer-coimport type { MessageEditor } from '../Channel/create-message-editor';import { MessageEditorContent } from '../Channel/InlineMessageEditor';import { longPressHighlight } from '@core/directive/longPressHighlight';+import { isTouchDevice } from '@core/mobile/isTouchDevice';type ChannelMessageProps = {channelId: string;@@ -79,9 +80,16 @@ function GroupedMeta(props: { messageEditor?: MessageEditor }) {return (<Show when={!isEditingMessage(props.messageEditor, message().id)}>- <div class="flex items-center gap-2 shrink-0">+ <div+ class={cn(+ 'absolute right-1 -top-9 z-10',+ 'items-center gap-2 shrink-0 bg-panel p-1',+ 'hidden group-hover/message:flex',+ isTouchDevice() && 'hidden'+ )}+ ><Message.EditedIndicator />- <Message.Timestamp compact />+ <Message.Timestamp compact format="time" /></div></Show>);@@ -99,7 +107,10 @@ function RegularMessageLayout(props: {<Message.Slot placement="header" class="flex items-center gap-1 min-w-0"><Message.SenderName /><Message.EditedIndicator />- <Message.Timestamp class="ml-auto" />+ {/* On message hover, timestamp floats above actions. */}+ <div class="grow-1 shrink-0 min-w-0 flex justify-end group-hover/message:absolute group-hover/message:right-1 group-hover/message:-top-9 group-hover/message:p-1">+ <Message.Timestamp class="ml-auto shrink-0" format="dateAndTime" />+ </div></Message.Slot><Message.Slot placement="content" class="ph-no-capture"><MessageContentSlot@@ -113,9 +124,7 @@ function RegularMessageLayout(props: {><MessageFooter messageEditor={props.messageEditor} /></Message.Slot>- <Message.Slot placement="actions">- <MessageActionsSlot messageEditor={props.messageEditor} />- </Message.Slot>+ <MessageActionsSlot messageEditor={props.messageEditor} /></Message.Layout>);}@@ -131,12 +140,10 @@ function GroupedMessageLayout(props: {</Message.Slot><Message.Slot placement="content"><div class={cn('ph-no-capture flex gap-3 min-w-0 items-start')}>- <div class="flex-1 min-w-0">- <MessageContentSlot- channelId={props.channelId}- messageEditor={props.messageEditor}- />- </div>+ <MessageContentSlot+ channelId={props.channelId}+ messageEditor={props.messageEditor}+ /><GroupedMeta messageEditor={props.messageEditor} /></div></Message.Slot>@@ -146,9 +153,7 @@ function GroupedMessageLayout(props: {><MessageFooter messageEditor={props.messageEditor} /></Message.Slot>- <Message.Slot placement="actions">- <MessageActionsSlot messageEditor={props.messageEditor} />- </Message.Slot>+ <MessageActionsSlot messageEditor={props.messageEditor} /></Message.Layout>);}diff --git a/js/app/packages/channel/Message/HoverActions.tsx b/js/app/packages/channel/Message/HoverActions.tsxindex 3a12b29386..882f0954f6 100644--- a/js/app/packages/channel/Message/HoverActions.tsx+++ b/js/app/packages/channel/Message/HoverActions.tsx@@ -12,7 +12,7 @@ export function HoverActions(props: HoverActionsProps) {return (<divclass={cn(- 'absolute right-2 top-0 -translate-y-1/2 z-10',+ 'absolute right-0 top-0 -translate-y-1/2 z-10',props.persistentVisible ? '' : 'hidden group-hover/message:block',isTouchDevice() && 'hidden',props.classdiff --git a/js/app/packages/channel/Message/Layout.tsx b/js/app/packages/channel/Message/Layout.tsxindex a53cd2c4ad..0fe52a5d5e 100644--- a/js/app/packages/channel/Message/Layout.tsx+++ b/js/app/packages/channel/Message/Layout.tsx@@ -13,9 +13,8 @@ export function Layout(props: JSX.HTMLAttributes<HTMLDivElement>) {<divclass="grid min-w-0 items-start gap-x-2"style={{- 'grid-template-columns': 'var(--user-icon-width) minmax(0, 1fr) auto',- 'grid-template-areas':- '"icon header actions" "icon content actions" "icon footer actions"',+ 'grid-template-columns': 'var(--user-icon-width) minmax(0, 1fr)',+ 'grid-template-areas': '"icon header" "icon content" "icon footer"',}}><div class="contents">{local.children}</div>diff --git a/js/app/packages/channel/Message/Timestamp.tsx b/js/app/packages/channel/Message/Timestamp.tsxindex 69e1da1f18..4c0bc05cb4 100644--- a/js/app/packages/channel/Message/Timestamp.tsx+++ b/js/app/packages/channel/Message/Timestamp.tsx@@ -1,10 +1,13 @@import { cn } from '@ui/utils/classname';-import { formatDate } from '@core/util/date';+import { formatDate, formatTime } from '@core/util/date';import { useMessage } from './context';+import { Match, Switch } from 'solid-js';+import { isMobileWidth } from '@core/mobile/mobileWidth';type TimestampProps = {class?: string;compact?: boolean;+ format?: 'dateAndTime' | 'time';};export function Timestamp(props: TimestampProps) {@@ -18,7 +21,17 @@ export function Timestamp(props: TimestampProps) {props.class)}>- {formatDate(message().created_at)}+ <Switch>+ <Match when={props.format === 'time'}>+ {formatTime(message().created_at)}+ </Match>+ <Match when={props.format === 'dateAndTime' || true}>+ {formatDate(message().created_at, {+ showTime: true,+ shortWeekday: isMobileWidth(),+ })}+ </Match>+ </Switch></span>);}diff --git a/js/app/packages/core/util/date.ts b/js/app/packages/core/util/date.tsindex 85388fd9fe..46a513be11 100644--- a/js/app/packages/core/util/date.ts+++ b/js/app/packages/core/util/date.ts@@ -18,8 +18,29 @@ export interface FormatDateOptions {timeZone?: string;/** If true, always include time in the output (e.g., 'Thursday at 4:53 PM' instead of 'Thursday'). */showTime?: boolean;+ /** If true, use short weekday names (e.g., 'Wed' instead of 'Wednesday'). */+ shortWeekday?: boolean;}+/**+ * Formats a date to just the time, e.g. '4:53 PM'.+ * @param date - Date object or RFC3339 string+ * @param timeZone - IANA timezone string. Defaults to system timezone.+ */+export const formatTime = (+ date: DateValue | null | undefined,+ timeZone?: string+): string => {+ if (!date) return '';+ const d = date instanceof Date ? date : toDate(date);+ return d.toLocaleTimeString('en-US', {+ hour: 'numeric',+ minute: '2-digit',+ hour12: true,+ timeZone,+ });+};+/*** Formats a date to a human readable string.* @param date - Date object or Unix timestamp in seconds@@ -33,28 +54,23 @@ export const formatDate = () => {if (!date) return '';const d = date instanceof Date ? date : toDate(date);- const { timeZone, showTime } = options ?? {};+ const { timeZone, showTime, shortWeekday } = options ?? {};const timeZoneOpts = timeZone ? { in: tz(timeZone) } : {};const now = new Date();- const time = d.toLocaleTimeString('en-US', {- hour: 'numeric',- minute: '2-digit',- hour12: true,- timeZone,- });+ const time = formatTime(date, timeZone);if (isToday(date, timeZoneOpts)) {return time;}if (isYesterday(date, timeZoneOpts)) {- return `Yesterday at ${time}`;+ return `${shortWeekday ? 'Yest' : 'Yesterday'} at ${time}`;}if (differenceInWeeks(now, date) < 1) {const weekday = d.toLocaleDateString(undefined, {- weekday: 'long',+ weekday: shortWeekday ? 'short' : 'long',timeZone,});return showTime ? `${weekday} at ${time}` : weekday;