From fe5baf75691400f69fa5febc412a81bfe8e2630f Mon Sep 17 00:00:00 2001 From: Siddharth Ganesan Date: Thu, 9 Apr 2026 13:44:57 -0700 Subject: [PATCH] Tool display intetns --- .../components/file-viewer/file-viewer.tsx | 17 +++++++++++++++-- .../app/workspace/[workspaceId]/home/types.ts | 4 ++-- .../lib/copilot/generated/tool-catalog-v1.ts | 10 +++------- .../lib/copilot/generated/tool-schemas-v1.ts | 11 +++-------- apps/sim/lib/copilot/tools/handlers/vfs.ts | 19 +++++++++++++------ 5 files changed, 36 insertions(+), 25 deletions(-) diff --git a/apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/file-viewer.tsx b/apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/file-viewer.tsx index 3163939169..f1cd23cf8c 100644 --- a/apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/file-viewer.tsx +++ b/apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/file-viewer.tsx @@ -838,6 +838,15 @@ function PptxPreview({ const [rendering, setRendering] = useState(false) const [renderError, setRenderError] = useState(null) + const shouldSuppressStreamingPptxError = (message: string): boolean => { + return ( + message.includes('SyntaxError: Invalid or unexpected token') || + message.includes('PPTX generation cancelled') || + message.includes('Preview failed') || + message.includes('AbortError') + ) + } + // Streaming preview: only re-triggers when the streaming source code or // workspace changes. Isolated from fileData/dataUpdatedAt so that file-list // refreshes don't abort the in-flight compilation request. @@ -879,8 +888,12 @@ function PptxPreview({ } catch (err) { if (!cancelled && !(err instanceof DOMException && err.name === 'AbortError')) { const msg = err instanceof Error ? err.message : 'Failed to render presentation' - logger.error('PPTX render failed', { error: msg }) - setRenderError(msg) + if (shouldSuppressStreamingPptxError(msg)) { + logger.info('Suppressing transient PPTX streaming preview error', { error: msg }) + } else { + logger.error('PPTX render failed', { error: msg }) + setRenderError(msg) + } } } finally { if (!cancelled) setRendering(false) diff --git a/apps/sim/app/workspace/[workspaceId]/home/types.ts b/apps/sim/app/workspace/[workspaceId]/home/types.ts index 88cbb59e6c..26f39e689f 100644 --- a/apps/sim/app/workspace/[workspaceId]/home/types.ts +++ b/apps/sim/app/workspace/[workspaceId]/home/types.ts @@ -269,12 +269,12 @@ export const TOOL_UI_METADATA: Record = { phase: 'resource', }, [WorkspaceFile.id]: { - title: 'Managing file', + title: 'Declaring file intent', phaseLabel: 'Resource', phase: 'resource', }, [EditContent.id]: { - title: 'Writing content', + title: 'Applying file content', phaseLabel: 'Resource', phase: 'resource', }, diff --git a/apps/sim/lib/copilot/generated/tool-catalog-v1.ts b/apps/sim/lib/copilot/generated/tool-catalog-v1.ts index 5a75fe2ded..591b20d794 100644 --- a/apps/sim/lib/copilot/generated/tool-catalog-v1.ts +++ b/apps/sim/lib/copilot/generated/tool-catalog-v1.ts @@ -2587,7 +2587,7 @@ export const WorkspaceFile: ToolCatalogEntry = { operation: { type: 'string', description: 'The file operation to perform.', - enum: ['append', 'update', 'patch', 'rename', 'delete'], + enum: ['append', 'update', 'patch'], }, target: { type: 'object', @@ -2613,7 +2613,7 @@ export const WorkspaceFile: ToolCatalogEntry = { title: { type: 'string', description: - 'Optional short UI label for create/append chunks, e.g. "Chapter 1" or "Slide 3".', + 'Required short UI label for this content unit, e.g. "Chapter 1", "Slide 3", or "Fix footer spacing".', }, contentType: { type: 'string', @@ -2684,12 +2684,8 @@ export const WorkspaceFile: ToolCatalogEntry = { }, }, }, - newName: { - type: 'string', - description: 'New file name for rename. Must be a plain workspace filename like "main.py".', - }, }, - required: ['operation', 'target'], + required: ['operation', 'target', 'title'], }, resultSchema: { type: 'object', diff --git a/apps/sim/lib/copilot/generated/tool-schemas-v1.ts b/apps/sim/lib/copilot/generated/tool-schemas-v1.ts index a4e11906e9..58d6162ce5 100644 --- a/apps/sim/lib/copilot/generated/tool-schemas-v1.ts +++ b/apps/sim/lib/copilot/generated/tool-schemas-v1.ts @@ -2355,7 +2355,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record = { operation: { type: 'string', description: 'The file operation to perform.', - enum: ['append', 'update', 'patch', 'rename', 'delete'], + enum: ['append', 'update', 'patch'], }, target: { type: 'object', @@ -2382,7 +2382,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record = { title: { type: 'string', description: - 'Optional short UI label for create/append chunks, e.g. "Chapter 1" or "Slide 3".', + 'Required short UI label for this content unit, e.g. "Chapter 1", "Slide 3", or "Fix footer spacing".', }, contentType: { type: 'string', @@ -2453,13 +2453,8 @@ export const TOOL_RUNTIME_SCHEMAS: Record = { }, }, }, - newName: { - type: 'string', - description: - 'New file name for rename. Must be a plain workspace filename like "main.py".', - }, }, - required: ['operation', 'target'], + required: ['operation', 'target', 'title'], }, resultSchema: { type: 'object', diff --git a/apps/sim/lib/copilot/tools/handlers/vfs.ts b/apps/sim/lib/copilot/tools/handlers/vfs.ts index 315fe585e8..e5007924fb 100644 --- a/apps/sim/lib/copilot/tools/handlers/vfs.ts +++ b/apps/sim/lib/copilot/tools/handlers/vfs.ts @@ -21,6 +21,10 @@ function isOversizedReadPlaceholder(content: string): boolean { ) } +function hasImageAttachment(result: { attachment?: { type?: string } }): boolean { + return result.attachment?.type === 'image' +} + export async function executeVfsGrep( params: Record, context: ExecutionContext @@ -153,8 +157,9 @@ export async function executeVfsRead( const uploadResult = await readChatUpload(filename, context.chatId) if (uploadResult) { if ( - isOversizedReadPlaceholder(uploadResult.content) || - serializedResultSize(uploadResult) > TOOL_RESULT_MAX_INLINE_CHARS + !hasImageAttachment(uploadResult) && + (isOversizedReadPlaceholder(uploadResult.content) || + serializedResultSize(uploadResult) > TOOL_RESULT_MAX_INLINE_CHARS) ) { return { success: false, @@ -183,8 +188,9 @@ export async function executeVfsRead( const fileContent = await vfs.readFileContent(path) if (fileContent) { if ( - isOversizedReadPlaceholder(fileContent.content) || - serializedResultSize(fileContent) > TOOL_RESULT_MAX_INLINE_CHARS + !hasImageAttachment(fileContent) && + (isOversizedReadPlaceholder(fileContent.content) || + serializedResultSize(fileContent) > TOOL_RESULT_MAX_INLINE_CHARS) ) { return { success: false, @@ -214,8 +220,9 @@ export async function executeVfsRead( return { success: false, error: `File not found: ${path}.${hint}` } } if ( - isOversizedReadPlaceholder(result.content) || - serializedResultSize(result) > TOOL_RESULT_MAX_INLINE_CHARS + !hasImageAttachment(result) && + (isOversizedReadPlaceholder(result.content) || + serializedResultSize(result) > TOOL_RESULT_MAX_INLINE_CHARS) ) { return { success: false,