blob: f11910315bbd5a45c990b18afd9a9531268977cc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
<script lang="ts">
/**
* The `settings` view — FE-local settings (the chat limit). Not
* conversation-scoped (no {#key}: the chat limit is global). A chat-limit
* RAISE refills the active chat (prepends older history) — the reader's
* viewport is preserved over the prepend via the chat viewport bridge
* (exactly like today's saveChatLimit).
*/
import { tick } from "svelte";
import { ChatLimitField, type ChatLimitSaveResult } from "../../features/settings";
import { SearchBackendField } from "../../features/search-settings";
import type { AppViewPorts } from "../view-ports";
let { ports }: { ports: AppViewPorts } = $props();
const store = $derived(ports.store);
async function saveChatLimit(value: number): Promise<ChatLimitSaveResult> {
const el = ports.chatViewport.el;
const prevHeight = el?.scrollHeight ?? 0;
const prevTop = el?.scrollTop ?? 0;
const result = await store.setChatLimit(value);
await tick();
if (el) {
const delta = el.scrollHeight - prevHeight;
if (delta > 0) el.scrollTop = prevTop + delta;
}
return result.ok
? { ok: true, chatLimit: result.chatLimit }
: { ok: false, error: result.error };
}
</script>
<div class="flex flex-col gap-3">
<ChatLimitField chatLimit={store.chatLimit} save={saveChatLimit} />
<SearchBackendField
load={() => store.searchBackendConfig()}
save={(backend) => store.setSearchBackend(backend)}
/>
</div>
|