The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
fix(agent): an empty folder and an empty search say so
purple9f0032f41c0c
diff --git a/src/api/__tests__/codex-run-isolation.test.ts b/src/api/__tests__/codex-run-isolation.test.tsindex 18df49af..d3338d18 100644--- a/src/api/__tests__/codex-run-isolation.test.ts+++ b/src/api/__tests__/codex-run-isolation.test.ts@@ -209,7 +209,7 @@ describe("a chat-artifact run does not capture the coding run's writes", () => {expect(backendCalls.some((c) => c.cmd === 'fs_write' && c.body?.workingDirectory === '/repo-a')).toBe(true)const bOut = await registry.execute('file_write', { path: 'note.md', content: 'hi' }, 1, b)- expect(bOut).toContain('nothing was written to disk')+ expect(bOut).toContain('Nothing was written to disk')endAgentRun(b)endAgentRun(a)@@ -224,7 +224,7 @@ describe("a chat-artifact run does not capture the coding run's writes", () => {backendCalls.length = 0const aOut = await registry.execute('file_write', { path: 'out.txt', content: 'hello' })- expect(aOut).toContain('nothing was written to disk')+ expect(aOut).toContain('Nothing was written to disk')expect(backendCalls.some((c) => c.cmd === 'fs_write')).toBe(false)endAgentRun(b)diff --git a/src/api/mcp/__tests__/an-empty-folder-says-it-is-empty.test.ts b/src/api/mcp/__tests__/an-empty-folder-says-it-is-empty.test.tsnew file mode 100644index 00000000..acba3d3d--- /dev/null+++ b/src/api/mcp/__tests__/an-empty-folder-says-it-is-empty.test.ts@@ -0,0 +1,42 @@+/**+ * 3.0.4 box run: file_list on a fresh workspace returned an empty string. The+ * model said "I listed the files" and named none, the opened step showed no+ * result. An empty listing and an empty search now say so.+ *+ * Run: npx vitest run src/api/mcp/__tests__/an-empty-folder-says-it-is-empty.test.ts+ */+import { describe, it, expect, vi } from 'vitest'++let answer: unknown = {}+vi.mock('../../backend', () => ({+ backendCall: vi.fn(async () => answer),+ fetchExternal: vi.fn(),+}))+vi.mock('../../agents/sub-agent', () => ({+ DELEGATE_TASK_TOOL_DEF: { name: 'delegate_task', description: '', category: 'system', inputSchema: {} },+ buildDelegateExecutor: () => async () => 'stub',+}))+vi.mock('../../../lib/workflow-engine', () => ({ WorkflowEngine: class {} }))++import { registerBuiltinTools } from '../builtin-tools'+import { ToolRegistry } from '../tool-registry'++const registry = new ToolRegistry()+registerBuiltinTools(registry)++describe('empty answers are named', () => {+ it('file_list of an empty folder', async () => {+ answer = { entries: [], count: 0 }+ expect(await registry.execute('file_list', { path: './.' })).toBe('The folder is empty.')+ })++ it('file_search without a match', async () => {+ answer = { results: [], count: 0 }+ expect(await registry.execute('file_search', { path: '.', pattern: 'x' })).toBe('No matches.')+ })++ it('NEGATIVE CONTROL: a folder with a file still lists it', async () => {+ answer = { entries: [{ name: 'hello.txt', path: '/ws/hello.txt', size: 2, isDir: false }], count: 1 }+ expect(await registry.execute('file_list', { path: '.' })).toContain('hello.txt')+ })+})diff --git a/src/api/mcp/builtin-tools.ts b/src/api/mcp/builtin-tools.tsindex 984ba711..1e1f06dd 100644--- a/src/api/mcp/builtin-tools.ts+++ b/src/api/mcp/builtin-tools.ts@@ -688,7 +688,7 @@ async function executeFileWrite(args: ToolArgs, run?: AgentRunContext): Promise<if (isChatArtifactMode(run)) {const name = artifactBaseName(path)captureChatArtifact(name, content, mimeForName(name), run)- return `Created "${name}" (${formatBytes(content.length)}). It is shown to the user right here in the chat with a preview and a Download button — nothing was written to disk. Do not call file_read on it; just tell the user it's ready.`+ return `Created "${name}" (${formatBytes(content.length)}). It is shown to the user right here in the chat with a preview and a Download button. Nothing was written to disk. Do not call file_read on it; just tell the user it's ready.`}const data = await backendCall<FsWriteResult>('fs_write', { path, content, ...chatCtx(run) })// Rust returns {status: 'saved'|'unchanged', path: <absolute>, bytes}. Surface@@ -781,6 +781,9 @@ async function executeFileList(args: ToolArgs, run?: AgentRunContext): Promise<s...chatCtx(run),})if (Array.isArray(data.entries)) {+ // An empty answer read as nothing: the model said "I listed the files"+ // and named none, the step showed no result (3.0.4 box run).+ if (!data.entries.length) return 'The folder is empty.'return data.entries.map((e) => `${e.isDir ? '[DIR]' : ''} ${e.name} (${formatBytes(e.size)}) ${e.path}`).join('\n')@@ -798,6 +801,7 @@ async function executeFileSearch(args: ToolArgs, run?: AgentRunContext): Promise...chatCtx(run),})if (Array.isArray(data.results)) {+ if (!data.results.length) return 'No matches.'return data.results.map((r) => {const matches = r.matches?.map((m) => ` L${m.line}: ${m.text}`).join('\n') || ''