Add ollama dependency and dialog backdrop blur

- Add ollama package to web-ui dependencies for ModelSelector
- Add backdrop blur to SettingsDialog (bg-black/50 backdrop-blur-sm)
- Update mini-lit to 0.1.9 for backdropClassName prop support
- Fix TypeScript errors in ModelSelector (ollama import, parameter types)
- Add backward compatibility methods to SessionsStore (saveSession, loadSession, getLatestSessionId)
This commit is contained in:
Mario Zechner 2025-10-08 17:49:56 +02:00
parent db34ef01bf
commit 91c1dc6475
10 changed files with 133 additions and 70 deletions

View file

@ -17,7 +17,7 @@ export class IndexedDBStorageBackend implements StorageBackend {
request.onerror = () => reject(request.error);
request.onsuccess = () => resolve(request.result);
request.onupgradeneeded = (event) => {
request.onupgradeneeded = (_event) => {
const db = request.result;
// Create object stores from config
@ -145,7 +145,7 @@ export class IndexedDBStorageBackend implements StorageBackend {
}
async getQuotaInfo(): Promise<{ usage: number; quota: number; percent: number }> {
if (navigator.storage && navigator.storage.estimate) {
if (navigator.storage?.estimate) {
const estimate = await navigator.storage.estimate();
return {
usage: estimate.usage || 0,
@ -157,7 +157,7 @@ export class IndexedDBStorageBackend implements StorageBackend {
}
async requestPersistence(): Promise<boolean> {
if (navigator.storage && navigator.storage.persist) {
if (navigator.storage?.persist) {
return await navigator.storage.persist();
}
return false;

View file

@ -83,4 +83,51 @@ export class SessionsStore extends Store {
async requestPersistence(): Promise<boolean> {
return this.getBackend().requestPersistence();
}
// Alias methods for backward compatibility
async saveSession(id: string, state: any, metadata: SessionMetadata | undefined, title?: string): Promise<void> {
// If metadata is provided, use it; otherwise create it from state
const meta: SessionMetadata = metadata || {
id,
title: title || "",
createdAt: new Date().toISOString(),
lastModified: new Date().toISOString(),
messageCount: state.messages?.length || 0,
usage: state.usage || {
input: 0,
output: 0,
cacheRead: 0,
cacheWrite: 0,
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
},
modelId: state.model?.id || null,
thinkingLevel: state.thinkingLevel || "off",
preview: "",
};
const data: SessionData = {
id,
title: title || meta.title,
model: state.model,
thinkingLevel: state.thinkingLevel,
messages: state.messages || [],
createdAt: meta.createdAt,
lastModified: new Date().toISOString(),
};
await this.save(data, meta);
}
async loadSession(id: string): Promise<SessionData | null> {
return this.get(id);
}
async getLatestSessionId(): Promise<string | null> {
const allMetadata = await this.getAllMetadata();
if (allMetadata.length === 0) return null;
// Sort by lastModified descending
allMetadata.sort((a, b) => b.lastModified.localeCompare(a.lastModified));
return allMetadata[0].id;
}
}