Skip to content

Commit 1457f2d

Browse files
committed
refac
1 parent 1111a3a commit 1457f2d

4 files changed

Lines changed: 92 additions & 91 deletions

File tree

src/lib/components/chat/Chat.svelte

Lines changed: 80 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -3177,96 +3177,94 @@
31773177
</div>
31783178

31793179
{#if readOnly}
3180-
<div class="pb-6 z-10">
3181-
<div
3182-
class="text-xs text-gray-400 dark:text-gray-500 text-center"
3183-
>
3184-
{$i18n.t('Read only')}
3180+
<div class="pb-6 z-10">
3181+
<div class="text-xs text-gray-400 dark:text-gray-500 text-center">
3182+
{$i18n.t('Read only')}
3183+
</div>
31853184
</div>
3186-
</div>
3187-
{:else}
3188-
<div class=" pb-2 {dragged ? 'z-0' : 'z-10'}">
3189-
<MessageInput
3190-
bind:this={messageInput}
3191-
{history}
3192-
{taskIds}
3193-
{selectedModels}
3194-
bind:files
3195-
bind:prompt
3196-
bind:autoScroll
3197-
bind:selectedToolIds
3198-
bind:selectedSkillIds
3199-
bind:selectedFilterIds
3200-
bind:imageGenerationEnabled
3201-
bind:codeInterpreterEnabled
3202-
{pendingOAuthTools}
3203-
bind:webSearchEnabled
3204-
bind:atSelectedModel
3205-
bind:showCommands
3206-
bind:dragged
3207-
toolServers={$toolServers}
3208-
{generating}
3209-
{stopResponse}
3210-
{createMessagePair}
3211-
{onUpload}
3212-
messageQueue={$chatRequestQueues[$chatId] ?? []}
3213-
{chatTasks}
3214-
onQueueSendNow={async (id) => {
3215-
const queue = $chatRequestQueues[$chatId] ?? [];
3216-
const item = queue.find((m) => m.id === id);
3217-
if (item) {
3218-
// Remove from queue
3219-
chatRequestQueues.update((q) => ({
3220-
...q,
3221-
[$chatId]: queue.filter((m) => m.id !== id)
3222-
}));
3223-
await stopResponse(false);
3224-
await tick();
3225-
await submitPrompt(item.prompt, item.files);
3226-
}
3227-
}}
3228-
onQueueEdit={(id) => {
3229-
const queue = $chatRequestQueues[$chatId] ?? [];
3230-
const item = queue.find((m) => m.id === id);
3231-
if (item) {
3232-
// Remove from queue
3185+
{:else}
3186+
<div class=" pb-2 {dragged ? 'z-0' : 'z-10'}">
3187+
<MessageInput
3188+
bind:this={messageInput}
3189+
{history}
3190+
{taskIds}
3191+
{selectedModels}
3192+
bind:files
3193+
bind:prompt
3194+
bind:autoScroll
3195+
bind:selectedToolIds
3196+
bind:selectedSkillIds
3197+
bind:selectedFilterIds
3198+
bind:imageGenerationEnabled
3199+
bind:codeInterpreterEnabled
3200+
{pendingOAuthTools}
3201+
bind:webSearchEnabled
3202+
bind:atSelectedModel
3203+
bind:showCommands
3204+
bind:dragged
3205+
toolServers={$toolServers}
3206+
{generating}
3207+
{stopResponse}
3208+
{createMessagePair}
3209+
{onUpload}
3210+
messageQueue={$chatRequestQueues[$chatId] ?? []}
3211+
{chatTasks}
3212+
onQueueSendNow={async (id) => {
3213+
const queue = $chatRequestQueues[$chatId] ?? [];
3214+
const item = queue.find((m) => m.id === id);
3215+
if (item) {
3216+
// Remove from queue
3217+
chatRequestQueues.update((q) => ({
3218+
...q,
3219+
[$chatId]: queue.filter((m) => m.id !== id)
3220+
}));
3221+
await stopResponse(false);
3222+
await tick();
3223+
await submitPrompt(item.prompt, item.files);
3224+
}
3225+
}}
3226+
onQueueEdit={(id) => {
3227+
const queue = $chatRequestQueues[$chatId] ?? [];
3228+
const item = queue.find((m) => m.id === id);
3229+
if (item) {
3230+
// Remove from queue
3231+
chatRequestQueues.update((q) => ({
3232+
...q,
3233+
[$chatId]: queue.filter((m) => m.id !== id)
3234+
}));
3235+
// Set files and restore prompt to input
3236+
files = item.files;
3237+
messageInput?.setText(item.prompt);
3238+
}
3239+
}}
3240+
onQueueDelete={(id) => {
3241+
const queue = $chatRequestQueues[$chatId] ?? [];
32333242
chatRequestQueues.update((q) => ({
32343243
...q,
32353244
[$chatId]: queue.filter((m) => m.id !== id)
32363245
}));
3237-
// Set files and restore prompt to input
3238-
files = item.files;
3239-
messageInput?.setText(item.prompt);
3240-
}
3241-
}}
3242-
onQueueDelete={(id) => {
3243-
const queue = $chatRequestQueues[$chatId] ?? [];
3244-
chatRequestQueues.update((q) => ({
3245-
...q,
3246-
[$chatId]: queue.filter((m) => m.id !== id)
3247-
}));
3248-
}}
3249-
onChange={(data) => {
3250-
if (!$temporaryChatEnabled) {
3251-
saveDraft(data, $chatId);
3252-
}
3253-
}}
3254-
on:submit={async (e) => {
3255-
clearDraft($chatId);
3256-
if (e.detail || files.length > 0) {
3257-
await tick();
3246+
}}
3247+
onChange={(data) => {
3248+
if (!$temporaryChatEnabled) {
3249+
saveDraft(data, $chatId);
3250+
}
3251+
}}
3252+
on:submit={async (e) => {
3253+
clearDraft($chatId);
3254+
if (e.detail || files.length > 0) {
3255+
await tick();
32583256

3259-
submitHandler(e.detail);
3260-
}
3261-
}}
3262-
/>
3257+
submitHandler(e.detail);
3258+
}
3259+
}}
3260+
/>
32633261

3264-
<div
3265-
class="absolute bottom-1 text-xs text-gray-500 text-center line-clamp-1 right-0 left-0"
3266-
>
3267-
<!-- {$i18n.t('LLMs can make mistakes. Verify important information.')} -->
3262+
<div
3263+
class="absolute bottom-1 text-xs text-gray-500 text-center line-clamp-1 right-0 left-0"
3264+
>
3265+
<!-- {$i18n.t('LLMs can make mistakes. Verify important information.')} -->
3266+
</div>
32683267
</div>
3269-
</div>
32703268
{/if}
32713269
{:else}
32723270
<div class="flex items-center h-full">

src/lib/components/chat/Navbar.svelte

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,11 @@
123123
"
124124
>
125125
{#if showModelSelector}
126-
<ModelSelector bind:selectedModels showSetDefault={!shareEnabled && !readOnly} disabled={readOnly} />
126+
<ModelSelector
127+
bind:selectedModels
128+
showSetDefault={!shareEnabled && !readOnly}
129+
disabled={readOnly}
130+
/>
127131
{/if}
128132
</div>
129133

src/lib/components/chat/Placeholder/ChatList.svelte

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
let orderBy = 'updated_at';
5656
let direction = 'desc'; // 'asc' or 'desc'
5757
58-
5958
$: if (chats) {
6059
init();
6160
}

src/lib/components/chat/Placeholder/FolderPlaceholder.svelte

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,18 @@
3838
if (folder && folder.id) {
3939
// Always use the shared folder endpoint so owners also see
4040
// chats created by users who have write access to this folder.
41-
const res = await getSharedFolderChats(localStorage.token, folder.id).catch(
42-
(error) => {
43-
console.error(error);
44-
return null;
45-
}
46-
);
41+
const res = await getSharedFolderChats(localStorage.token, folder.id).catch((error) => {
42+
console.error(error);
43+
return null;
44+
});
4745
if (res && res.chats) {
4846
chats = res.chats;
4947
allChatsLoaded = true;
5048
} else {
5149
// Fallback to regular API (e.g. if user has no shared access)
52-
const fallback = await getChatListByFolderId(localStorage.token, folder.id, page).catch(() => []);
50+
const fallback = await getChatListByFolderId(localStorage.token, folder.id, page).catch(
51+
() => []
52+
);
5353
chats = fallback || [];
5454
}
5555
} else {

0 commit comments

Comments
 (0)