MCPcopy Create free account
hub / github.com/winfunc/opcode / MultiEditWidget

Function MultiEditWidget

src/components/ToolWidgets.tsx:1597–1694  ·  view source on GitHub ↗
({ file_path, edits, result: _result })

Source from the content-addressed store, hash-verified

1595 edits: Array<{ old_string: string; new_string: string }>;
1596 result?: any;
1597}> = ({ file_path, edits, result: _result }) => {
1598 const [isExpanded, setIsExpanded] = useState(false);
1599 const language = getLanguage(file_path);
1600 const { theme } = useTheme();
1601 const syntaxTheme = getClaudeSyntaxTheme(theme);
1602
1603 return (
1604 <div className="space-y-2">
1605 <div className="flex items-center gap-2 mb-2">
1606 <FileEdit className="h-4 w-4 text-muted-foreground" />
1607 <span className="text-sm font-medium">Using tool: MultiEdit</span>
1608 </div>
1609 <div className="ml-6 space-y-2">
1610 <div className="flex items-center gap-2">
1611 <FileText className="h-3 w-3 text-blue-500" />
1612 <code className="text-xs font-mono text-blue-500">{file_path}</code>
1613 </div>
1614
1615 <div className="space-y-1">
1616 <button
1617 onClick={() => setIsExpanded(!isExpanded)}
1618 className="flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors"
1619 >
1620 <ChevronRight className={cn("h-3 w-3 transition-transform", isExpanded && "rotate-90")} />
1621 {edits.length} edit{edits.length !== 1 ? 's' : ''}
1622 </button>
1623
1624 {isExpanded && (
1625 <div className="space-y-3 mt-3">
1626 {edits.map((edit, index) => {
1627 const diffResult = Diff.diffLines(edit.old_string || '', edit.new_string || '', {
1628 newlineIsToken: true,
1629 ignoreWhitespace: false
1630 });
1631
1632 return (
1633 <div key={index} className="space-y-1">
1634 <div className="text-xs font-medium text-muted-foreground">Edit {index + 1}</div>
1635 <div className="rounded-lg border bg-zinc-950 overflow-hidden text-xs font-mono">
1636 <div className="max-h-[300px] overflow-y-auto overflow-x-auto">
1637 {diffResult.map((part, partIndex) => {
1638 const partClass = part.added
1639 ? 'bg-green-950/20'
1640 : part.removed
1641 ? 'bg-red-950/20'
1642 : '';
1643
1644 if (!part.added && !part.removed && part.count && part.count > 8) {
1645 return (
1646 <div key={partIndex} className="px-4 py-1 bg-zinc-900 border-y border-zinc-800 text-center text-zinc-500 text-xs">
1647 ... {part.count} unchanged lines ...
1648 </div>
1649 );
1650 }
1651
1652 const value = part.value.endsWith('\n') ? part.value.slice(0, -1) : part.value;
1653
1654 return (

Callers

nothing calls this directly

Calls 4

useThemeFunction · 0.90
getClaudeSyntaxThemeFunction · 0.90
cnFunction · 0.90
getLanguageFunction · 0.85

Tested by

no test coverage detected