From c5b67ee7c14a89f1262d9d76fbd0ec14fcd099e0 Mon Sep 17 00:00:00 2001
From: "Fabian @ Blax Software"
Date: Thu, 22 Oct 2026 18:36:17 +0200
Subject: [PATCH] R saves like a game: one save per project on every device,
Load game in the menu, a pause menu, and a lean side panel
- Sync: when two devices changed the same project, the newer save wins
everywhere and the other becomes a savegame of it (new endpoint to keep
a savegame without replacing the save), never an "(other device)" copy.
A first visit keeps its starter unsaved until something changes, and
the main menu waits for the account's saves before anything starts.
- Main menu: Load game lists every save. In the editor, Esc with nothing
selected (or the project button) opens a pause menu: Resume, Save,
Save as copy, Load, Settings, How to play, Main menu. The projects
dialog is gone.
- Selection tab: name and transistors on top, one icon row (open,
duplicate, unlink, delete, more = the right-click menu), only the
settings that matter for the part; pins, component tools, keys, cable
and panel options fold away and remember it. X/Y fields removed.
The Circuit tab folds its component settings, transistor breakdown
and tools the same way.
Co-Authored-By: Claude Opus 5.5
---
README.md | 6 +-
app/assets/css/main.css | 274 +++++++++++
app/components/editor/App.vue | 2 +-
app/components/editor/Canvas.vue | 6 +-
app/components/editor/CircuitPane.vue | 147 +++---
app/components/editor/Fold.vue | 30 ++
app/components/editor/Help.vue | 1 +
app/components/editor/MainMenu.vue | 20 +-
app/components/editor/NodeSettings.vue | 487 +++++++++----------
app/components/editor/PauseMenu.vue | 88 ++++
app/components/editor/ProjectList.vue | 3 +-
app/components/editor/ProjectsDialog.vue | 16 -
app/components/editor/ShareDialog.vue | 2 +-
app/components/editor/Toolbar.vue | 5 +-
app/components/editor/VersionsDialog.vue | 2 +-
app/composables/useEditor.ts | 80 ++-
server/api/me/projects/[id]/versions.post.ts | 32 ++
17 files changed, 824 insertions(+), 377 deletions(-)
create mode 100644 app/components/editor/Fold.vue
create mode 100644 app/components/editor/PauseMenu.vue
delete mode 100644 app/components/editor/ProjectsDialog.vue
create mode 100644 server/api/me/projects/[id]/versions.post.ts
diff --git a/README.md b/README.md
index a7bc085..b4b8170 100644
--- a/README.md
+++ b/README.md
@@ -32,8 +32,8 @@ Nuxt 4 (client-only editor, `ssr: false`), Tailwind CSS v4, Lucide icons via `@n
- Connecting: drag from a pin, or click a pin and then the other one. While a wire is drawn, every pin it can go to is ringed (dashed when it already has a wire, which would be replaced); dropping it on a part uses that part's next free pin. "Connect one by one" (W, or the button with several parts selected; on a component "Wire one by one: Inputs / Outputs") numbers the pins of the selection top to bottom and wires them in turn, one click each; clicking the same component again and again fills its pins in order.
- Tidy wiring (Settings, or "Tidy all wires", which also drops hand-placed bends): every forward wire takes its vertical step in the free gap right in front of the part it feeds. All wires entering parts at the same column are ordered together (each goes where it adds the fewest crossings) and laid out as one compact staircase a grid step apart, slid sideways to where it runs along no other signal; one signal shares one trunk. Only the columns of that gap are looked at, so it stays cheap. On the 4-bit adder without hand routing this cuts crossings from 32 to 18.
- Wire editing: drag any segment (a stub keeps the pin end straight), drag corner squares, Alt+drag to pull out a new bend, Ctrl+drag to branch a new wire off a signal, double-click to select the whole signal, Shift+click and box selection for several wires, arrow keys to shift them, six colour tags.
-- Several projects per browser (Projects dialog: open, rename, duplicate, delete). Export a project file, open a file as a new project, or add the components of a file to the open project.
-- Accounts: email and password. Signed in, every project in the browser is also kept in the account and synced in both directions (on sign-in, on focus, every minute, and two seconds after a change). If two computers changed the same project, both versions are kept. The untouched starter project of a new browser is not uploaded; signing in there opens your latest project instead.
+- Saves are handled like a game: the main menu's "Load game" lists every save (open, rename, copy, delete, savegames, recently deleted, new, open a file), and in the editor Esc (with nothing selected) or the project button opens the pause menu: Resume, Save, Save as copy, Load, Settings, How to play, Main menu. Export a project file, open a file as a new project, or add the components of a file to the open project.
+- Accounts: email and password. Signed in, every project in the browser is also kept in the account and synced in both directions (on sign-in, on focus, every minute, and two seconds after a change). One save per project on every device: if two computers changed the same project, the newer save wins everywhere and the other one is kept as a savegame of that project (never as a second project). A new browser keeps its starter project unsaved until something changes in it, and while signed in the main menu waits for the account's saves before anything can be started, so a second device never makes a twin.
- Share links: `/p/`. The creator's changes save to the link automatically. Anyone else who opens it gets their own copy; their first edit detaches it from the link.
- Truth table, NAND count, gate delay, and loop detection for the open circuit. The table can go full screen, be downloaded as CSV or copied as a Markdown table; the row the switches are set to is highlighted.
- 17 challenges (NOT up to a D flip-flop) checked against a truth table or a step sequence.
@@ -69,7 +69,7 @@ The editor UI is in [app/components/editor/](app/components/editor/) with state
No database: everything is JSON files under `data/`, which keeps memory use flat. Three layers protect it:
- **Crash-safe writes** ([server/utils/safe-fs.ts](server/utils/safe-fs.ts), mounted in [server/plugins/storage.ts](server/plugins/storage.ts)). A save writes a temporary file, flushes it to disk, keeps the current intact version as `.bak` and then renames the new file into place. A power cut at any moment leaves the old or the new version; reading falls back to `.bak` when a file is missing or damaged, and leftover temporary files are removed at start.
-- **Savegames** ([server/utils/history.ts](server/utils/history.ts)). Before a save replaces an account project, its state is kept as a version (at most one per 15 minutes; always before a restore and on deletion). Kept: the newest 30 plus the last of each day for 90 days. Deleted projects stay restorable for 30 days. In the app: Projects dialog, clock icon (restore, or open as copy), and "Recently deleted".
+- **Savegames** ([server/utils/history.ts](server/utils/history.ts)). Before a save replaces an account project, its state is kept as a version (at most one per 15 minutes; always before a restore and on deletion). Kept: the newest 30 plus the last of each day for 90 days. Deleted projects stay restorable for 30 days. In the app: Load game (main or pause menu), clock icon (restore, or open as copy), and "Recently deleted".
- **Daily backup** ([server/utils/backup.ts](server/utils/backup.ts), [server/plugins/backup.ts](server/plugins/backup.ts)). Once a day the production server writes all of `data/` into `backups/logigate-YYYY-MM-DD.ndjson.gz`, leaving out damaged files. Kept: the newest 14 plus the first of each month for a year. `backups/` sits next to `data/` on the same disk, so it protects against damaged files and mistakes, not against losing the disk; copy it elsewhere for that.
Restore a backup on edgerealm (the current `data/` is moved aside first, so this can be undone):
diff --git a/app/assets/css/main.css b/app/assets/css/main.css
index 0d5020d..cc9e74c 100644
--- a/app/assets/css/main.css
+++ b/app/assets/css/main.css
@@ -3819,3 +3819,277 @@ table.board {
.menu-board .name-row .field {
margin-bottom: 0;
}
+
+.title-item:disabled {
+ opacity: 0.45;
+ cursor: progress;
+}
+
+.title-item:disabled:hover {
+ background: none;
+ border-color: transparent;
+}
+
+.project-list .badge.mode {
+ color: var(--muted);
+ border: 1px solid var(--border);
+ border-radius: 4px;
+ padding: 0 4px;
+}
+
+/* ── Pause menu ─────────────────────────────────────────────────── */
+.pause-backdrop {
+ position: fixed;
+ inset: 0;
+ z-index: 65;
+ display: grid;
+ place-items: center;
+ padding: 16px;
+ background: rgb(5 8 12 / 0.72);
+ backdrop-filter: blur(3px);
+ animation: pause-in 0.15s ease-out;
+}
+
+.pause {
+ width: min(360px, 100%);
+ max-height: calc(100dvh - 32px);
+ overflow-y: auto;
+ padding: 22px 20px 18px;
+ background: rgb(19 24 31 / 0.96);
+ border: 1px solid var(--border);
+ border-radius: 14px;
+ box-shadow: 0 30px 80px rgb(0 0 0 / 0.55);
+}
+
+.pause.wide {
+ width: min(720px, 100%);
+}
+
+.pause-kicker {
+ font-size: 11px;
+ font-weight: 700;
+ letter-spacing: 0.08em;
+ text-transform: uppercase;
+ color: var(--muted);
+}
+
+.pause h2 {
+ margin-top: 2px;
+ font-size: 20px;
+ font-weight: 700;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.pause-where {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ margin-top: 4px;
+ font-size: 12px;
+ color: var(--muted);
+}
+
+.pause-nav {
+ display: grid;
+ gap: 2px;
+ margin-top: 16px;
+}
+
+.pause-item {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ width: 100%;
+ padding: 9px 12px;
+ border: 1px solid transparent;
+ border-radius: 8px;
+ font-size: 15px;
+ font-weight: 600;
+ text-align: left;
+ color: var(--text);
+}
+
+.pause-item kbd {
+ margin-left: auto;
+}
+
+.pause-item:hover,
+.pause-item:focus-visible {
+ background: var(--panel-2);
+ border-color: var(--border);
+ outline: none;
+}
+
+.pause-item:focus-visible {
+ border-color: var(--accent);
+}
+
+.pause-item.primary {
+ color: var(--on);
+}
+
+.pause-item:disabled {
+ opacity: 0.5;
+}
+
+.pause-head {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ margin-bottom: 6px;
+}
+
+@keyframes pause-in {
+ from {
+ opacity: 0;
+ }
+}
+
+/* ── Selection tab: header, compact rows, folds ─────────────────── */
+.sel-head {
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
+ margin: -2px 0 12px;
+}
+
+.sel-title {
+ display: flex;
+ align-items: baseline;
+ gap: 8px;
+ min-width: 0;
+}
+
+.inspector .sel-title h3 {
+ margin: 0;
+ font-size: 15px;
+ font-weight: 700;
+ letter-spacing: 0;
+ text-transform: none;
+ color: var(--text);
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.sel-t {
+ margin-left: auto;
+ flex-shrink: 0;
+ font-family: var(--font-mono);
+ font-size: 11px;
+ color: var(--muted);
+}
+
+.sel-actions {
+ display: flex;
+ gap: 2px;
+ padding: 3px;
+ border: 1px solid var(--border);
+ border-radius: 8px;
+ background: var(--panel-2);
+}
+
+.sel-actions .icon-btn {
+ flex: 1;
+ width: auto;
+}
+
+.sel-actions .icon-btn:disabled {
+ opacity: 0.35;
+}
+
+.icon-btn.danger:hover {
+ color: var(--danger);
+}
+
+.sel-row {
+ display: flex;
+ gap: 8px;
+ margin-bottom: 8px;
+}
+
+.sel-row > .field {
+ margin-bottom: 0;
+}
+
+.sel-row .grow {
+ flex: 1;
+ min-width: 0;
+}
+
+.sel-row .narrow {
+ flex: 0 0 72px;
+}
+
+.field input.auto-name {
+ color: var(--muted);
+ font-style: italic;
+}
+
+.field-input {
+ width: 100%;
+ background: var(--panel-2);
+ border: 1px solid var(--border);
+ border-radius: 6px;
+ padding: 6px 8px;
+ font-size: 13px;
+ color: var(--text);
+ outline: none;
+}
+
+.field-input:focus {
+ border-color: var(--accent);
+}
+
+.fold {
+ margin: 0 -14px;
+ border-top: 1px solid var(--border);
+}
+
+.fold:last-of-type {
+ margin-bottom: -14px;
+}
+
+.fold-head {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ width: 100%;
+ padding: 9px 14px;
+ font-size: 11px;
+ font-weight: 700;
+ letter-spacing: 0.06em;
+ text-transform: uppercase;
+ color: var(--muted);
+ text-align: left;
+}
+
+.fold-head:hover {
+ color: var(--text);
+ background: rgb(255 255 255 / 0.02);
+}
+
+.fold-chev {
+ transition: transform 0.15s;
+}
+
+.fold.open .fold-chev {
+ transform: rotate(90deg);
+}
+
+.fold-note {
+ max-width: 55%;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ font-family: var(--font-mono);
+ font-weight: 500;
+ letter-spacing: 0;
+ text-transform: none;
+}
+
+.fold-body {
+ padding: 2px 14px 14px;
+}
diff --git a/app/components/editor/App.vue b/app/components/editor/App.vue
index 619b44b..1e96437 100644
--- a/app/components/editor/App.vue
+++ b/app/components/editor/App.vue
@@ -71,7 +71,7 @@ watch(
-
+
diff --git a/app/components/editor/Canvas.vue b/app/components/editor/Canvas.vue
index b07b4dc..a5184bd 100644
--- a/app/components/editor/Canvas.vue
+++ b/app/components/editor/Canvas.vue
@@ -912,7 +912,7 @@ function nudge(dx: number, dy: number) {
function onKey(e: KeyboardEvent) {
const el = e.target as HTMLElement
- if (el.closest('input, textarea, select, [contenteditable]')) return
+ if (el.closest?.('input, textarea, select, [contenteditable]')) return
if (ed.dialog.value || ed.showHelp.value) {
if (e.key === 'Escape') {
ed.dialog.value = null
@@ -920,6 +920,8 @@ function onKey(e: KeyboardEvent) {
}
return
}
+ // Paused: the pause menu has the keys.
+ if (ed.paused.value) return
const mod = e.ctrlKey || e.metaKey
const key = e.key.toLowerCase()
if (e.key === 'ContextMenu' || (e.shiftKey && e.key === 'F10')) {
@@ -987,6 +989,8 @@ function onKey(e: KeyboardEvent) {
return
}
if (ed.linking.value) return ed.stopLinking()
+ // Nothing to cancel: Esc pauses, like in a game.
+ if (!ed.placing.value && !ed.selection.value.length && !ed.wireSel.value.length) return ed.pause()
ed.placing.value = null
ed.clearSelection()
} else if (ARROWS[e.key]) {
diff --git a/app/components/editor/CircuitPane.vue b/app/components/editor/CircuitPane.vue
index f415d05..fb30e13 100644
--- a/app/components/editor/CircuitPane.vue
+++ b/app/components/editor/CircuitPane.vue
@@ -38,7 +38,6 @@ const groupNames = computed(() => [...new Set(ed.project.value.components.map(d
const hasFace = computed(() => def.value.nodes.some(n => n.kind === 'lamp' || n.kind === 'hex' || n.kind === 'pixel'))
const total = computed(() => ed.transistors(def.value.id))
const breakdown = computed(() => transistorBreakdown(def.value, ed.nands.value, ed.getDef.value))
-const showBreakdown = ref(true)
function toggleFace(e: Event) {
def.value.face = (e.target as HTMLInputElement).checked
@@ -96,34 +95,10 @@ watch(() => def.value.id, () => (confirmDelete.value = false))
-
- Everything here is built from NAND gates, and a CMOS NAND gate has 4 transistors: 2 in parallel to the supply, 2 in series to
- ground. So the count is 4 per NAND inside, at every depth: a NOT costs 4, an AND 8, a full adder 60. (A NOT made directly in
- CMOS would need only 2; here it is built from a NAND.)
-