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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (gemini): SSE isOpen on terminal frame; validate pinned code-agent provider
Adam Eivy00eb167c23e0
diff --git a/PLAN.md b/PLAN.mdindex 3da6665718..f0d12485c4 100644--- a/PLAN.md+++ b/PLAN.md@@ -185,6 +185,7 @@ Lower-severity findings from the xhigh code-review of the importer feature; theSurfaced by the multi-reviewer release gate for v2.11.0. The correctness/contract findings were fixed in-release (comic two-speaker-panel attribution, editorial-analysis pipe-enum prompt corruption + migration 042, `agentLifecycle` fallback-provider map shape, weather half-set-coordinate pairing, plus several comment-accuracy nits). This item was deferred as a non-blocking hardening gap.+- [ ] [comic-allcaps-continuation-vs-cue] **`normalizeBareComicScript` in `server/lib/comicScriptParser.js` (~line 193) can misread a short all-caps continuation line (e.g. a bare `STOP` on its own line, mid-balloon) as a new speaker cue.** The continuation branch's `!BARE_SPEAKER_LINE.test(t)` guard exists so a genuine second speaker (`GIANT` … `KESSA`) opens a new balloon — but an all-caps shouted continuation with no punctuation matches the same shape and gets treated as a cue instead of GIANT's next line. This is the inherent flip-side of the two-speaker fix: an all-caps line in *continuation* position is genuinely ambiguous between "shout" and "new cue," and the current heuristic favors "new cue" (the more common multi-speaker-panel case; shouts usually carry `!`/`?` which already excludes them). A proper fix needs one-line lookahead (a real cue is followed by its own dialogue line; a trailing shout is followed by a marker/EOF) — which means converting the `for…of` line loop to indexed iteration. Deferred from the v2.11.0 release review (gemini) as IMPROVEMENT: flipping the heuristic instead would regress the more-common multi-speaker case. Surfaced 2026-05-27.- [ ] [voice-taskcomplete-announce-once-guard] **`onTaskUpdated` in `server/services/voice/proactiveTriggers.js` (~line 193) re-announces if an already-completed voice-dispatched task is updated again.** The spoken "your coding task is done" line keys on `tasks:changed action:'updated'` + terminal status (`completed`/`blocked`) + `voiceDispatch`, with no record of already-announced task ids — so any future caller that runs `updateTask` on an already-completed voice-dispatched task (e.g. attaching a PR URL or metadata *after* marking it completed) would re-fire the announcement. The comment claims it "announces once (at its terminal outcome)," which holds only because no current caller re-updates completed tasks. Fix: track announced task ids in a `Set` in the closure (clear on unwire) and skip if already announced, OR gate on the previous→terminal status *transition* if the event carries the prior status. Low severity (no current re-update path; worst case is a duplicate spoken line, not data loss) — deferred per YAGNI since the path doesn't exist today. Surfaced 2026-05-27.## Future Ideasdiff --git a/client/src/hooks/useSseProgress.js b/client/src/hooks/useSseProgress.jsindex ef51dec42d..316b5b5ecc 100644--- a/client/src/hooks/useSseProgress.js+++ b/client/src/hooks/useSseProgress.js@@ -54,6 +54,7 @@ export function useSseProgress(url, { enabled = true } = {}) {setLatest(data);if (TERMINAL_TYPES.has(data?.type)) {es.close();+ setIsOpen(false); // the connection is now closed — keep isOpen honestsetClosed(true);}};diff --git a/server/services/voice/tools.js b/server/services/voice/tools.jsindex cd075ad6ee..ba6e4f5dc9 100644--- a/server/services/voice/tools.js+++ b/server/services/voice/tools.js@@ -1844,33 +1844,39 @@ const TOOLS = [const provider = typeof codeAgent.provider === 'string' ? codeAgent.provider.trim() : '';const model = typeof codeAgent.model === 'string' ? codeAgent.model.trim() : '';- // Resolve a code-capable provider when none is explicitly pinned. A coding- // agent must run a CLI/TUI provider (Claude Code, Codex, Gemini CLI, …);- // an API backend (LM Studio / Ollama / OpenAI-compatible) can't, and the- // spawner would otherwise fall through to the Claude CLI spawn config with- // a non-Claude model name (buildCliSpawnConfig defaults to claude). So only- // inherit the system default when it is itself code-capable; if it's an API- // provider, substitute the first enabled CLI/TUI provider, and if there is- // none, fail with actionable copy instead of queuing a doomed task.+ // Resolve a code-capable provider. A coding agent must run a CLI/TUI+ // provider (Claude Code, Codex, Gemini CLI, …); an API backend (LM Studio+ // / Ollama / OpenAI-compatible) can't, and the spawner would otherwise+ // fall through to the Claude CLI spawn config with a non-Claude model name+ // (buildCliSpawnConfig defaults to claude). Validate BOTH the inherited+ // system default AND an explicit pin — the Voice settings UI only lists+ // CLI/TUI providers for the code agent, but a hand-edited config can still+ // pin an API one. When the effective provider isn't code-capable,+ // substitute the first enabled CLI/TUI provider, or fail with actionable+ // copy if none exists. A pin that doesn't resolve to a known provider is+ // left as-is (the spawner surfaces the unknown-provider error).+ const { getActiveProvider, getAllProviders, getProviderById } = await import('../providers.js');+ const isCodeCapable = (p) => p?.type === 'cli' || p?.type === 'tui';+ const candidate = provider+ ? await getProviderById(provider).catch(() => null)+ : await getActiveProvider().catch(() => null);+ const needsSwap = provider+ ? (candidate != null && !isCodeCapable(candidate)) // known pin that's API-only+ : !isCodeCapable(candidate); // default (incl. none) not capablelet resolvedProvider = provider;let substituted = false;- if (!resolvedProvider) {- const { getActiveProvider, getAllProviders } = await import('../providers.js');- const isCodeCapable = (p) => p?.type === 'cli' || p?.type === 'tui';- const active = await getActiveProvider().catch(() => null);- if (!isCodeCapable(active)) {- const { providers = [] } = await getAllProviders().catch(() => ({ providers: [] }));- const codeProvider = providers.find((p) => p?.enabled && isCodeCapable(p));- if (!codeProvider) {- return {- ok: false,- error: 'no code-capable provider',- summary: "Your active AI provider can't run a coding agent. Enable a CLI provider like Claude Code, Codex, or Gemini under Settings, AI Providers, then try again.",- };- }- resolvedProvider = codeProvider.id;- substituted = true;+ if (needsSwap) {+ const { providers = [] } = await getAllProviders().catch(() => ({ providers: [] }));+ const codeProvider = providers.find((p) => p?.enabled && isCodeCapable(p));+ if (!codeProvider) {+ return {+ ok: false,+ error: 'no code-capable provider',+ summary: "Your AI provider can't run a coding agent. Enable a CLI provider like Claude Code, Codex, or Gemini under Settings, AI Providers, then try again.",+ };}+ resolvedProvider = codeProvider.id;+ substituted = true;}const created = await addTask({diff --git a/server/services/voice/tools.test.js b/server/services/voice/tools.test.jsindex 6877587b8c..d42fd93555 100644--- a/server/services/voice/tools.test.js+++ b/server/services/voice/tools.test.js@@ -150,13 +150,16 @@ vi.mock('../cos.js', () => ({vi.mock('../providers.js', () => ({getActiveProvider: vi.fn(async () => ({ id: 'claude-code', type: 'tui', enabled: true })),getAllProviders: vi.fn(async () => ({ activeProvider: 'claude-code', providers: [{ id: 'claude-code', type: 'tui', enabled: true }] })),+ // Default: a pinned provider isn't in the test registry → resolves to null,+ // so the pin is trusted as-is (matches the spawner's unknown-provider path).+ getProviderById: vi.fn(async () => null),}));const { dispatchTool, getToolSpecs, getToolSpecsForIntent, classifyIntent, anchorLocalMidnightUtc } = await import('./tools.js');const { getUtcOffsetMs: mockedGetUtcOffsetMs } = await import('../../lib/timezone.js');const { getVoiceConfig: mockedGetVoiceConfig } = await import('./config.js');const { addTask: mockedAddTask, isRunning: mockedIsRunning } = await import('../cos.js');-const { getActiveProvider: mockedGetActiveProvider, getAllProviders: mockedGetAllProviders } = await import('../providers.js');+const { getActiveProvider: mockedGetActiveProvider, getAllProviders: mockedGetAllProviders, getProviderById: mockedGetProviderById } = await import('../providers.js');describe('getToolSpecs', () => {it('returns OpenAI-format function specs', () => {@@ -183,6 +186,7 @@ describe('dispatch_code_agent', () => {mockedGetVoiceConfig.mockResolvedValue({ llm: { codeAgent: { enabled: true, provider: '', model: '' } } });mockedGetActiveProvider.mockResolvedValue({ id: 'claude-code', type: 'tui', enabled: true });mockedGetAllProviders.mockResolvedValue({ activeProvider: 'claude-code', providers: [{ id: 'claude-code', type: 'tui', enabled: true }] });+ mockedGetProviderById.mockResolvedValue(null);});it('rejects an empty task without creating a CoS task', async () => {@@ -244,6 +248,32 @@ describe('dispatch_code_agent', () => {expect(mockedAddTask).not.toHaveBeenCalled();});+ it('substitutes a CLI/TUI provider when a hand-edited config pins an API-only provider', async () => {+ // The Voice UI only lists cli/tui providers for the code agent, but a+ // hand-edited config can pin an API one — which can't run a coding CLI.+ mockedGetVoiceConfig.mockResolvedValue({ llm: { codeAgent: { enabled: true, provider: 'lmstudio', model: 'qwen' } } });+ mockedGetProviderById.mockResolvedValue({ id: 'lmstudio', type: 'api', enabled: true });+ mockedGetAllProviders.mockResolvedValue({ providers: [+ { id: 'lmstudio', type: 'api', enabled: true },+ { id: 'claude-code', type: 'tui', enabled: true },+ ] });+ const r = await dispatchTool('dispatch_code_agent', { task: 'fix the build' });+ expect(r.ok).toBe(true);+ const [data] = mockedAddTask.mock.calls[0];+ expect(data.provider).toBe('claude-code');+ expect(data).not.toHaveProperty('model');+ });++ it('trusts a pinned provider that is not in the registry (spawner handles unknown)', async () => {+ // getProviderById → null means we can't judge the pin's type; leave it for+ // the spawner rather than swapping a provider we know nothing about.+ mockedGetVoiceConfig.mockResolvedValue({ llm: { codeAgent: { enabled: true, provider: 'my-custom-cli', model: 'x' } } });+ mockedGetProviderById.mockResolvedValue(null);+ const r = await dispatchTool('dispatch_code_agent', { task: 'fix the build' });+ expect(r.ok).toBe(true);+ expect(mockedAddTask.mock.calls[0][0]).toMatchObject({ provider: 'my-custom-cli', model: 'x' });+ });+it('warns in the summary when the CoS runner is stopped', async () => {mockedIsRunning.mockReturnValue(false);const r = await dispatchTool('dispatch_code_agent', { task: 'refactor X' });