Inline file diff in review pane (git mode)
Summary
When the provider is git and we have file history, surface a markdown-aware diff in the review screen so reviewers can see what changed — not just that something closed. Most useful in two contexts:
- Closed feedback resolution. When a closed FB carries a commit SHA in
iterations[], expand the FeedbackItem to show a unified diff of the file the fix-hat touched. Connects directly to the iteration history we just shipped (#95-adjacent — Task #94 in the local tracker; FeedbackItem renders the chain but the commit pill is currently display-only). - "What changed since I last signed?" When a slot has
signed_at: <ISO>+body_sha256, the artifact pane could offer a "show changes since I signed" toggle. We already havegitLogSinceTimestampinpackages/haiku/src/orchestrator/workflow/drift-sweep.ts:63andgit show <commit>:<path>for retrieving body-at-commit; the missing piece is the renderer.
Why this isn't trivial
Markdown is paragraph-flow, not line-flow. A naive line diff produces visual noise where prose got reflowed but didn't actually change meaning.
Three approach families:
diff(npm) → unified line diff inside<MarkdownViewer>. Smallest blast radius. Works fine for code blocks and structural edits; ugly for prose reflows.markdown-diff(npm). Markdown-aware; outputs markdown-flavored unified diff. Lighter weight, last published Apr 2024.- Custom remark-based renderer. We already have
remark+remark-gfm+remark-htmlinpackages/haiku-ui/package.json. Could AST-diff with token-level granularity. Highest fidelity, most work.
Suggested scope (minimum viable)
-
Add
diffpackage topackages/haiku-ui. -
Build
<UnifiedDiff body=\"...\" since=\"...\" />component that renders a unified-diff block with+/-lines + minimal syntax highlighting. -
In
FeedbackItem.tsxexpanded view, when:- the FB is closed
iterations[]has at least one entry with acommitSHA- the host runtime is git-mode (a new
gitMode: booleanprop threaded from session data)
…surface a "Show changes" expander next to the iteration row. Click → fetch the diff via a new
/api/diff/:commit/:pathendpoint that shellsgit show <commit>:<path>against the previous parent and returns the raw bodies for the renderer to diff client-side.
Out of scope for v1
- Side-by-side view (unified is enough for prose).
- Multi-file diff per iteration (one commit = one rendered file path).
- Image diff (
fileSha256outputs are already covered by the drift sweep; image diff is a separate UX surface).
References
packages/haiku/src/orchestrator/workflow/drift-sweep.ts:63—gitLogSinceTimestampexists for git enrichment.packages/haiku/src/state-tools.ts:1036—isGitRepo()is the runtime gate.packages/haiku-api/src/schemas/feedback.ts:127—iterations[]schema;commit: z.string().max(64).optional()is the field to consume.packages/haiku-ui/src/organisms/FeedbackItem.tsx— the iteration commit pill is already rendered (truncated to 7 chars). Diff expander hooks here.
Tracking
Filed as a followup to the review-screen UX bundle that landed Task #94 (iterations chain rendering) and Task #95 (agent excerpts via inline_anchor).