diff --git a/frontend/src/app/page.tsx b/frontend/src/app/page.tsx index e6452ecd..c22b3a92 100644 --- a/frontend/src/app/page.tsx +++ b/frontend/src/app/page.tsx @@ -55,7 +55,6 @@ export default function HomePage() { const { user, loading } = useAuth(); const router = useRouter(); const [hallOfFameOpen, setHallOfFameOpen] = useState(false); - const [maintenanceVisible, setMaintenanceVisible] = useState(true); const docsUrl = (process.env.NEXT_PUBLIC_API_URL || "https://param20h-pdf-assit-rag.hf.space") + "/docs"; @@ -283,28 +282,6 @@ export default function HomePage() { {/* Floating open-source badge */} setHallOfFameOpen(true)} /> - - {/* Maintenance Pop-up Banner */} - {maintenanceVisible && ( -
-
-
- -

System Maintenance

-
- -
-

- We are currently running database updates. Some features may be temporarily offline, but the app will be fully live soon! -

-
- )} ); } diff --git a/frontend/src/components/chat/MessageBubble.tsx b/frontend/src/components/chat/MessageBubble.tsx index b3710276..2460a2ba 100644 --- a/frontend/src/components/chat/MessageBubble.tsx +++ b/frontend/src/components/chat/MessageBubble.tsx @@ -73,6 +73,28 @@ const markdownComponents: Components = { }, }; +/** + * Extracts a valid Date from a message. + * + * History messages from the DB have real UUIDs as IDs — + * splitting on "-" and parsing as a number gives NaN. + * We use `created_at` (returned by the history API) when + * available, and fall back to the synthetic ID-based + * timestamp only for streamed messages (format: role-timestamp). + */ +const getMessageDate = (message: ChatMsg): Date | null => { + if (message.created_at) { + const d = new Date(message.created_at); + if (!isNaN(d.getTime())) return d; + } + const parts = message.id.split("-"); + if (parts.length >= 2) { + const ts = Number(parts[1]); + if (!isNaN(ts) && ts > 0) return new Date(ts); + } + return null; +}; + export default function MessageBubble({ message }: Props) { const isUser = message.role === "user"; const [copied, setCopied] = useState(false); @@ -109,6 +131,8 @@ export default function MessageBubble({ message }: Props) { large: "text-base", }[activeFontSize]; + const messageDate = getMessageDate(message); + const handleCopy = async () => { if (!message.content) return; try { @@ -177,7 +201,6 @@ export default function MessageBubble({ message }: Props) { const handleBranch = () => { setCurrentBranchId(message.id); - console.log("Branch created from:", message.id); }; @@ -355,13 +378,11 @@ export default function MessageBubble({ message }: Props) { isUser ? "justify-end" : "justify-start" }`} > -
- {formatDistanceToNow(new Date(Number(message.id.split("-")[1])), { - addSuffix: true, - })} -
+ {messageDate && ( +
+ {formatDistanceToNow(messageDate, { addSuffix: true })} +
+ )} {!isUser && message.response_time_ms && ( ⚡ {(message.response_time_ms / 1000).toFixed(1)}s @@ -369,6 +390,7 @@ export default function MessageBubble({ message }: Props) { )} + {isUser && (
diff --git a/frontend/src/store/chat-store.ts b/frontend/src/store/chat-store.ts index 25097890..a1eccd12 100644 --- a/frontend/src/store/chat-store.ts +++ b/frontend/src/store/chat-store.ts @@ -30,6 +30,7 @@ export interface ChatMsg { feedback?: "up" | "down" | null; isStreaming?: boolean; response_time_ms?: number; + created_at?: string; } export interface ChatSession { @@ -93,7 +94,9 @@ export const useChatStore = create((set, get) => ({ }, setIsTyping(value) { - set((state) => ({ isTyping: resolveValue(value, state.isTyping) })); + set((state) => ({ + isTyping: resolveValue(value, state.isTyping), + })); }, setHistoryLoading(value) {