Merge pull request #1396 from guangyang1206/fix/shared-thread-timestamp-formatter-1376
Some checks failed
Build and Push Docker Images / tag_release (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64, production) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64, production) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_web, ./surfsense_web/Dockerfile, web, surfsense-web, ubuntu-24.04-arm, linux/arm64, arm64, runner) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_web, ./surfsense_web/Dockerfile, web, surfsense-web, ubuntu-latest, linux/amd64, amd64, runner) (push) Has been cancelled
Build and Push Docker Images / create_manifest (backend, surfsense-backend) (push) Has been cancelled
Build and Push Docker Images / create_manifest (web, surfsense-web) (push) Has been cancelled

feat(shared): extract formatThreadTimestamp helper for chats sidebars…
This commit is contained in:
Rohan Verma 2026-05-15 04:55:47 -07:00 committed by GitHub
commit eea2d68098
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 4 deletions

View file

@ -1,7 +1,7 @@
"use client";
import { useQuery, useQueryClient } from "@tanstack/react-query";
import { format } from "date-fns";
import { formatThreadTimestamp } from "@/lib/format-date";
import { useSetAtom } from "jotai";
import {
ArchiveIcon,
@ -390,7 +390,7 @@ export function AllPrivateChatsSidebarContent({
<TooltipContent side="bottom" align="start">
<p>
{t("updated") || "Updated"}:{" "}
{format(new Date(thread.updatedAt), "MMM d, yyyy 'at' h:mm a")}
{formatThreadTimestamp(thread.updatedAt)}
</p>
</TooltipContent>
</Tooltip>

View file

@ -1,7 +1,7 @@
"use client";
import { useQuery, useQueryClient } from "@tanstack/react-query";
import { format } from "date-fns";
import { formatThreadTimestamp } from "@/lib/format-date";
import { useSetAtom } from "jotai";
import {
ArchiveIcon,
@ -389,7 +389,7 @@ export function AllSharedChatsSidebarContent({
<TooltipContent side="bottom" align="start">
<p>
{t("updated") || "Updated"}:{" "}
{format(new Date(thread.updatedAt), "MMM d, yyyy 'at' h:mm a")}
{formatThreadTimestamp(thread.updatedAt)}
</p>
</TooltipContent>
</Tooltip>

View file

@ -22,3 +22,11 @@ export function formatRelativeDate(dateString: string): string {
if (daysAgo < 7) return `${daysAgo}d ago`;
return format(date, "MMM d, yyyy");
}
/**
* Format a thread's last-updated timestamp for the chats sidebars.
* Example: "Mar 23, 2026 at 4:30 PM"
*/
export function formatThreadTimestamp(dateString: string): string {
return format(new Date(dateString), "MMM d, yyyy 'at' h:mm a");
}