|
| 1 | +# Plan: AWS S3 Browse Mode |
| 2 | + |
| 3 | +## Phase 1: S3 Backend Module |
| 4 | +<!-- execution: sequential --> |
| 5 | + |
| 6 | +- [ ] Task 1: Create S3 types and path parsing (`src/s3/mod.rs`, `src/s3/types.rs`) |
| 7 | + - [ ] Define `S3Path` struct (bucket, prefix/key) |
| 8 | + - [ ] Parse `s3://bucket/prefix/key` URIs into `S3Path` |
| 9 | + - [ ] Define `S3Entry` struct (name, is_dir, size, modified) |
| 10 | + - [ ] Define `S3Backend` struct (profile: Option<String>) |
| 11 | + - [ ] Unit tests for URI parsing (edge cases: root bucket, trailing slash, no prefix) |
| 12 | + |
| 13 | +- [ ] Task 2: Implement `aws s3 ls` output parser (`src/s3/parser.rs`) |
| 14 | + - [ ] Parse `PRE <name>/` lines as directory entries |
| 15 | + - [ ] Parse `<date> <time> <size> <name>` lines as file entries |
| 16 | + - [ ] Handle empty output (empty prefix) |
| 17 | + - [ ] Handle error output from stderr |
| 18 | + - [ ] Unit tests with sample `aws s3 ls` output (dirs, files, mixed, empty, errors) |
| 19 | + |
| 20 | +- [ ] Task 3: Implement async S3 listing via CLI (`src/s3/backend.rs`) |
| 21 | + - [ ] `S3Backend::list_prefix()` — spawn `aws [--profile] s3 ls s3://...` via `tokio::process::Command` |
| 22 | + - [ ] Capture stdout → parse with parser; capture stderr → error handling |
| 23 | + - [ ] `S3Backend::check_cli()` — verify `aws` exists on PATH |
| 24 | + - [ ] `S3Backend::download_to_cache()` — `aws s3 cp` to temp cache dir |
| 25 | + - [ ] Manage temp cache directory lifecycle (`/tmp/fm-s3-cache-<pid>/`) |
| 26 | + - [ ] Unit tests for command construction (verify args are correct) |
| 27 | + |
| 28 | +- [ ] Task 4: Add CLI flags for S3 mode (`src/config.rs`, `src/main.rs`) |
| 29 | + - [ ] Add `--aws-profile <name>` flag to clap args |
| 30 | + - [ ] Detect `s3://` prefix in PATH argument |
| 31 | + - [ ] Store S3 config in `AppConfig` (s3_mode: bool, aws_profile: Option<String>, s3_path: Option<S3Path>) |
| 32 | + - [ ] Validate `aws` CLI at startup; exit with actionable error if missing |
| 33 | + - [ ] Tests for CLI arg parsing |
| 34 | + |
| 35 | +- [ ] Task: Conductor - User Manual Verification 'S3 Backend Module' (Protocol in workflow.md) |
| 36 | + |
| 37 | +## Phase 2: S3 Tree Integration |
| 38 | +<!-- execution: sequential --> |
| 39 | + |
| 40 | +- [ ] Task 1: Add backend mode to App state (`src/app.rs`) |
| 41 | + - [ ] Add `BackendMode` enum (Local, S3 { backend: S3Backend }) |
| 42 | + - [ ] Store `backend_mode` on `App` struct |
| 43 | + - [ ] Initialize `BackendMode::S3` when config has s3_path |
| 44 | + - [ ] Add `App::is_s3_mode()` helper |
| 45 | + - [ ] Disable filesystem watcher when in S3 mode |
| 46 | + |
| 47 | +- [ ] Task 2: Build S3 TreeNodes from listing results (`src/fs/tree.rs`) |
| 48 | + - [ ] Add `TreeNode::from_s3_entry()` constructor — creates node without `fs::metadata` |
| 49 | + - [ ] Use S3 URI string as the `path` field (stored as PathBuf for compatibility) |
| 50 | + - [ ] Set `FileMeta` from `S3Entry` (size, modified, is_hidden) |
| 51 | + - [ ] S3 root node: `TreeNode::new_s3_root(s3_path)` — creates expandable root |
| 52 | + - [ ] Tests for S3 TreeNode construction |
| 53 | + |
| 54 | +- [ ] Task 3: S3 directory expansion (`src/app.rs`, `src/fs/tree.rs`) |
| 55 | + - [ ] Override `expand_selected()` path for S3 mode — call `S3Backend::list_prefix()` instead of `fs::read_dir` |
| 56 | + - [ ] Build children from `Vec<S3Entry>` via `TreeNode::from_s3_entry()` |
| 57 | + - [ ] Async expansion with loading indicator (reuse `is_loading` + `DirScanComplete` event pattern) |
| 58 | + - [ ] Wire `DirScanComplete` handler to accept S3 listing results |
| 59 | + - [ ] Tests for S3 tree expansion flow |
| 60 | + |
| 61 | +- [ ] Task 4: Disable write operations in S3 mode (`src/handler.rs`) |
| 62 | + - [ ] Guard `a`/`A` (create), `r` (rename), `d` (delete), `x` (cut), `p` (paste) keys |
| 63 | + - [ ] Show "Not available in S3 mode" status message when attempted |
| 64 | + - [ ] Disable `Ctrl+Z` undo in S3 mode |
| 65 | + - [ ] Disable inline editor (`e` key) in S3 mode |
| 66 | + - [ ] Disable `T` (open terminal at path) for S3 entries |
| 67 | + |
| 68 | +- [ ] Task: Conductor - User Manual Verification 'S3 Tree Integration' (Protocol in workflow.md) |
| 69 | + |
| 70 | +## Phase 3: S3 Preview & Clipboard |
| 71 | +<!-- execution: sequential --> |
| 72 | + |
| 73 | +- [ ] Task 1: S3 metadata preview (`src/app.rs`, `src/preview_content.rs`) |
| 74 | + - [ ] When in S3 mode + selected item is file: render metadata preview (size, date, URI, download prompt) |
| 75 | + - [ ] Add `load_s3_metadata_preview()` function in `preview_content.rs` |
| 76 | + - [ ] Generate styled `Vec<Line<'static>>` showing S3 object info |
| 77 | + - [ ] For S3 directories: show prefix info + child count from listing |
| 78 | + |
| 79 | +- [ ] Task 2: On-demand download and preview (`src/app.rs`, `src/handler.rs`) |
| 80 | + - [ ] Enter key on S3 file → spawn async download via `S3Backend::download_to_cache()` |
| 81 | + - [ ] Show loading indicator in preview panel during download |
| 82 | + - [ ] On download complete: pipe cached file through existing `update_preview()` pipeline |
| 83 | + - [ ] Cache tracking: `HashMap<String, PathBuf>` mapping S3 keys → local cache paths |
| 84 | + - [ ] Skip re-download if already cached for this session |
| 85 | + |
| 86 | +- [ ] Task 3: S3 URI clipboard copy (`src/app.rs`, `src/handler.rs`) |
| 87 | + - [ ] `y` key on S3 file → copy `s3://bucket/key` string to clipboard |
| 88 | + - [ ] Use existing system clipboard + OSC 52 fallback path |
| 89 | + - [ ] Show "📋 Copied: s3://..." status message |
| 90 | + |
| 91 | +- [ ] Task: Conductor - User Manual Verification 'S3 Preview & Clipboard' (Protocol in workflow.md) |
| 92 | + |
| 93 | +## Phase 4: UX Polish & Error Handling |
| 94 | +<!-- execution: parallel --> |
| 95 | + |
| 96 | +- [ ] Task 1: S3 status bar badge (`src/components/status_bar.rs`) |
| 97 | + <!-- files: src/components/status_bar.rs --> |
| 98 | + - [ ] Show `☁ S3 | s3://bucket` on the left section when in S3 mode |
| 99 | + - [ ] Replace local path display with S3 URI for selected item |
| 100 | + |
| 101 | +- [ ] Task 2: S3 tree colors (`src/theme.rs`, `src/components/tree.rs`) |
| 102 | + <!-- files: src/theme.rs, src/components/tree.rs --> |
| 103 | + - [ ] Add `tree_s3_fg` color to `ThemeColors` (default: amber/orange #fab387) |
| 104 | + - [ ] Apply S3-specific color to S3 entries in tree widget rendering |
| 105 | + - [ ] Add S3 icon prefix: `☁` for S3 directories, `📦` for S3 objects |
| 106 | + |
| 107 | +- [ ] Task 3: Loading indicators (`src/components/preview.rs`) |
| 108 | + <!-- files: src/components/preview.rs --> |
| 109 | + - [ ] Show `⏳ Downloading...` in preview panel during S3 file download |
| 110 | + - [ ] Show `⏳ Loading...` in tree during S3 directory expansion (reuse existing pattern) |
| 111 | + |
| 112 | +- [ ] Task 4: Help overlay updates (`src/components/help.rs`) |
| 113 | + <!-- files: src/components/help.rs --> |
| 114 | + - [ ] Grey out disabled S3 keybindings with `DarkGray` color |
| 115 | + - [ ] Add "(S3: disabled)" suffix to write operation entries |
| 116 | + - [ ] Add S3-specific hints: "Enter: Download & preview", "y: Copy S3 URI" |
| 117 | + |
| 118 | +- [ ] Task 5: Error handling polish (`src/s3/backend.rs`) |
| 119 | + <!-- files: src/s3/backend.rs --> |
| 120 | + - [ ] Parse common AWS CLI errors (ExpiredToken, AccessDenied, NoSuchBucket) into user-friendly messages |
| 121 | + - [ ] Show error dialog for authentication failures |
| 122 | + - [ ] Add retry prompt on network/timeout errors |
| 123 | + - [ ] Clean up temp cache directory on app exit |
| 124 | + |
| 125 | +- [ ] Task: Conductor - User Manual Verification 'UX Polish & Error Handling' (Protocol in workflow.md) |
| 126 | + |
| 127 | +## Phase 5: Integration & Cleanup |
| 128 | +<!-- execution: sequential --> |
| 129 | +<!-- depends: phase1, phase2, phase3, phase4 --> |
| 130 | + |
| 131 | +- [ ] Task 1: Disable incompatible features (`src/app.rs`, `src/main.rs`) |
| 132 | + - [ ] Fuzzy search (Ctrl+P): show "Not available in S3 mode" |
| 133 | + - [ ] File watcher: skip initialization entirely |
| 134 | + - [ ] Terminal panel: allow toggle but `T` action on S3 entries shows message |
| 135 | + - [ ] Inline filter (`/`): works on currently loaded tree nodes (no S3 calls) |
| 136 | + |
| 137 | +- [ ] Task 2: Temp cache cleanup and session management |
| 138 | + - [ ] Create unique cache dir per session: `/tmp/fm-s3-cache-<pid>/` |
| 139 | + - [ ] Register cleanup on app shutdown (in `main.rs` restore flow) |
| 140 | + - [ ] Handle Ctrl+C cleanup via existing panic hook |
| 141 | + |
| 142 | +- [ ] Task 3: End-to-end manual testing checklist |
| 143 | + - [ ] Verify: `fm s3://bucket/prefix/ --aws-profile mfa` launches correctly |
| 144 | + - [ ] Verify: expanding S3 directories lists contents |
| 145 | + - [ ] Verify: file metadata preview shows without download |
| 146 | + - [ ] Verify: Enter downloads and shows syntax-highlighted preview |
| 147 | + - [ ] Verify: disabled operations show correct messages |
| 148 | + - [ ] Verify: status bar, colors, loading indicators work |
| 149 | + - [ ] Verify: error cases (missing CLI, bad credentials, no internet) |
| 150 | + |
| 151 | +- [ ] Task: Conductor - User Manual Verification 'Integration & Cleanup' (Protocol in workflow.md) |
0 commit comments