11import { useEffect , useState } from "react" ;
22import type { GraphNode } from "../lib/types" ;
33
4- /* Upstream tracker for indexing gaps — issues land on the codebase-memory-mcp
5- * project itself (the tool that failed to index), never the user's repo. */
6- const UPSTREAM_ISSUES_URL = "https://github.com/DeusData/codebase-memory-mcp/issues/new" ;
4+ /* Upstream tracker for indexing gaps. The URL is served by the backend
5+ * (/api/ui-config) — the UI security audit forbids hardcoded external URLs in
6+ * graph-ui source, so external targets come from an auditable backend
7+ * response (same pattern as the /api/repo-info deep-links). */
8+ let issuesUrlRequest : Promise < string | null > | null = null ;
9+
10+ function fetchIssuesUrl ( ) : Promise < string | null > {
11+ issuesUrlRequest ??= fetch ( "/api/ui-config" )
12+ . then ( ( r ) => ( r . ok ? r . json ( ) : null ) )
13+ . then ( ( cfg ) => {
14+ const url : unknown = cfg ?. upstream_issues_url ;
15+ /* Accept only an https URL (regex literal on purpose — the UI security
16+ * audit greps source for protocol strings). */
17+ return typeof url === "string" && / ^ h t t p s : \/ \/ / . test ( url ) ? url : null ;
18+ } )
19+ . catch ( ( ) => null ) ;
20+ return issuesUrlRequest ;
21+ }
722
823interface MissedCalloutProps {
924 node : GraphNode ;
1025 project : string | null ;
1126 onClose : ( ) => void ;
1227}
1328
14- function buildIssueUrl ( path : string , project : string | null ) : string {
29+ function buildIssueUrl ( base : string , path : string , project : string | null ) : string {
1530 const title = `Indexing gap: ${ path } ` ;
1631 const body = [
1732 "## Not fully indexed (best-effort coverage signal)" ,
@@ -25,17 +40,20 @@ function buildIssueUrl(path: string, project: string | null): string {
2540 "" ,
2641 "_Reported from the graph UI's missed-coverage view._" ,
2742 ] . join ( "\n" ) ;
28- return `${ UPSTREAM_ISSUES_URL } ?title=${ encodeURIComponent ( title ) } &body=${ encodeURIComponent ( body ) } ` ;
43+ return `${ base } ?title=${ encodeURIComponent ( title ) } &body=${ encodeURIComponent ( body ) } ` ;
2944}
3045
31- function buildAgentPrompt ( path : string , project : string | null ) : string {
46+ function buildAgentPrompt ( issuesUrl : string | null , path : string , project : string | null ) : string {
47+ const where = issuesUrl
48+ ? `file a GitHub issue at ${ issuesUrl } `
49+ : "file a GitHub issue on the codebase-memory-mcp project" ;
3250 return (
3351 `codebase-memory-mcp could not fully index \`${ path } \`` +
3452 ( project ? ` (project \`${ project } \`)` : "" ) +
3553 " — best-effort coverage signal. Please: " +
3654 "1) call the index_status MCP tool and note this file's flagged line ranges under parse_partial; " +
3755 "2) read those ranges in the file and summarize which construct fails to parse; " +
38- `3) file a GitHub issue at ${ UPSTREAM_ISSUES_URL } titled "Indexing gap: ${ path } " ` +
56+ `3) ${ where } , titled "Indexing gap: ${ path } ", ` +
3957 "with the summary — include a minimal reproducible snippet ONLY if the code is shareable."
4058 ) ;
4159}
@@ -46,6 +64,17 @@ function buildAgentPrompt(path: string, project: string | null): string {
4664export function MissedCallout ( { node, project, onClose } : MissedCalloutProps ) {
4765 const path = node . file_path || node . name ;
4866 const [ copied , setCopied ] = useState ( false ) ;
67+ const [ issuesUrl , setIssuesUrl ] = useState < string | null > ( null ) ;
68+
69+ useEffect ( ( ) => {
70+ let cancelled = false ;
71+ fetchIssuesUrl ( ) . then ( ( url ) => {
72+ if ( ! cancelled ) setIssuesUrl ( url ) ;
73+ } ) ;
74+ return ( ) => {
75+ cancelled = true ;
76+ } ;
77+ } , [ ] ) ;
4978
5079 useEffect ( ( ) => {
5180 if ( ! copied ) return ;
@@ -55,7 +84,7 @@ export function MissedCallout({ node, project, onClose }: MissedCalloutProps) {
5584
5685 const copyPrompt = async ( ) => {
5786 try {
58- await navigator . clipboard . writeText ( buildAgentPrompt ( path , project ) ) ;
87+ await navigator . clipboard . writeText ( buildAgentPrompt ( issuesUrl , path , project ) ) ;
5988 setCopied ( true ) ;
6089 } catch {
6190 /* clipboard unavailable (permissions/insecure context) — leave the
@@ -103,14 +132,16 @@ export function MissedCallout({ node, project, onClose }: MissedCalloutProps) {
103132 >
104133 { copied ? "✓ Copied — paste it to your agent" : "Copy agent prompt" }
105134 </ button >
106- < a
107- href = { buildIssueUrl ( path , project ) }
108- target = "_blank"
109- rel = "noreferrer"
110- className = "text-[12px] font-medium rounded-md border border-white/10 bg-white/[0.03] text-foreground/80 hover:bg-white/[0.07] px-3 py-1.5 transition-all"
111- >
112- File a GitHub issue (prefilled) ↗
113- </ a >
135+ { issuesUrl && (
136+ < a
137+ href = { buildIssueUrl ( issuesUrl , path , project ) }
138+ target = "_blank"
139+ rel = "noreferrer"
140+ className = "text-[12px] font-medium rounded-md border border-white/10 bg-white/[0.03] text-foreground/80 hover:bg-white/[0.07] px-3 py-1.5 transition-all"
141+ >
142+ File a GitHub issue (prefilled) ↗
143+ </ a >
144+ ) }
114145 </ div >
115146
116147 < p className = "text-[10px] leading-snug text-foreground/35 mt-1" >
0 commit comments