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.
This commit is contained in:
parent
aa49ce0ccc
commit
090c1d47aa
4 changed files with 11 additions and 7 deletions
|
|
@ -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"
|
||||
]
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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()}
|
||||
>
|
||||
<Paperclip size={14} />
|
||||
<ImagePlus size={14} />
|
||||
</button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="top">
|
||||
|
|
|
|||
Loading…
Reference in a new issue