Skip to content

fix(web): apply [keybindings] remaps to the page's own hunk.web.* commands - #1338

Open
benvinegar wants to merge 12 commits into
claude/web-ui-09-review-barfrom
claude/web-keybindings-page-commands
Open

benvinegar wants to merge 12 commits into
claude/web-ui-09-review-barfrom
claude/web-keybindings-page-commands

Conversation

@benvinegar

Copy link
Copy Markdown
Member

Stacked on #1337 (claude/web-ui-09-review-bar), which has not merged yet. This PR targets that branch so the diff contains only its own work; merge after #1337, or retarget to main once the stack lands. The gap exists on main too, independent of the stack.

Problem

A [keybindings] remap of one of the browser review page's own commands never reached the page. With

[keybindings]
"hunk.web.toggleViewed" = "x"

the page still showed and obeyed the default V, and the terminal reported Keybinding for unknown command "hunk.web.toggleViewed" ignored. docs/keybindings.md said the page reads the same [keybindings] table, which was true for catalog commands only.

Cause: the host resolved [keybindings] against the shared catalog alone (resolveCommandKeys), so a hunk.web.* entry was dropped as an unknown id, and the keymap published in the review's shared state carried catalog ids only. The page declared its own commands in web/commands/webLocalCommands.ts, which core/ and app/ may not import, and fell back to their shipped chords.

Approach

  • One declaration both tiers can read. The page-command table moves to core/run/webLocalCommandCatalog.ts (import-free, registered in the browser's closed command-module set in source-boundaries.test.ts). web/commands/webLocalCommands.ts keeps the Ctrl/Cmd chord matcher and labels and re-exports the table, so page imports are unchanged.
  • The host resolves and publishes. buildReviewPresentationDefaults folds the remappable page commands beside the catalog in the same resolveCommandKeys call and publishes them in the same presentation.keymap. A remap, an unbind (false), a first binding of a command that ships unbound, and the exclusivity rule all apply to them by the existing resolver, with no page-side re-derivation.
  • Terminal surfaces accept, and bind nothing. Review, log, status, and documents add the page-command names to the set of other surfaces' commands they already recognize. An entry for one raises no notice, binds no key, and takes no key away from a terminal command.
  • The page obeys the published entry. It already preferred a host entry for a page id over its default; now every remappable page command binds through the keymap (not only the four that ship with a key), and key presses run through the same runLocal the palette uses. The shipped chords remain only as the fallback for a keymap that carries no entry for the id: the catalog defaults before the shared state arrives, and a session built before this change registered with a newer daemon.

Decisions worth a look

  • Unbound page commands are bindable too (hunk.web.toggleHideViewed, toggleMinimap, togglePreview, the two copy-link commands, useSessionTheme, filesAsTree/filesAsList). Accepting those ids on the host without binding them on the page would have left the same kind of silent gap this PR closes, and the docs already described toggleHideViewed as "unbound".
  • The two Ctrl/Cmd dialog chords stay fixed, as scoped: hunk.web.commandPalette and hunk.web.goToFile are outside the shared chord grammar the page binds. They are not in the keymap. An entry for either is now reported as Keybinding for "hunk.web.commandPalette" ignored • its shortcut is fixed and cannot be remapped instead of as an unknown command (a new fixedCommandNames option on the resolver).
  • Exclusivity is per surface. "hunk.web.toggleViewed" = "w" takes w from line wrapping in the page; the terminal keeps w for line wrapping, since the entry binds nothing there. Documented.

Non-goals

  • No default binding changes.
  • No session wire change: the keymap's shape (Record<string, string[]>) is unchanged and is not part of session-wire.v22.json; wire.snapshot.test.ts passes without a HUNK_SESSION_DAEMON_VERSION bump.
  • The Ctrl/Cmd chords are not made remappable.

Why core

Keybinding resolution is host behavior shared by every review surface; the page must not re-resolve config. The only new shared piece is the page-command table's location.

Tests

  • core/run/webLocalCommandCatalog.test.ts: every page id is under hunk.web.* and outside every terminal command set; remappable and fixed partition the table.
  • ui/lib/keymap.test.ts: an inactive command's chord stays with the active command that holds it by default; a fixed command's entry is reported and the rest applies.
  • app/review/sharedState.test.ts (host resolution): page commands publish with shipped chords; a remap, unbind, and first binding fold in; exclusivity in both directions and both spellings (V / shift+v); a fixed id never enters the keymap.
  • ui/AppHost.interactions.test.tsx: in the terminal, "hunk.web.toggleViewed" = "q" raises no notice and q still quits; a fixed id is reported.
  • ui/status, ui/documents tests: page ids join the "inactive names raise no notice" loops.
  • web/panel/panelCommands.test.ts, web/palette/paletteEntries.test.ts: the remapped key runs the command and the default does not; an unbound command binds once given a key; palette and help label from the resolved keymap.
  • ui/lib/appCommands.test.ts: the new page-command table in docs/keybindings.md is held to the declaration, ids and default keys.
  • test/web/review-keybindings.e2e.ts: the expected-failure case from feat(web): add a review bar with progress, next unviewed, key hints, and copy notes #1337 now passes with test.fail() removed, extended to check the help overlay; a new case binds a command that ships unbound.

Commands run (macOS, Darwin 25.6.0; Bun 1.4.4):

Command Result
bun run typecheck pass
bun run lint 0 warnings, 0 errors
bun run format:check pass
bun run deps:check no violations
bun test ./test/review-conformance 203 pass
bun run build:web && bun run test:web 144 passed, 9 skipped (the opt-in screenshot captures)
bun run test see below

bun run test fails on this machine on the base branch too. On a clean checkout of claude/web-ui-09-review-bar (c8ae4e8): 5841 pass, 55 fail. On this branch: the same 55 names fail and nothing else, apart from filesystemSource.observe.test.ts, a native file-watch test that fails 0, 1, or 2 cases across three consecutive reruns of the file alone. The 55 are environmental: 44 are extension tests that pick up a globally installed extension from this machine's real ~/.config/hunk/extensions (Can't resolve './constants.js' in …/installed/hunk-diff-context/src), 8 are the known macOS /var vs /private/var path comparisons, and 3 are file-watch and daemon-launcher timing tests. None touch keybindings.

