Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: dedupe error toasts, default video model to distilled, taste API fallback

Adam Eivy9b11b9a0f3e4
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index e40420e205..d85cab1dd9 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -1,5 +1,11 @@
# Next Release
+## Fixed
+
+- **Stop showing the same error toast 3-4 times.** A single failing API call could surface its error message multiple times because three independent channels all toasted the same payload: `apiCore.request` toasts on every non-OK response, the server emits both `io.emit('error:occurred')` (broadcast) and `errorEvents → broadcastToErrors('error:notified')` (subscriber) for the same error, and `useErrorNotifications` listened to *both* socket events with the same handler. Two changes: (1) `useErrorNotifications` now subscribes to the targeted `error:notified` channel only — `error:occurred` was the duplicate broadcast leg — and (2) the Toast layer added a content-based dedup window (1.5s) so any duplicate from any source is silently dropped. Explicit-`id` toasts (loading→success swaps) skip dedup so progress toasts still update in place. Files: `client/src/components/ui/Toast.jsx`, `client/src/hooks/useErrorNotifications.js`.
+- **Media Gen Video defaults to the smallest model.** The macOS default was LTX-2 Unified (~42 GB). New default is LTX-2.3 Distilled Q4 (~22 GB) so a fresh install fits on smaller machines without a manual override. File: `server/services/videoGen/local.js`.
+- **Taste questionnaire falls back to a configured API provider.** The Digital Twin → Taste tab was auto-selecting the first enabled provider for `Generate Summary` / `Go Deeper`. When that happened to be a CLI provider (Claude Code, Codex, Gemini CLI), the request failed with a generic "requires an API-based provider" toast — three times, because both the API client and two socket subscribers re-toasted the same error. Now (1) the section provider picker filters to API-type providers only, (2) the server resolves any usable API provider when the requested one isn't compatible (requested → active → first enabled API) via a new `resolveAPIProvider` helper in `server/lib/aiProvider.js`, (3) the section-complete view shows an inline link to AI Providers when no compatible provider is configured instead of leaving the user with a wall of red toasts and no direction, and (4) the redundant component-level `toast.error` calls were removed (apiCore already toasts on non-OK responses). Files: `server/lib/aiProvider.js`, `server/services/taste-questionnaire.js`, `client/src/components/digital-twin/tabs/TasteTab.jsx`.
+
## Changed
- **Send to Video carries the source image's prompts.** Clicking "Send to Video" on an Image Gen result, gallery card, or lightbox — or the same action from Media History — now pre-populates the Video Gen prompt and negative prompt from the source image's metadata. Previously only the source image filename was passed, leaving the user to retype or paste the prompt to keep the same scene direction. The flow piggybacks on the existing `?sourceImageFile=` query-param hand-off: `?prompt=` and `?negativePrompt=` are added when the source has them, and `VideoGen.jsx` reads both on first render and re-syncs on subsequent navigations (mirroring the existing source-image effect). Files: `client/src/pages/ImageGen.jsx`, `client/src/pages/MediaHistory.jsx`, `client/src/pages/VideoGen.jsx`.
diff --git a/client/src/components/digital-twin/tabs/TasteTab.jsx b/client/src/components/digital-twin/tabs/TasteTab.jsx
index a6d3407b29..0cd3d3bae4 100644
--- a/client/src/components/digital-twin/tabs/TasteTab.jsx
+++ b/client/src/components/digital-twin/tabs/TasteTab.jsx
@@ -46,6 +46,9 @@ const SECTION_COLORS = {
digital: 'cyan'
};
+const NO_API_PROVIDER_TOAST = 'No API provider configured — open AI Providers to add one (e.g. LM Studio, OpenAI).';
+const NO_API_PROVIDER_TITLE = 'Configure an AI provider to enable';
+
export default function TasteTab({ onRefresh }) {
const [profile, setProfile] = useState(null);
const [loading, setLoading] = useState(true);
@@ -85,10 +88,13 @@ export default function TasteTab({ onRefresh }) {
const loadProviders = useCallback(async () => {
const data = await api.getProviders().catch(() => ({ providers: [] }));
- const enabled = (data.providers || []).filter(p => p.enabled);
- setProviders(enabled);
- if (enabled.length > 0) {
- setSelectedProvider({ providerId: enabled[0].id, model: enabled[0].defaultModel });
+ // Taste summaries / personalized questions need a chat-completions endpoint —
+ // CLI providers (Claude Code, Codex, Gemini CLI) can't run them. Filter the
+ // picker so the user can't accidentally select an incompatible default.
+ const apiProviders = (data.providers || []).filter(p => p.enabled && p.type === 'api');
+ setProviders(apiProviders);
+ if (apiProviders.length > 0) {
+ setSelectedProvider({ providerId: apiProviders[0].id, model: apiProviders[0].defaultModel });
}
}, []);
@@ -148,7 +154,7 @@ export default function TasteTab({ onRefresh }) {
const handleGoDeeper = async () => {
if (!selectedProvider) {
- toast.error('Select a provider first');
+ toast.error(NO_API_PROVIDER_TOAST);
return;
}
setLoadingPersonalized(true);
@@ -198,19 +204,19 @@ export default function TasteTab({ onRefresh }) {
const handleGenerateSummary = async (sectionId) => {
if (!selectedProvider) {
- toast.error('Select a provider first');
+ toast.error(NO_API_PROVIDER_TOAST);
return;
}
setGeneratingSummary(true);
+ // apiCore.request already shows a toast on non-OK responses, so swallow
+ // the rejection here instead of re-toasting the same error.
const result = await api.generateTasteSummary(
selectedProvider.providerId,
selectedProvider.model,
sectionId
- ).catch(e => ({ error: e.message }));
+ ).catch(() => null);
- if (result.error) {
- toast.error(result.error);
- } else {
+ if (result) {
toast.success('Summary generated');
await loadProfile();
}
@@ -234,18 +240,16 @@ export default function TasteTab({ onRefresh }) {
const handleGenerateOverallSummary = async () => {
if (!selectedProvider) {
- toast.error('Select a provider first');
+ toast.error(NO_API_PROVIDER_TOAST);
return;
}
setGeneratingSummary(true);
const result = await api.generateTasteSummary(
selectedProvider.providerId,
selectedProvider.model
- ).catch(e => ({ error: e.message }));
+ ).catch(() => null);
- if (result.error) {
- toast.error(result.error);
- } else {
+ if (result) {
toast.success('Taste profile generated');
await loadProfile();
}
@@ -396,11 +400,21 @@ export default function TasteTab({ onRefresh }) {
<span className="text-green-400">All questions for this section are complete.</span>
</div>
</div>
+ {!selectedProvider && (
+ <div className="p-4 bg-port-warning/10 border border-port-warning/30 rounded-lg mb-4 text-sm text-port-warning">
+ No API-based provider configured — Go Deeper and Generate Summary need one.{' '}
+ <a href="/ai" className="underline hover:text-yellow-300">
+ Open AI Providers
+ </a>{' '}
+ and add LM Studio, OpenAI, or Anthropic to enable these.
+ </div>
+ )}
<div className="flex flex-col sm:flex-row gap-3">
<button
onClick={handleGoDeeper}
disabled={loadingPersonalized || !selectedProvider}
className="flex items-center justify-center gap-2 px-4 py-3 min-h-[44px] bg-purple-600 text-white rounded-lg text-sm hover:bg-purple-500 disabled:opacity-50"
+ title={!selectedProvider ? NO_API_PROVIDER_TITLE : ''}
>
{loadingPersonalized ? <RefreshCw className="w-4 h-4 animate-spin" /> : <Telescope size={16} />}
Go Deeper
@@ -414,8 +428,9 @@ export default function TasteTab({ onRefresh }) {
</button>
<button
onClick={() => handleGenerateSummary(activeSection)}
- disabled={generatingSummary}
+ disabled={generatingSummary || !selectedProvider}
className="flex items-center justify-center gap-2 px-4 py-3 min-h-[44px] bg-violet-600 text-white rounded-lg text-sm hover:bg-violet-500 disabled:opacity-50"
+ title={!selectedProvider ? NO_API_PROVIDER_TITLE : ''}
>
{generatingSummary ? <RefreshCw className="w-4 h-4 animate-spin" /> : <Sparkles size={16} />}
Generate Summary
diff --git a/client/src/components/ui/Toast.jsx b/client/src/components/ui/Toast.jsx
index 16cc5e5605..153788dd7b 100644
--- a/client/src/components/ui/Toast.jsx
+++ b/client/src/components/ui/Toast.jsx
@@ -14,10 +14,38 @@ function notify() {
}
const DEFAULT_DURATION = 4000;
+const DEDUP_WINDOW_MS = 1500;
+
+// Fingerprint → expiry timestamp. Same content+type within DEDUP_WINDOW_MS is
+// silently dropped so a single user action that flows through multiple error
+// channels (API client toast + socket error:occurred + error:notified) doesn't
+// stack 3-4 identical red toasts. Render-prop content (functions) is never
+// deduped — those are intentional custom UIs and the caller controls identity.
+const recentFingerprints = new Map();
+const fingerprintFor = (content, type) =>
+ typeof content === 'string' ? `${type}::${content}` : null;
function add(content, opts = {}, type = 'default') {
const id = opts.id || crypto.randomUUID();
const duration = opts.duration !== undefined ? opts.duration : (type === 'loading' ? Infinity : DEFAULT_DURATION);
+
+ // Skip if an identical toast was just shown — but only when the caller
+ // didn't supply an explicit id (explicit id = caller is intentionally
+ // updating the same toast, e.g. a loading-then-success swap).
+ if (!opts.id) {
+ const fp = fingerprintFor(content, type);
+ if (fp) {
+ const now = Date.now();
+ // Sweep expired entries opportunistically.
+ for (const [k, exp] of recentFingerprints) {
+ if (exp <= now) recentFingerprints.delete(k);
+ }
+ const expiry = recentFingerprints.get(fp);
+ if (expiry && expiry > now) return id;
+ recentFingerprints.set(fp, now + DEDUP_WINDOW_MS);
+ }
+ }
+
const entry = { id, type, content, icon: opts.icon, duration, style: opts.style };
const idx = toasts.findIndex(t => t.id === id);
diff --git a/client/src/hooks/useErrorNotifications.js b/client/src/hooks/useErrorNotifications.js
index 2eab1b9904..d673dfc287 100644
--- a/client/src/hooks/useErrorNotifications.js
+++ b/client/src/hooks/useErrorNotifications.js
@@ -13,12 +13,13 @@ export function useErrorNotifications() {
}, []);
useEffect(() => {
- // Subscribe to error events
+ // Subscribe to targeted error broadcasts. We listen to ONLY `error:notified`
+ // (subscriber-scoped) and skip `error:occurred` (broadcast-to-all) — the
+ // server emits both for every error, so listening to both doubled every
+ // toast. The Toast layer also dedupes by content as a defense in depth.
socket.emit('errors:subscribe');
- // Handle error notifications from server
const handleError = (error) => {
- // Platform unavailability is a warning, not an error
if (error.code === 'PLATFORM_UNAVAILABLE') {
toast(error.message, { duration: 5000, icon: '⚠️' });
console.warn(`[${error.code}] ${error.message}`, error.context);
@@ -30,18 +31,14 @@ export function useErrorNotifications() {
icon: error.severity === 'critical' ? '💥' : '❌'
};
- // Format message based on severity
const message = error.severity === 'critical'
? `Critical: ${error.message}`
: error.message;
toast.error(message, toastOptions);
-
- // Log to console for debugging
console.error(`[${error.code}] ${error.message}`, error.context);
};
- // Handle critical system errors
const handleCriticalError = (error) => {
toast.error(`System Critical: ${error.message}`, {
duration: 15000,
@@ -49,7 +46,6 @@ export function useErrorNotifications() {
});
};
- // Handle auto-fix task creation notifications
const handleRecoveryRequested = (data) => {
toast.success(`Auto-fix task created: ${data.taskId}`, {
duration: 5000,
@@ -57,15 +53,12 @@ export function useErrorNotifications() {
});
};
- // Register handlers
- socket.on('error:occurred', handleError);
socket.on('error:notified', handleError);
socket.on('system:critical-error', handleCriticalError);
socket.on('error:recover:requested', handleRecoveryRequested);
return () => {
socket.emit('errors:unsubscribe');
- socket.off('error:occurred', handleError);
socket.off('error:notified', handleError);
socket.off('system:critical-error', handleCriticalError);
socket.off('error:recover:requested', handleRecoveryRequested);
diff --git a/server/lib/aiProvider.js b/server/lib/aiProvider.js
index 72140d06fd..45a0c1f420 100644
--- a/server/lib/aiProvider.js
+++ b/server/lib/aiProvider.js
@@ -3,6 +3,42 @@
* Used by insightsService, identity, goalCheckIn, taste-questionnaire, etc.
*/
+import { getAllProviders } from '../services/providers.js';
+
+const isAPI = (p) => p && p.type === 'api' && p.enabled !== false;
+
+/**
+ * Resolve an API-type provider for features that can only run against an API
+ * endpoint (CLI providers don't support the simple chat-completions call path).
+ *
+ * Resolution order:
+ * 1. The requested provider (if API-type)
+ * 2. The user's active provider (if API-type)
+ * 3. The first enabled API provider configured
+ *
+ * Returns null when no API provider is configured — callers should surface a
+ * "configure an API provider" hint rather than re-throwing.
+ */
+export async function resolveAPIProvider(requestedProviderId) {
+ // One read of providers.json — getAllProviders returns both the active id
+ // and the full list, so we don't need separate getProviderById/getActiveProvider
+ // round-trips for each step of the fallback chain.
+ const all = await getAllProviders().catch(() => null);
+ const providers = Array.isArray(all?.providers)
+ ? all.providers
+ : Object.values(all?.providers || {});
+
+ if (requestedProviderId) {
+ const requested = providers.find(p => p.id === requestedProviderId);
+ if (isAPI(requested)) return requested;
+ }
+ if (all?.activeProvider) {
+ const active = providers.find(p => p.id === all.activeProvider);
+ if (isAPI(active)) return active;
+ }
+ return providers.find(isAPI) || null;
+}
+
/**
* Call an API-based AI provider with a simple prompt.
* Returns { text } on success, { error } on failure.
diff --git a/server/services/taste-questionnaire.js b/server/services/taste-questionnaire.js
index 2fb44068e1..18dccb94df 100644
--- a/server/services/taste-questionnaire.js
+++ b/server/services/taste-questionnaire.js
@@ -11,12 +11,13 @@ import { existsSync } from 'fs';
import { join } from 'path';
import { v4 as uuidv4 } from '../lib/uuid.js';
import { ensureDir, safeJSONParse, PATHS } from '../lib/fileUtils.js';
-import { getActiveProvider, getProviderById } from './providers.js';
+import { resolveAPIProvider, callProviderAISimple } from '../lib/aiProvider.js';
import { buildPrompt } from './promptService.js';
import { digitalTwinEvents } from './digital-twin.js';
const DIGITAL_TWIN_DIR = PATHS.digitalTwin;
const TASTE_PROFILE_FILE = join(DIGITAL_TWIN_DIR, 'taste-profile.json');
+const NO_API_PROVIDER_HINT = 'No API-based AI provider is configured. Open AI Providers (e.g. LM Studio, OpenAI, Anthropic) and add one — CLI providers like Claude Code can\'t run this analysis.';
function now() {
return new Date().toISOString();
@@ -630,11 +631,8 @@ export async function generateSectionSummary(sectionId, providerId, model) {
throw new Error(`No responses to summarize for section: ${sectionId}`);
}
- const provider = providerId
- ? await getProviderById(providerId)
- : await getActiveProvider();
-
- if (!provider) throw new Error('No AI provider available');
+ const provider = await resolveAPIProvider(providerId);
+ if (!provider) throw new Error(NO_API_PROVIDER_HINT);
const modelId = model || provider.defaultModel;
@@ -699,11 +697,8 @@ export async function generateOverallSummary(providerId, model) {
throw new Error('No taste responses to summarize. Complete at least one section first.');
}
- const provider = providerId
- ? await getProviderById(providerId)
- : await getActiveProvider();
-
- if (!provider) throw new Error('No AI provider available');
+ const provider = await resolveAPIProvider(providerId);
+ if (!provider) throw new Error(NO_API_PROVIDER_HINT);
const modelId = model || provider.defaultModel;
@@ -876,10 +871,7 @@ export async function generatePersonalizedTasteQuestion(sectionId, providerId, m
const { context, sourcesUsed } = await aggregateIdentityContext(sectionId);
if (!context) return null;
- const provider = providerId
- ? await getProviderById(providerId)
- : await getActiveProvider();
-
+ const provider = await resolveAPIProvider(providerId);
if (!provider) return null;
const modelId = model || provider.defaultModel;
@@ -945,43 +937,6 @@ function findQuestionDef(sectionId, questionId) {
return null;
}
-async function callProviderAISimple(provider, model, prompt, { temperature = 0.3, max_tokens = 1000 } = {}) {
- const timeout = provider.timeout || 300000;
-
- if (provider.type === 'api') {
- const headers = { 'Content-Type': 'application/json' };
- if (provider.apiKey) headers['Authorization'] = `Bearer ${provider.apiKey}`;
-
- const controller = new AbortController();
- const timer = setTimeout(() => controller.abort(), timeout);
-
- const response = await fetch(`${provider.endpoint}/chat/completions`, {
- method: 'POST',
- headers,
- signal: controller.signal,
- body: JSON.stringify({
- model,
- messages: [{ role: 'user', content: prompt }],
- temperature,
- max_tokens
- })
- });
-
- clearTimeout(timer);
-
- if (!response.ok) {
- const errorText = await response.text().catch(() => 'Unknown error');
- return { error: `Provider returned ${response.status}: ${errorText}` };
- }
-
- const data = await response.json();
- return { text: data.choices?.[0]?.message?.content || '' };
- }
-
- // CLI providers not supported for summary generation — require API
- return { error: 'Taste profile summary requires an API-based provider' };
-}
-
async function appendToAestheticsDoc(sectionId, config, questionId, answer) {
const targetPath = join(DIGITAL_TWIN_DIR, 'AESTHETICS.md');
let content = '';
diff --git a/server/services/videoGen/local.js b/server/services/videoGen/local.js
index 0fbf7aee31..5aed7b7374 100644
--- a/server/services/videoGen/local.js
+++ b/server/services/videoGen/local.js
@@ -40,7 +40,7 @@ export const VIDEO_MODELS = IS_WIN ? MODELS_WINDOWS : MODELS_MACOS;
export const listVideoModels = () =>
Object.entries(VIDEO_MODELS).map(([id, m]) => ({ id, ...m }));
-export const defaultVideoModelId = () => IS_WIN ? 'ltx_video' : 'ltx2_unified';
+export const defaultVideoModelId = () => IS_WIN ? 'ltx_video' : 'ltx23_distilled_q4';
const HISTORY_FILE = join(PATHS.data, 'video-history.json');