refactor: code review improvements — fix bugs, extract shared utilities, add README

- Fix reactivity bug: use SvelteMap instead of Map in sessions store
- Fix theme listener memory leak: guard against double-init, return cleanup function
- Fix transport singleton ignoring different endpoints
- Fix form/button type mismatch in MessageInput
- Add safer retry validation in chat page
- Extract shared utilities: date formatting, session config check, result source config
- Extract shared components: Backdrop, PageHeader
- Extract orchestration composable from chat page (310→85 lines of script)
- Consolidate AuditTimeline switch functions into config record
- Move sample data to dedicated module
- Add dark mode support for LineageTree SVG colors
- Memoize leaf count computation in LineageTree
- Update README with usage guide and project structure

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
shahondin1624
2026-03-12 13:48:06 +01:00
parent bb0eebff1b
commit 38f5f31b92
26 changed files with 753 additions and 579 deletions

View File

@@ -4,6 +4,8 @@
import { SessionConfigSchema } from '$lib/proto/llm_multiverse/v1/orchestrator_pb';
import { create } from '@bufbuild/protobuf';
import { presetStore } from '$lib/stores/presets.svelte';
import { isNonDefaultConfig } from '$lib/utils/sessionConfig';
import Backdrop from '$lib/components/Backdrop.svelte';
let {
config,
@@ -37,11 +39,7 @@
{ value: OverrideLevel.ALL, label: 'All', description: 'No enforcement' }
];
const isNonDefault = $derived(
config.overrideLevel !== OverrideLevel.NONE ||
config.disabledTools.length > 0 ||
config.grantedPermissions.length > 0
);
const isNonDefault = $derived(isNonDefaultConfig(config));
function setOverrideLevel(level: OverrideLevel) {
const updated = create(SessionConfigSchema, {
@@ -120,16 +118,8 @@
}
</script>
<!-- Mobile overlay backdrop -->
{#if onClose}
<div
class="fixed inset-0 z-40 bg-black/50 md:hidden"
role="button"
tabindex="-1"
onclick={onClose}
onkeydown={(e) => { if (e.key === 'Escape') onClose?.(); }}
aria-label="Close config sidebar"
></div>
<Backdrop onClose={onClose} />
{/if}
<aside