feat(ui): the whole file — full source with gutter ports and intra-file call arcs (CG-52)

The File view gains a Source tab: the file itself, top to bottom, with the
Symbol view's line grid, gutter ports and call-site links, a line-anchored
callee rail, and — in the left margin — an arc for every call that stays inside
the file, drawn from the calling line to the callee's definition line.

The arcs are the point. Source order is already a layout, chosen by whoever
wrote the file, so a file's internal call structure can be drawn with no
algorithm placing anything. Crabviz's idea, in the one place it is legible.

Everything is arithmetic, not measurement. The Symbol view queries the laid-out
DOM to place a callee row beside its line; a 6 820-line file cannot afford that.
Here a line is exactly 20px at `10 + (n - 1) x 20`, so ~90 line elements exist at
a time and the arcs, ports, rail rows and connectors are all functions of a line
number. `src/mcp/tools.ts` scrolls at a 16.6ms median frame.

- `GET /api/filecode/<path>` — outline, one call group per (caller, callee) PAIR
  with its call-site lines, unresolved references, and the file's length. The
  source is NOT in it: it pages through `/api/source` 800 lines at a time with a
  discarded 150-line lead-in, so a page starting inside a block comment does not
  render prose as code, and so the ports and arcs are complete from the first
  frame while the text fills in behind them.
- `intraFileCalls` is counted over the groups actually returned, so the header
  and the picture under it cannot disagree once a cap bites.
- Above 40 arcs the diagram narrows to the symbol under the pointer (or the one
  the scroll position is inside) and the header states the total. Accent is for
  the pointer only, never for the filter.
- Sticky outline rail at >= 1400px, following the reader down the file.
- `QueryBuilder.getUnresolvedReferencesInFile` — one indexed lookup instead of
  one per symbol; `buildOutlineEntries` lifted out of `/api/file` so both
  readings of a file draw the same rows.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Colby McHenry
2026-08-27 03:47:42 -05:00
co-authored by Claude Opus 5
parent 62e0a89b0e
commit bd99c5e99a
24 changed files with 3227 additions and 40 deletions
+20
View File
@@ -159,6 +159,26 @@ windowed above 250 rows (this repo's own fixtures hold a 1,681-symbol `.d.ts`);
live together in `ui/src/lib/file-model.ts`. Keyboard: ↑/↓ within a pane, ←/→ across the three
panes, Enter follows; `?hl=<line>` selects the DEEPEST outline row whose range holds the line.
**Whole-file source, as built (phase 2, CG-52).** `?src=1` on the same route. Four columns inside
one scroller: sticky outline rail (240px, only at ≥ 1400px) | arcs 56px | source | callee rail 320px.
The line grid, the 6x6 ports and the accent call-site links are the Symbol view's, unchanged — what
differs is that **line positions are arithmetic, not measured**: every line is exactly 20px and sits
at `10 + (n - 1) x 20`, so a 6 820-line file renders ~90 line elements and the arcs, ports, rail
rows and connectors are all functions of a line number. `ui/src/lib/filecode-model.ts` holds the
constant; `FileCodeBlock.svelte`'s CSS holds the other half of it, and they must move together.
Source pages in 800 lines at a time from `/api/source`, each request reaching back 150 lines that are
then discarded so a page starting inside a block comment does not render prose as code; a line whose
page has not arrived still shows its number, its port and its place. Callee-rail rows are one per
(CALLING symbol, called symbol) PAIR rather than one per callee — a row is anchored to a line and a
helper called from two functions a thousand lines apart has no line that is both — and uncertain rows
stay in place with their dotted underline rather than folding, because a fold has nowhere to sit on
this screen. Arcs are half-ellipses bulging left, both ends on the arc column's right edge, depth a
log function of the arc's own SPAN (so short arcs sit innermost and filtering never moves a survivor
sideways); `--ink-4` 1px at rest, `--accent` 1.5px when the call line or the callee is under the
pointer — never as a consequence of the crowding filter. Above 40 arcs only the focused symbol's are
drawn (hovered symbol, else the symbol the scroll position is inside) and the header states the
total. Clicking an arc scrolls to the callee's definition and marks it. Data: `GET /api/filecode/<path>`.
### 3.5 Flow strip (`#/flow/<key>`)
Header: "Flow" + a `<select>` of flows (`--paper-2`, `--rule-soft` border, 12.5px sans) + a 78ch note.
Cards **380px** wide, `--rule-soft` border (`--ink` on hover, `--accent` when current), header grid `16px | 1fr` padding `10px 12px 6px`