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:
@@ -14,6 +14,7 @@ export interface ModelRouterConfig {
|
||||
tierFallbacks?: Map<ModelTier, ModelClient[]>;
|
||||
retryConfig?: RetryConfig;
|
||||
labels?: Partial<Record<ModelTier, string>>;
|
||||
onTierChange?: (tier: ModelTier) => void;
|
||||
}
|
||||
|
||||
export class ModelRouter implements ModelClient {
|
||||
@@ -25,6 +26,7 @@ export class ModelRouter implements ModelClient {
|
||||
private currentTier: ModelTier = 'default';
|
||||
private localProviderName?: string;
|
||||
private retryConfig?: RetryConfig;
|
||||
private onTierChange?: (tier: ModelTier) => void;
|
||||
|
||||
constructor(config: ModelRouterConfig) {
|
||||
this.clients = new Map();
|
||||
@@ -33,6 +35,7 @@ export class ModelRouter implements ModelClient {
|
||||
this.fallbackChain = config.fallbackChain;
|
||||
this.tierFallbacks = config.tierFallbacks ?? new Map();
|
||||
this.retryConfig = config.retryConfig;
|
||||
this.onTierChange = config.onTierChange;
|
||||
|
||||
this.clients.set('default', config.default);
|
||||
if (config.fast) this.clients.set('fast', config.fast);
|
||||
@@ -51,11 +54,16 @@ export class ModelRouter implements ModelClient {
|
||||
setTier(tier: ModelTier): boolean {
|
||||
if (this.clients.has(tier)) {
|
||||
this.currentTier = tier;
|
||||
this.onTierChange?.(tier);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
setOnTierChange(callback: (tier: ModelTier) => void): void {
|
||||
this.onTierChange = callback;
|
||||
}
|
||||
|
||||
getTier(): ModelTier {
|
||||
return this.currentTier;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user