@@ -7,11 +7,13 @@ import {
77 processKernelData ,
88 getIRType ,
99} from "./utils/dataLoader" ;
10+ import { checkFbDirectoryExists } from "./utils/fbDetection" ;
1011import CodeView from "./pages/CodeView" ;
1112import SingleCodeViewer from "./components/SingleCodeViewer" ;
1213import KernelOverview from "./pages/KernelOverview" ;
1314import DataSourceSelector from "./components/DataSourceSelector" ;
1415import WelcomeScreen from "./components/WelcomeScreen" ;
16+ import ExternalLink from "./components/ExternalLink" ;
1517import { mapLanguageToHighlighter } from "./components/CodeViewer" ;
1618
1719/**
@@ -35,6 +37,11 @@ function App() {
3537 const [ dataLoaded , setDataLoaded ] = useState < boolean > ( false ) ;
3638 // Track the loaded data source URL
3739 const [ loadedUrl , setLoadedUrl ] = useState < string | null > ( null ) ;
40+ // Track if fb directory exists for internal wiki link
41+ const [ fbDirectoryExists , setFbDirectoryExists ] = useState < boolean > ( false ) ;
42+
43+ // Internal wiki URL - will be loaded dynamically if fb directory exists
44+ const [ internalWikiUrl , setInternalWikiUrl ] = useState < string > ( '' ) ;
3845
3946 /**
4047 * Helper function to find a kernel by its hash
@@ -45,7 +52,7 @@ function App() {
4552 ) ;
4653 } ;
4754
48- // Check URL parameters when component mounts
55+ // Check URL parameters and fb directory when component mounts
4956 useEffect ( ( ) => {
5057 // Parse URL parameters
5158 const params = new URLSearchParams ( window . location . search ) ;
@@ -61,6 +68,21 @@ function App() {
6168 newUrl . searchParams . set ( "json_url" , jsonUrl ) ;
6269 window . history . replaceState ( { } , "" , newUrl . toString ( ) ) ;
6370 }
71+
72+ // Check if fb directory exists and load internal utils if available
73+ checkFbDirectoryExists ( ) . then ( async ( exists ) => {
74+ setFbDirectoryExists ( exists ) ;
75+ if ( exists ) {
76+ try {
77+ // Dynamically import internal utils only if fb directory exists
78+ const { getInternalWikiUrl } = await import ( './utils/fb/internal_utils' ) ;
79+ const url = getInternalWikiUrl ( ) ;
80+ setInternalWikiUrl ( url ) ;
81+ } catch ( error ) {
82+ console . warn ( 'Failed to load internal utils:' , error ) ;
83+ }
84+ }
85+ } ) ;
6486 } , [ ] ) ; // Empty dependency array means this runs once on mount
6587
6688 /**
@@ -340,21 +362,62 @@ function App() {
340362 < header className = "bg-white border-b border-gray-200" >
341363 < div className = "w-full px-6 py-4" >
342364 < div className = "flex justify-between items-center" >
343- < h1
344- className = "text-gray-800 text-2xl font-bold cursor-pointer hover:text-indigo-600 transition-colors"
345- onClick = { ( ) => {
346- // Reset app state to show welcome page
347- if ( dataLoaded ) {
348- setDataLoaded ( false ) ;
349- setSelectedIR ( null ) ;
350- setSelectedKernel ( - 1 ) ;
351- setError ( null ) ;
352- }
353- } }
354- title = "Back to home"
355- >
356- TritonParse
357- </ h1 >
365+ < div className = "flex items-center space-x-6" >
366+ < h1
367+ className = "text-gray-800 text-2xl font-bold cursor-pointer hover:text-indigo-600 transition-colors"
368+ onClick = { ( ) => {
369+ // Reset app state to show welcome page
370+ if ( dataLoaded ) {
371+ setDataLoaded ( false ) ;
372+ setSelectedIR ( null ) ;
373+ setSelectedKernel ( - 1 ) ;
374+ setError ( null ) ;
375+ }
376+ } }
377+ title = "Back to home"
378+ >
379+ TritonParse
380+ </ h1 >
381+
382+ { /* GitHub and Wiki Links */ }
383+ < div className = "flex items-center space-x-4" >
384+ < ExternalLink
385+ href = "https://github.com/pytorch-labs/tritonparse"
386+ title = "View on GitHub"
387+ text = "GitHub"
388+ icon = {
389+ < svg className = "w-5 h-5" fill = "currentColor" viewBox = "0 0 24 24" >
390+ < path d = "M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z" />
391+ </ svg >
392+ }
393+ />
394+
395+ < ExternalLink
396+ href = "https://github.com/pytorch-labs/tritonparse/wiki"
397+ title = "View Wiki"
398+ text = "Wiki"
399+ icon = {
400+ < svg className = "w-5 h-5" fill = "none" stroke = "currentColor" viewBox = "0 0 24 24" >
401+ < path strokeLinecap = "round" strokeLinejoin = "round" strokeWidth = { 2 } d = "M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.746 0 3.332.477 4.5 1.253v13C19.832 18.477 18.246 18 16.5 18c-1.746 0-3.332.477-4.5 1.253" />
402+ </ svg >
403+ }
404+ />
405+
406+ { /* Internal Wiki Link - only show if fb directory exists */ }
407+ { fbDirectoryExists && (
408+ < ExternalLink
409+ href = { internalWikiUrl }
410+ title = "View Internal Wiki"
411+ text = "Internal Wiki"
412+ icon = {
413+ < svg className = "w-5 h-5" fill = "none" stroke = "currentColor" viewBox = "0 0 24 24" >
414+ < path strokeLinecap = "round" strokeLinejoin = "round" strokeWidth = { 2 } d = "M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.746 0 3.332.477 4.5 1.253v13C19.832 18.477 18.246 18 16.5 18c-1.746 0-3.332.477-4.5 1.253" />
415+ </ svg >
416+ }
417+ />
418+ ) }
419+ </ div >
420+ </ div >
358421
359422 { /* Data source selector (only show when data is loaded or when on the welcome screen) */ }
360423 < DataSourceSelector
0 commit comments