Edit file: built-in editor + external editor with watch & auto-upload

- Built-in editor (default): large modal with monospace textarea, Cmd+S save,
  dirty guard; reads/writes through the provider streams so it works on local
  and remote files identically (2MB cap with a friendly error)
- External editor: remote files download to appDataDir/edits/<id>, open via
  macOS `open -a`, the temp DIR is watched (survives atomic rename-saves) and
  every save enqueues a normal upload job (progress/errors in the transfer
  list); watchers + temp dirs are cleaned when the session disconnects
- Editor setting: Built-in | Custom with a NATIVE app picker (electrobun
  openFileDialog, /Applications, .app filter) and reset-to-default
- Leftover temp files from a crash prompt for cleanup at boot
- F4, toolbar button (mynaFileText), and File > Edit File (Cmd+E) menu entry
- README: feature notes + Portability notes (open/start/xdg-open seam
  documented in code and README per user request)

Verified headless against the box: sftp read/write roundtrip incl. UTF-8,
size cap, watch->save->auto-upload->remote-updated, session cleanup, orphan
listing and clearing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Jokin
2026-07-11 20:28:54 +02:00
co-authored by Claude Fable 5
parent 38ac454380
commit e4f7ca86f7
17 changed files with 606 additions and 5 deletions
+18
View File
@@ -25,6 +25,12 @@ remote server over SSH/SFTP, so you can move files **local↔remote**,
(MB/s or Mbps), persisted across restarts.
- On macOS the tab bar is fused with the window titlebar; other platforms keep
a standard titlebar.
- **Edit files** (F4 / toolbar / File menu): a built-in editor works on local
and remote files directly; or pick an external app (Options → Editor →
Custom → Choose…). External edits of remote files download to a temp folder,
are watched, and every save auto-uploads (visible in the transfer list) until
the session disconnects. Leftover temp files from a crash are offered for
cleanup at the next start.
- Browse, sort (name/size/modified, folders first), keyboard navigation.
- Create folder / file, rename, delete (recursive), change permissions (chmod).
- Upload, download, and remote→remote copy — files **and** whole folders —
@@ -136,6 +142,18 @@ Saved connections live in a plain JSON file in the OS app-data directory
(On Macs, function keys may need `fn` — every action also has a toolbar button.)
## Portability notes
The codebase is platform-neutral except for two seams, both macOS-only today:
- **External editor launch** (`launchEditor` in [src/bun/edits.ts](src/bun/edits.ts)):
uses macOS `open [-a app] file`. A Windows port should use
`cmd /c start "" [app] file`; Linux `xdg-open file` (or invoke the configured
editor binary directly). The `.app` picker in the `pickEditorApp` handler
needs the equivalent executable picker per platform.
- **Application menu** ([src/bun/menu.ts](src/bun/menu.ts)): electrobun menus
are macOS-only; the in-app UI covers every menu action.
## Known issues
- **Rare native crash under load.** A long-running session (multiple remote