Skip to content

Add keyboard shortcuts - #116

Merged
macnev2013 merged 2 commits into
macnev2013:mainfrom
iamnoksio:add/key-shortcut
Jul 25, 2026
Merged

Add keyboard shortcuts#116
macnev2013 merged 2 commits into
macnev2013:mainfrom
iamnoksio:add/key-shortcut

Conversation

@iamnoksio

@iamnoksio iamnoksio commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Enable keyboard row navigation and shift-range selection in the file explorer, plus terminal font zoom shortcuts.

  • ExplorerFileTable: handle ArrowUp/ArrowDown to move focus between rows, support Shift+Arrow for range selection, scroll focused row into view, and update selection state. Also tidy aria-sort/JSX formatting and minor data-entry-perms/size rendering adjustments.
  • AppShell: introduce preZoomFontSizeRef and add Meta+=, Meta+-, Meta+0 shortcuts to increase, decrease, and reset terminal font size (active only on terminal tabs).

Close #104

Greptile Summary

This PR adds two keyboard-shortcut features: row-level Arrow navigation and Shift+Arrow range selection in the file explorer, and Meta+= / Meta+- / Meta+0 terminal font zoom shortcuts in the app shell. It also memoises sortedEntries and the derived sortedIds array to avoid rebuilding them on every keypress.

  • ExplorerFileTable: Arrow key navigation walks the sorted row list with DOM-sibling focus/scroll; Shift+Arrow builds a range selection anchored at lastClickedId; sortedEntries and sortedIds are wrapped in useMemo; additional changes are formatting-only.
  • AppShell: A preZoomFontSizeRef stores the font size before the first zoom step so Meta+0 can restore it; the ref is initialised to null and Meta+0 exits early when no zoom session is active, addressing a previous issue where it would hard-code 14 as the reset value.

Confidence Score: 5/5

Safe to merge; both feature areas are well-scoped and the previously reported regressions are resolved.

The keyboard navigation in the file explorer is straightforward DOM-sibling walking with a correctly memoised ID list. The font-zoom logic guards the pre-zoom ref properly and exits early on Meta+0 when nothing is zoomed. The two remaining observations (Cmd++ not covered, stale baseline on mid-session Settings change) are edge-case UX gaps rather than data-loss or crash conditions.

Files Needing Attention: AppShell.tsx — the zoom-baseline ref is the only place that could produce a surprising font-size reset.

Important Files Changed

Filename Overview
src/components/layout/AppShell.tsx Introduces terminal font zoom shortcuts (Meta+=/−/0) with a stable preZoomFontSizeRef; previous Meta+0 regression addressed. Minor: external Settings changes during an active zoom session will cause Meta+0 to restore a stale pre-zoom baseline rather than the user's updated configured value.
src/components/explorer/ExplorerFileTable.tsx Adds ArrowUp/Down keyboard navigation and Shift+Arrow range selection for file rows, with DOM-sibling focus traversal and scrollIntoView. sortedEntries and sortedIds are properly memoised. Formatting-only changes to JSX and sort helpers are clean.

Sequence Diagram

sequenceDiagram
    participant User
    participant KeyboardHandler as useKeyboardShortcuts
    participant AppShell
    participant SettingsStore

    Note over User,SettingsStore: Terminal Font Zoom (AppShell)
    User->>KeyboardHandler: "Meta+="
    KeyboardHandler->>AppShell: action()
    AppShell->>SettingsStore: getState().terminalFontSize
    AppShell->>AppShell: "preZoomFontSizeRef.current = fontSize (if null)"
    AppShell->>SettingsStore: setTerminalFontSize(fontSize + 1)

    User->>KeyboardHandler: Meta+0
    KeyboardHandler->>AppShell: action()
    AppShell->>AppShell: "if preZoomFontSizeRef.current === null return"
    AppShell->>SettingsStore: setTerminalFontSize(preZoomFontSizeRef.current)
    AppShell->>AppShell: "preZoomFontSizeRef.current = null"

    Note over User,SettingsStore: Explorer Arrow Navigation (ExplorerFileTable)
    User->>KeyboardHandler: ArrowDown / ArrowUp (on row)
    KeyboardHandler->>KeyboardHandler: lookup nextIdx in sortedIds
    alt no Shift
        KeyboardHandler->>KeyboardHandler: setSelectedIds(nextId)
        KeyboardHandler->>KeyboardHandler: "lastClickedId = nextId"
    else Shift held
        KeyboardHandler->>KeyboardHandler: "anchor = lastClickedId or entry.id"
        KeyboardHandler->>KeyboardHandler: setSelectedIds(range anchor to next)
    end
    KeyboardHandler->>KeyboardHandler: nextRow.focus() + scrollIntoView()
Loading

Reviews (3): Last reviewed commit: "fix: address review — safe Meta+0 reset ..." | Re-trigger Greptile

Enable keyboard row navigation and shift-range selection in the file explorer, plus terminal font zoom shortcuts.

- ExplorerFileTable: handle ArrowUp/ArrowDown to move focus between rows, support Shift+Arrow for range selection, scroll focused row into view, and update selection state. Also tidy aria-sort/JSX formatting and minor data-entry-perms/size rendering adjustments.
- AppShell: introduce preZoomFontSizeRef and add Meta+=, Meta+-, Meta+0 shortcuts to increase, decrease, and reset terminal font size (active only on terminal tabs).

Close macnev2013#104
Comment thread src/components/layout/AppShell.tsx
Comment thread src/components/layout/AppShell.tsx Outdated
Comment thread src/components/explorer/ExplorerFileTable.tsx Outdated
- Meta+0 is a no-op when no zoom is active instead of clobbering the
  configured terminal font size with a hard-coded default
- sortedEntries and its id list are memoized so arrow-key navigation
  no longer rebuilds an array per keypress in large directories
@macnev2013
macnev2013 merged commit a1182ad into macnev2013:main Jul 25, 2026
8 checks passed
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.

Feature request: Keyboard shortcut (Cmd+/Cmd-) to adjust terminal font size

2 participants