+ {shortTime && fullTime && typeof timestamp === "number" ? (
+
+
+
+
+
+ {fullTime}
+
+
+ ) : null}
- {linksShown && links.length > 0 ? { setLinksShown(false); contentRef.current?.focus({ preventScroll: true }); }}
- onClose={() => onOpenChange(false)} /> : 0 ? () => setLinksShown(true) : undefined}
- />}
+ {actions}
);
}
const ThreadDisplayUnit = memo(function ThreadDisplayUnit({
+ mobileActions,
unitKey,
unit,
marginTop,
@@ -579,6 +633,7 @@ const ThreadDisplayUnit = memo(function ThreadDisplayUnit({
]);
const blockMenu = unit.type === "message" && contextBlockKey !== undefined ? (
- {unit.message.role === "assistant" ? blockMenu : null}
+ {unit.message.role === "assistant" && !mobileActions ? blockMenu : null}
{showBlockContext && blockActivity ? (
+ {mobileActions ? blockMenu : null}
{unit.message.role === "assistant"
&& unit.message.kind !== "compaction"
&& contextBlockKey === undefined ? (
@@ -702,6 +758,7 @@ function threadDisplayUnitPropsEqual(
): boolean {
return (
displayUnitsEqual(previous.unit, next.unit)
+ && previous.mobileActions === next.mobileActions
&& previous.marginTop === next.marginTop
&& previous.userPromptId === next.userPromptId
&& previous.hasBodyBelow === next.hasBodyBelow
diff --git a/webui/src/components/ui/dialog.tsx b/webui/src/components/ui/dialog.tsx
index 7e8b8f8a8..02773a88d 100644
--- a/webui/src/components/ui/dialog.tsx
+++ b/webui/src/components/ui/dialog.tsx
@@ -38,9 +38,10 @@ const DialogPositionedContent = React.forwardRef<
React.ElementRef
,
React.ComponentPropsWithoutRef & {
positionerStyle?: React.CSSProperties;
+ placement?: "center" | "bottom";
}
->(({ positionerStyle, ...props }, ref) => (
-
+>(({ positionerStyle, placement, ...props }, ref) => (
+
));
@@ -50,19 +51,20 @@ interface DialogContentProps
extends React.ComponentPropsWithoutRef
{
showCloseButton?: boolean;
overlayClassName?: string;
+ placement?: "center" | "bottom";
}
const DialogContent = React.forwardRef<
React.ElementRef,
DialogContentProps
->(({ className, children, showCloseButton = true, overlayClassName, onOpenAutoFocus, ...props }, ref) => {
+>(({ className, children, showCloseButton = true, overlayClassName, placement = "center", onOpenAutoFocus, ...props }, ref) => {
const { t } = useTranslation();
const [container, setContainer] = React.useState(null);
const contentNode = React.useRef(null);
const layoutAnchor = React.useContext(DialogLayoutContext);
const [layout, setLayout] = React.useState();
React.useLayoutEffect(() => {
- if (!layoutAnchor) {
+ if (!layoutAnchor || placement === "bottom") {
setLayout(undefined);
return;
}
@@ -81,7 +83,7 @@ const DialogContent = React.forwardRef<
observer?.disconnect();
window.removeEventListener("resize", update);
};
- }, [layoutAnchor]);
+ }, [layoutAnchor, placement]);
const contentRef = React.useCallback((node: HTMLDivElement | null) => {
contentNode.current = node;
setContainer(node);
@@ -93,6 +95,7 @@ const DialogContent = React.forwardRef<
{
if (onOpenAutoFocus) onOpenAutoFocus(event);
@@ -103,7 +106,10 @@ const DialogContent = React.forwardRef<
}}
className={cn(
modalSurfaceClassName,
- "relative grid w-full max-w-lg origin-center gap-4 rounded-modal p-6 duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 motion-reduce:animate-none",
+ "relative grid w-full max-w-lg gap-4 p-6 duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 motion-reduce:animate-none",
+ placement === "bottom"
+ ? "max-h-[85dvh] overflow-y-auto overscroll-contain rounded-t-modal pb-[max(1rem,env(safe-area-inset-bottom))] data-[state=open]:slide-in-from-bottom-4 data-[state=closed]:slide-out-to-bottom-4"
+ : "origin-center rounded-modal data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",
className,
)}
{...props}
@@ -112,7 +118,7 @@ const DialogContent = React.forwardRef<
{children}
{showCloseButton ? (
-
+
{t("common.close")}
diff --git a/webui/src/globals.css b/webui/src/globals.css
index 642cf4fde..a14a7607c 100644
--- a/webui/src/globals.css
+++ b/webui/src/globals.css
@@ -805,7 +805,8 @@
padding-inline-end: max(0.75rem, calc((100% - var(--content-column-width)) / 2));
}
-.message-block-menu-trigger {
+.message-block-menu-trigger,
+.message-block-hover-time {
pointer-events: none;
opacity: 0;
}
@@ -815,9 +816,16 @@
top: calc((1rem + 28px - var(--message-block-control-size)) / 2);
}
+[data-user-text-bubble] > .message-block-hover-time {
+ top: calc((1rem + 28px + var(--message-block-control-size)) / 2);
+}
+
[data-context-block-active] .message-block-menu-trigger,
[data-message-context-menu-open] .message-block-menu-trigger,
-.message-block-menu-trigger:focus-visible {
+.message-block-menu-trigger:focus-visible,
+[data-context-block-active] .message-block-hover-time,
+[data-message-context-menu-open] .message-block-hover-time,
+.message-block-hover-time:focus-visible {
pointer-events: auto;
opacity: 1;
}
@@ -859,6 +867,19 @@
}
}
+/* On phones, actions follow the message instead of taking a separate gutter. */
+@media (max-width: 767px) {
+ .thread-message-row {
+ padding-inline: 1rem;
+ }
+
+ [data-message-mobile-actions],
+ [data-message-mobile-sheet] {
+ --message-block-control-size: 2.75rem;
+ --message-block-action-width: 2.75rem;
+ }
+}
+
/*
* Composer controls adapt to their actual container, not just the viewport.
* Narrow layouts move access and usage into a separate metadata row.
diff --git a/webui/src/lib/format.ts b/webui/src/lib/format.ts
index 6e2abedaa..29f8e19d0 100644
--- a/webui/src/lib/format.ts
+++ b/webui/src/lib/format.ts
@@ -83,6 +83,7 @@ const RELATIVE_THRESHOLDS: [number, Intl.RelativeTimeFormatUnit][] = [
const relativeTimeFormatters = new Map();
const dateTimeFormatters = new Map();
const clockTimeFormatters = new Map();
+const hoverTimeFormatters = new Map();
function activeLocale(locale?: string): string {
return locale || i18n.resolvedLanguage || i18n.language || currentLocale();
@@ -167,6 +168,27 @@ export function formatMessageEndTime(
: dateTimeFormatter(loc).format(date);
}
+/** One-line gutter label; the full local date/time belongs in its tooltip. */
+export function formatMessageHoverTime(
+ value: number | null | undefined,
+ locale?: string,
+ now = new Date(),
+): string {
+ const date = parseDate(value);
+ if (!date) return "";
+ const loc = activeLocale(locale);
+ const today = isSameLocalCalendarDay(date, now);
+ const key = `${loc}:${today ? "clock" : "date"}`;
+ let formatter = hoverTimeFormatters.get(key);
+ if (!formatter) {
+ formatter = new Intl.DateTimeFormat(loc, today
+ ? { hour: "2-digit", minute: "2-digit", hourCycle: "h23" }
+ : { month: "numeric", day: "numeric" });
+ hoverTimeFormatters.set(key, formatter);
+ }
+ return formatter.format(date);
+}
+
/** Human-readable turn duration (wall-clock), locale-aware via ``Intl`` (seconds/minutes). */
export function formatTurnLatency(ms: number, locale?: string): string {
const loc = activeLocale(locale);
diff --git a/webui/src/tests/format.i18n.test.ts b/webui/src/tests/format.i18n.test.ts
index a79e1b5d4..9b09078ba 100644
--- a/webui/src/tests/format.i18n.test.ts
+++ b/webui/src/tests/format.i18n.test.ts
@@ -4,6 +4,7 @@ import { setAppLanguage } from "@/i18n";
import {
fmtDateTime,
formatMessageEndTime,
+ formatMessageHoverTime,
formatTurnLatency,
relativeTime,
} from "@/lib/format";
@@ -112,4 +113,31 @@ describe("localized format helpers", () => {
expect(minutePlus).toContain("m");
expect(minutePlus).toContain("s");
});
+
+ it("uses a short 24-hour clock today and localized month/day for every other date", () => {
+ const now = new Date(2026, 8, 24, 16, 0);
+ expect(formatMessageHoverTime(new Date(2026, 8, 24, 14, 32).getTime(), "zh-CN", now)).toBe("14:32");
+ expect(formatMessageHoverTime(new Date(2026, 8, 24, 0, 5).getTime(), "en", now)).toBe("00:05");
+ expect(formatMessageHoverTime(new Date(2026, 8, 23, 14, 32).getTime(), "zh-CN", now)).toBe("9/23");
+ expect(formatMessageHoverTime(new Date(2026, 8, 23).getTime(), "fr", now)).toBe(
+ new Intl.DateTimeFormat("fr", { month: "numeric", day: "numeric" }).format(new Date(2026, 8, 23)),
+ );
+ expect(formatMessageHoverTime(new Date(2025, 8, 22).getTime(), "zh-CN", now)).toBe("9/22");
+ expect(formatMessageHoverTime(new Date(2026, 8, 25).getTime(), "zh-CN", now)).toBe("9/25");
+ });
+
+ it.each([
+ [new Date(2026, 0, 1, 0, 30), new Date(2025, 11, 31, 23, 55)],
+ [new Date(2026, 2, 1, 0, 30), new Date(2026, 1, 28, 23, 55)],
+ [new Date(2026, 2, 9, 0, 30), new Date(2026, 2, 8, 0, 15)],
+ [new Date(2026, 10, 2, 0, 30), new Date(2026, 10, 1, 23, 55)],
+ ])("compares local calendar days across month/year and DST boundaries (%s)", (now, previousDay) => {
+ expect(formatMessageHoverTime(previousDay.getTime(), "en", now)).toBe(
+ new Intl.DateTimeFormat("en", { month: "numeric", day: "numeric" }).format(previousDay),
+ );
+ });
+
+ it.each([null, undefined, NaN, Infinity, 9e15])("omits invalid hover time %s", (value) => {
+ expect(formatMessageHoverTime(value)).toBe("");
+ });
});
diff --git a/webui/src/tests/message-hover-time.test.tsx b/webui/src/tests/message-hover-time.test.tsx
new file mode 100644
index 000000000..8d4db53b3
--- /dev/null
+++ b/webui/src/tests/message-hover-time.test.tsx
@@ -0,0 +1,56 @@
+import { cleanup, fireEvent, render, screen } from "@testing-library/react";
+import { afterEach, describe, expect, it, vi } from "vitest";
+import { ThreadMessages } from "@/components/thread/ThreadMessages";
+import { fmtDateTime } from "@/lib/format";
+
+vi.mock("@/components/MarkdownText", () => ({ MarkdownText: ({ content }: { content: string }) => {content}
}));
+afterEach(() => { cleanup(); vi.useRealTimers(); });
+
+describe("desktop hover timestamp", () => {
+ it("uses user creation / assistant completion time and exposes the full date on keyboard focus", async () => {
+ vi.useFakeTimers({ toFake: ["Date"] });
+ vi.setSystemTime(new Date(2026, 8, 24, 16));
+ const createdAt = new Date(2026, 8, 23, 12).getTime();
+ const completedAt = new Date(2026, 8, 24, 14, 32).getTime();
+ const { container } = render();
+ const times = container.querySelectorAll("[data-message-hover-time]");
+ expect(times).toHaveLength(2);
+ expect(times[0]).toHaveTextContent("9/23");
+ expect(times[1]).toHaveTextContent("14:32");
+ expect(times[1]).toHaveAttribute("datetime", new Date(completedAt).toISOString());
+ expect(times[1]).toHaveAttribute("aria-label", fmtDateTime(completedAt));
+ fireEvent.focus(times[1]);
+ expect(await screen.findByRole("tooltip")).toHaveTextContent(fmtDateTime(completedAt));
+ expect(times[1].closest("[data-thread-display-unit]")).toHaveAttribute("data-context-block-active");
+ });
+
+ it("refreshes the short date when hovering again after midnight", () => {
+ vi.useFakeTimers({ toFake: ["Date"] });
+ const createdAt = new Date(2026, 11, 31, 23, 30).getTime();
+ vi.setSystemTime(new Date(2026, 11, 31, 23, 50));
+ const { container } = render();
+ const time = container.querySelector("[data-message-hover-time]")!;
+ const row = time.closest("[data-thread-display-unit]")!;
+ fireEvent.pointerEnter(row, { pointerType: "mouse" });
+ expect(time).toHaveTextContent("23:30");
+ fireEvent.pointerLeave(row, { pointerType: "mouse", relatedTarget: document.body });
+ vi.setSystemTime(new Date(2027, 0, 1, 0, 10));
+ fireEvent.pointerEnter(row, { pointerType: "mouse" });
+ expect(time).toHaveTextContent("12/31");
+ });
+
+ it("falls back to creation time and omits invalid timestamps", () => {
+ vi.useFakeTimers({ toFake: ["Date"] });
+ vi.setSystemTime(new Date(2026, 8, 24, 16));
+ const { container } = render();
+ const times = container.querySelectorAll("[data-message-hover-time]");
+ expect(times).toHaveLength(1);
+ expect(times[0]).toHaveTextContent("9/22");
+ });
+});
diff --git a/webui/src/tests/message-links-menu.test.tsx b/webui/src/tests/message-links-menu.test.tsx
index 77a74a706..77f65efee 100644
--- a/webui/src/tests/message-links-menu.test.tsx
+++ b/webui/src/tests/message-links-menu.test.tsx
@@ -7,7 +7,7 @@ import { useMessageWebLinks } from "@/components/MessageLinksMenu";
import { copyTextToClipboard } from "@/lib/clipboard";
vi.mock("@/lib/clipboard", () => ({ copyTextToClipboard: vi.fn(async () => true) }));
-afterEach(() => { cleanup(); vi.mocked(copyTextToClipboard).mockReset().mockResolvedValue(true); });
+afterEach(() => { cleanup(); vi.unstubAllGlobals(); vi.mocked(copyTextToClipboard).mockReset().mockResolvedValue(true); });
function view(content: string, openPreview?: (url: string) => void) {
return
@@ -22,6 +22,76 @@ async function openLinks() {
}
describe("message link actions", () => {
+ function mobileViewport() {
+ const listeners = new Set<() => void>();
+ let narrow = true;
+ vi.stubGlobal("matchMedia", vi.fn((query: string) => ({
+ get matches() { return query === "(max-width: 767px)" && narrow; },
+ media: query,
+ addEventListener: (_event: string, listener: () => void) => listeners.add(listener),
+ removeEventListener: (_event: string, listener: () => void) => listeners.delete(listener),
+ })));
+ return (value: boolean) => act(() => { narrow = value; listeners.forEach(listener => listener()); });
+ }
+
+ it("puts mobile actions after the reply and opens one bottom sheet with working back, copy and preview", async () => {
+ mobileViewport();
+ const preview = vi.fn();
+ const content = "[Website](https://example.com/demo)";
+ const { container } = render(view(content, preview));
+ const link = await screen.findByRole("link", { name: /Website/ });
+ const footer = container.querySelector("[data-message-mobile-actions]")!;
+ expect(link.compareDocumentPosition(footer) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
+ expect(container.querySelector(".message-block-menu-trigger")).not.toBeInTheDocument();
+ expect(container.querySelector("[data-message-hover-time]")).not.toBeInTheDocument();
+ fireEvent.click(within(footer as HTMLElement).getByRole("button", { name: "Copy" }));
+ await waitFor(() => expect(copyTextToClipboard).toHaveBeenCalledWith(content));
+ const menu = await openLinks();
+ expect(menu).toHaveAttribute("data-message-mobile-sheet");
+ expect(screen.getAllByRole("dialog")).toHaveLength(1);
+ fireEvent.click(within(menu).getByRole("button", { name: "Back" }));
+ expect(within(menu).queryByRole("button", { name: "Copy" })).not.toBeInTheDocument();
+ fireEvent.click(within(menu).getByRole("button", { name: "Close" }));
+ await waitFor(() => expect(screen.queryByRole("dialog")).not.toBeInTheDocument());
+ expect(screen.getByRole("button", { name: "Message actions" })).toHaveFocus();
+ await openLinks();
+ fireEvent.click(screen.getByRole("button", { name: "Preview website" }));
+ expect(preview).toHaveBeenCalledWith("https://example.com/demo");
+ await waitFor(() => expect(screen.queryByRole("dialog")).not.toBeInTheDocument());
+ });
+
+ it("restores the desktop menu on resize without duplicating actions", async () => {
+ const resize = mobileViewport();
+ const { container } = render(view("[Website](https://example.com/demo)"));
+ await screen.findByRole("link", { name: /Website/ });
+ await openLinks();
+ resize(false);
+ await waitFor(() => expect(container.querySelector("[data-message-mobile-actions]")).not.toBeInTheDocument());
+ expect(screen.queryByRole("dialog")).not.toHaveAttribute("data-message-mobile-sheet");
+ expect(screen.getAllByRole("button", { name: "Message actions" })).toHaveLength(1);
+ // Resizing may close the modal as focus is returned; either way its trigger stays usable.
+ if (!screen.queryByRole("dialog")) fireEvent.click(screen.getByRole("button", { name: "Message actions" }));
+ expect(screen.getAllByRole("dialog")).toHaveLength(1);
+ });
+
+ it("keeps user actions outside the bubble and exposes a labelled mobile fork action", async () => {
+ mobileViewport();
+ const fork = vi.fn();
+ const { container } = render();
+ await screen.findByText("A reply");
+ expect(container.querySelector("[data-user-text-bubble] [data-message-block-menu-trigger]")).toBeNull();
+ expect(container.querySelectorAll("[data-message-mobile-actions]")).toHaveLength(2);
+ fireEvent.click(screen.getAllByRole("button", { name: "Message actions" })[1]);
+ const menu = screen.getByRole("dialog");
+ expect(within(menu).getByRole("button", { name: "Fork" })).toHaveTextContent("Fork");
+ fireEvent.click(within(menu).getByRole("button", { name: "Fork" }));
+ expect(fork).toHaveBeenCalledWith(1);
+ await waitFor(() => expect(screen.queryByRole("dialog")).not.toBeInTheDocument());
+ });
+
it("collects rendered links, deduplicates destinations and ignores code, images and file references", async () => {
render(view("[First](https://example.com/) and [Again](https://example.com).\n\n[Second](https://example.org/demo)\n\nhttps://example.net/plain\n\n`https://code.invalid/inline`\n\n```text\nhttps://code.invalid/block\n```\n\n\n\n[notes.txt](notes.txt)"));
await screen.findByRole("link", { name: "First" });