')
+ .text(segment.original)
+ .css({
+ 'background-color': 'rgba(255, 0, 0, 0.2)',
+ 'cursor': 'pointer',
+ 'padding': '5px',
+ 'margin-bottom': '2px',
+ 'white-space': 'pre-wrap',
+ 'color': '#d4d4d4'
+ })
+ .attr('title', '点击恢复 (Click to restore)');
+
+ const added = $('
')
+ .attr('contenteditable', 'true')
+ .css({
+ 'background-color': 'rgba(0, 255, 0, 0.2)',
+ 'cursor': 'text',
+ 'padding': '5px',
+ 'white-space': 'pre-wrap',
+ 'color': '#d4d4d4',
+ 'outline': 'none'
+ })
+ .attr('title', '点击编辑');
+
+ const toggle = () => {
+ segment.active = false;
+ renderChange();
+ if (agentManager) {
+ const newDiff = reconstructDiff(file.segments);
+ agentManager.updatePendingToolArgs({ diff: newDiff });
+ }
+ };
+
+ removed.on('click', toggle);
+
+ added.on('input', function() {
+ segment.new = $(this).text();
+ if (agentManager) {
+ const newDiff = reconstructDiff(file.segments);
+ agentManager.updatePendingToolArgs({ diff: newDiff });
+ }
+ });
+
+ container.append(removed).append(added);
+ } else {
+
+ const restored = $('
')
+ .text(segment.original)
+ .css({
+ 'cursor': 'pointer',
+ 'border-left': '3px solid #666',
+ 'padding': '5px',
+ 'white-space': 'pre-wrap',
+ 'opacity': '0.7'
+ })
+ .attr('title', '点击重新应用修改 (Click to re-apply change)');
+
+ restored.on('click', () => {
+ segment.active = true;
+ renderChange();
+ if (agentManager) {
+ const newDiff = reconstructDiff(file.segments);
+ agentManager.updatePendingToolArgs({ diff: newDiff });
+ }
+ });
+
+ container.append(restored);
+ }
+ };
+
+ renderChange();
+ editorDiv.append(container);
+ }
+ });
+ } else {
+ editorDiv.text('Error: No segments found for diff view.');
+ }
+
+ contentDiv.append(editorDiv);
+ } else {
+
+ const textarea = $('