From 16007ec3908c988ecec410e883a49d003caeccf0 Mon Sep 17 00:00:00 2001 From: Lucy Batten Date: Fri, 1 May 2026 22:25:07 +0100 Subject: [PATCH] feat: add open in github to file inspector Co-authored-by: lucyb0207 Co-authored-by: xyzyzyz-del --- frontend/src/pages/Analyze.tsx | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/frontend/src/pages/Analyze.tsx b/frontend/src/pages/Analyze.tsx index 95aa4f1..5988fc1 100644 --- a/frontend/src/pages/Analyze.tsx +++ b/frontend/src/pages/Analyze.tsx @@ -17,6 +17,8 @@ export default function App() { const [focusMode, setFocusMode] = useState(true); const [depth, setDepth] = useState(2); const [loading, setLoading] = useState(false); + const [repoUrl, setRepoUrl] = useState(""); + const API = import.meta.env.DEV ? "http://localhost:8080" : "https://codeatlas-production-e4f8.up.railway.app"; @@ -28,7 +30,17 @@ export default function App() { setCopied(true); setTimeout(() => setCopied(false), 1500); }, [selectedFile]); + + const handleOpenInGitHub = useCallback((): void => { + if (!selectedFile || !repoUrl) return; + + const cleanRepoUrl = repoUrl.replace(/\.git$/, ""); + const branch = "main"; + const url = `${cleanRepoUrl}/blob/${branch}/${selectedFile}`; + + window.open(url, "_blank"); + }, [selectedFile, repoUrl]); const displayData = useMemo(() => { if (!graphData) return null; @@ -77,6 +89,7 @@ export default function App() { })), backLinks: graph.backLinks || {}, }); + setRepoUrl(url); } catch (err) { console.error("Analyze error:", err); setGraphData(null); @@ -104,6 +117,7 @@ export default function App() { return "plaintext"; }; + return ( <> @@ -187,7 +201,17 @@ export default function App() { > {copied ? "✓" : "Copy"} +
|
+ +
Imports