Skip to content

feat(app): directory autocomplete for new session path picker#1077

Open
chphch wants to merge 1 commit intoslopus:mainfrom
chphch:feat/44-filepath-autocomplete
Open

feat(app): directory autocomplete for new session path picker#1077
chphch wants to merge 1 commit intoslopus:mainfrom
chphch:feat/44-filepath-autocomplete

Conversation

@chphch
Copy link
Copy Markdown
Contributor

@chphch chphch commented Apr 15, 2026

Closes #44.

What this adds: Live subdirectory autocomplete in the new-session "Project path" picker. As soon as the user types a path (e.g. /home/user/proj) the picker fetches matching subdirs from the selected machine via machineBash (ls -1ap) and shows them above the existing "Recent" list; tapping a suggestion appends / so the user can keep drilling down. Debounced 250ms, per-machine cache (10s TTL), no network or disk hit when no machine is selected or the field is empty.

Proof

Screencast of typing a partial path → suggestions appear → tap → drill down: video pending — will attach before requesting human review per CONTRIBUTING.md.

How it works

User types: /home/user/proj
        ↓
parentDir = /home/user/   prefix = proj
        ↓
machineBash: ls -1ap /home/user/ | grep '/$' | grep -v '^\.\.?/$'
        ↓
Filter by prefix → ["projects/", "project-alpha/"]
        ↓
Show as suggestions; tap → sets value to /home/user/projects/

Scope

  • 3 files, +174 / -0 — pure addition, no existing behaviour changes when the field is empty or no machine is selected.
  • No new dependencies.

@chphch chphch force-pushed the feat/44-filepath-autocomplete branch from d436bd1 to 52fd08f Compare April 26, 2026 07:00
@chphch
Copy link
Copy Markdown
Contributor Author

chphch commented Apr 26, 2026

Proof — directory autocomplete drills correctly

Captured locally via standalone happy-server (PGlite, port 3055) + Expo web (port 8088), authenticated through getDevWebQueryCredentials() dev URL bypass, driven headlessly with Playwright.

useDirSuggestions calls out to machineBash(machineId, 'ls -1ap "<dir>"', dir) — which requires a connected happy-cli daemon. To capture the UI flow without bringing up a CLI, the hook's fetchDirs was tap-injected at the window.__HAPPY_DIR_MOCK__ boundary so a deterministic mock filesystem stands in for the real ls output. No production code path changed; the mock is removed after capture.

directory autocomplete

The GIF cycles three states:

  1. /home/user/proj typed → Suggestions: /home/user/projects, /home/user/project-alpha, /home/user/project-beta (filter by proj prefix).
  2. Tap a suggestion → path appended with trailing /, drilled into the selected directory.
  3. /home/user/projects/happy typed → Suggestions: /home/user/projects/happy, /home/user/projects/happy-cli, /home/user/projects/happy-server (filter by happy prefix at the new depth).

Mock filesystem (substitutes for real ls output):

{
  '/home/user/':            ['projects', 'project-alpha', 'project-beta', 'photos', 'docs'],
  '/home/user/projects/':   ['happy', 'happy-cli', 'happy-server', 'web-app', 'mobile-app'],
}

Production behaviour matches: with a real machine connected, useDirSuggestions calls machineBash with the same ls -1ap | grep '/$' | grep -v '^\.\.\?/$' pipeline, debounced 250 ms with a 10 s per-(machineId, parentDir) cache, and feeds the same prefix-filter into the same <Suggestions> UI rendered above the existing Recent list.

Capture details

@chphch chphch force-pushed the feat/44-filepath-autocomplete branch 2 times, most recently from 0781ed8 to 0f1bee5 Compare April 29, 2026 06:53
When a user types a project path in the new session screen, the path
picker now shows filesystem directory suggestions fetched from the
selected machine via `machineBash`. Suggestions are debounced (250ms),
cached per (machineId, parentDir) pair for 10s, and filtered by the
current typed prefix. Tapping a suggestion appends `/` so the user can
keep drilling down.

New hook: `useDirSuggestions(machineId, pathText)`
Closes: slopus#44

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
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.

Add autocomplete for filepaths when creating new session

1 participant