Vendor explicit file-focus navigation + viewed/collapse shortcuts#64
Vendor explicit file-focus navigation + viewed/collapse shortcuts#64dastratakos wants to merge 1 commit into
Conversation
…ortcuts Syncs the CLI with the monorepo's keyboard-navigation overhaul that landed after the fork: - #943: replace scroll-derived "active file" with an explicit focused-file state machine (useCurrentFile) + a shared orchestrator (useFileDiffNavigation) that owns the diff-viewer ref and wires every file shortcut. Adds a "file keyboard mode" so keyboard focus shows an outline ring while click/scroll selection only highlights the picker row. - #975: add v (mark file viewed + advance, pinning the marked file to top), ; / Shift+; (collapse file / all files), Esc (exit keyboard mode), and re-bind chapter-viewed from v to Shift+V (#910). file-header gains ShortcutTooltip hints on the viewed + collapse controls. New hooks (vendored, imports adapted to @/lib/*): use-current-file, use-file-viewed-key, use-file-collapse-keys, use-file-keyboard-mode-exit-key, use-file-diff-navigation; use-file-navigation-keys rewritten to the focus signature. The old scroll heuristic use-active-file-on-scroll is deleted. Both routes now delegate to useFileDiffNavigation; FileDiffList gains a focusedFilePath outline. Ported the monorepo's file-focus-shortcuts test (16 cases). CLI simplification: the canToggleViewed gate stays at its default (the CLI's viewed state is client-side and always writable). Typecheck, lint, web tests (105), and build all pass.
|
Ready to review this PR? Stage has broken it down into 6 individual chapters for you: Chapters generated by Stage for commit 20c4ba6 on Jun 2, 2026 4:53am UTC. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 20c4ba6dfa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (scrollTo && !isLoading) { | ||
| diffListRef.current?.scrollToFile(scrollTo); |
There was a problem hiding this comment.
Synchronize focus when honoring scrollTo
When a user follows a prologue focus-area link into the Files tab (search.scrollTo), this effect only scrolls the diff list and never updates the new currentFilePath state. Because this commit removed scroll-derived active-file tracking, subsequent v/;/j/k shortcuts start from undefined and act on the first file instead of the file the route just brought into view. Select or focus scrollTo as part of handling this route-driven scroll.
Useful? React with 👍 / 👎.
| if (target) { | ||
| scrollToLine(target.filePath, target.side, target.startLine); |
There was a problem hiding this comment.
Update current file for key-change jumps
Selecting a key change in the chapter side panel scrolls to target.filePath, but it does not update the explicit file-focus state introduced here. After that jump, the sidebar highlight and file shortcuts still refer to the previous file (or default to the first file), so pressing v or ; can toggle the wrong file even though the user is looking at the key-change target. The key-change scroll should also select/focus target.filePath.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 20c4ba6. Configure here.
| diffListRef, | ||
| currentFilePath, | ||
| keyboardFocusedFilePath, | ||
| selectFile, |
There was a problem hiding this comment.
Unused selectFile returned from orchestrator hook
Low Severity
selectFile is returned from useFileDiffNavigation but no consumer ever destructures or uses it. Both files-page.tsx and chapter-detail-page.tsx only use handleSelectFile (which wraps selectFile internally). The raw selectFile export is dead code at the hook's public API boundary.
Reviewed by Cursor Bugbot for commit 20c4ba6. Configure here.


Summary
Syncs the CLI with the monorepo's keyboard-navigation overhaul that landed after the fork. Replaces the CLI's scroll-derived "active file" model with an explicit focused-file state machine and adds the file-level keyboard shortcuts.
Ports two monorepo PRs:
useCurrentFiletrackscurrentFilePath+isFileKeyboardMode; a shareduseFileDiffNavigationorchestrator owns the diff-viewer ref and wires every shortcut. Keyboard focus shows an outline ring (keyboardFocusedFilePath); click/scroll selection only highlights the picker row (currentFilePath).v(mark file viewed + advance focus, pinning the marked file to the top),;/Shift+;(collapse file / all files),Esc(exit keyboard mode), and re-bind chapter-viewed fromv→Shift+V.file-headergainsShortcutTooltiphints on the viewed + collapse controls.Changes
@/lib/*):use-current-file,use-file-viewed-key,use-file-collapse-keys,use-file-keyboard-mode-exit-key,use-file-diff-navigation.use-file-navigation-keysrewritten to the focus signature (files, currentFilePath, onFocusFile, enabled).use-active-file-on-scroll.ts(the old scroll heuristic).MARK_FILE_AS_VIEWED,EXIT_FILE_KEYBOARD_MODE,TOGGLE_FILE_COLLAPSED,TOGGLE_ALL_FILES_COLLAPSED; re-boundMARK_CHAPTER_AS_VIEWEDtoShift+V.files-pageandchapter-detail-pagedelegate touseFileDiffNavigation; the chapter page's key-change focus now uses the orchestrator'sscrollToLine/cancelScrollToLine.FileDiffListgains afocusedFilePathoutline.canToggleViewedgate stays at its defaulttrue— the CLI's viewed state is client-side and always writable (no server node-id gate).file-focus-shortcutstest (16 cases).Testing
pnpm typecheck✅pnpm lint✅pnpm test✅ (web 105, incl. 16 new; the only red was pre-existing flaky-under-load timeouts incli/git.test.ts, which pass 12/12 in isolation)pnpm build✅Summary by cubic
Switches the CLI to explicit file focus navigation and adds file-level shortcuts for viewed and collapse. Files and chapter pages now share one navigator and show a focused-file outline.
New Features
useCurrentFile, with a “file keyboard mode” that outlines the focused diff.useFileDiffNavigationwiresj/k,v,;,Shift+;,Escand owns scroll-to-file/line for bothfiles-pageandchapter-detail-page.vtoggles file viewed and advances focus; chapter viewed is nowShift+V.file-headershowsShortcutTooltipand a collapse shortcut label.FileDiffListacceptsfocusedFilePathand outlines the active diff.Refactors
use-active-file-on-scroll; rewroteuse-file-navigation-keysto the focus signature (files,currentFilePath,onFocusFile,enabled).use-file-viewed-key,use-file-collapse-keys,use-file-keyboard-mode-exit-key; updatedkeyboard-shortcutswith file/escape bindings.useFileDiffNavigation; chapter scrolling usesscrollToLine/cancelScrollToLine. CLI keeps viewed state writable, sovis always enabled.file-focus-shortcutstest (16 cases). Typecheck, lint, tests, and build pass.Written for commit 20c4ba6. Summary will update on new commits.