git list refactor
This commit is contained in:
@@ -56,6 +56,7 @@
|
||||
cancelAssistantOperation,
|
||||
getAssistantHistory,
|
||||
getAssistantConversations,
|
||||
deleteAssistantConversation,
|
||||
} from "$lib/api/assistant.js";
|
||||
import { api } from "$lib/api.js";
|
||||
import { gitService } from "../../../services/gitService.js";
|
||||
@@ -175,6 +176,32 @@
|
||||
}
|
||||
// [/DEF:loadConversations:Function]
|
||||
|
||||
// [DEF:removeConversation:Function]
|
||||
// @PURPOSE: Removes a conversation from the list and deletes it from the backend.
|
||||
// @PRE: conversationId string is provided.
|
||||
// @POST: It is soft-deleted from the API and removed from local UI. If active, reset state.
|
||||
async function removeConversation(e, conversationIdTemp) {
|
||||
if (e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
}
|
||||
try {
|
||||
await deleteAssistantConversation(conversationIdTemp);
|
||||
conversations = conversations.filter(
|
||||
(c) => c.conversation_id !== conversationIdTemp,
|
||||
);
|
||||
if (conversationId === conversationIdTemp) {
|
||||
$assistantChatStore.conversationId = null;
|
||||
$assistantChatStore.messages = [];
|
||||
$assistantChatStore.state = "idle";
|
||||
}
|
||||
addToast("Conversation deleted", "success");
|
||||
} catch (err) {
|
||||
addToast("Failed to delete conversation: " + err.message, "error");
|
||||
}
|
||||
}
|
||||
// [/DEF:removeConversation:Function]
|
||||
|
||||
// [DEF:loadOlderMessages:Function]
|
||||
/**
|
||||
* @PURPOSE: Lazy-load older messages for active conversation when user scrolls to top.
|
||||
@@ -622,21 +649,30 @@
|
||||
</div>
|
||||
<div class="flex gap-2 overflow-x-auto pb-1">
|
||||
{#each conversations as convo (convo.conversation_id)}
|
||||
<button
|
||||
class="min-w-[140px] max-w-[220px] rounded-lg border px-2.5 py-1.5 text-left text-xs transition {convo.conversation_id ===
|
||||
conversationId
|
||||
? 'border-sky-300 bg-sky-50 text-sky-900'
|
||||
: 'border-slate-200 bg-white text-slate-700 hover:bg-slate-50'}"
|
||||
on:click={() => selectConversation(convo)}
|
||||
title={formatConversationTime(convo.updated_at)}
|
||||
>
|
||||
<div class="truncate font-semibold">
|
||||
{buildConversationTitle(convo)}
|
||||
</div>
|
||||
<div class="truncate text-[10px] text-slate-500">
|
||||
{convo.last_message || ""}
|
||||
</div>
|
||||
</button>
|
||||
<div class="relative group min-w-[140px] max-w-[220px]">
|
||||
<button
|
||||
class="w-full rounded-lg border px-2.5 py-1.5 text-left text-xs transition {convo.conversation_id ===
|
||||
conversationId
|
||||
? 'border-sky-300 bg-sky-50 text-sky-900'
|
||||
: 'border-slate-200 bg-white text-slate-700 hover:bg-slate-50'}"
|
||||
on:click={() => selectConversation(convo)}
|
||||
title={formatConversationTime(convo.updated_at)}
|
||||
>
|
||||
<div class="truncate font-semibold pr-4">
|
||||
{buildConversationTitle(convo)}
|
||||
</div>
|
||||
<div class="truncate text-[10px] text-slate-500 pr-4">
|
||||
{convo.last_message || ""}
|
||||
</div>
|
||||
</button>
|
||||
<button
|
||||
class="absolute right-1.5 top-1.5 hidden group-hover:block p-1 text-slate-400 hover:text-red-500 rounded bg-white/80 hover:bg-red-50"
|
||||
on:click={(e) => removeConversation(e, convo.conversation_id)}
|
||||
title="Удалить диалог"
|
||||
>
|
||||
<Icon name="trash" size={12} />
|
||||
</button>
|
||||
</div>
|
||||
{/each}
|
||||
{#if loadingConversations}
|
||||
<div
|
||||
|
||||
Reference in New Issue
Block a user