MCPcopy Create free account
hub / github.com/CodeGraphContext/CodeGraphContext / onFileClick

Function onFileClick

website/src/components/PRReviewer.tsx:1249–1301  ·  view source on GitHub ↗
(path: string | null, targetLine?: number)

Source from the content-addressed store, hash-verified

1247 }, [data.links, data.nodes, buildNodeFocus, openNodeInPanel]);
1248
1249 const onFileClick = (path: string | null, targetLine?: number) => {
1250 if (!path) {
1251 setSelectedFile(null);
1252 setSelectedNode(null);
1253 setFocusSet(null);
1254 setCodeContent(null);
1255 setCodeError(null);
1256 setHighlightLine(null);
1257 return;
1258 }
1259
1260 setHighlightLine(targetLine || null);
1261
1262 if (path !== selectedFile) {
1263 setSelectedFile(path);
1264 loadFileCode(path);
1265 } else if (targetLine) {
1266 setCodePanelTab('code');
1267 setTimeout(() => {
1268 const el = codeBodyRef.current?.querySelector(`[data-line="${targetLine}"]`);
1269 el?.scrollIntoView({ behavior: 'smooth', block: 'center' });
1270 }, 100);
1271 }
1272
1273 const fileNode = data.nodes.find((n: any) => n.file === path && n.type === 'File');
1274 if (fileNode) {
1275 if (fgRef.current) {
1276 fgRef.current.centerAt(fileNode.x, fileNode.y, 800);
1277 fgRef.current.zoom(2.5, 800);
1278 }
1279
1280 setFocusSet(buildNodeFocus(fileNode.id));
1281 } else {
1282 const fileNodes = data.nodes.filter((n: any) => n.file === path);
1283 if (fileNodes.length > 0) {
1284 const focusNodes = new Set<any>();
1285 const focusLinks = new Set<any>();
1286 for (const fn of fileNodes) {
1287 focusNodes.add(fn.id);
1288 data.links.forEach((l: any) => {
1289 const sId = typeof l.source === "object" ? l.source.id : l.source;
1290 const tId = typeof l.target === "object" ? l.target.id : l.target;
1291 if (sId === fn.id || tId === fn.id) {
1292 focusNodes.add(sId);
1293 focusNodes.add(tId);
1294 focusLinks.add(l);
1295 }
1296 });
1297 }
1298 setFocusSet({ nodes: focusNodes, links: focusLinks });
1299 }
1300 }
1301 };
1302
1303 const onGraphNodeClick = (node: any) => {
1304 if (isPathMode) {

Callers 3

TreeItemFunction · 0.70
onGraphNodeClickFunction · 0.70
PRReviewerFunction · 0.70

Calls 1

addMethod · 0.45

Tested by

no test coverage detected