feat: @agor/stores package (3 stores) + 58 BackendAdapter tests

@agor/stores:
- theme.svelte.ts, notifications.svelte.ts, health.svelte.ts extracted
- Original files replaced with re-exports (zero consumer changes needed)
- pnpm workspace + Vite/tsconfig aliases configured

BackendAdapter tests (58 new):
- backend-adapter.test.ts: 9 tests (lifecycle, singleton, testing seam)
- tauri-adapter.test.ts: 28 tests (invoke mapping, command names, params)
- electrobun-adapter.test.ts: 21 tests (RPC names, capabilities, stubs)

Total: 523 tests passing (was 465, +58)
This commit is contained in:
Hibryda 2026-03-22 04:45:56 +01:00
parent 5e1fd62ed9
commit f0850f0785
22 changed files with 1389 additions and 25 deletions

View file

@ -2,6 +2,7 @@
import { onMount } from 'svelte';
import { appRpc } from '../rpc.ts';
import { PROVIDER_CAPABILITIES, type ProviderId } from '../provider-capabilities';
import { setRetentionConfig } from '../agent-store.svelte.ts';
const ANCHOR_SCALES = ['small', 'medium', 'large', 'full'] as const;
type AnchorScale = typeof ANCHOR_SCALES[number];
@ -34,6 +35,10 @@
let selectedId = $state('p1');
let proj = $derived(projects.find(p => p.id === selectedId)!);
// Feature 6: Retention settings
let sessionRetentionCount = $state(5);
let sessionRetentionDays = $state(30);
function updateProj(patch: Partial<ProjectConfig>) {
projects = projects.map(p => p.id === selectedId ? { ...p, ...patch } : p);
const updated = projects.find(p => p.id === selectedId)!;
@ -43,6 +48,17 @@
}).catch(console.error);
}
// Feature 6: Save retention settings
function updateRetention(key: string, value: number) {
if (key === 'count') sessionRetentionCount = value;
else sessionRetentionDays = value;
setRetentionConfig(sessionRetentionCount, sessionRetentionDays);
appRpc?.request['settings.set']({
key: key === 'count' ? 'session_retention_count' : 'session_retention_days',
value: String(value),
}).catch(console.error);
}
onMount(async () => {
if (!appRpc) return;
const res = await appRpc.request['settings.getProjects']({}).catch(() => ({ projects: [] }));
@ -52,6 +68,12 @@
});
if (loaded.length > 0) projects = loaded;
}
// Feature 6: Load retention settings
try {
const { settings } = await appRpc.request['settings.getAll']({});
if (settings['session_retention_count']) sessionRetentionCount = parseInt(settings['session_retention_count'], 10) || 5;
if (settings['session_retention_days']) sessionRetentionDays = parseInt(settings['session_retention_days'], 10) || 30;
} catch { /* use defaults */ }
});
</script>
@ -110,6 +132,23 @@
{/each}
</div>
<!-- Feature 6: Session retention controls -->
<h3 class="sh" style="margin-top: 0.625rem;">Session retention</h3>
<div class="slider-row">
<span class="lbl">Keep last</span>
<input type="range" min="1" max="20" step="1" value={sessionRetentionCount}
oninput={e => updateRetention('count', parseInt((e.target as HTMLInputElement).value, 10))}
/>
<span class="slider-val">{sessionRetentionCount}</span>
</div>
<div class="slider-row">
<span class="lbl">Max age</span>
<input type="range" min="1" max="90" step="1" value={sessionRetentionDays}
oninput={e => updateRetention('days', parseInt((e.target as HTMLInputElement).value, 10))}
/>
<span class="slider-val">{sessionRetentionDays}d</span>
</div>
<h3 class="sh" style="margin-top: 0.625rem;">Custom context</h3>
<textarea
class="prompt"