MCPcopy Index your code
hub / github.com/codeaashu/claude-code / showDiff

Function showDiff

src/hooks/useDiffInIDE.ts:77–138  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

75 getConnectedIdeName(toolUseContext.options.mcpClients) ?? 'IDE'
76
77 async function showDiff(): Promise<void> {
78 if (!shouldShowDiffInIDE) {
79 return
80 }
81
82 try {
83 logEvent('tengu_ext_will_show_diff', {})
84
85 const { oldContent, newContent } = await showDiffInIDE(
86 filePath,
87 edits,
88 toolUseContext,
89 tabName,
90 )
91 // Skip if component has been unmounted
92 if (isUnmounted.current) {
93 return
94 }
95
96 logEvent('tengu_ext_diff_accepted', {})
97
98 const newEdits = computeEditsFromContents(
99 filePath,
100 oldContent,
101 newContent,
102 editMode,
103 )
104
105 if (newEdits.length === 0) {
106 // No changes -- edit was rejected (eg. reverted)
107 logEvent('tengu_ext_diff_rejected', {})
108 // We close the tab here because 'no' no longer auto-closes
109 const ideClient = getConnectedIdeClient(
110 toolUseContext.options.mcpClients,
111 )
112 if (ideClient) {
113 // Close the tab in the IDE
114 await closeTabInIDE(tabName, ideClient)
115 }
116 onChange(
117 { type: 'reject' },
118 {
119 file_path: filePath,
120 edits: edits,
121 },
122 )
123 return
124 }
125
126 // File was modified - edit was accepted
127 onChange(
128 { type: 'accept-once' },
129 {
130 file_path: filePath,
131 edits: newEdits,
132 },
133 )
134 } catch (error) {

Callers 1

useDiffInIDEFunction · 0.85

Calls 7

logEventFunction · 0.85
showDiffInIDEFunction · 0.85
computeEditsFromContentsFunction · 0.85
getConnectedIdeClientFunction · 0.85
closeTabInIDEFunction · 0.85
onChangeFunction · 0.50
logErrorFunction · 0.50

Tested by

no test coverage detected