fix: dev startup — Redis eviction policy, mana-media port crash, Svelte warnings

- Redis: allkeys-lru → noeviction to prevent silent data loss when memory full
- mana-media: --watch → --hot to fix EADDRINUSE crash on Bun HMR reload
- Svelte: build initial values before $state() to avoid state_referenced_locally warnings
  in create-app-onboarding.svelte.ts and shared-llm/store.svelte.ts

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Till JS 2026-04-10 18:33:41 +02:00
parent a9956c0009
commit 3e81a6ebef
6 changed files with 25 additions and 26 deletions

View file

@ -724,6 +724,14 @@ export function createUnifiedSync(serverUrl: string, getToken: () => Promise<str
count: pending.length,
durationMs: Date.now() - startedAt,
});
// If there are more pending rows beyond this batch, schedule
// another push immediately (with a tiny delay to avoid starving
// the UI thread). This drains the backlog in PUSH_BATCH_SIZE
// chunks without sending a single oversized request.
if (hasMore) {
schedulePush(appId);
}
} catch (err) {
channel.lastError = err instanceof Error ? err.message : 'Push failed';
setStatus('error');

View file

@ -31,7 +31,7 @@ services:
image: redis:7-alpine
container_name: mana-redis
restart: unless-stopped
command: redis-server --requirepass ${REDIS_PASSWORD:-devpassword} --maxmemory 256mb --maxmemory-policy allkeys-lru
command: redis-server --requirepass ${REDIS_PASSWORD:-devpassword} --maxmemory 256mb --maxmemory-policy noeviction
volumes:
- redis-data:/data
ports:

View file

@ -56,7 +56,8 @@ function persistSettings(settings: LlmSettings): void {
// ─── Reactive state ──────────────────────────────────────────────
let _settings = $state<LlmSettings>(loadSettings());
const initialSettings = loadSettings();
let _settings = $state<LlmSettings>(initialSettings);
// Backends are constructed once per page session. They're stateless
// (or hold their own internal state in the case of BrowserBackend
@ -65,7 +66,7 @@ let _settings = $state<LlmSettings>(loadSettings());
const backends = [new BrowserBackend(), new ManaServerBackend(), new CloudBackend()];
export const llmOrchestrator = new LlmOrchestrator({
settings: _settings,
settings: initialSettings,
backends,
});

View file

@ -42,21 +42,20 @@ const ONBOARDING_PREFERENCES_KEY = 'onboarding_preferences';
export function createAppOnboardingStore(config: AppOnboardingConfig): AppOnboardingStore {
const { appId, steps, userSettings, onComplete, onSkip } = config;
// Build initial preferences from step defaults before creating state
const initialPreferences: AppOnboardingPreferences = {};
for (const step of steps) {
if ((step.type === 'select' || step.type === 'toggle') && step.defaultValue !== undefined) {
initialPreferences[step.id] = step.defaultValue;
}
}
// State
let currentStep = $state(0);
let preferences = $state<AppOnboardingPreferences>({});
let preferences = $state<AppOnboardingPreferences>(initialPreferences);
let saving = $state(false);
let completed = $state(false);
// Initialize preferences with default values
for (const step of steps) {
if (step.type === 'select' && step.defaultValue !== undefined) {
preferences[step.id] = step.defaultValue;
} else if (step.type === 'toggle' && step.defaultValue !== undefined) {
preferences[step.id] = step.defaultValue;
}
}
// Derived values
const totalSteps = $derived(steps.length);
const isFirstStep = $derived(currentStep === 0);
@ -170,16 +169,7 @@ export function createAppOnboardingStore(config: AppOnboardingConfig): AppOnboar
completed = false;
currentStep = 0;
// Reset preferences to defaults
preferences = {};
for (const step of steps) {
if (step.type === 'select' && step.defaultValue !== undefined) {
preferences[step.id] = step.defaultValue;
} else if (step.type === 'toggle' && step.defaultValue !== undefined) {
preferences[step.id] = step.defaultValue;
}
}
preferences = { ...initialPreferences };
} finally {
saving = false;
}

View file

@ -3,7 +3,7 @@
"version": "0.2.0",
"private": true,
"scripts": {
"dev": "bun run --watch src/index.ts",
"dev": "bun run --hot src/index.ts",
"start": "bun run src/index.ts",
"type-check": "tsc --noEmit",
"db:push": "drizzle-kit push",

View file

@ -36,7 +36,7 @@ services:
container_name: mana-search-redis-dev
ports:
- "6380:6379" # Different port to avoid conflicts
command: redis-server --appendonly yes --maxmemory 64mb --maxmemory-policy allkeys-lru
command: redis-server --appendonly yes --maxmemory 64mb --maxmemory-policy noeviction
volumes:
- redis-dev-data:/data
networks: