From f0d3819093742d47afef01a732bdc204ff8c7fe4 Mon Sep 17 00:00:00 2001 From: Siddharth Ganesan Date: Thu, 9 Apr 2026 14:23:34 -0700 Subject: [PATCH] Fix dev --- apps/sim/lib/copilot/tools/handlers/vfs.test.ts | 10 +++++----- .../sim/lib/copilot/tools/server/files/edit-content.ts | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/sim/lib/copilot/tools/handlers/vfs.test.ts b/apps/sim/lib/copilot/tools/handlers/vfs.test.ts index 40431c7445..a215c09e8b 100644 --- a/apps/sim/lib/copilot/tools/handlers/vfs.test.ts +++ b/apps/sim/lib/copilot/tools/handlers/vfs.test.ts @@ -4,6 +4,7 @@ import { loggerMock } from '@sim/testing' import { beforeEach, describe, expect, it, vi } from 'vitest' +import { TOOL_RESULT_MAX_INLINE_CHARS } from '@/lib/copilot/constants' const { getOrMaterializeVFS } = vi.hoisted(() => ({ getOrMaterializeVFS: vi.fn(), @@ -24,6 +25,8 @@ vi.mock('./upload-file-reader', () => ({ import { executeVfsGrep, executeVfsRead } from './vfs' +const OVERSIZED_INLINE_CONTENT = 'x'.repeat(TOOL_RESULT_MAX_INLINE_CHARS + 1) + function makeVfs() { return { grep: vi.fn(), @@ -40,10 +43,7 @@ describe('vfs handlers oversize policy', () => { it('fails oversized grep results with narrowing guidance', async () => { const vfs = makeVfs() - vfs.grep.mockReturnValue([ - { path: 'files/a.txt', line: 1, content: 'a'.repeat(60_000) }, - { path: 'files/b.txt', line: 2, content: 'b'.repeat(60_000) }, - ]) + vfs.grep.mockReturnValue([{ path: 'files/a.txt', line: 1, content: OVERSIZED_INLINE_CONTENT }]) getOrMaterializeVFS.mockResolvedValue(vfs) const result = await executeVfsGrep( @@ -57,7 +57,7 @@ describe('vfs handlers oversize policy', () => { it('fails oversized read results with grep guidance', async () => { const vfs = makeVfs() - vfs.read.mockReturnValue({ content: 'a'.repeat(100_001), totalLines: 1 }) + vfs.read.mockReturnValue({ content: OVERSIZED_INLINE_CONTENT, totalLines: 1 }) getOrMaterializeVFS.mockResolvedValue(vfs) const result = await executeVfsRead( diff --git a/apps/sim/lib/copilot/tools/server/files/edit-content.ts b/apps/sim/lib/copilot/tools/server/files/edit-content.ts index de32aff1a4..0e5eb93f37 100644 --- a/apps/sim/lib/copilot/tools/server/files/edit-content.ts +++ b/apps/sim/lib/copilot/tools/server/files/edit-content.ts @@ -103,7 +103,9 @@ export const editContentServerTool: BaseServerTool