Every editor operates on exactly one persisted project ID. Opening /#/editor without a project ID creates a project with a readable, topic-neutral English verb + noun ID (for example, create-ideas), using the same string as its initial name. On successful creation the router replaces the current history entry with /#/editor?id=create-ideas. The manager's New Project action uses the same creation helper and opens the same URL. Collisions are checked in the create transaction; retry with a short random suffix rather than overwrite an existing record.
Opening an ID loads that record. Refreshing the editor keeps the ID. Renaming changes only the display name, never the ID. The editor header contains a name input on the left and a compact action toolbar on the right. Changes to name, blocks, source and libraries are saved automatically; Save explicitly flushes the same serialized persistence path and reports the result in a three-second toast after the transaction commits. Autosave success is silent; storage errors remain visible until dismissed or recovered. Import feedback uses the same project toast, independent of device progress. Save, Import and Export use the same compact SVG icon-button dimensions as the device toolbar, with localized tooltips and accessible names. Save, Import and Export are grouped on the right. Project cards open via their preview or name, with Rename, Duplicate, Export and Delete in a native auto popover using the shared Dropdown and Menu styles. Import remains a page-level action in My Projects. New projects start empty. After explicit confirmation, editor Import replaces the current program content without changing its ID or name; Export downloads portable format-version-1 JSON using the project name with the .pyblocks.json suffix. Both pages use the same filename helper. Older JSON backups remain readable by content; their original suffix is stripped when suggesting a project name. The manager supports list, search, new, rename, duplicate, delete, import and export. Manager imports create a new record.
There is no separate draft mode, session adapter, or legacy localStorage migration. Older localStorage data is neither read nor modified. Existing IndexedDB records retain their IDs; the ID is opaque after creation. A missing or deleted ID is an error, not an implicit create. On creation failure the editor cannot redirect and displays a storage error. On load failure the editor shows an empty workspace and an error; it may export but cannot overwrite the missing/invalid record.
/#/editor -> src/editor/page.js -> src/editor/app.js --+
/#/projects -> src/projects.js ------------------------+
|
src/project/repository.js
|
src/storage/indexeddb.js
|
IndexedDB
No page imports another page's UI. src/project/identity.js provides shared ID generation, creation and URL helpers. src/project/storage.js validates portable project content. src/storage/indexeddb.js remains a generic database wrapper: it opens a database, performs upgrades and exposes transaction-scoped get/getAll/add/put/delete; a transaction resolves only after commit. Callbacks must await only transaction requests.
const record = await projects.save({
id: 'create-ideas',
name: 'create-ideas',
revision: null
});
const loaded = await projects.load(record.id);
// The editor saves content and its editable name.
await projects.save({
id: loaded.id,
name: 'My robot',
project: nextProject,
revision: loaded.revision
});
// The manager can save metadata only, preserving content.
const current = await projects.load(record.id);
await projects.save({ id: current.id, name: 'Robot', revision: current.revision });save is the single create/update operation: null revision creates a new record, a numeric revision updates that existing version. Omitted name or content is preserved on update. New metadata-only records receive empty portable content. load(id) returns a complete record or undefined. list() returns metadata ordered by recent modification; remove(id) deletes a record. The database remains pyblocks, version 1, store projects, with key path id. Records have id, name, createdAt, updatedAt, revision and project. No storage migration is needed.
Version checks cover both metadata and content in a single readwrite transaction. Stale saves fail rather than overwrite other tabs or resurrect deleted records. The editor serializes debounced saves and shows storage errors; export before reloading after conflicts. Explicit editor links await pending writes. Leaving the editor route flushes pending writes, and visibility changes and pagehide trigger best-effort saving. Browser termination can interrupt writes. The manager refreshes on focus; there is no live multi-tab synchronization or cloud service.
Test readable identities, collisions, metadata-only saves, unchanged IDs, portable content preservation, stale/deleted saves, transaction completion, URL routing and import/export controls. The production Chrome smoke test exercises IndexedDB project operations, direct entry and client-side navigation under a deployment subpath.
See reuse design and project Python dependencies. Extend the existing project library path with curated and URL imports, retaining local file upload; keep cross-project block snippet collection separate from project deployment. No library editor or IndexedDB migration is required. Extend the existing library name field to support validated relative paths; older flat-only readers cannot load nested library entries. See the dependency design for collision and deployment rules.
The shared Backpack uses its own IndexedDB database (pyblocks-backpack); its native contents are never included in a project record or portable export. Concurrent editors do not live-sync. See reuse design.