feat(tui): persist model tier selection and fix formatting
Persist /model tier choice to ~/.local/share/flynn/preferences.json so it survives restarts. Decode HTML entities (e.g. ') in markdown renderer output. Suppress noisy logger.info and punycode deprecation warnings in TUI startup. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import { readFileSync, writeFileSync, mkdirSync } from 'fs';
|
||||
import { dirname, resolve } from 'path';
|
||||
|
||||
export interface Preferences {
|
||||
modelTier?: string;
|
||||
}
|
||||
|
||||
export function loadPreferences(dataDir: string): Preferences {
|
||||
const filePath = resolve(dataDir, 'preferences.json');
|
||||
try {
|
||||
const raw = readFileSync(filePath, 'utf-8');
|
||||
return JSON.parse(raw) as Preferences;
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
export function savePreference(dataDir: string, key: string, value: unknown): void {
|
||||
const filePath = resolve(dataDir, 'preferences.json');
|
||||
let prefs: Record<string, unknown> = {};
|
||||
try {
|
||||
prefs = JSON.parse(readFileSync(filePath, 'utf-8'));
|
||||
} catch {
|
||||
// start fresh
|
||||
}
|
||||
prefs[key] = value;
|
||||
mkdirSync(dirname(filePath), { recursive: true });
|
||||
writeFileSync(filePath, JSON.stringify(prefs, null, 2) + '\n');
|
||||
}
|
||||
Reference in New Issue
Block a user