Skip to content

Keep several versions of a story in the library, and send the current one to the device - #60

Open
lgnap wants to merge 1 commit into
antoinevalentinHA:masterfrom
lgnap:feat/issue-16-story-versions
Open

lgnap wants to merge 1 commit into
antoinevalentinHA:masterfrom
lgnap:feat/issue-16-story-versions

Conversation

@lgnap

@lgnap lgnap commented Sep 11, 2026

Copy link
Copy Markdown

What

The library already keeps every archive of a UUID — the editor names them <title>-<uuid>-v<version>.zip — so a story can exist as v1 and v2 side by side. But a UUID's group was ordered by file modification time: a v1 copied in after the v2 was saved became "latest", lent its title and thumbnail to the tile, and was what a drop on the device sent. The device has one slot per UUID and no notion of version (see FORMATS.md §9, #59), so that silently replaced the newer story. The card that motivated this held the same story under three UUIDs for exactly that reason.

The story pack version is the one piece of identity the formats carry for this, so it now decides:

  • LibraryService.packs() orders a group highest version first; modification time only breaks ties within a version. The unofficial metadata (title, thumbnail) is refreshed from that first entry.
  • chooseDropAction only considers artefacts of the current (highest) version. An older version's conversion, however recent and device-readable, is neither reused nor offered as the source of a re-conversion. Artefacts without a version are grouped as before, so every existing C7 case holds unchanged.
  • isDowngrade + a confirmation dialog: sending a lower version than the one the device holds asks first (en/fr). Every path to the device funnels through doAddToDevice, so the guard covers transfer, convert and re-convert alike. A missing version on either side does not fire it — a guard that fires on missing data would block every legacy pack.
  • The library tile shows the current version (vN badge, same style as device tiles).

Not done, on purpose: no editor change — the version field exists and already names the file, and re-exporting keeps the UUID. Explicitly choosing an older version to send is not offered yet; the per-file rows still list every version.

Tests

  • LibraryVersionOrderingTest (3): highest version first even when the older file is newer; timestamp breaks ties within a version; the tile's title comes from the highest version. Red before the change ([1, 2] where [2, 1] was expected).
  • packs.test.js (+13): currentVersion, the four cross-version drop cases (V1–V4, V4 pinning that version-less packs behave as before), isDowngrade including the missing-version cases.

Locally: mvn … test → 330 run, 0 failures (39 FAT32 opt-in skips); yarn test → 67 passed; yarn build compiles. git diff --exit-code clean.

Tracked in lgnap#16.

🤖 Generated with Claude Code

…urrent one to the device

The library already keeps every archive of a UUID (the editor names them
<title>-<uuid>-v<version>.zip), so a story could exist as v1 and v2 side
by side. But the group was ordered by file modification time: a v1
copied in after the v2 was saved became "latest", lent its title and
thumbnail to the tile, and was what a drop on the device sent. The
device has one slot per UUID and no notion of version (FORMATS.md §9),
so that silently replaced the newer story.

The story pack version is the one piece of identity the formats carry
for this, so it now decides:

- LibraryService orders a group highest version first, modification
  time only breaking ties within a version; the unofficial metadata is
  refreshed from that first entry.
- chooseDropAction only considers artefacts of the current (highest)
  version: an older version's conversion, however recent and
  device-readable, is neither reused nor offered as a source. Artefacts
  without a version are grouped as before, so every existing case holds.
- isDowngrade + a confirmation dialog: sending a lower version than the
  one the device holds asks first. Every path to the device funnels
  through doAddToDevice, so the guard covers transfer, convert and
  re-convert alike. Missing versions on either side do not fire it.
- The library tile shows the current version.

No editor change: the version field exists and already names the file;
re-exporting keeps the UUID. Choosing an older version explicitly is
not offered yet.

Tests: LibraryVersionOrderingTest (3), packs.test.js (+13).

Closes #16

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

1 participant