fix(chat): hide internal system messages from webchat (#710)

This commit is contained in:
Kagura
2026-03-30 14:57:26 +08:00
committed by GitHub
parent 47c9560b9e
commit ef3cf64484
5 changed files with 129 additions and 3 deletions

View File

@@ -598,6 +598,16 @@ function isToolResultRole(role: unknown): boolean {
return normalized === 'toolresult' || normalized === 'tool_result';
}
/** True for internal plumbing messages that should never be shown in the UI. */
function isInternalMessage(msg: { role?: unknown; content?: unknown }): boolean {
if (msg.role === 'system') return true;
if (msg.role === 'assistant') {
const text = getMessageText(msg.content);
if (/^(HEARTBEAT_OK|NO_REPLY)\s*$/.test(text)) return true;
}
return false;
}
function extractTextFromContent(content: unknown): string {
if (typeof content === 'string') return content;
if (!Array.isArray(content)) return '';
@@ -824,6 +834,7 @@ export {
extractRawFilePaths,
makeAttachedFile,
enrichWithToolResultFiles,
isInternalMessage,
isToolResultRole,
enrichWithCachedImages,
loadMissingPreviews,