Skip to content

fix(app): make Enter drill into directories in file tree#125

Merged
andrewmelchor merged 2 commits intomainfrom
fix(app)/file-tree-enter-toggle
Mar 6, 2026
Merged

fix(app): make Enter drill into directories in file tree#125
andrewmelchor merged 2 commits intomainfrom
fix(app)/file-tree-enter-toggle

Conversation

@andrewmelchor
Copy link
Copy Markdown
Member

Summary

Make enter drill into directories in file tree

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Mar 6, 2026

Greptile Summary

This PR makes the Enter key drill into (toggle) directories in the file tree, whereas previously it was a no-op for directories. The change introduces a new pure utility function resolveLeftPanelEnterAction that encapsulates the decision logic for what Enter should do based on the active tab and the type of the selected node, and refactors executeActiveLeftSelection in app.tsx to delegate to it.

Key changes:

  • New resolveLeftPanelEnterAction utility maps (activeTab, selectedIsDirectory)'none' | 'toggle-directory' | 'execute-file', cleanly separating decision logic from the UI layer.
  • executeActiveLeftSelection now calls store.toggleDir when Enter is pressed on a directory, instead of returning early.
  • toggleActiveDirectory (bound to Space) is left unchanged, so both Space and Enter now toggle directories.
  • Full unit test coverage for the new utility across all meaningful input combinations.
  • Minor: LeftPanelTabId in the new utility duplicates the existing LeftPanelTab type from tabbed-panel.tsx; these two types should be consolidated to prevent silent drift if new tabs are added in the future.

Confidence Score: 5/5

  • This PR is safe to merge — the change is small, well-tested, and the logic is straightforward.
  • The refactoring is minimal and contained to a single function in app.tsx, with the new logic extracted into a well-tested pure utility. All code paths are covered by unit tests, and the only identified issue is a non-critical duplicate type definition that should be consolidated but does not affect runtime behavior.
  • No files require special attention beyond the type duplication in left-panel-enter-action.ts (which does not block merging).

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A([User presses Enter]) --> B[executeActiveLeftSelection]
    B --> C[store.selectedNode]
    C --> D[resolveLeftPanelEnterAction\nactiveTab, isDir]
    D --> E{activeTab === 'files'?}
    E -- No --> F[return 'none']
    E -- Yes --> G{selectedIsDirectory\n=== undefined?}
    G -- Yes --> F
    G -- No --> H{isDir?}
    H -- Yes --> I[return 'toggle-directory']
    H -- No --> J[return 'execute-file']
    F --> K{!selectedNode\nor action === 'none'?}
    I --> K
    J --> K
    K -- Yes --> L([return false / no-op])
    K -- No --> M{action === 'toggle-directory'?}
    M -- Yes --> N[store.toggleDir\npath]
    M -- No --> O[handleFileExecute\npath]
    N --> P([return true])
    O --> P
Loading

Last reviewed commit: 21abb4a

Comment thread packages/app/src/tui/util/left-panel-enter-action.ts Outdated
@andrewmelchor andrewmelchor merged commit cfd84e8 into main Mar 6, 2026
1 check passed
@andrewmelchor andrewmelchor deleted the fix(app)/file-tree-enter-toggle branch March 6, 2026 20:46
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