Tabs are open documents: Scene, Game and Plugins stay as fixed tabs, every other asset opens in its own tab (double click or Enter in the asset panel, on creation, from the list button), several assets of one kind can be open at once, a tab is labelled with its kind dimmed before the name, cut at 160 px and renamed with its asset, closes with its x or a middle click and goes away when its asset is deleted; a tab always shows its own document instead of following the selection, the picker in the tab head is gone, zoom and scroll are kept per document for the session and dropped on close, a double click on a call node stays in the same tab with breadcrumbs per tab; one editor per kind is switched between documents, the placement rules live in the pure module documents.ts, and the test hook showTab stays as a compatibility path; new e2e module 44 documents (#171)
game-maker / gate (push) Successful in 1m59s
game-maker / suite (push) Successful in 6m53s

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 5 committed 2026-09-19 15:49:54 +02:00
1 parent 4f546c0e08
commit cc285af10a
33 files changed
+895 -225

No files matched your search

+39
View File
@@ -0,0 +1,39 @@
/**
* The open documents of the tab row (#171): which tabs there are, in which order, and which one is
* showing. `null` as the active one means a fixed tab (Scene, Game, Plugins, a plugin's) is showing.
*/
export interface DocumentRow<T> {
docs: readonly T[];
active: T | null;
}
/** Opens `doc`: an open one merely becomes active, a new one goes right of the active document, or last. */
export function openDocument<T>(row: DocumentRow<T>, doc: T): DocumentRow<T> {
if (row.docs.includes(doc)) return { docs: row.docs, active: doc };
const at = row.active === null ? -1 : row.docs.indexOf(row.active);
const docs = [...row.docs];
docs.splice(at < 0 ? docs.length : at + 1, 0, doc);
return { docs, active: doc };
}
/**
* Closes `doc`. Closing the one on screen shows its left neighbour, or the right one when it was
* first; with none left, `active` is null and the caller goes back to the scene.
*/
export function closeDocument<T>(row: DocumentRow<T>, doc: T): DocumentRow<T> {
const at = row.docs.indexOf(doc);
if (at < 0) return row;
const docs = row.docs.filter((d) => d !== doc);
if (row.active !== doc) return { docs, active: row.active };
return { docs, active: docs[Math.max(0, at - 1)] ?? null };
}
/**
* Puts `to` where `from` is – a tab that goes on to another document, like a behavior followed
* into a call. Where `to` was open already, that tab goes: a document has one tab.
*/
export function replaceDocument<T>(row: DocumentRow<T>, from: T, to: T): DocumentRow<T> {
if (from === to || !row.docs.includes(from)) return row;
const docs = row.docs.filter((d) => d !== to).map((d) => (d === from ? to : d));
return { docs, active: row.active === from || row.active === to ? to : row.active };
}