Skip to content

[codex] add file navigation shortcuts#308

Closed
theimpostor wants to merge 1 commit into
modem-dev:mainfrom
theimpostor:codex/issue-307-file-navigation
Closed

[codex] add file navigation shortcuts#308
theimpostor wants to merge 1 commit into
modem-dev:mainfrom
theimpostor:codex/issue-307-file-navigation

Conversation

@theimpostor
Copy link
Copy Markdown

Summary

  • Adds , and . keyboard shortcuts for previous/next file navigation in the visible review stream.
  • Wires file navigation through the shared review controller, Navigate menu, and help dialog.
  • Adds unit, component, app interaction, and PTY coverage for the new navigation path.

Closes #307

Verification

  • bun run typecheck
  • bun run format:check
  • bun run lint
  • env PATH="/Users/shoda/.bun/bin:/opt/homebrew/bin:$PATH" /Users/shoda/.bun/bin/bun test ./src ./packages ./scripts ./test/cli
  • /Users/shoda/.bun/bin/bun test ./test/pty

Note: test/session is not included in the clean local run because this macOS environment resolves BSD /usr/bin/script, which rejects the GNU-style script -e -c options those tests use.

@theimpostor theimpostor marked this pull request as ready for review May 14, 2026 02:20
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 14, 2026

Greptile Summary

This PR adds , / . keyboard shortcuts for previous/next file navigation in the review stream, wired through the shared ReviewController, the Navigate menu, and the help dialog.

  • findNextFile in files.ts: New pure helper that clamps navigation at stream edges and handles the undefined-selection case (navigating from no selection defaults to the first or last file depending on direction).
  • moveToFile in useReviewController.ts: Callback that calls findNextFile over visibleFiles (respecting any active filter) and delegates to selectFile with alignFileHeaderTop: true to pin the header to the top of the viewport on arrival.
  • useAppKeyboardShortcuts.ts + appMenus.ts: Shortcuts and menu items wired up consistently with the existing [/] hunk-navigation pattern; filter-focus mode safely swallows all keys before the new handlers are reached.

Confidence Score: 5/5

Safe to merge — the change adds a self-contained navigation feature with no mutations to existing data paths.

The new findNextFile helper is purely functional, all edge cases (empty list, undefined selection, clamping at both ends) are covered by unit tests, and the filter-interaction behavior is verified by a dedicated component test. The keyboard handler follows the established guard order so the shortcuts are correctly suppressed in filter-focus, pager, and menu modes. Four independent test layers (unit, component, app interaction, PTY) exercise the end-to-end path.

No files require special attention.

Important Files Changed

Filename Overview
src/ui/lib/files.ts Adds findNextFile pure helper with correct clamping and undefined-selection handling; well covered by unit tests.
src/ui/hooks/useReviewController.ts Adds moveToFile callback over visibleFiles with alignFileHeaderTop: true; dependencies are correct and the method is properly exposed on the ReviewController interface.
src/ui/hooks/useAppKeyboardShortcuts.ts New ,/. shortcuts added in handleAppShortcut, correctly guarded behind filter-focus and pager/menu modes; pattern consistent with existing bracket shortcuts.
src/ui/lib/appMenus.ts Adds Previous/Next file menu items with correct hint keys between hunk and comment groups in the Navigate menu.
src/ui/App.tsx Threads review.moveToFile into both buildAppMenus and useAppKeyboardShortcuts options, and correctly adds it to the useMemo dependency array.
src/ui/lib/files.test.ts Unit tests cover forward/backward movement, clamping at both ends, undefined selection, and empty file list.
src/ui/hooks/useReviewController.test.tsx Component-level test verifies filter interaction: navigation respects visibleFiles after a filter is applied and correctly clamps at the single visible file.
src/ui/AppHost.interactions.test.tsx App interaction test drives . then , keypresses and asserts the review pane scrolls to the expected file header.
test/pty/ui-integration.test.ts PTY-level test launches a real terminal session and verifies keyboard-driven file navigation against live rendered output.

Sequence Diagram

sequenceDiagram
    participant User
    participant Keyboard as useAppKeyboardShortcuts
    participant Controller as useReviewController
    participant Files as files.ts (findNextFile)
    participant UI as Review Pane

    User->>Keyboard: Press "," or "."
    Keyboard->>Keyboard: Guard: pagerMode? filterFocus? menuOpen?
    Keyboard->>Controller: moveToFile(-1 or +1)
    Controller->>Files: findNextFile(visibleFiles, selectedFile.id, delta)
    Files-->>Controller: nextFile (clamped) or null
    Controller->>Controller: "selectFile(nextFile.id, 0, { alignFileHeaderTop: true })"
    Controller-->>UI: Scroll view to file header top
Loading

Reviews (1): Last reviewed commit: "feat: add file navigation shortcuts" | Re-trigger Greptile

@benvinegar
Copy link
Copy Markdown
Member

Hey @theimpostor, I appreciate you submitting this, but we had #280 waiting which has a lot of overlap and I chose to merge that.

If you feel #280 is missing something please isolate those changes and maybe re-open as a new PR.

Closing as done in the meantime.

@benvinegar benvinegar closed this May 14, 2026
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.

Next/prev file keyboard shortcuts

2 participants