Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions apps/sim/lib/copilot/tools/server/files/edit-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,10 @@ export const editContentServerTool: BaseServerTool<EditContentArgs, EditContentR
return { success: false, message: `Unsupported operation in intent: ${operation}` }
}

let fileBuffer: Buffer
if (docInfo.isDoc) {
try {
await runSandboxTask(
fileBuffer = await runSandboxTask(
docInfo.taskId!,
{ code: finalContent, workspaceId },
{ ownerKey: `user:${context.userId}`, signal: context.abortSignal }
Expand All @@ -215,9 +216,9 @@ export const editContentServerTool: BaseServerTool<EditContentArgs, EditContentR
message: `${docInfo.formatName} generation failed: ${msg}. Fix the content and retry.`,
}
}
} else {
fileBuffer = Buffer.from(finalContent, 'utf-8')
}

const fileBuffer = Buffer.from(finalContent, 'utf-8')
assertServerToolNotAborted(context)
const mime = docInfo.sourceMime || inferContentType(fileRecord.name, intent.contentType)
await updateWorkspaceFileContent(workspaceId, intent.fileId, context.userId, fileBuffer, mime)
Expand Down
7 changes: 4 additions & 3 deletions apps/sim/lib/copilot/tools/server/files/workspace-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,10 @@ export const workspaceFileServerTool: BaseServerTool<WorkspaceFileArgs, Workspac

const docInfo = getDocumentFormatInfo(fileName)
let contentType = inferContentType(fileName, explicitType)
let fileBuffer: Buffer
if (docInfo.isDoc) {
try {
await runSandboxTask(
fileBuffer = await runSandboxTask(
docInfo.taskId!,
{ code: content, workspaceId },
{ ownerKey: `user:${context.userId}`, signal: context.abortSignal }
Expand All @@ -214,9 +215,9 @@ export const workspaceFileServerTool: BaseServerTool<WorkspaceFileArgs, Workspac
}
}
contentType = docInfo.sourceMime!
} else {
fileBuffer = Buffer.from(content, 'utf-8')
}

const fileBuffer = Buffer.from(content, 'utf-8')
assertServerToolNotAborted(context)
const result = await uploadWorkspaceFile(
workspaceId,
Expand Down
Loading