Skip to content

feat(attribution): interactive why viewer + tag legend#1614

Merged
suhaanthayyil merged 2 commits into
fix-why-metadata-consistencyfrom
feat-why-tui
Jul 2, 2026
Merged

feat(attribution): interactive why viewer + tag legend#1614
suhaanthayyil merged 2 commits into
fix-why-metadata-consistencyfrom
feat-why-tui

Conversation

@suhaanthayyil

@suhaanthayyil suhaanthayyil commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

https://entire.io/gh/entireio/cli/trails/738

Base: fix-why-metadata-consistency (stacked on the #1551 fix — review that first).

What

An interactive viewer for entire why <file> plus the readability fixes insiders asked for — built strictly under the new Agent-Safe CLI Fallbacks rules (#1596).

entire why <file> --tui

Master-detail Bubble Tea viewer over the already-resolved attribution (no git/network I/O inside the TUI):

  • Left pane: the file's lines with [AI]/[MX]/[HU]/[??] tags and ~/? markers, windowed scrolling for large files.
  • Right pane: the selected line's full explanation — authorship sentence, commit/author/time, agent · model, session (OSC 8 hyperlink to the entire.io session when origin resolves — the CLI↔UI linking idea from the summit), checkpoint, prompt (with the Session prompt caveat), intent, metadata-missing reason, candidate checkpoints, and the checkpoint explain hint (suppressed when metadata is missing, matching the text view).
  • Keys: ↑/↓ line, n/p next/previous agent-attributed line (jump straight to the interesting lines), enter expands the full prompt/candidates, pgup/pgdn, g/G, q. why <file>:12 --tui opens positioned at line 12.

Agent-safe by construction

  • TUI is opt-in (--tui) and TTY-gated (interactive.IsTerminalWriter) and skipped in accessible mode — the exact experts --tui pattern the guidelines cite as good.
  • Non-TTY with --tui falls through to the same deterministic plain output; --json always wins over --tui so scripted callers never block. Both pinned by tests against a non-TTY writer.
  • No information is TUI-only: everything the TUI shows exists in the plain/JSON paths.

Insider-feedback fixes (text output)

  • Tag legend everywhere (blame, why file view, TUI footer): [AI] all agent · [MX] agent+human mixed · [HU] no agent · [??] uncommitted — wording per soph's correction (AI = 100% agent-authored checkpoint work; MX = agent + human edits; careful not to overclaim). Full sentences in the TUI detail pane.
  • Fits the blame table's 80-column budget (test-enforced).

Testing

  • Model-level TUI tests (the repo's established pattern — pure Update/View, color off): render + summary, navigation → prompt detail, start-line positioning, n/p agent-line jumps (including exhaustion + status message), expand toggle, missing-metadata reason + suppressed explain hint, quit keys, empty file, tiny window.
  • Agent-safe fallback pins: --tui on a non-TTY writer produces the plain file summary; --tui --json produces JSON.
  • Found during development: the shared keymap claims n/p for paging — the viewer rebinds paging to pgup/pgdn so n/p can do agent-line jumps (commented).
  • mise run lint 0 issues; full cmd/entire/cli suite green; mise run test:ci green.

Notes

entire why stays hidden/labs. The TUI addresses the insiders' "why is hard to read" feedback and pfleidi's browse-the-file/summit-linking ideas without touching the default output contract.

Adds an opt-in TUI for 'entire why <file>' and the readability fixes insiders
asked for, built under the Agent-Safe CLI Fallbacks rules:

- --tui opens a master-detail Bubble Tea viewer over the already-resolved
  attribution (no git/network I/O inside the TUI): file lines with
  [AI]/[MX]/[HU] tags on the left; the selected line's full explanation on the
  right (authorship sentence, commit, agent/model, session with an OSC 8
  entire.io hyperlink when origin resolves, checkpoint, prompt with the
  session-level caveat, intent, metadata-missing reason, candidates, explain
  hint). n/p jump to the next/previous agent-attributed line; enter expands
  the full prompt; why <file>:12 --tui opens positioned at line 12.
- Agent-safe: the TUI is opt-in AND TTY-gated (IsTerminalWriter) and skipped
  in accessible mode; non-TTY --tui falls through to the identical plain
  output, and --json always wins — both pinned by tests against a non-TTY
  writer. Nothing is TUI-only.
- Tag legend on blame, the why file view, and the TUI footer: [AI] all agent,
  [MX] agent+human mixed, [HU] no agent, [??] uncommitted — kept within the
  blame table's 80-column budget; full sentences in the detail views.

Model-level TUI tests cover rendering, navigation, agent-line jumps, expand,
missing-metadata handling, quit keys, empty files, and tiny windows. Paging is
bound to pgup/pgdn because the shared keymap claims n/p.
Copilot AI review requested due to automatic review settings July 2, 2026 19:56
@suhaanthayyil suhaanthayyil requested a review from a team as a code owner July 2, 2026 19:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an opt-in, TTY-only interactive (Bubble Tea) viewer for entire why <file> while keeping agent-safe fallbacks: non-TTY and/or --json continue to use deterministic plain/JSON output with no information gated behind the TUI.

Changes:

  • Add --tui flag to entire why with strict TTY + non-accessible gating, and --json precedence.
  • Introduce a new Bubble Tea master/detail TUI for browsing per-line attribution + details (including optional entire.io session links).
  • Add model-level TUI tests plus agent-safe fallback tests to pin non-TTY behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
cmd/entire/cli/attribution.go Adds --tui flag, TTY/accessibility gating, and tag legend rendering + repo name derivation for links.
cmd/entire/cli/attribution_tui.go New Bubble Tea TUI implementation for interactive browsing of why output.
cmd/entire/cli/attribution_tui_test.go Adds TUI model tests and non-TTY fallback/--json precedence tests.

Comment on lines +178 to +195
// Paging is bound to pgup/pgdown explicitly: the shared keymap's
// NextPage/PrevPage claim n/p, which this viewer uses for the more useful
// next/previous agent-attributed line jumps.
case msg.String() == "pgup":
return m.moveCursor(m.cursor - m.bodyHeight()), nil
case msg.String() == "pgdown":
return m.moveCursor(m.cursor + m.bodyHeight()), nil
case key.Matches(msg, keys.Home):
return m.moveCursor(0), nil
case key.Matches(msg, keys.End):
return m.moveCursor(len(m.result.Lines) - 1), nil
case key.Matches(msg, keys.Confirm):
m.expanded = !m.expanded
return m.refreshDetail(), nil
case msg.String() == "n":
return m.jumpAgentLine(1), nil
case msg.String() == "p", msg.String() == "N":
return m.jumpAgentLine(-1), nil
The [AI]/[MX]/[HU] tags are a per-commit inference, not a per-line truth:
[AI] means the commit's checkpointed work was fully agent-authored, [MX]
means the commit mixed agent and human edits (any given line may be either),
[HU] means no agent checkpoint. The legend now says so explicitly —
'per commit: [AI] all agent · [MX] mixed — line may be either · [HU] no
agent' — instead of reading like per-line labels. [??] moved to the
conditional marker legend line (shown only when uncommitted lines exist),
keeping the main legend inside the blame table's 80-column budget.
@suhaanthayyil

Copy link
Copy Markdown
Contributor Author

Folded into #1613 — one PR now carries the determinism fix, the TUI, and the legend.

@suhaanthayyil suhaanthayyil merged commit 043702b into fix-why-metadata-consistency Jul 2, 2026
9 checks passed
@suhaanthayyil suhaanthayyil deleted the feat-why-tui branch July 2, 2026 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants