From 968e09f0b50d17f7c591baa977666b991a1e59b7 Mon Sep 17 00:00:00 2001 From: Taylor Mullen Date: Thu, 15 May 2025 23:51:53 -0700 Subject: fix: Ensure filename is available for diff rendering in write-file This commit resolves a bug where the `write-file` operation could fail to render content due to a missing filename. The fix involves: - Ensuring `fileName` is consistently passed to `DiffRenderer.tsx` through `ToolConfirmationMessage.tsx`, `ToolMessage.tsx`, and `useGeminiStream.ts`. - Modifying `edit.ts` and `write-file.ts` to include `fileName` in the `FileDiff` object. - Expanding the `FileDiff` interface in `tools.ts` to include `fileName`. Additionally, this commit enhances the diff rendering by: - Adding syntax highlighting based on file extension in `DiffRenderer.tsx`. - Adding more language mappings to `getLanguageFromExtension` in `DiffRenderer.tsx`. - Added lots of tests for all the above. Fixes https://b.corp.google.com/issues/418125982 --- packages/cli/src/ui/hooks/atCommandProcessor.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'packages/cli/src/ui/hooks/atCommandProcessor.ts') diff --git a/packages/cli/src/ui/hooks/atCommandProcessor.ts b/packages/cli/src/ui/hooks/atCommandProcessor.ts index e0cf65c5..e2934840 100644 --- a/packages/cli/src/ui/hooks/atCommandProcessor.ts +++ b/packages/cli/src/ui/hooks/atCommandProcessor.ts @@ -154,7 +154,9 @@ export async function handleAtCommand({ if (isNodeError(error) && error.code === 'ENOENT') { onDebugMessage(`Path not found, proceeding with original: ${pathSpec}`); } else { - console.error(`Error stating path ${pathPart}:`, error); + console.error( + `Error stating path ${pathPart}: ${getErrorMessage(error)}`, + ); onDebugMessage( `Error stating path, proceeding with original: ${pathSpec}`, ); @@ -200,7 +202,7 @@ export async function handleAtCommand({ ); return { processedQuery, shouldProceed: true }; - } catch (error) { + } catch (error: unknown) { // Handle errors during tool execution toolCallDisplay = { callId: `client-read-${userMessageTimestamp}`, -- cgit v1.2.3