@@ -640,9 +640,11 @@ const html = `<!DOCTYPE html>
640640 contentDiv.innerHTML = todoHtml;
641641 } else {
642642 // Format raw input with expandable content for long values
643- // Use diff format for Edit tool , regular format for others
643+ // Use diff format for Edit and MultiEdit tools , regular format for others
644644 if (data.toolName === 'Edit') {
645645 contentDiv.innerHTML = formatEditToolDiff(data.rawInput);
646+ } else if (data.toolName === 'MultiEdit') {
647+ contentDiv.innerHTML = formatMultiEditToolDiff(data.rawInput);
646648 } else {
647649 contentDiv.innerHTML = formatToolInputUI(data.rawInput);
648650 }
@@ -728,7 +730,7 @@ const html = `<!DOCTYPE html>
728730
729731 function addToolResultMessage(data) {
730732 // For Read and Edit tools with hidden flag, just hide loading state and show completion message
731- if (data.hidden && (data.toolName === 'Read' || data.toolName === 'Edit' || data.toolName === 'TodoWrite') && !data.isError) {
733+ if (data.hidden && (data.toolName === 'Read' || data.toolName === 'Edit' || data.toolName === 'TodoWrite' || data.toolName === 'MultiEdit' ) && !data.isError) {
732734 return
733735 // Show completion message
734736 const toolName = data.toolName;
@@ -898,6 +900,120 @@ const html = `<!DOCTYPE html>
898900 return result;
899901 }
900902
903+ function formatMultiEditToolDiff(input) {
904+ if (!input || typeof input !== 'object') {
905+ return formatToolInputUI(input);
906+ }
907+
908+ // Check if this is a MultiEdit tool (has file_path and edits array)
909+ if (!input.file_path || !input.edits || !Array.isArray(input.edits)) {
910+ return formatToolInputUI(input);
911+ }
912+
913+ // Format file path with better display
914+ const formattedPath = formatFilePath(input.file_path);
915+ let result = '<div class="diff-file-path" onclick="openFileInEditor(\\\'' + escapeHtml(input.file_path) + '\\\')">' + formattedPath + '</div>\\n';
916+
917+ // Count total lines across all edits for truncation
918+ let totalLines = 0;
919+ for (const edit of input.edits) {
920+ if (edit.old_string && edit.new_string) {
921+ const oldLines = edit.old_string.split('\\n');
922+ const newLines = edit.new_string.split('\\n');
923+ totalLines += oldLines.length + newLines.length;
924+ }
925+ }
926+
927+ const maxLines = 6;
928+ const shouldTruncate = totalLines > maxLines;
929+
930+ result += '<div class="diff-container">';
931+ result += '<div class="diff-header">Changes (' + input.edits.length + ' edit' + (input.edits.length > 1 ? 's' : '') + '):</div>';
932+
933+ // Create a unique ID for this diff
934+ const diffId = 'multiedit_' + Math.random().toString(36).substr(2, 9);
935+
936+ let currentLineCount = 0;
937+ let visibleEdits = [];
938+ let hiddenEdits = [];
939+
940+ // Determine which edits to show/hide based on line count
941+ for (let i = 0; i < input.edits.length; i++) {
942+ const edit = input.edits[i];
943+ if (!edit.old_string || !edit.new_string) continue;
944+
945+ const oldLines = edit.old_string.split('\\n');
946+ const newLines = edit.new_string.split('\\n');
947+ const editLines = oldLines.length + newLines.length;
948+
949+ if (shouldTruncate && currentLineCount + editLines > maxLines && visibleEdits.length > 0) {
950+ hiddenEdits.push(edit);
951+ } else {
952+ visibleEdits.push(edit);
953+ currentLineCount += editLines;
954+ }
955+ }
956+
957+ // Show visible edits
958+ result += '<div id="' + diffId + '_visible">';
959+ for (let i = 0; i < visibleEdits.length; i++) {
960+ const edit = visibleEdits[i];
961+ if (i > 0) result += '<div class="diff-edit-separator"></div>';
962+ result += formatSingleEdit(edit, i + 1);
963+ }
964+ result += '</div>';
965+
966+ // Show hidden edits (initially hidden)
967+ if (hiddenEdits.length > 0) {
968+ result += '<div id="' + diffId + '_hidden" style="display: none;">';
969+ for (let i = 0; i < hiddenEdits.length; i++) {
970+ const edit = hiddenEdits[i];
971+ result += '<div class="diff-edit-separator"></div>';
972+ result += formatSingleEdit(edit, visibleEdits.length + i + 1);
973+ }
974+ result += '</div>';
975+
976+ // Add expand button
977+ result += '<div class="diff-expand-container">';
978+ result += '<button class="diff-expand-btn" onclick="toggleDiffExpansion(\\\'' + diffId + '\\\')">Show ' + hiddenEdits.length + ' more edit' + (hiddenEdits.length > 1 ? 's' : '') + '</button>';
979+ result += '</div>';
980+ }
981+
982+ result += '</div>';
983+
984+ // Add other properties if they exist
985+ for (const [key, value] of Object.entries(input)) {
986+ if (key !== 'file_path' && key !== 'edits') {
987+ const valueStr = typeof value === 'string' ? value : JSON.stringify(value, null, 2);
988+ result += '\\n<strong>' + key + ':</strong> ' + valueStr;
989+ }
990+ }
991+
992+ return result;
993+ }
994+
995+ function formatSingleEdit(edit, editNumber) {
996+ let result = '<div class="single-edit">';
997+ result += '<div class="edit-number">Edit #' + editNumber + '</div>';
998+
999+ // Create diff view for this single edit
1000+ const oldLines = edit.old_string.split('\\n');
1001+ const newLines = edit.new_string.split('\\n');
1002+
1003+ // Show removed lines
1004+ for (const line of oldLines) {
1005+ result += '<div class="diff-line removed">- ' + escapeHtml(line) + '</div>';
1006+ }
1007+
1008+ // Show added lines
1009+ for (const line of newLines) {
1010+ result += '<div class="diff-line added">+ ' + escapeHtml(line) + '</div>';
1011+ }
1012+
1013+ result += '</div>';
1014+ return result;
1015+ }
1016+
9011017 function escapeHtml(text) {
9021018 const div = document.createElement('div');
9031019 div.textContent = text;
0 commit comments