refactor: unify call-ref and tests rendering format between audit and inspect commands#1900
Conversation
… inspect commands Extracts the duplicated "Calls"/"Called by"/"Tests" section rendering from presentation/audit.ts's renderCallRefs/renderRelatedTests and presentation/queries-cli/inspect.ts's renderExplainEdges into shared helpers in the new presentation/call-ref-sections.ts (renderCallRefsSection, renderNoCallEdgesFallback, renderRelatedTestsSection), following the same pattern established by #1756's impact-levels.ts unification. inspect.ts's richer format (indent-aware, "no call edges" fallback, singular/plural "Tests" label) is adopted as canonical in both commands. BEHAVIOR CHANGE: `codegraph audit`'s plain-text output (not --json/--ndjson) now matches `codegraph audit --quick`/`codegraph explain` exactly for these sections: - Prints "(no call edges found -- may be invoked dynamically or via re-exports)" when a function has neither callers nor callees. Previously audit printed nothing in this case. - "Tests (N):" is now "Tests (N file):"/"Tests (N files):" (singular/plural), matching explain's existing label. No changes to `codegraph audit --quick`/`codegraph explain` output — inspect.ts keeps its exact current format, just via the shared helper. docs check acknowledged: this is an internal presentation-layer refactor (no new command, language, or architecture change). CLAUDE.md's presentation/*.ts catch-all row already covers the new shared helper file, matching the precedent set by #1756's impact-levels.ts, which likewise did not get its own table row. Fixes #1772 Impact: 14 functions changed, 6 affected
Greptile SummaryThis PR extracts duplicated rendering helpers for "Calls", "Called by", and "Tests" sections from both
Confidence Score: 5/5Safe to merge — purely a presentation-layer refactor with no logic changes beyond the two intentionally documented behaviour improvements in audit. All three changed files are in the presentation layer and touch only console output. The extracted helpers are structurally identical to the inline code they replace; the two behaviour additions (no-edges fallback and pluralised Tests label in audit) match what inspect already produced and are explicitly called out in the PR description. TypeScript compatibility is enforced by the structural interfaces, and the full test suite passes with zero test updates. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[audit.ts] -->|calls| D[renderCallRefsSection]
A -->|calls| E[renderNoCallEdgesFallback]
A -->|calls| F[renderRelatedTestsSection]
B[inspect.ts] -->|calls| D
B -->|calls| E
B -->|calls| F
D & E & F -->|defined in| C[call-ref-sections.ts]
C -->|imports| G[domain/queries.ts kindIcon]
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A[audit.ts] -->|calls| D[renderCallRefsSection]
A -->|calls| E[renderNoCallEdgesFallback]
A -->|calls| F[renderRelatedTestsSection]
B[inspect.ts] -->|calls| D
B -->|calls| E
B -->|calls| F
D & E & F -->|defined in| C[call-ref-sections.ts]
C -->|imports| G[domain/queries.ts kindIcon]
Reviews (1): Last reviewed commit: "refactor: unify call-ref and tests rende..." | Re-trigger Greptile |
Codegraph Impact Analysis14 functions changed → 6 callers affected across 3 files
|
Summary
BEHAVIOR CHANGE:
codegraph audit's Calls/Called by/Tests sections now matchinspect.ts's richer format (same pattern as #1756's impact-level unification earlier in this batch).audit.ts'srenderCallRefs/renderRelatedTestsandinspect.ts'srenderExplainEdges(calls/called-by/tests portions) duplicated near-identical rendering with different formats: audit.ts's had no indent support, no "no edges" fallback, and unpluralized "Tests (N):"; inspect.ts's had all three.renderExplainEdges's text output and asserts on a format that didn't change;audit.test.tsonly tests the data layer;codegraph query/contextuse entirely different renderers, untouched.renderCallRefsSection/renderNoCallEdgesFallback/renderRelatedTestsSectioninto a newsrc/presentation/call-ref-sections.ts(following theimpact-levels.tspattern/location from Duplicate impact-level rendering logic: presentation/audit.ts vs presentation/queries-cli/impact.ts #1756), adopted in both call sites.Closes #1772
Test plan
npm test— full suite green (3560 passed, 0 failed), zero test updates needednpm run lint/npx tsc --noEmit— cleanaudit(previously silent); populated case now byte-identical betweenaudit/inspect; pluralization verified both ways (Tests (1 file):vsTests (58 files):)Stacked on #1898 (base branch
fix/issue-1771-dispatch-table-reference-edges) — only the presentation diff is this issue's change.