({ graph, selected, path, agents, onNavigate, onImpact, scope }: {
graph?: GraphData; selected?: GraphNode; path: string; agents?: AgentsState;
onNavigate: (path: string, line?: number, name?: string) => void; onImpact?: () => void;
/**
* In Galaxy: the loaded scope. Its relationships replace the repository
* snapshot, which is capped (20,000 nodes by file path) and missed, for
* JSONBAgg, all 23 incoming relationships from the tests behind the cap.
*/
scope?: SelectionScope;
})
| 20 | } |
| 21 | |
| 22 | export default function SelectionContextPanel({ graph, selected, path, agents, onNavigate, onImpact, scope }: { |
| 23 | graph?: GraphData; selected?: GraphNode; path: string; agents?: AgentsState; |
| 24 | onNavigate: (path: string, line?: number, name?: string) => void; onImpact?: () => void; |
| 25 | /** |
| 26 | * In Galaxy: the loaded scope. Its relationships replace the repository |
| 27 | * snapshot, which is capped (20,000 nodes by file path) and missed, for |
| 28 | * JSONBAgg, all 23 incoming relationships from the tests behind the cap. |
| 29 | */ |
| 30 | scope?: SelectionScope; |
| 31 | }) { |
| 32 | const inScope = Boolean(scope && selected && scope.graph.nodes.some(node => selected.qualified_name |
| 33 | ? node.qualified_name === selected.qualified_name && (node.file_path ?? '') === path : node.id === selected.id)); |
| 34 | const source = inScope ? scope!.graph : graph; |
| 35 | const context = useMemo(() => selectionContext(source, selected, path, agents, { allRelations: inScope }), [source, selected, path, agents, inScope]); |
| 36 | const callers = context.incoming.filter(edge => edge.type === 'CALLS'); |
| 37 | const callerFiles = new Set(callers.map(edge => edge.source.file_path).filter(Boolean)); |
| 38 | return <section className="selection-context" aria-label="Selection context" data-testid="selection-context"> |
| 39 | <h3>Selection context</h3> |
| 40 | {/* Round 4 (N1): a selected node without a file, such as a Branch node, keeps its connections and its shown name. */} |
| 41 | {!path && !selected ? <p>{selectionScopeText.selectSomething}</p> : <> |
| 42 | <p className="selection-context-subject">{selected ? graphNodeName(selected) : path}</p> |
| 43 | <h4>Graph evidence</h4> |
| 44 | {!source ? <p>The repository graph is not available. Relevance cannot be established yet.</p> : <> |
| 45 | {scope && <p className="selection-context-source" data-source={inScope ? 'scope' : 'snapshot'}>{inScope ? selectionScopeText.fromScope(scope.depth) : selectionScopeText.fromSnapshot}</p>} |
| 46 | {inScope && !scope!.complete && <p role="status">{selectionScopeText.loading}</p>} |
| 47 | {inScope && scope!.partial && <p role="status">{selectionScopeText.partial(scope!.partial.layer, scope!.partial.limit)}</p>} |
| 48 | {inScope && scope!.direction !== 'both' && <p>{selectionScopeText.notTraced(scope!.direction)}</p>} |
| 49 | {inScope && scope!.edgeTypes && <p>{selectionScopeText.typesOnly(scope!.edgeTypes)}</p>} |
| 50 | {context.selected?.status === 'entry' && <p>The index classifies this declaration as an entry candidate. Open its source and follow outgoing calls to verify its role.</p>} |
| 51 | {callers.length > 0 && <p>{callers.length} indexed caller edges from {callerFiles.size} files reach this selection. Check these callers when changing its contract.</p>} |
| 52 | {context.entryPath.length > 0 && <details><summary>Reachable from {context.entryPath[0].source.name} · inspect {context.entryPath.length} calls</summary> |
| 53 | <p>This selection is reachable from an indexed entry candidate. This is static reachability, not an observed execution or data flow.</p> |
| 54 | <RelationshipEvidence edges={context.entryPath} onNavigate={onNavigate} /> |
| 55 | </details>} |
| 56 | {!context.incoming.length && !context.outgoing.length && <p>{/\.(md|rst|txt)$/i.test(path) |
| 57 | ? 'This documentation file has no code dependencies in the loaded graph. Read its source for project context.' |
| 58 | : 'No supported dependency edge for this selection is present in the loaded graph. Inspect the source and index coverage before assessing its impact.'}</p>} |
| 59 | {/* RelationshipEvidence prints the type as text, so a scope type outside the map relations reads the same. */} |
| 60 | {context.incoming.length > 0 && <details><summary>{selectionScopeText.incoming(context.incoming.length, context.incomingByType)}</summary> |
| 61 | <RelationshipEvidence edges={context.incoming as MapEvidence[]} onNavigate={onNavigate} /></details>} |
| 62 | {context.outgoing.length > 0 && <details><summary>{selectionScopeText.outgoing(context.outgoing.length, context.outgoingByType)}</summary> |
| 63 | <RelationshipEvidence edges={context.outgoing as MapEvidence[]} onNavigate={onNavigate} /></details>} |
| 64 | {context.pathSearchLimited && !context.entryPath.length && <p>No entry path found within 4 calls / 500 visited symbols. Longer paths were not evaluated.</p>} |
| 65 | </>} |
| 66 | {agents && <details><summary>Observed agent activity · {context.activity.length} retained events for this file</summary> |
| 67 | {context.activity.length === 0 ? <p>No observed tool event for this file is available in the loaded agent activity. The Agents view shows the connection and event source.</p> |
| 68 | : <ul>{context.activity.map(({ agent, event }) => <li key={`${agent}:${event.run}:${event.seq}:${event.phase}`}> |
| 69 | <details><summary>{agent} · {event.tool} · {event.phase} · <time dateTime={new Date(event.ts).toISOString()}>{new Date(event.ts).toLocaleTimeString()}</time></summary> |
| 70 | <p>Observed tool event for this file. A tool name does not reveal intention or prove a successful change.</p> |
| 71 | <pre>{JSON.stringify(event, null, 2)}</pre> |
| 72 | <button onClick={() => onNavigate(path, event.lines?.[0])}>Open event location</button> |
| 73 | </details> |
| 74 | </li>)}</ul>} |
| 75 | </details>} |
| 76 | <div className="selection-context-actions">{path && <button onClick={() => onNavigate(path, context.selected?.start_line, context.selected?.name)}>{selectionScopeText.readSource}</button>} |
| 77 | {onImpact && <button onClick={onImpact}>Assess change impact</button>}</div> |
| 78 | </>} |
| 79 | </section>; |
nothing calls this directly
no test coverage detected