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 (codex): preserve all-caps first dialogue; code-capable voice agent provider
Adam Eivy187035405ff0
diff --git a/server/lib/comicScriptParser.js b/server/lib/comicScriptParser.jsindex 727d1d42c0..140030f1f4 100644--- a/server/lib/comicScriptParser.js+++ b/server/lib/comicScriptParser.js@@ -174,10 +174,12 @@ function normalizeBareComicScript(script) {out.push('SFX:'); field = 'sfx'; awaitingFirst = true; dialogueSpeaker = null;continue;}- // First spoken line for a pending speaker. The `!BARE_SPEAKER_LINE` guard- // stops a second bare-name line (two cues in a row) from being eaten as the- // first speaker's dialogue — the speaker-cue branch below re-flushes instead.- if (pendingSpeaker && t && !BARE_SPEAKER_LINE.test(t)) {+ // First spoken line for a pending speaker. A speaker cue is ALWAYS followed+ // by its own dialogue, so emit this line as that speaker's dialogue even+ // when it is all-caps — a shouted line like `I DON'T KNOW` also matches+ // BARE_SPEAKER_LINE, and guarding here would drop it to the panel text.+ // (The first line after a cue can never itself be a second cue.)+ if (pendingSpeaker && t) {out.push('Dialogue:');out.push(`${pendingSpeaker}: ${t}`);dialogueSpeaker = pendingSpeaker;@@ -187,9 +189,11 @@ function normalizeBareComicScript(script) {}// Continuation line of a multi-line balloon — attribute it to the same// speaker so parsePanelBody captures it (otherwise lines 2+ were dropped).- // The `!BARE_SPEAKER_LINE` guard (same as the pendingSpeaker branch above)- // lets a SECOND speaker cue in the panel fall through to the speaker-cue- // branch below instead of being eaten as the first speaker's dialogue.+ // Unlike the first-line branch above, a fresh all-caps NAME-like line in+ // continuation position IS treated as a SECOND speaker cue: the+ // `!BARE_SPEAKER_LINE` guard lets it fall through to the speaker-cue branch+ // below. Two speakers in one panel is common, and a second balloon's cue+ // naturally follows the first speaker's spoken line.if (field === 'dialogue' && dialogueSpeaker && t && !BARE_SPEAKER_LINE.test(t)) {out.push(`${dialogueSpeaker}: ${t}`);continue;diff --git a/server/lib/comicScriptParser.test.js b/server/lib/comicScriptParser.test.jsindex 17983f9422..d169ee9134 100644--- a/server/lib/comicScriptParser.test.js+++ b/server/lib/comicScriptParser.test.js@@ -458,6 +458,14 @@ Thud!`;expect(pages[0].panels[0].caption).toBe('The end.');});+ it('emits an all-caps first dialogue line as dialogue, not a dropped second cue', () => {+ // A speaker cue is always followed by its spoken line; an all-caps shout+ // immediately after the cue must be that speaker's dialogue even though it+ // matches the speaker-cue shape — the first line after a cue is never a cue.+ const { pages } = parseComicScript("PAGE 1\nPANEL 1\nA scared face.\nGIANT\nI DON'T KNOW");+ expect(pages[0].panels[0].dialogue).toEqual([{ character: 'GIANT', line: "I DON'T KNOW" }]);+ });+it('attributes a second speaker cue in the same panel to the new speaker (not the first)', () => {// Two speakers in one panel is extremely common. The continuation-line// branch must let a fresh all-caps cue open a NEW speaker instead ofdiff --git a/server/services/voice/tools.js b/server/services/voice/tools.jsindex 13ee846e9f..cd075ad6ee 100644--- a/server/services/voice/tools.js+++ b/server/services/voice/tools.js@@ -1844,6 +1844,35 @@ 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.+ let 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;+ }+ }+const created = await addTask({description: text,priority: 'HIGH',@@ -1857,12 +1886,13 @@ const TOOLS = [// worktree and surfaces a PR for review.useWorktree: true,openPR: true,- // Pin only when configured. Omitting provider/model lets the CoS- // spawner fall back to the system default (providers.json- // activeProvider) + selectModelForTask — the "default to system AI- // provider → model" behavior.- ...(provider ? { provider } : {}),- ...(model ? { model } : {}),+ // Pin the configured (or substituted code-capable) provider. Omitting+ // it lets the CoS spawner inherit the system default — only done when+ // that default is itself code-capable (see resolution above). A pinned+ // model belongs to a specific provider, so drop it when we substituted+ // a different provider than the (empty) configured one.+ ...(resolvedProvider ? { provider: resolvedProvider } : {}),+ ...(model && !substituted ? { model } : {}),}, 'user');// addTask auto-spawns user tasks, but only while the CoS runner is up.diff --git a/server/services/voice/tools.test.js b/server/services/voice/tools.test.jsindex e79c976f54..6877587b8c 100644--- a/server/services/voice/tools.test.js+++ b/server/services/voice/tools.test.js@@ -143,11 +143,20 @@ vi.mock('../cos.js', () => ({addTask: vi.fn(async (data) => ({ id: 'task-test', ...data })),isRunning: vi.fn(() => true),}));+// dispatch_code_agent resolves a code-capable provider when none is pinned.+// Default the active provider to a code-capable (tui) one so the inherit path+// is exercised; individual tests override for the API-default / substitution+// / no-CLI-provider cases.+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 }] })),+}));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');describe('getToolSpecs', () => {it('returns OpenAI-format function specs', () => {@@ -172,6 +181,8 @@ describe('dispatch_code_agent', () => {mockedAddTask.mockClear();mockedIsRunning.mockReturnValue(true);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 }] });});it('rejects an empty task without creating a CoS task', async () => {@@ -208,6 +219,31 @@ describe('dispatch_code_agent', () => {expect(mockedAddTask.mock.calls[0][0]).toMatchObject({ provider: 'codex-cli', model: 'gpt-5' });});+ it('substitutes an enabled CLI/TUI provider when the system default is an API backend', async () => {+ // A coding agent can't run on an API provider (LM Studio/Ollama); without+ // a pin we must NOT inherit the API default — pick a code-capable provider.+ mockedGetActiveProvider.mockResolvedValue({ id: 'lmstudio', type: 'api', enabled: true });+ mockedGetAllProviders.mockResolvedValue({ providers: [+ { id: 'lmstudio', type: 'api', enabled: true },+ { id: 'codex', type: 'cli', 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('codex');+ // A substituted provider must not carry a model meant for another provider.+ expect(data).not.toHaveProperty('model');+ });++ it('errors when the system default is an API backend and no CLI/TUI provider is enabled', async () => {+ mockedGetActiveProvider.mockResolvedValue({ id: 'lmstudio', type: 'api', enabled: true });+ mockedGetAllProviders.mockResolvedValue({ providers: [{ id: 'lmstudio', type: 'api', enabled: true }] });+ const r = await dispatchTool('dispatch_code_agent', { task: 'fix the build' });+ expect(r.ok).toBe(false);+ expect(r.error).toMatch(/code-capable/);+ expect(mockedAddTask).not.toHaveBeenCalled();+ });+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' });