Skip to content

A file with a repeated or missing group frame id opens the same way every time - #654

Merged
MerciHanrim merged 1 commit into
mainfrom
frame-id-derived-on-read
Nov 23, 2026
Merged

MerciHanrim merged 1 commit into
mainfrom
frame-id-derived-on-read

Conversation

@MerciHanrim

Copy link
Copy Markdown
Owner

Part of #619 (item 4 only; items 1 and 5 stay for their own scopes).

What was wrong

A file whose saved frames repeat an id, or miss one (hand-edited or damaged; Loop Studio never writes one), was read by readSavedFrames, which gave that frame frame_<time>_<counter>, new on every read. Measured on main dca35c0b before this change:

  • two reads, or two opens, of one file gave the frame two different ids and two different projection digests;
  • the projection of the file content itself (canonicalContent on the raw file) differed on every call;
  • a revision file whose header has no contentDigest (which the project reader accepts) is read once to verify and once to load, so it opened already changed;
  • the engine's first step was the same both times: the engine does not read frames.

No bundled example or Template has such a file: the 11 bundled JSON files with saved frames all have unique ids.

The change (src/model/serialize.ts, readSavedFrames)

  • Before deriving anything, every id string the file's frames carry is reserved.
  • The first frame with an id keeps it.
  • A repeat of x becomes x_2, x_3, …
  • A missing (or empty, or non-string) id becomes frame_<p>, p the entry's 1-based position in the file's frames array, then frame_<p>_2, …
  • The derived id is the first of these that no frame of the file carries, a later one included, and that this read has not used.
  • Order, labels, rects and colours are read as before.

A file with unique ids reads as before, and so does every file Loop Studio has written, since those hold unique ids.

Specs

The two specs disagreed. docs/large-graph-readability-saved-frames.md asked that a file with clashing ids "still loads deterministically". docs/specs/SEMANTICS-R5.md §R5-1.1 said "a fresh session id is assigned on read". Both now state the derived rule:

  • SEMANTICS-R5.md: the §R5-1.1 row and R5-D5.
  • large-graph-readability-saved-frames.md: the read rule and the SF9 test list.

Tests, written first

On main's code, 7 of the new tests fail; with the change all pass.

src/model/serialize.test.ts:

  • A repeated id read twice: main gives time-based ids that differ per read; the change gives frame_dup, frame_dup_2, frame_dup_3 on both reads.
  • A missing id read twice: main gives a time-based id per read; the change gives frame_one, frame_2 on both reads.
  • A collision, a, a, (missing), a_2, frame_3: main gives time-based ids; the change gives a, a_3, frame_3_2, a_2, frame_3, the same on both reads.
  • The projection digest of the raw file, computed twice: differs on main, the same with the change.
  • Control, unique ids: read as they are, before and after.

src/store/frameIdOnRead.test.ts:

  • Open one file twice through the app's open path (importFile), with a repeated and with a missing id: main gives different ids per open; the change gives the same ids. The first step is a 3, b 1 both times, before and after.
  • A revision without contentDigest, via routeImport then refreshDirty: changed on main, unchanged with the change.
  • Control, the same revision with unique ids: unchanged, before and after.
  • The proposal path (proposedGraph), read twice: different frame ids on main, the same with the change. This is the only proposal check: the proposal path itself is not changed, as agreed.

Checks

  • npx tsc -b: clean.
  • npm run lint: 88 warnings, the baseline.
  • All check:* scripts: pass.
  • Unit suite: 5744 passed, 4 skipped.
  • Related e2e, one worker, no retries: e2e/frame-list.spec.ts, e2e/revision.spec.ts and e2e/revision-fixture.spec.ts, 33 passed. They hold no screenshot comparisons.

What it touches

  • Only a file with a repeated or missing frame id, and every read of it: open, the revision and proposal readers, a Template's frames, and the projection.
  • Run results are unchanged: the engine and a Workspace's result check do not read frames.
  • A file that was already opened and saved holds the time-based id that open gave it. That id is unique, so the file reads as it is.

…very time

readSavedFrames replaces a repeated id x with x_2, x_3, and a missing id with frame_<position>, skipping every id the file's frames carry, a later one included. It was frame_<time>_<counter>, new on every read, so two opens of one file disagreed and a revision without a content digest opened already changed. Part of #619.
@MerciHanrim MerciHanrim added the bug Something isn't working label Nov 23, 2026
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying cozy-loop-studio with  Cloudflare Pages  Cloudflare Pages

Latest commit: a9e9195
Status: ✅  Deploy successful!
Preview URL: https://c06d6bde.cozy-loop-studio.pages.dev
Branch Preview URL: https://frame-id-derived-on-read.cozy-loop-studio.pages.dev

View logs

@MerciHanrim
MerciHanrim merged commit 05257b3 into main Nov 23, 2026
13 checks passed
@MerciHanrim
MerciHanrim deleted the frame-id-derived-on-read branch November 23, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant