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 round 2: ui_ask abort handling + test placement
Adam Eivy24f40dee68c5
diff --git a/server/routes/palette.test.js b/server/routes/palette.test.jsindex ddac7dca24..1ba4263662 100644--- a/server/routes/palette.test.js+++ b/server/routes/palette.test.js@@ -89,6 +89,16 @@ describe('GET /api/palette/manifest', () => {expect(ids).not.toContain('ui_navigate');expect(ids).toContain('ui_ask');});++ it('exposes ui_ask in the manifest with description hydrated from voice tools', async () => {+ const res = await request(makeApp()).get('/api/palette/manifest');+ const askAction = res.body.actions.find((a) => a.id === 'ui_ask');+ expect(askAction).toBeTruthy();+ expect(askAction.label).toBe('Ask Yourself');+ expect(askAction.section).toBe('Ask');+ expect(askAction.description).toMatch(/digital twin|retrieval/i);+ expect(askAction.parameters?.properties?.question).toBeTruthy();+ });});describe('POST /api/palette/action/:id', () => {@@ -118,16 +128,6 @@ describe('POST /api/palette/action/:id', () => {expect(res.status).toBe(404);});- it('exposes ui_ask in the manifest with description hydrated from voice tools', async () => {- const res = await request(makeApp()).get('/api/palette/manifest');- const askAction = res.body.actions.find((a) => a.id === 'ui_ask');- expect(askAction).toBeTruthy();- expect(askAction.label).toBe('Ask Yourself');- expect(askAction.section).toBe('Ask');- expect(askAction.description).toMatch(/digital twin|retrieval/i);- expect(askAction.parameters?.properties?.question).toBeTruthy();- });-it('dispatches ui_ask through the palette and returns the answer + sources', async () => {const res = await request(makeApp()).post('/api/palette/action/ui_ask')diff --git a/server/services/voice/tools.js b/server/services/voice/tools.jsindex 485adda3b2..a18ec5a1a0 100644--- a/server/services/voice/tools.js+++ b/server/services/voice/tools.js@@ -1032,6 +1032,12 @@ const TOOLS = [if (errorMsg) {return { ok: false, error: errorMsg, summary: `I couldn't answer that — ${errorMsg}` };}+ // Barge-in: runAsk exits early on signal.aborted without emitting a `done`+ // event, so the loop ends with only partial deltas. Surface that as a+ // cancellation rather than a successful partial answer.+ if (ctx.signal?.aborted) {+ return { ok: false, error: 'aborted', summary: 'Cancelled before I could finish answering.' };+ }const finalAnswer = (doneAnswer ?? deltas.join('')).trim();if (!finalAnswer) {return { ok: false, summary: 'I came up empty on that question.' };diff --git a/server/services/voice/tools.test.js b/server/services/voice/tools.test.jsindex 47dc4c9fec..30e4848f64 100644--- a/server/services/voice/tools.test.js+++ b/server/services/voice/tools.test.js@@ -369,6 +369,20 @@ describe('ui_ask', () => {expect(r.ok).toBe(false);expect(r.summary).toMatch(/empty/i);});++ it('returns ok:false on barge-in abort even with partial deltas', async () => {+ const askService = await import('../askService.js');+ askService.runAsk.mockImplementationOnce(async function* () {+ yield { type: 'delta', text: 'partial answer' };+ // runAsk exits early on abort without emitting `done`+ });+ const ctrl = new AbortController();+ ctrl.abort();+ const r = await dispatchTool('ui_ask', { question: 'cancel mid-stream' }, { signal: ctrl.signal });+ expect(r.ok).toBe(false);+ expect(r.error).toBe('aborted');+ expect(r.summary).toMatch(/cancelled/i);+ });});describe('classifyIntent — ask group', () => {