agent terminal: show full body for send tool calls
send was truncating to 80 chars in the tool_use row, hiding anything past the first sentence. now renders as a collapsed <details> like Write/Edit — summary still shows the recipient + headline (so the operator can scan), expanding reveals the full body unchanged. recv side was already covered: the wake prompt shows the full incoming body, and explicit recv() tool_result rows expand to the full text via the existing collapsed-results path.
This commit is contained in:
parent
3b532753b3
commit
fd0e493bf5
1 changed files with 44 additions and 30 deletions
|
|
@ -614,38 +614,51 @@
|
||||||
default: return name + ' ' + trim(JSON.stringify(input), 200);
|
default: return name + ' ' + trim(JSON.stringify(input), 200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Build a tool_use row for Write/Edit as a collapsed <details>
|
// Build a "rich" tool_use row for tools whose input has a body
|
||||||
// showing the actual change. Returns null for any other tool so
|
// we want the operator to see in full. Returns null for any
|
||||||
// the caller falls back to the flat-row path.
|
// other tool so the caller falls back to the flat-row path.
|
||||||
|
//
|
||||||
// Write: every input.content line is "+".
|
// Write: every input.content line is "+".
|
||||||
// Edit: old_string lines as "-", new_string lines as "+".
|
// Edit: old_string lines as "-", new_string lines as "+".
|
||||||
// Not a true diff algorithm — claude's Edit blocks are already a
|
// mcp__hyperhive__send: collapsed <details>, full body text
|
||||||
// contiguous old/new pair, so a literal -/+ rendering is honest.
|
// inside. Truncating to 80 chars in the summary was hiding
|
||||||
function renderFileWriteEdit(c) {
|
// anything past the first sentence.
|
||||||
|
function renderRichToolUse(c) {
|
||||||
const name = c.name || '';
|
const name = c.name || '';
|
||||||
const input = c.input || {};
|
const input = c.input || {};
|
||||||
if (name !== 'Write' && name !== 'Edit') return null;
|
if (name === 'Write' || name === 'Edit') {
|
||||||
const path = input.file_path || '?';
|
const path = input.file_path || '?';
|
||||||
let body;
|
let body;
|
||||||
let plus = 0;
|
let plus = 0;
|
||||||
let minus = 0;
|
let minus = 0;
|
||||||
if (name === 'Write') {
|
if (name === 'Write') {
|
||||||
const content = String(input.content || '');
|
const content = String(input.content || '');
|
||||||
const lines = content.split('\n');
|
const lines = content.split('\n');
|
||||||
plus = lines.length;
|
plus = lines.length;
|
||||||
body = lines.map(l => '+ ' + l).join('\n');
|
body = lines.map(l => '+ ' + l).join('\n');
|
||||||
} else {
|
} else {
|
||||||
const oldLines = String(input.old_string || '').split('\n');
|
const oldLines = String(input.old_string || '').split('\n');
|
||||||
const newLines = String(input.new_string || '').split('\n');
|
const newLines = String(input.new_string || '').split('\n');
|
||||||
minus = oldLines.length;
|
minus = oldLines.length;
|
||||||
plus = newLines.length;
|
plus = newLines.length;
|
||||||
body = oldLines.map(l => '- ' + l).join('\n')
|
body = oldLines.map(l => '- ' + l).join('\n')
|
||||||
+ '\n'
|
+ '\n'
|
||||||
+ newLines.map(l => '+ ' + l).join('\n');
|
+ newLines.map(l => '+ ' + l).join('\n');
|
||||||
|
}
|
||||||
|
const summary = '→ ' + name + ' ' + path + ' · '
|
||||||
|
+ (minus ? '-' + minus + ' ' : '') + '+' + plus;
|
||||||
|
return detailsDiff('tool-use', summary, body);
|
||||||
}
|
}
|
||||||
const summary = '→ ' + name + ' ' + path + ' · '
|
if (name === 'mcp__hyperhive__send') {
|
||||||
+ (minus ? '-' + minus + ' ' : '') + '+' + plus;
|
const to = input.to || '?';
|
||||||
return detailsDiff('tool-use', summary, body);
|
const body = String(input.body || '');
|
||||||
|
const headline = body.replace(/\s+/g, ' ').trim().slice(0, 80);
|
||||||
|
const lines = body.split('\n').length;
|
||||||
|
const summary = '→ send → ' + to + (lines > 1 ? ` · ${lines}L` : '')
|
||||||
|
+ (headline ? ' · ' + headline + (body.length > 80 ? '…' : '') : '');
|
||||||
|
return details('tool-use', summary, body);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
function detailsDiff(cls, summary, body) {
|
function detailsDiff(cls, summary, body) {
|
||||||
clearPlaceholder();
|
clearPlaceholder();
|
||||||
|
|
@ -705,9 +718,10 @@
|
||||||
row('thinking', txt ? '· ' + txt : '· thinking …');
|
row('thinking', txt ? '· ' + txt : '· thinking …');
|
||||||
}
|
}
|
||||||
else if (c.type === 'tool_use') {
|
else if (c.type === 'tool_use') {
|
||||||
// Write/Edit get a collapsed +/- diff body; everything
|
// Write/Edit get a +/- diff body; send gets a collapsed
|
||||||
// else stays as the flat row produced by fmtToolUse.
|
// <details> with the full body text; everything else
|
||||||
if (!renderFileWriteEdit(c)) {
|
// stays as the flat row produced by fmtToolUse.
|
||||||
|
if (!renderRichToolUse(c)) {
|
||||||
row('tool-use', '→ ' + fmtToolUse(c));
|
row('tool-use', '→ ' + fmtToolUse(c));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue