Skip to content

feat(story): tell the review as a story written by a model - #412

Draft
pavelzw wants to merge 1 commit into
mainfrom
pavelzw/gla-239-add-guide-view
Draft

pavelzw wants to merge 1 commit into
mainfrom
pavelzw/gla-239-add-guide-view

Conversation

@pavelzw

@pavelzw pavelzw commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

What

A third view next to Diff and Graph, keyed on S: a model groups the changed files into parts a reader follows in order, with a summary up front and a couple of sentences per part. Each part has a sticky column with its number, title, narrative, a part-level Reviewed box and its file list; beside it, each file's diff with the story's note, a Viewed box, a fold toggle and an open-in-diff button. Keys: j/k files, n/p parts, v/V viewed, z fold, Enter opens the file in the diff for comments, r writes or rewrites.

How

  • Contract (src/shared/protocol.ts): Story, StoryPart, StoryFile, StoryState and a story server message; the generated schema is updated.
  • Server (crates/diffle/src/story/): prompt.rs builds the request from the comparison label, the commits, the file list with status and flags, and the patches within a size budget (generated and binary files are listed by name only). client.rs makes one raw HTTPS call to the Anthropic Messages API behind a StoryModel trait: claude-opus-5-5 at medium effort, the answer constrained to a JSON schema, server-side fallbacks on. validate.rs drops unknown and repeated paths, collects forgotten files into an "Other changes" part and always closes with "Generated files". mod.rs owns the state: one story in the writing at a time, kept under <git-dir>/diffle/stories/<fingerprint>.json where the fingerprint hashes the endpoints and every changed blob, so a reopened review finds its story and an edit marks it stale.
  • Routes: GET /api/story and POST /api/story; story on the socket when the writing starts and ends. Error::Story answers 409 for something to fix (no key, no changes) and 502 for a model that did not answer.
  • Client (src/client/story/): the view definition, its state store, the pane, and a standalone DiffBlock over the library's FileDiff. The diff library's CodeView only takes file and diff items, so part headers cannot sit inside the virtualised list; the story pane renders its own layout and hands line-level work to the diff view.
  • Config: ANTHROPIC_API_KEY, with ANTHROPIC_BASE_URL and DIFFLE_STORY_MODEL as overrides. Without a key the view says so and the run prints 📖 story off.

Tests

  • crates/diffle/tests/story.rs: a fake model through the API, persistence across servers, staleness after an edit, failure and retry, the no-key and no-changes blockers, and the request shape against a fake Anthropic endpoint (two insta snapshots).
  • test/client/HelpOverlay.test.ts covers the story's help.
  • Format, lint, typecheck, clippy, the quality gate, test-node, test-rust and the release build pass locally.

Notes

  • The header gained a button, so the e2e screenshot snapshots will differ: the Update snapshots workflow needs a pass once CI has run.
  • The pull request's title and body are not in the prompt yet: discovery needs a token and a network call, left to a follow-up.
  • Screenshots of the view over the fixture repository are in the session; they could not be attached from here.

Generated by Claude Code

Add a third view next to the diff and the graph: a model groups the changed files into parts a
reader follows in order, with a summary up front and a narrative per part. Each part lists its
files with their diffs beside them and a Reviewed box for the whole part; a file opens in the diff
for comments.

The server owns the story: `GET /api/story` and `POST /api/story`, one raw call to the Anthropic
Messages API constrained to a JSON schema, the answer validated against the snapshot (unknown and
repeated paths dropped, forgotten files in a trailing part, generated files always last), and the
result kept under `<git-dir>/diffle/stories/` by a fingerprint of the endpoints and the changed
blobs, so a reopened review finds it and an edit marks it stale. The key comes from
ANTHROPIC_API_KEY; without one the view says so.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LWB8Be3qmrYtGnBxbNsV9S

@moritzwilksch moritzwilksch left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

TBD

@pavelzw

pavelzw commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator Author

Not intended to be merged. Just want to get the vibe of it

This branch has not been deployed

No deployments
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.

2 participants