Not run: bun run test:integration and bun run test:tty-smoke (no terminal rendering, layout, or interaction change; the terminal change is that four surfaces recognize more ids as another surface's). Linux and Windows not tested locally.

Visual check

In a real Chromium session started with "hunk.web.toggleViewed" = "x" and "hunk.web.toggleHideViewed" = "H": the review bar's hint reads x viewed, the selected file's Viewed checkbox shows x, pressing x checks it, and the help overlay's Browser section lists x mark the selected file viewed, or clear its mark and H hide or show viewed files. Screenshots were captured locally.

Known limitation / follow-up

A conflict that exists only in the page (a page command and a catalog command both given the same chord in [keybindings]) is resolved first-wins on the host, as documented, but nobody reports it: the terminal skips page ids before conflict detection, and the host drops the issues from the keymap it publishes (it did before this change too). Surfacing page-keymap issues, in the page or on the headless runner's stderr, is a separate change.

This PR description was generated by Claude Code using Claude Fable 5.2

benvinegar and others added 12 commits November 16, 2026 17:16
The browser review page used the theme accent for pressed toggles,
checked segments, the active panel tab, every note card, and the
minimap viewport as well as for the selected hunk and file. An "on"
control now uses a neutral raised fill, so the accent marks only where
the reviewer is and what has keyboard focus.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The browser review page's toolbar was two rows of text buttons and
wrapped to three at 800px. It is now one 44px row: layout, refresh,
copy link, and the pane toggles are icon buttons, viewed progress is a
ring, and the line and review toggles plus the theme picker live in a
View menu that shows each shortcut. Adds the inline SVG icon module the
rest of the page builds on.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…able

The toolbar's Commands button named its key with a literal. It now reads
the palette command's chord from the page's command table, the same
source the help overlay and the palette use, so no control states a key
of its own.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… row

Four readability fixes on the browser review page. Line and file counts
group their digits (+25,048 −47) with tabular figures. The command
palette groups commands under section headings when the query is empty
and shows shortcuts as key caps. Split view states "N unchanged lines"
once per gap instead of once per column. The remaining text-glyph icons
(close, disclosure, gap chevrons) use the icon module.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… ticks

The browser review page's minimap was 44px of full-strength green and
red, which turned into a barcode on a changeset of similar files. It is
now 16px wide: one faint neutral block per file, thin ticks where the
changes are (split red and green where a cell holds both), and viewed
files drawn at lower strength. Note pips, agent marks, and the selected
hunk keep the accent. Click and drag behavior is unchanged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…tions

In the browser review stream every note and reply was its own box with
text buttons, and agents and people looked the same. A thread is now one
card: each message has an avatar, the author's name, a role chip, a
relative time, and its location in words ("line 13", "lines 14–16"),
with reply, edit, and delete as icon buttons and one Reply row at the
foot. The active note gets the accent ring back, moved in place as the
selection changes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…y path

A file header in the browser review stream now dims the directory and
bolds the file name, states what kind of change it is in a chip (new,
deleted, renamed with no content changes, binary, too large) instead of
printing "+0 −0" and a sentence row, and gains a chevron that collapses
any file, a copy-path button, and a button-like Viewed control whose
shortcut hint comes from the keymap. Files with nothing to draw become
header-only rows.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…t right

The source-boundary gate scans for `from "…"` to find module specifiers,
and a class name ending in `from` followed by a quote matched it. The
old-path span is now `file-path-previous`, and the helper's field is
`previous` to match.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The browser review page's sidebar encoded review state in terse glyphs:
`*2` for notes, `✓` for viewed, `Δ` for changed since viewed. A note
count is now a comment mark with the number, a viewed file dims and gets
a green check, a file changed since viewed gets a refresh mark, and a
folder shows how much of it is viewed (`1/40`). The header shows the
file count, and Tree / Flat is an icon radiogroup.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…e panel closed

The browser review page opened its side panel by default to say how big
a changeset is. A one-line strip above the stream now carries the size
badge, a sentence naming what most of the change is ("Mostly
data/huge.json (+24,999 −1). Without it: 46 files, +49 −46."), the
non-zero file roles, and a button to the Overview. The side panel starts
closed at every width and opens on Notes when the review has any. The
Overview tab drops zero rows and says what "Meaningful" leaves out.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…and copy notes

The browser review page gains a bar along the bottom: viewed progress
(moved from the toolbar), a button to the next unviewed file, the keys a
reviewer uses most, the note count, and a button that copies the
review's notes as Markdown. Every key shown is read from the resolved
keymap by command id, so a remap in the user's config shows here as it
does in the terminal, and an unbound command shows no hint.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…rowser page

A `[keybindings]` entry for a `hunk.web.*` command never reached the
browser review page: the host resolved the table against the shared
catalog alone, dropped the entry as an unknown id, and published only
catalog ids in the review's keymap, so the page fell back to its own
default (and the terminal reported an unknown command).

The page's command declaration moves to
`core/run/webLocalCommandCatalog.ts`, where the host can read it. The
host folds the remappable page commands beside the catalog when it
resolves the keymap a review publishes, so a remap, an unbind, a first
binding of a command that ships unbound, and the exclusivity rule all
apply to them. Terminal surfaces read only the names, to accept an entry
without binding anything. The page binds every remappable page command
through the resolved keymap and keeps its shipped chords only for a
keymap that carries no entry for the id.

The Ctrl/Cmd dialog chords (`hunk.web.commandPalette`,
`hunk.web.goToFile`) stay fixed; an entry for either is reported as not
remappable instead of as an unknown command. No default binding changes,
and the session wire fixture is unchanged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The PR changes key configuration behavior in browser reviews and terminal screens.

The PR appears safe to merge, with a non-blocking fix needed for page commands assigned to /.

Findings

  1. P2 Slash remaps still open filter ▶
Fix with agent prompt
### Issue 1
packages/hunk/src/app/review/sharedState.ts:101-102
**Slash remaps still open filter.** With `"hunk.web.toggleViewed" = "/"`, the host now publishes `/` and removes the default `V`. But `ReviewApp` adds `/` back to the empty `hunk.review.focusFilter` entry. Catalog commands run before page commands, so `/` focuses the filter instead of marking the file viewed, even though the hints advertise it. Account for the page's filter shortcut when resolving these bindings, and add a regression test for this case.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

The host now resolves browser-only command shortcuts and sends them to the review page, including commands that ship without a key.

  • Browser review commands now follow the keys in [keybindings].
  • Terminal screens accept browser-only command names without binding them.

benvinegar explicitly deferred reporting conflicts between user-assigned page and catalog shortcuts because publishing those warnings needs a separate change.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Config[User keybindings] --> Host[Host resolves catalog and page commands]
  Host --> State[Published review keymap]
  State --> Page[Page keyboard, hints, palette, and help]
  Config --> Terminal[Terminal resolves its own commands]
  Terminal --> Skip[Page-only entries bind nothing]
Loading

Reviews (1) · Last reviewed commit: "fix(web): deliver [keybindings] remaps o..." · Reviewed by Greptile

Comment on lines +101 to +102
...WEB_LOCAL_COMMAND_KEY_DEFAULTS,
],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Slash remaps still open filter. With "hunk.web.toggleViewed" = "/", the host now publishes / and removes the default V. But ReviewApp adds / back to the empty hunk.review.focusFilter entry. Catalog commands run before page commands, so / focuses the filter instead of marking the file viewed, even though the hints advertise it. Account for the page's filter shortcut when resolving these bindings, and add a regression test for this case.

Knowledge Base Used: Browser review client

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/hunk/src/app/review/sharedState.ts
Line: 101-102

Comment:
**Slash remaps still open filter.** With `"hunk.web.toggleViewed" = "/"`, the host now publishes `/` and removes the default `V`. But `ReviewApp` adds `/` back to the empty `hunk.review.focusFilter` entry. Catalog commands run before page commands, so `/` focuses the filter instead of marking the file viewed, even though the hints advertise it. Account for the page's filter shortcut when resolving these bindings, and add a regression test for this case.

**Knowledge Base Used:** [Browser review client](https://app.greptile.com/-/switch-tenant?tenant=modem&next=%2Fcustom-context%2Fknowledge-base%2Fmodem-dev%2Fhunk%2F-%2Fdocs%2Fbrowser-review-client.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

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.

1 participant