Skip to content

Inline file diff in review pane (git mode) #324

Description

@jwaldrip

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:

  1. 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 (feat(builder): add version-aware building with rollback guidance #95-adjacent — Task feat(planner): add relevance-ranked learning search #94 in the local tracker; FeedbackItem renders the chain but the commit pill is currently display-only).
  2. "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 have gitLogSinceTimestamp in packages/haiku/src/orchestrator/workflow/drift-sweep.ts:63 and git 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-html in packages/haiku-ui/package.json. Could AST-diff with token-level granularity. Highest fidelity, most work.

Suggested scope (minimum viable)

  • Add diff package to packages/haiku-ui.

  • Build <UnifiedDiff body=\"...\" since=\"...\" /> component that renders a unified-diff block with +/- lines + minimal syntax highlighting.

  • In FeedbackItem.tsx expanded view, when:

    • the FB is closed
    • iterations[] has at least one entry with a commit SHA
    • the host runtime is git-mode (a new gitMode: boolean prop threaded from session data)

    …surface a "Show changes" expander next to the iteration row. Click → fetch the diff via a new /api/diff/:commit/:path endpoint that shells git 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 (fileSha256 outputs are already covered by the drift sweep; image diff is a separate UX surface).

References

  • packages/haiku/src/orchestrator/workflow/drift-sweep.ts:63gitLogSinceTimestamp exists for git enrichment.
  • packages/haiku/src/state-tools.ts:1036isGitRepo() is the runtime gate.
  • packages/haiku-api/src/schemas/feedback.ts:127iterations[] 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).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions