Skip to content

Commit f0d3819

Browse files
committed
Fix dev
1 parent fe5baf7 commit f0d3819

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

apps/sim/lib/copilot/tools/handlers/vfs.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import { loggerMock } from '@sim/testing'
66
import { beforeEach, describe, expect, it, vi } from 'vitest'
7+
import { TOOL_RESULT_MAX_INLINE_CHARS } from '@/lib/copilot/constants'
78

89
const { getOrMaterializeVFS } = vi.hoisted(() => ({
910
getOrMaterializeVFS: vi.fn(),
@@ -24,6 +25,8 @@ vi.mock('./upload-file-reader', () => ({
2425

2526
import { executeVfsGrep, executeVfsRead } from './vfs'
2627

28+
const OVERSIZED_INLINE_CONTENT = 'x'.repeat(TOOL_RESULT_MAX_INLINE_CHARS + 1)
29+
2730
function makeVfs() {
2831
return {
2932
grep: vi.fn(),
@@ -40,10 +43,7 @@ describe('vfs handlers oversize policy', () => {
4043

4144
it('fails oversized grep results with narrowing guidance', async () => {
4245
const vfs = makeVfs()
43-
vfs.grep.mockReturnValue([
44-
{ path: 'files/a.txt', line: 1, content: 'a'.repeat(60_000) },
45-
{ path: 'files/b.txt', line: 2, content: 'b'.repeat(60_000) },
46-
])
46+
vfs.grep.mockReturnValue([{ path: 'files/a.txt', line: 1, content: OVERSIZED_INLINE_CONTENT }])
4747
getOrMaterializeVFS.mockResolvedValue(vfs)
4848

4949
const result = await executeVfsGrep(
@@ -57,7 +57,7 @@ describe('vfs handlers oversize policy', () => {
5757

5858
it('fails oversized read results with grep guidance', async () => {
5959
const vfs = makeVfs()
60-
vfs.read.mockReturnValue({ content: 'a'.repeat(100_001), totalLines: 1 })
60+
vfs.read.mockReturnValue({ content: OVERSIZED_INLINE_CONTENT, totalLines: 1 })
6161
getOrMaterializeVFS.mockResolvedValue(vfs)
6262

6363
const result = await executeVfsRead(

apps/sim/lib/copilot/tools/server/files/edit-content.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ export const editContentServerTool: BaseServerTool<EditContentArgs, EditContentR
103103
case 'append': {
104104
const existing = intent.existingContent ?? ''
105105
finalContent = docInfo.isDoc
106-
? `${existing}\n{\n${content}\n}`
106+
? existing
107+
? `${existing}\n{\n${content}\n}`
108+
: content
107109
: existing
108110
? `${existing}\n${content}`
109111
: content

0 commit comments

Comments
 (0)