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
6a31d440a4
commit
fbcfd7b1a7
4 changed files with 11 additions and 7 deletions
|
|
@ -51,9 +51,10 @@
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
"src/**/*.{ts,tsx,js,jsx}": [
|
"src/**/*.{ts,tsx,js,jsx}": [
|
||||||
"eslint --fix"
|
"eslint --fix",
|
||||||
|
"prettier --write"
|
||||||
],
|
],
|
||||||
"src/**/*.{ts,tsx,js,jsx,json,css}": [
|
"src/**/*.{json,css}": [
|
||||||
"prettier --write"
|
"prettier --write"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -810,7 +810,7 @@ async function handleSendMessage(
|
||||||
});
|
});
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
} catch (stdinError) {
|
} catch (stdinError: unknown) {
|
||||||
// Stdin failed (process died between check and write)
|
// Stdin failed (process died between check and write)
|
||||||
// If attachments were requested, fail rather than silently dropping them
|
// If attachments were requested, fail rather than silently dropping them
|
||||||
if (validatedAttachments?.length) {
|
if (validatedAttachments?.length) {
|
||||||
|
|
@ -818,7 +818,8 @@ async function handleSendMessage(
|
||||||
'Failed to deliver message with attachments: team process became unavailable'
|
'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
|
// Fallback to inbox path for text-only messages
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,9 @@ function highlightLogsHtml(text: string): string {
|
||||||
const trimmed = line.trimStart();
|
const trimmed = line.trimStart();
|
||||||
if (trimmed.startsWith('{') || trimmed.startsWith('[')) {
|
if (trimmed.startsWith('{') || trimmed.startsWith('[')) {
|
||||||
try {
|
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 {
|
} catch {
|
||||||
return escapeHtml(line);
|
return escapeHtml(line);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import { useDraftPersistence } from '@renderer/hooks/useDraftPersistence';
|
||||||
import { cn } from '@renderer/lib/utils';
|
import { cn } from '@renderer/lib/utils';
|
||||||
import { formatAgentRole } from '@renderer/utils/formatAgentRole';
|
import { formatAgentRole } from '@renderer/utils/formatAgentRole';
|
||||||
import { getModifierKeyName } from '@renderer/utils/keyboardUtils';
|
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 { MentionSuggestion } from '@renderer/types/mention';
|
||||||
import type { AttachmentPayload, ResolvedTeamMember } from '@shared/types';
|
import type { AttachmentPayload, ResolvedTeamMember } from '@shared/types';
|
||||||
|
|
@ -256,7 +256,7 @@ export const MessageComposer = ({
|
||||||
disabled={!canAttach}
|
disabled={!canAttach}
|
||||||
onClick={() => fileInputRef.current?.click()}
|
onClick={() => fileInputRef.current?.click()}
|
||||||
>
|
>
|
||||||
<Paperclip size={14} />
|
<ImagePlus size={14} />
|
||||||
</button>
|
</button>
|
||||||
</TooltipTrigger>
|
</TooltipTrigger>
|
||||||
<TooltipContent side="top">
|
<TooltipContent side="top">
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue