Switch from code block to blockquote format
Code blocks collapse after ~4 lines in Mattermost, requiring click to expand. Blockquotes (> prefix) never collapse and show all content inline with a distinct left border. - Tool calls: inline code formatting (backtick tool name) - Thinking text: box drawing prefix for visual distinction - Header: bold status + code agent name - All lines visible without clicking to expand
This commit is contained in:
@@ -42,12 +42,12 @@ function format(sessionState, opts = {}) {
|
|||||||
const elapsed = formatElapsed(Date.now() - sessionState.startTime);
|
const elapsed = formatElapsed(Date.now() - sessionState.startTime);
|
||||||
const agentId = sessionState.agentId || extractAgentId(sessionState.sessionKey);
|
const agentId = sessionState.agentId || extractAgentId(sessionState.sessionKey);
|
||||||
const statusPrefix = statusIcon(sessionState.status);
|
const statusPrefix = statusIcon(sessionState.status);
|
||||||
lines.push(`${indent}${statusPrefix} ${agentId} | ${elapsed}`);
|
lines.push(`${indent}**${statusPrefix}** \`${agentId}\` | ${elapsed}`);
|
||||||
|
|
||||||
// Status lines (trimmed to maxLines, most recent)
|
// Status lines (trimmed to maxLines, most recent)
|
||||||
const statusLines = (sessionState.lines || []).slice(-maxLines);
|
const statusLines = (sessionState.lines || []).slice(-maxLines);
|
||||||
for (const line of statusLines) {
|
for (const line of statusLines) {
|
||||||
lines.push(`${indent} ${truncateLine(line)}`);
|
lines.push(`${indent}${formatStatusLine(truncateLine(line))}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Child sessions (sub-agents)
|
// Child sessions (sub-agents)
|
||||||
@@ -63,13 +63,14 @@ function format(sessionState, opts = {}) {
|
|||||||
const tokenStr = sessionState.tokenCount
|
const tokenStr = sessionState.tokenCount
|
||||||
? ` | ${formatTokens(sessionState.tokenCount)} tokens`
|
? ` | ${formatTokens(sessionState.tokenCount)} tokens`
|
||||||
: '';
|
: '';
|
||||||
lines.push(`${indent} [${sessionState.status.toUpperCase()}] ${elapsed}${tokenStr}`);
|
lines.push(`${indent}**[${sessionState.status.toUpperCase()}]** ${elapsed}${tokenStr}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wrap in code block at top level so it looks distinct from normal messages
|
// Wrap in blockquote at top level — visually distinct (left border),
|
||||||
|
// never collapses like code blocks do, supports inline markdown
|
||||||
var body = lines.join('\n');
|
var body = lines.join('\n');
|
||||||
if (depth === 0) {
|
if (depth === 0) {
|
||||||
body = '```\n' + body + '\n```';
|
body = body.split('\n').map(function (l) { return '> ' + l; }).join('\n');
|
||||||
}
|
}
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
@@ -120,6 +121,24 @@ function statusIcon(status) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format a status line with inline markdown.
|
||||||
|
* Tool calls get inline code formatting; thinking text stays plain.
|
||||||
|
* @param {string} line
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
function formatStatusLine(line) {
|
||||||
|
// Tool call lines: "toolName: arguments [OK]" or "toolName: label"
|
||||||
|
var match = line.match(/^(\S+?): (.+?)( \[OK\]| \[ERR\])?$/);
|
||||||
|
if (match) {
|
||||||
|
var marker = match[3] || '';
|
||||||
|
return '`' + match[1] + ':` ' + match[2] + marker;
|
||||||
|
}
|
||||||
|
// Thinking text — use a unicode marker to distinguish from tool calls
|
||||||
|
// Avoid markdown italic (*) since it breaks with special characters
|
||||||
|
return '\u2502 ' + line;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Truncate a line to MAX_LINE_CHARS.
|
* Truncate a line to MAX_LINE_CHARS.
|
||||||
* @param {string} line
|
* @param {string} line
|
||||||
|
|||||||
Reference in New Issue
Block a user