Skip to content

Rework the File menu: Open, Save, Save As, Load and slot names - #2274

Merged
maniator merged 3 commits into
mainfrom
claude/project-thread-o02hzf
Nov 15, 2026
Merged

maniator merged 3 commits into
mainfrom
claude/project-thread-o02hzf

Conversation

@maniator

Copy link
Copy Markdown
Owner

Requested by Naftali · project thread

What & why

The File menu reads like a 90s program's, for 4.1 (Naftali, 2026-11-15: rename Import and Export to Open and Save As, rename Saves, reorder the menu, "Full set plus slot names", and "load can be a sub menu that contains the auto and other saves").

  • New names and order: New Tower…, Open… (Ctrl+O), Load ▸, Saved Towers…, Close, then Save (Ctrl+S, the quick save into the Auto-save) and Save As… (Ctrl+Shift+S, the .vctower download). Cmd works on a Mac. The Save As dialog's primary reads "Save .vctower".
  • The keys (src/game/fileShortcuts.ts): one keydown listener. A text box, text area, list box or editable text keeps its keys (nothing runs, no preventDefault). Elsewhere the press is taken so the browser's Open and Save Page never show over the game; nothing runs over a dialog, after the engine stopped, or on a held key's repeats; on the title screen only Open runs, as the grayed items say. New Tower and Close get no keys (Ctrl+N and Ctrl+W are the browser's).
  • File > Load (src/game/loadMenu.ts): lists the Auto-save and each readable slot as "Slot 1: Tower One", refilled from the cached SaveGame.listSlots() each time File opens. At most four rows, so it never scrolls. In a tower it runs the same load as Saved Towers…' Load; on the title screen it runs loadFromSplash and welcomes a founder, as the title picker does.
  • Submenus (src/ui/menuBar.ts): a mouse opens a submenu by pointing and its click keeps it open; a tap toggles it; Right, Left and Esc walk in and out. On a phone the submenu opens in place under its title (media-phone.css).
  • Slot names (src/storage/slotLabels.ts, src/ui/slotRename.ts): Saved Towers… gains Rename… on each numbered slot. The name is a device preference in its own key (vc.slotNames), never in a tower file, up to 28 characters; empty gives the number back. It shows in Saved Towers…, File > Load and the title picker (slotName).
  • Saved Towers… footer holds Close alone (Naftali: "remove the export and import buttons on this modal"); the File menu has both.
  • Analytics (Naftali: "make sure all analytics are tracked"): the Load items send menu_pick codes load_auto and load_slot_1 to load_slot_3; a File key sends its item's menu_pick with via: "shortcut" and browsed: 0; a rename sends app_action rename_slot (named or cleared, never the name). Existing codes keep their names across the rename (import, export, quick_save, saves). Data map and the dashboard's persistence tile updated.
  • Help pages (saving, importing and exporting, controls, the menu table) and the bug and parity forms use the new names.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • Classic-canon fix (matches the 1994 original for all towers)
  • Modern-mode feature (opt-in, "what the original couldn't do")
  • New player-facing feature (mode-agnostic)
  • Refactor / internal-only (no player-facing behavior change)
  • Docs / tooling

Game mode impact

  • This change is classic-canon (affects all towers, stays faithful to the 1994 original)
  • This change is modern-only (gated behind Modern mode, does not alter Classic behavior)
  • This change is mode-agnostic (identical in both modes)
  • Any mode-divergent behavior is isolated in the mode rule-set (resolved once at founding), not smeared into the simulation with ad-hoc mode checks

Quality gates

  • npm run typecheck
  • npm run lint
  • npm test (the UI, game, storage, analytics and guard suites locally; the full suite runs in CI)
  • npm run build (vite build locally; CI runs the full build)

Versioning

  • Added a .changes note with the right app: and crate: levels (app: minor, crate: none)
  • This PR changes no engine source

Complexity

Nothing runs per frame or per tick. Opening the File menu reads the cached slot list (four rows) and, for a named slot, one localStorage read compared against the last text read, so a name is parsed only when it changed. A key press does two compares before it knows it is not a File key.

Hot-path record (section 6): no hot path is touched. HP-1 per-pass work: none added to a tick, frame or status pump; the menu-open fill is four rows. HP-2 allocations: none per frame. HP-3 DOM writes: four item texts per File open, none per frame. HP-8 caches: listSlots' remembered rows are used as they are; the slot names add their own last-read cache.

Screenshots / recordings

Previews from a host build (preview only, not the gallery): File > Load open on desktop and on a phone, sent to the owner in the project thread. The gallery is redrawn in the pinned Playwright image and pushed to this branch.

Notes for reviewers


Generated by Claude Code

@vercel

vercel Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
verticopolis Ready Ready Preview Nov 15, 2026 5:48am UTC

Request Review

Copy link
Copy Markdown
Owner Author

CI status: engine-wasm fails in verify-precache: the precache is over its 4.5 MiB budget. Main's own tooling build at b7328f8 already sits at 4649.59 KiB in the workbox count ("4.50 MiB" in verify-precache, just under), and this PR adds about 6 KiB (the Load submenu, slot names, the File keys and their markup). The e2e jobs failed only because they download the tooling app that job never uploaded. Raising PRECACHE_BUDGET_BYTES is the owner's call per its own comment; it has been asked, and this PR waits on that answer.


Generated by Claude Code

Copy link
Copy Markdown
Owner Author

Stand-in review (stand-in-pr-review + /bmad-code-review, lean pass): CONDITIONAL GO at a0f5b60, one patch finding

The code is sound. One governed dashboard tile changes meaning without being updated, so that needs a fix before merge.

F1 (patch, Acceptance Auditor): File-key picks feed the menu funnel as if they came through a menu

reportKey sends a menu_pick (with via: "shortcut") that has no menu_open before it, and trackMenuPick sets lastPick from it. The governed tiles in scripts/posthog-dashboard.mjs don't separate these picks:

  • "Menu bar: open to pick funnel" counts any menu_pick within a minute of a menu_open. A player who opens a menu, dismisses it, then presses Ctrl+S counts as a conversion, so the funnel overstates the menu's success.
  • "Menu bar: picks by item" breaks down by item and grayed only, so menu Saves and Ctrl+S Saves merge into one row.
  • "Menu bar: what follows what" describes "the click path through the menus", but a key press now becomes the next pick's after.
  • docs/analytics-measurement-status.md row 26 still says "One open and one pick or dismissal per trip, so open to pick is a real funnel". That stops being true once the keys report picks.

Fix: give the funnel's pick step a via not-equal-to shortcut property filter, add via to the picks-by-item breakdown (or exclude shortcuts there and add a small "File keys" tile), and either keep shortcut picks out of lastPick or say in the "what follows what" description that keys are part of the path. Then update row 26 to match. The data map entry itself is already accurate.

Nits (fold in, no re-review needed)

  • N1. The wireFileShortcuts doc says "The keys follow the menu's gray", but after the engine stops the keys refuse Open, Save and Save As, while the menu grays only Close (menuWiring.ts:280). Refusing is the safer behavior, since no engine holds the tower. Either gray mb-import, mb-quick-save and mb-export in the menu when isEngineStopped() too, or reword the comment.
  • N2. keptUnreadableNote now says "open the file with Open". The dialog no longer has that button, so "with File > Open…" says where to find it.

Checked

  • Submenu (menuBar.ts). items() keeps a submenu's items out of the parent's arrow cycle. Mouse: pointing at Load opens it, pointing at a sibling closes it, and clicking Load keeps it open. Tap: toggles it without focusing. Keys: Enter, Space and Right open it and focus the first item; Left and Escape return to Load; Tab and any close go through close(), which calls closeSub. A click on the submenu title is neither a pick nor a close (in both menuWiring and the popup listener). menuBarSubmenu.test.ts covers these.
  • File keys (fileShortcuts.ts). Ctrl or Cmd is required and Alt is left alone. Caps Lock S still means Save, because the key is lowercased and Shift is read separately. Text fields, text areas, selects and contenteditable keep the key. preventDefault comes before the dialog, stopped-engine and repeat checks, so the browser's Open and Save Page never show over the game. Save and Save As report grayed on the title screen and don't run. inputKeys.blocksGameKey already ignores modifier combinations, so nothing runs twice.
  • Title-screen loads (loadMenu.ts). loadFromSplash returns false on a failed read and records load_failed itself; success goes through welcomeFounder, as the picker does. Inside a tower it uses the same onLoadSlot as Saved Towers…' Load. Items are filled with textContent, and the dialog uses lit's escaping, so a slot name can't inject markup.
  • Slot names (slotLabels.ts). Device-local key, trimmed and capped at 28 code points; a damaged entry reads as no names; an empty name clears it; a refused write shows a message and leaves the dialog up. rename_slot sends only named or cleared, never the text.
  • No player-facing string still says Quick Save, Export to file, Import from file or Saves… (searched src and help-site).
  • Local: tsc --noEmit and ESLint on the touched files are clean; vitest over src/game, src/ui, src/storage and src/analytics* passes, 2,221 tests.

Hot-path record (section 6)

Item Result
HP-1 tier fileShortcuts keydown: per key press (two compares before it knows a key isn't one of its own); fillLoadMenu: per File menu open; submenu handlers: per pointer event over an open menu
HP-2 to HP-5 scans fillLoadMenu: listSlots (remembered rows) plus 4 items, one find over at most 4 slots each; slotLabel: one localStorage.getItem per slot, and the parse is memoized on the raw text
HP-6 allocation a few small arrays per menu open; none per frame
HP-7 DOM writes 4 hidden/textContent writes per File open; none per frame
HP-8 caches listSlots' remembered rows are used; no cache dropped or bypassed
HP-9 measured n/a: command tier only, nothing per frame or step
HP-10 to HP-12 no engine, save format or binding change; slot names stay out of the save

Verdict: CONDITIONAL GO, on condition that F1 is fixed (the funnel's pick step excludes via: "shortcut", picks-by-item can tell keys apart, and row 26 is updated). I'll confirm on the new head. Merge waits on #2272, as the release thread set out.


Generated by Claude Code

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

📸 Screenshot drift check

No drift: the committed screenshots already match a fresh deterministic generation. ✅

@maniator maniator mentioned this pull request Nov 15, 2026
7 of 12 tasks

Copy link
Copy Markdown
Owner Author

Review fixes in 9d32772:

  • F1: the File keys no longer send menu_pick at all. A key that ran sends app_action file_key with detail open, save or save_as; a grayed key (Save on the title screen) sends nothing. MenuPickVia is back to pointer and keys, so the open-to-pick funnel, picks by item and what-follows-what count menu trips only, lastPick never sees a key, and measurement-status row 26 stays true as written. The data map documents file_key. menuWiring.test.ts asserts the file_key calls and that no menu_pick is sent.
  • N1: Open, Save and Save As now gray with Close once the engine has stopped (the test covers all four graying and coming back).
  • N2: the kept-unreadable note says "File > Open…".
  • Also from the owner: Close moves to the end of the File menu, below its own line.

The precache budget failure is waiting on the separate budget PR from the release thread (6 MiB per the party); this branch rebases once it lands. The pinned gallery redraw is running.


Generated by Claude Code

Copy link
Copy Markdown
Owner Author

Stand-in re-review: GO at 9d32772

  • F1 fixed. The File keys no longer send menu_pick; a key that ran sends app_action file_key with detail open, save or save_as, and a grayed key sends nothing. via: "shortcut" is gone from the type and the data map, so the menu funnel, picks-by-item, what-follows-what and measurement-status row 26 again count real menu trips only. The test asserts file_key rows and no pick.
  • N1 fixed. Close, Open…, Save and Save As… all gray on a stopped engine and come back with a live tower (the test covers both directions). Open… is ungrayed only when the engine isn't stopped, and the NEEDS_A_TOWER loop still grays Save and Save As on the title screen, so the order of the two rules holds.
  • N2 fixed. The note now says "File > Open…".
  • Close moved to the end of the File menu below its own separator, and the help page's File row matches.
  • Local: tsc --noEmit and ESLint on the touched files are clean; vitest over src/game, src/ui and src/analytics* passes, 2,056 tests.

The hot-path record from a0f5b60 carries: the change replaces one trackMenuPick call per key press with one trackAppAction, and adds a loop over 4 ids per File open. GO on 9d32772. Merge waits on #2272 and green CI (drift gate included) on the final head.


Generated by Claude Code

File > Import becomes Open… (Ctrl+O), Quick Save becomes Save (Ctrl+S),
Export becomes Save As… (Ctrl+Shift+S) and Saves… becomes Saved Towers….
Cmd works in place of Ctrl on a Mac. The keys leave a text box alone, do
nothing over a dialog or after the engine stopped, and on the title screen
only Open runs.

File > Load is a submenu listing the Auto-save and each saved slot by name,
filled each time the File menu opens. A mouse opens it by pointing, a tap
toggles it, and the arrow keys walk in and out. On a phone it opens in
place under its title.

Saved Towers… gains Rename… for each numbered slot. The name is a device
preference beside the saves, never in a tower file, and shows in File >
Load and the title screen's picker. The dialog's own Save As and Open
buttons are gone: the File menu has both.

Analytics: the Load items report menu_pick codes load_auto and
load_slot_1 to 3, a File key reports its item's menu_pick with via
"shortcut", and a slot rename reports app_action rename_slot (named or
cleared, never the name). Help pages, issue forms and the data map follow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ms7traNLWiXFbFoq6kWKFU
…opped engine

Close moves to the end of the File menu below its own line, as a program's
Exit does (owner). A File key that ran now reports app_action file_key
(open, save or save_as) instead of a menu_pick, so the menu funnels and
the picks-by-item and what-follows-what tiles count menu trips only
(review F1). Open, Save and Save As gray with Close once the engine has
stopped, matching the keys, which refuse them then. The kept-unreadable
note points at File > Open….

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ms7traNLWiXFbFoq6kWKFU
@maniator
maniator marked this pull request as ready for review November 15, 2026 05:35
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-15T05:35:48.866621Z
We couldn’t complete this review. Comment @codex review to try again.
9d32772 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

Saved Towers now shows Rename… on each slot and Close alone in its footer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ms7traNLWiXFbFoq6kWKFU
@maniator
maniator merged commit 67b06a1 into main Nov 15, 2026
44 checks passed
@maniator
maniator deleted the claude/project-thread-o02hzf branch November 15, 2026 05:50

This branch was successfully deployed

1 active deployment
Preview — 052cd083 Deployed Nov 15, 2026 by vercel[bot]
screenshot-approval — 6607c76d Deployed Nov 15, 2026 by maniator via commit-on-approval #5005
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.

2 participants