Skip to content

feat(quiz): diff coverage map in the sidebar - #27

Merged
jonasbrami merged 1 commit into
mainfrom
feat/coverage-map
May 29, 2026
Merged

feat(quiz): diff coverage map in the sidebar#27
jonasbrami merged 1 commit into
mainfrom
feat/coverage-map

Conversation

@jonasbrami

@jonasbrami jonasbrami commented May 29, 2026

Copy link
Copy Markdown
Owner

What

A "Diff coverage" sidebar block showing which of the PR's changed files have a question anchored to them — so the reader sees at a glance what the quiz probes and what it skips. Builds directly on the anchors feature (#26).

Changes

  • webGET /changed-files returns the PR's changed-file paths via a new changed_files callable (wired in server.py to the shared _DiffProvider). Returns 503 when no diff source is wired (mirrors /diff).
  • frontend — a "Diff coverage" block in the answering-view sidebar: each changed file with a covered (✓) / uncovered (○) marker and an "N of M files probed" count. Coverage is computed client-side by matching question anchors to changed files using the same exact / repo-relative-suffix / basename logic as the server's do_file_diff, so a covered marker lines up with what /diff would actually serve.

Display only — the one-click "ask the host to cover this file" steer is Track B (needs the host-wake mechanism), intentionally out of scope here.

Invariants preserved

  • Browser ↔ host still only via QuizState; /changed-files is browser↔web (in-process).
  • textContent-only frontend (file names via text:).
  • Degrades cleanly: no diff source → 503 → the block is simply omitted.

Testing

  • Unit: /changed-files returns the list; 503 when unavailable. Full mcp/engine suite green; ruff + ruff format --check + mypy --strict clean.
  • Real-browser check (Chrome DevTools): exact-path and basename-only anchors both mark their file covered; files with no anchored question show uncovered; the count ("2 of 4 files probed") is correct.

🤖 Generated with Claude Code

Shows which of the PR's changed files have a question anchored to them, so the
reader can see at a glance what the quiz does and doesn't probe.

- web: `GET /changed-files` returns the PR's changed-file paths (`changed_files`
  callable, wired in server.py to the shared `_DiffProvider`). 503 when unwired.
- frontend: a "Diff coverage" sidebar block (answering view) listing each changed
  file with a covered/uncovered marker + an "N of M files probed" count. Coverage
  is computed client-side by matching question anchors to changed files with the
  same exact / repo-relative-suffix / basename logic the server's do_file_diff uses.

Display only — the "ask the host to cover this file" steer is Track B. Builds on
the anchors feature (#26).

Tested: /changed-files endpoint (list + 503). Verified in a real browser: exact and
basename-only anchors both mark their file covered; files with no anchored question
show uncovered; count is correct.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jonasbrami
jonasbrami merged commit 845d1d9 into main May 29, 2026
2 checks passed
@jonasbrami
jonasbrami deleted the feat/coverage-map branch May 29, 2026 14:47
jonasbrami added a commit that referenced this pull request May 29, 2026
…29)

The anchored hunk now renders inline with the question (always visible, fetched on
render) instead of behind a click-to-expand panel — the code context is right there
next to the prompt. To keep that readable when a question anchors into a large diff
hunk, the inline view is clipped to a tight window around the anchored lines
(± a few context lines), with the anchored lines highlighted and trimmed regions
marked by an ellipsis. Falls back to the full hunk when there's no window to clip to.

Verified end-to-end by generating a real quiz with `cognit` against PR #27 and
serving it through the real web app: 5 questions (4 anchored + mermaid + open), each
inline hunk clipped to 12–20 lines (from 46) with ellipsis + highlighting, plus the
diff coverage map. Frontend only.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant