From b6db596d0f55790f28a9b4bd71cba1e345feae12 Mon Sep 17 00:00:00 2001 From: mwiegand Date: Sun, 17 May 2026 17:02:50 +0200 Subject: [PATCH] docs(files): drop the completed files-overlay rewrite plan The plan at docs/superpowers/plans/2026-05-17-files-overlay-rewrite.md described work that's now shipped across commits 4fa3964..5f82950 (12 implementation steps + the Step 0 prefactor). The design intent lives in the resulting code (4 modules under static/js/files-overlay/, the URL-addressable editor template, the shared route helpers) and the commit messages capture each step's reasoning. Git history preserves the plan content if anyone needs the original roadmap. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../plans/2026-05-17-files-overlay-rewrite.md | 271 ------------------ 1 file changed, 271 deletions(-) delete mode 100644 docs/superpowers/plans/2026-05-17-files-overlay-rewrite.md diff --git a/docs/superpowers/plans/2026-05-17-files-overlay-rewrite.md b/docs/superpowers/plans/2026-05-17-files-overlay-rewrite.md deleted file mode 100644 index 324d8fc..0000000 --- a/docs/superpowers/plans/2026-05-17-files-overlay-rewrite.md +++ /dev/null @@ -1,271 +0,0 @@ -# files-overlay.js Rewrite + Editor Migration + API Cleanup (handoff-ready) - -## Context - -`l4d2web/l4d2web/static/js/files-overlay.js` has grown to ~35 KB / 1092 lines and hosts 9+ feature areas in one IIFE: helpers, the legacy inline editor dialog (text + binary + create-new modes), new-folder modal, conflict modal, delete-confirm modal, file-row action dispatch, drag-drop on the file tree, upload queue + progress panel, and document-level delegation for the URL-addressable editor's save/delete. Event-binding patterns are inconsistent — direct-binds, clone-and-rebind anti-patterns, bind-and-remove per-call, and document-level delegation all coexist for similar tasks. - -Two flows still use the legacy inline ``: **create-new-file** (no URL to deep-link a file that doesn't exist yet) and **binary-replace** (the new URL-addressable template intentionally omitted binary-replace UI per Task 2's pilot scope cut). Migrating both flows to URL-addressable lets us delete the legacy dialog and simplifies the JS editor module dramatically. - -Meanwhile `routes/files_routes.py` (640+ lines) duplicates path-resolution and editability checks between `overlay_file_content` (JSON) and `overlay_file_edit_page` (HTML), and the JSON `/files/content` endpoint becomes dead code once create-new + binary-replace migrate away from JS-populated inline dialogs. - -**Goal:** rewrite the JS into focused modules with consistent delegation; migrate create-new + binary-replace flows to URL-addressable modals; delete the legacy dialog; clean up `routes/files_routes.py` to share helpers and drop dead endpoints. Behavior visible to the user is unchanged — same features, same UX. Each migration commit leaves the working tree in a known-good Chromium-verified state, so this plan can be paused, resumed, and handed off across sessions. - -## Approach: three phases, twelve commits - -Three natural pause points for cross-session handoff. Each phase is independently completable and verifiable. - -| Phase | Steps | Scope | Where the working tree lands | -|-------|-------|-------|------------------------------| -| **A** | 1-4 | JS rewrite into 4 modules (`core.js`, `editor.js`, `dialogs.js`, `uploads.js`). `editor.js` is dual-purpose at this point (legacy inline dialog + URL-addressable modal). | Old `files-overlay.js` is empty/stub; behavior unchanged; legacy dialog still exists and is still used by create-new + binary-replace. | -| **B** | 5-10 | URL-addressable migration of create-new + binary-replace. Adds `GET /overlays//files/new?at=`; binary-file detection in the edit route; binary-replace UI in `overlay_file_editor.html`; JS code-paths for both flows move to URL-addressable. Legacy dialog deleted from `overlay_detail.html`. `editor.js` becomes single-purpose. | Legacy dialog gone; `editor.js` ~200 lines, URL-addressable-only; create-new + binary-replace are URL-addressable. | -| **C** | 11-12 | API cleanup. Extract shared path-resolution + editability helper used by edit/save/content endpoints. Delete `GET /overlays//files/content` JSON endpoint if confirmed unused. Consolidate save/replace duplication where reasonable. | `routes/files_routes.py` ~450 lines; no dead routes; pytest still green. | - -Total estimate: ~12 commits, each independently revertable. - -## Decomposition (new JS modules) - -| Module | Phase A end | Phase B end | Responsibility | -|--------|-------------|-------------|----------------| -| `static/js/files-overlay/core.js` | ~120 lines | ~120 lines | Helpers (`postJson`, `postForm`, `scheduleRefresh`, `parentOf`, `joinPath`). Manager-element detection, CSRF read. File-row click delegation dispatch. | -| `static/js/files-overlay/editor.js` | ~350 lines (dual-purpose) | ~200 lines (URL-addressable only) | Save / delete / rename-on-save / 409 conflict handling. Filename rename hint. Ctrl+S. After Phase B, only handles URL-addressable modal content via document-level delegation gated on `#modal-content`. | -| `static/js/files-overlay/dialogs.js` | ~180 lines | ~180 lines | New-folder modal, delete-confirm modal, conflict modal (`askConflict` returning a promise). All document-level delegated, no clone-and-rebind. | -| `static/js/files-overlay/uploads.js` | ~280 lines | ~280 lines | Upload queue (concurrency 3), progress panel, per-row cancel via `data-upload-id`. Drag-drop on `treeRoot` kept direct-bound (5 coordinated events, persistent target). | - -Total after rewrite: ~780 lines across 4 files (vs 1092 in one). - -Direct-bind escape hatches (places we keep direct binding deliberately): -- `editor.js`: `input` / `keydown` on `.files-editor-filename` and `.files-editor-content` (high-frequency, persistent input elements in the swapped-in modal content — re-bound on each `htmx:afterSwap`). -- `uploads.js`: `dragstart` / `dragend` / `dragover` / `dragleave` / `drop` on `treeRoot` (5 coordinated events sharing per-target highlight state; document delegation would obscure the coordination logic). - -## Migration sequence - -### Phase A — JS rewrite (steps 1-4) - -**Step 1: scaffold `files-overlay/core.js`** - -Create the new directory. Move helpers (lines ~40-170 of the current file: `postJson`, `postForm`, `scheduleRefresh`, `parentOf`, `joinPath`, byte-count utility, manager-element detection, CSRF read). Add the file-row click delegation that currently lives at line 1054 — same selector match, but instead of switch-casing into local handlers, dispatch through a registry `window.__filesOverlay.handleAction(action, path, actionEl)` that feature modules register handlers into. Old `files-overlay.js` still has its own handlers for now — `core.js` dispatch is unused until subsequent steps wire features into it. - -`overlay_detail.html` (NOT base.html): add `