This commit is contained in:
Tim Baek
2026-02-08 03:39:29 +04:00
parent 4fa6123c04
commit 691a04f0dd
3 changed files with 30 additions and 2 deletions

View File

@@ -1244,6 +1244,7 @@
className=""
id={chat.id}
title={chat.title}
updatedAt={chat.updated_at}
{shiftKey}
selected={selectedChatId === chat.id}
on:select={() => {
@@ -1304,6 +1305,7 @@
className=""
id={chat.id}
title={chat.title}
updatedAt={chat.updated_at}
{shiftKey}
selected={selectedChatId === chat.id}
on:select={() => {

View File

@@ -47,12 +47,30 @@
export let id;
export let title;
export let updatedAt: number | null = null;
export let selected = false;
export let shiftKey = false;
export let onDragEnd = () => {};
function formatTimeAgo(timestamp: number): string {
const now = Date.now();
const diff = now - timestamp * 1000; // timestamp is in seconds
const seconds = Math.floor(diff / 1000);
const minutes = Math.floor(seconds / 60);
const hours = Math.floor(minutes / 60);
const days = Math.floor(hours / 24);
const weeks = Math.floor(days / 7);
if (weeks > 0) return `${weeks}w`;
if (days > 0) return `${days}d`;
if (hours > 0) return `${hours}h`;
if (minutes > 0) return `${minutes}m`;
return 'now';
}
let chat = null;
let mouseOver = false;
@@ -423,11 +441,18 @@
on:focus={(e) => {}}
draggable="false"
>
<div class=" flex self-center flex-1 w-full">
<div dir="auto" class=" text-left self-center overflow-hidden w-full h-[20px] truncate">
<div class="flex self-center flex-1 w-full min-w-0">
<div dir="auto" class="text-left self-center overflow-hidden w-full h-[20px] truncate">
{title}
</div>
</div>
<!-- Time ago indicator -->
{#if updatedAt && !mouseOver}
<div class="shrink-0 self-center text-[10px] text-gray-400 dark:text-gray-500 pl-2">
{formatTimeAgo(updatedAt)}
</div>
{/if}
</a>
{/if}

View File

@@ -643,6 +643,7 @@
<ChatItem
id={chat.id}
title={chat.title}
updatedAt={chat.updated_at}
{shiftKey}
on:change={(e) => {
dispatch('change', e.detail);