feat: Phase 2 — store audit, migration clusters, ADR, settings domain migration
- MIGRATION_CLUSTERS.md: reactive dependency graph across 20 bridges/stores - PHASE1_STORE_AUDIT.md: 11 stores audited (3 clean, 5 bridge-dependent, 3 platform-specific) - ADR-001: dual-stack binding strategy (accepted, S-1+S-3 hybrid) - Settings domain migration: all 6 settings components + App.svelte + FilesTab migrated from settings-bridge to getBackend() calls
This commit is contained in:
parent
df83b1df4d
commit
579157f6da
18 changed files with 657 additions and 26 deletions
|
|
@ -1,7 +1,7 @@
|
|||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { initTheme } from './lib/stores/theme.svelte';
|
||||
import { getSetting } from './lib/adapters/settings-bridge';
|
||||
import { getSetting } from './lib/stores/settings-store.svelte';
|
||||
import { isDetachedMode, getDetachedConfig } from './lib/utils/detach';
|
||||
import { startAgentDispatcher, stopAgentDispatcher } from './lib/agent-dispatcher';
|
||||
import { startHealthTick, stopHealthTick, clearHealthTracking } from './lib/stores/health.svelte';
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
import { invoke } from '@tauri-apps/api/core';
|
||||
|
||||
export async function getSetting(key: string): Promise<string | null> {
|
||||
return invoke('settings_get', { key });
|
||||
}
|
||||
|
||||
export async function setSetting(key: string, value: string): Promise<void> {
|
||||
return invoke('settings_set', { key, value });
|
||||
}
|
||||
|
||||
export async function listSettings(): Promise<[string, string][]> {
|
||||
return invoke('settings_list');
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<script lang="ts">
|
||||
import { listDirectoryChildren, readFileContent, writeFileContent, type DirEntry, type FileContent } from '../../adapters/files-bridge';
|
||||
import { getSetting } from '../../adapters/settings-bridge';
|
||||
import { getSetting } from '../../stores/settings-store.svelte';
|
||||
import { convertFileSrc } from '@tauri-apps/api/core';
|
||||
import CodeEditor from './CodeEditor.svelte';
|
||||
import PdfViewer from './PdfViewer.svelte';
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
import { deriveIdentifier, type GroupAgentRole, AGENT_ROLE_ICONS } from '../../types/groups';
|
||||
import { ProjectId, GroupId } from '../../types/ids';
|
||||
import { generateAgentPrompt } from '../../utils/agent-prompts';
|
||||
import { getSetting, setSetting } from '../../adapters/settings-bridge';
|
||||
import { getSetting, setSetting } from '../../stores/settings-store.svelte';
|
||||
import { getCurrentTheme, setTheme } from '../../stores/theme.svelte';
|
||||
import { THEME_LIST, getPalette, type ThemeId } from '../../styles/themes';
|
||||
import { listProfiles, type ClaudeProfile } from '../../adapters/claude-bridge';
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { getSetting, setSetting } from '../../adapters/settings-bridge';
|
||||
import { getSetting, setSetting } from '../../stores/settings-store.svelte';
|
||||
import { getPluginEntries, setPluginEnabled, reloadAllPlugins } from '../../stores/plugins.svelte';
|
||||
import { checkForUpdates, getCurrentVersion, getLastCheckTimestamp } from '../../utils/updater';
|
||||
import type { UpdateInfo } from '../../utils/updater';
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { getSetting, setSetting } from '../../adapters/settings-bridge';
|
||||
import { getSetting, setSetting } from '../../stores/settings-store.svelte';
|
||||
import { getProviders } from '../../providers/registry.svelte';
|
||||
import type { ProviderSettings } from '../../providers/types';
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
import { onMount } from 'svelte';
|
||||
import { getCurrentTheme, setTheme, setCustomTheme } from '../../stores/theme.svelte';
|
||||
import { THEME_LIST, getPalette, type ThemeId } from '../../styles/themes';
|
||||
import { getSetting, setSetting } from '../../adapters/settings-bridge';
|
||||
import { getSetting, setSetting } from '../../stores/settings-store.svelte';
|
||||
import { handleError } from '../../utils/handle-error';
|
||||
import { type CustomTheme, loadCustomThemes, deleteCustomTheme as deleteCustom, saveCustomThemes } from '../../styles/custom-themes';
|
||||
import ThemeEditor from '../ThemeEditor.svelte';
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { getSetting, setSetting } from '../../adapters/settings-bridge';
|
||||
import { getSetting, setSetting } from '../../stores/settings-store.svelte';
|
||||
import { ANCHOR_BUDGET_SCALES, ANCHOR_BUDGET_SCALE_LABELS, type AnchorBudgetScale } from '../../types/anchors';
|
||||
import { WAKE_STRATEGIES, WAKE_STRATEGY_LABELS, WAKE_STRATEGY_DESCRIPTIONS, type WakeStrategy } from '../../types/wake';
|
||||
import { handleError, handleInfraError } from '../../utils/handle-error';
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
addProject, removeProject, addGroup, removeGroup, switchGroup,
|
||||
updateProject,
|
||||
} from '../../stores/workspace.svelte';
|
||||
import { getSetting } from '../../adapters/settings-bridge';
|
||||
import { getSetting } from '../../stores/settings-store.svelte';
|
||||
import { setActiveProject } from '../../stores/settings-scope.svelte';
|
||||
|
||||
let newGroupName = $state('');
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { getSetting, setSetting } from '../../adapters/settings-bridge';
|
||||
import { getSetting, setSetting } from '../../stores/settings-store.svelte';
|
||||
import { storeSecret, getSecret, deleteSecret, listSecrets, hasKeyring, knownSecretKeys, SECRET_KEY_LABELS } from '../../adapters/secrets-bridge';
|
||||
import { handleError, handleInfraError } from '../../utils/handle-error';
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
import type { PluginMeta } from '../adapters/plugins-bridge';
|
||||
import { discoverPlugins } from '../adapters/plugins-bridge';
|
||||
import { getSetting, setSetting } from '../adapters/settings-bridge';
|
||||
import { getSetting, setSetting } from './settings-store.svelte';
|
||||
import { loadPlugin, unloadPlugin, unloadAllPlugins, getLoadedPlugins } from '../plugins/plugin-host';
|
||||
import { handleInfraError } from '../utils/handle-error';
|
||||
import type { GroupId, AgentId } from '../types/ids';
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Provides scoped get/set: reads project-level override if exists, falls back to global.
|
||||
// Single source of truth for which scope is active and how overrides cascade.
|
||||
|
||||
import { getSetting, setSetting } from '../adapters/settings-bridge';
|
||||
import { getSetting, setSetting } from './settings-store.svelte';
|
||||
|
||||
type Scope = 'global' | 'project';
|
||||
|
||||
|
|
|
|||
31
src/lib/stores/settings-store.svelte.ts
Normal file
31
src/lib/stores/settings-store.svelte.ts
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
// Settings store — thin accessor over BackendAdapter for settings persistence.
|
||||
// Replaces the old settings-bridge.ts (which imported Tauri invoke directly).
|
||||
// All consumers should import from here instead of settings-bridge.
|
||||
|
||||
import { getBackend } from '../backend/backend';
|
||||
|
||||
/**
|
||||
* Get a setting value by key. Returns null if not found.
|
||||
*/
|
||||
export async function getSetting(key: string): Promise<string | null> {
|
||||
return getBackend().getSetting(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a setting value by key.
|
||||
*/
|
||||
export async function setSetting(key: string, value: string): Promise<void> {
|
||||
return getBackend().setSetting(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all settings as a key-value map.
|
||||
* Note: returns Record<string, string> (SettingsMap), not [string, string][].
|
||||
* Callers that used listSettings() should adapt to the map format.
|
||||
*/
|
||||
export async function getAllSettings(): Promise<Record<string, string>> {
|
||||
return getBackend().getAllSettings();
|
||||
}
|
||||
|
||||
// Re-export for backward compat with code that imported listSettings
|
||||
export { getAllSettings as listSettings };
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
// Theme store — persists theme selection via settings bridge
|
||||
|
||||
import { getSetting, setSetting } from '../adapters/settings-bridge';
|
||||
import { getSetting, setSetting } from './settings-store.svelte';
|
||||
import { handleInfraError } from '../utils/handle-error';
|
||||
import {
|
||||
type ThemeId,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Custom theme persistence — store, load, validate, import/export
|
||||
|
||||
import { getSetting, setSetting } from '../adapters/settings-bridge';
|
||||
import { getSetting, setSetting } from '../stores/settings-store.svelte';
|
||||
import { handleError, handleInfraError } from '../utils/handle-error';
|
||||
import { type ThemePalette, type ThemeId, getPalette, PALETTE_KEYS } from './themes';
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue