left4me/l4d2web/l4d2web
mwiegand 8dc14f0cca
feat(files): wire askConflict into the routed new-file 409 path
The is_new branch of routedSaveClicked in editor.js used to alert on
409 and force the user to manually pick a different filename. Restore
the overwrite / keep-both / cancel prompt the legacy openEditorTextNew
flow had (via askConflict, lost when Step 9 deleted legacySaveClicked).

Flow on 409:
  * "overwrite" → re-POST /save with the same path. /save overwrites
    in place when the destination is a regular file.
  * "keep-both" → compose a suffixed path via fo.withCollisionSuffix
    (now multi-extension-aware after F3) and POST that.
  * "cancel" → leave the routed modal open with the user's typed
    content intact so they can edit the filename and retry.

Defensively gates the askConflict + withCollisionSuffix calls on
typeof === "function" so older bookmarks (or a dev environment with
one of the modules missing) fall back to an alert rather than a
TypeError. The 409 alert branch is preserved for that path.

Note on when /save actually 409s: regular-file collisions overwrite
silently (200). 409 fires only when the new path collides with a
directory (or a symlink, or a non-file fs entry) — same contract as
the legacy flow had.

Verified live on /overlays/2 in Chromium with a real round-trip:
  1. Click "+ new folder" → create tmp_409_probe
  2. Click "+ new file" → type "tmp_409_probe" → click Create
  3. /save returns 409 (destination is not a file) → askConflict
     opens with the colliding path displayed
  4. Routed modal stays open behind the conflict dialog (typed
     content preserved)
  5. Cancel on conflict → conflict closes, routed modal still open
  6. Cleanup: delete the tmp_409_probe folder via the action API
  * No console errors throughout
  * Demo overlay state unchanged after cleanup

pytest stays at 577 passed, 1 skipped, 3 deselected (no Python
changes in F4).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-17 17:12:14 +02:00
..
routes refactor(files): drop the always-True download_supported flag 2026-05-17 17:05:17 +02:00
services refactor(datetime): introduce UtcDateTime, remove naive-strip workarounds 2026-05-16 11:59:29 +02:00
static feat(files): wire askConflict into the routed new-file 409 path 2026-05-17 17:12:14 +02:00
templates refactor(files): drop the always-True download_supported flag 2026-05-17 17:05:17 +02:00
__init__.py refactor(repo): uv workspace + hatchling + layout restructure 2026-05-15 22:04:29 +02:00
app.py feat(modals): layout context processor for HX-Modal header 2026-05-17 11:27:25 +02:00
auth.py refactor(datetime): introduce UtcDateTime, remove naive-strip workarounds 2026-05-16 11:59:29 +02:00
cli.py refactor(repo): uv workspace + hatchling + layout restructure 2026-05-15 22:04:29 +02:00
config.py refactor(repo): uv workspace + hatchling + layout restructure 2026-05-15 22:04:29 +02:00
db.py refactor(repo): uv workspace + hatchling + layout restructure 2026-05-15 22:04:29 +02:00
models.py refactor(datetime): introduce UtcDateTime, remove naive-strip workarounds 2026-05-16 11:59:29 +02:00