From 090c1d47aa02e01af31c10e550f11e4fdb6ebb50 Mon Sep 17 00:00:00 2001 From: iliya Date: Tue, 24 Feb 2026 14:10:49 +0200 Subject: [PATCH] fix: improve error handling and logging in message sending process - Updated error handling in `handleSendMessage` to provide clearer error messages when stdin fails. - Enhanced JSON highlighting in `highlightLogsHtml` by parsing and pretty-printing JSON strings before highlighting. - Replaced the paperclip icon with an image plus icon in the `MessageComposer` for better visual representation of attachment options. --- package.json | 5 +++-- src/main/ipc/teams.ts | 5 +++-- src/renderer/components/team/ProvisioningProgressBlock.tsx | 4 +++- src/renderer/components/team/messages/MessageComposer.tsx | 4 ++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 0e0264f2..74585c95 100644 --- a/package.json +++ b/package.json @@ -51,9 +51,10 @@ }, "lint-staged": { "src/**/*.{ts,tsx,js,jsx}": [ - "eslint --fix" + "eslint --fix", + "prettier --write" ], - "src/**/*.{ts,tsx,js,jsx,json,css}": [ + "src/**/*.{json,css}": [ "prettier --write" ] }, diff --git a/src/main/ipc/teams.ts b/src/main/ipc/teams.ts index 2da44c76..93c95603 100644 --- a/src/main/ipc/teams.ts +++ b/src/main/ipc/teams.ts @@ -810,7 +810,7 @@ async function handleSendMessage( }); return result; - } catch (stdinError) { + } catch (stdinError: unknown) { // Stdin failed (process died between check and write) // If attachments were requested, fail rather than silently dropping them if (validatedAttachments?.length) { @@ -818,7 +818,8 @@ async function handleSendMessage( 'Failed to deliver message with attachments: team process became unavailable' ); } - logger.warn('stdin fallback for ' + tn + ': ' + String(stdinError)); + const errMsg = stdinError instanceof Error ? stdinError.message : 'unknown error'; + logger.warn(`stdin fallback for ${tn}: ${errMsg}`); // Fallback to inbox path for text-only messages } } diff --git a/src/renderer/components/team/ProvisioningProgressBlock.tsx b/src/renderer/components/team/ProvisioningProgressBlock.tsx index 632bfc9e..6c936434 100644 --- a/src/renderer/components/team/ProvisioningProgressBlock.tsx +++ b/src/renderer/components/team/ProvisioningProgressBlock.tsx @@ -69,7 +69,9 @@ function highlightLogsHtml(text: string): string { const trimmed = line.trimStart(); if (trimmed.startsWith('{') || trimmed.startsWith('[')) { try { - return hljs.highlight(line, { language: 'json' }).value; + const parsed: unknown = JSON.parse(trimmed); + const pretty = JSON.stringify(parsed, null, 2); + return hljs.highlight(pretty, { language: 'json' }).value; } catch { return escapeHtml(line); } diff --git a/src/renderer/components/team/messages/MessageComposer.tsx b/src/renderer/components/team/messages/MessageComposer.tsx index ed43a856..76750ed1 100644 --- a/src/renderer/components/team/messages/MessageComposer.tsx +++ b/src/renderer/components/team/messages/MessageComposer.tsx @@ -11,7 +11,7 @@ import { useDraftPersistence } from '@renderer/hooks/useDraftPersistence'; import { cn } from '@renderer/lib/utils'; import { formatAgentRole } from '@renderer/utils/formatAgentRole'; import { getModifierKeyName } from '@renderer/utils/keyboardUtils'; -import { AlertCircle, Check, ChevronDown, Paperclip, Send } from 'lucide-react'; +import { AlertCircle, Check, ChevronDown, ImagePlus, Send } from 'lucide-react'; import type { MentionSuggestion } from '@renderer/types/mention'; import type { AttachmentPayload, ResolvedTeamMember } from '@shared/types'; @@ -256,7 +256,7 @@ export const MessageComposer = ({ disabled={!canAttach} onClick={() => fileInputRef.current?.click()} > - +