From 932923695572965aca3d8f60b78138f7781c51cb Mon Sep 17 00:00:00 2001 From: Benjamin Hardy Date: Mon, 19 Oct 2026 10:48:59 +0200 Subject: [PATCH] Implemented export track grid locking --- CLAUDE.md | 28 +++++++++-- .../konduktor/adapters/rekordbox/export.py | 6 ++- .../adapters/rekordbox/new_content.py | 6 +++ backend/konduktor/adapters/rekordbox/store.py | 2 +- backend/konduktor/adapters/traktor/adapter.py | 4 ++ backend/konduktor/adapters/traktor/export.py | 2 + backend/konduktor/adapters/traktor/store.py | 11 +++++ backend/konduktor/core/model.py | 3 ++ backend/konduktor/exporter.py | 22 ++++++++- backend/konduktor/exports.py | 10 +++- backend/konduktor/main.py | 13 ++++- backend/konduktor/schemas.py | 8 ++++ backend/test_export.py | 48 +++++++++++++++++-- backend/test_export_pioneer.py | 10 ++++ frontend/src/api.ts | 15 ++++-- frontend/src/components/ExportRunDialog.tsx | 27 ++++++++++- 16 files changed, 196 insertions(+), 19 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 7611846..a048cb3 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1536,8 +1536,13 @@ serialization path.** It enforces: above all that **`` is volume-relative** — an export writing host paths would work perfectly on the machine that made it and resolve to nothing at the gig. Also that a flexible multi-marker grid and hot-cue PADS survive, - grids are not locked, loose tracks get their "Other" playlist, and re-exporting - into the same folder replaces rather than appends. + each grid keeps its source's lock, loose tracks get their "Other" playlist, and + re-exporting into the same folder replaces rather than appends. **Lock + beatgrids** (the run's option): a new set locks by default and remembers being + told not to; on, every exported track WITH a grid is locked (never one without + — Traktor would never give it a grid), written as Traktor 4.5 writes it + (`LOCK="1"` then `LOCK_MODIFICATION_TIME`, ISO, UTC); `test_export_pioneer.py` + pins the Rekordbox Library's `Analysed` 233 vs 105. It then runs a real export end to end (the source library is built with the exporter itself, so its LOCATIONs point at audio that exists) and pins the safety rules with teeth: a folder Konduktor did NOT write is refused, and @@ -1948,8 +1953,23 @@ that number and nothing else — everything derives from it: target** for v1, source is whatever library is loaded, **mirror the source folder structure** (so filename collisions cannot happen), playlists are **live links removable only as a whole**, re-export **clears the destination first**, - cancel **rolls back**, key notation **mirrors the source**, grids are **not - locked**, no whole-library export. + cancel **rolls back**, key notation **mirrors the source**, no whole-library + export. Grids were first left **unlocked**, and that went wrong: an exported + Traktor entry has no `AUDIO_ID` (Traktor's analysis fingerprint, which cannot + be computed), so Traktor re-analyses it on its first load — re-measuring the + BPM (a 174 track came back as 87) and drifting the grid. So the run dialog has + **Lock beatgrids** (decided 2026-10-19; `ExportSet.lock_grids`, default on, + sent with the run and remembered on the set; shown where a target's + `PlatformOption.locks_grids`). It rides on the generic `TrackCues.grid_locked` + (`exporter._locked`), the flag a source's own lock already arrives in, so off + still carries each track's own lock; Traktor writes `LOCK` + + `LOCK_MODIFICATION_TIME` (UTC), the Rekordbox Library sets bit 0x80 of + `djmdContent.Analysed` (105 -> 233, measured by locking tracks in rekordbox + 7). The stick formats carry NO lock: rekordbox 7's own device export of two + locked tracks left OneLibrary `analysedBits` and the pdb's `u5` at 41, as on + every unlocked track (measured on Hardy, 2026-10-19), so neither stick + exporter sets `locks_grids`. The Rekordbox ADAPTER does not yet + read or write that bit (`grid.lockable` stays false). Verified against the real collection: Traktor stores `VOLUME="Hardy"` plus a **volume-relative** `DIR`, never a host path — so a USB export is portable by construction, and the `.nml` cannot be written until the destination is known. diff --git a/backend/konduktor/adapters/rekordbox/export.py b/backend/konduktor/adapters/rekordbox/export.py index c5f93a1..1e9e5c7 100644 --- a/backend/konduktor/adapters/rekordbox/export.py +++ b/backend/konduktor/adapters/rekordbox/export.py @@ -109,6 +109,8 @@ class RekordboxExporter: computer_only = True library_filename = "master.db" drive_root = False + #: `djmdContent.Analysed` bit 0x80 — from `TrackCues.grid_locked`. + locks_grids = True def capabilities(self): """What a Rekordbox library can hold, with no library to read. @@ -332,7 +334,9 @@ class RekordboxExporter: """ rel = new_content.anlz_rel(str(content.UUID)) content.AnalysisDataPath = rel - content.Analysed = 105 # what a rekordbox-analysed track carries + content.Analysed = new_content.ANALYSED + if item.cues is not None and item.cues.grid_locked: + content.Analysed |= new_content.ANALYSED_LOCKED content.AnalysisUpdated = 1 db.flush() diff --git a/backend/konduktor/adapters/rekordbox/new_content.py b/backend/konduktor/adapters/rekordbox/new_content.py index f8e39c5..bff1d6f 100644 --- a/backend/konduktor/adapters/rekordbox/new_content.py +++ b/backend/konduktor/adapters/rekordbox/new_content.py @@ -34,6 +34,12 @@ from . import artwork #: only what is written: 0x2C060E. CONTENT_LINK = 2885134 +#: `djmdContent.Analysed` as a rekordbox-analysed track carries it, and the bit +#: rekordbox 7 sets beside it when the grid is LOCKED (the padlock in Grid Edit): +#: measured 2026-10-19 by locking two tracks — 105 -> 233, nothing else changed. +ANALYSED = 105 +ANALYSED_LOCKED = 0x80 + def anlz_rel(track_uuid: str) -> str: """`djmdContent.AnalysisDataPath` for a track. Rekordbox derives it from diff --git a/backend/konduktor/adapters/rekordbox/store.py b/backend/konduktor/adapters/rekordbox/store.py index b39b6ac..d648a3a 100644 --- a/backend/konduktor/adapters/rekordbox/store.py +++ b/backend/konduktor/adapters/rekordbox/store.py @@ -788,7 +788,7 @@ class RekordboxStore(ReplaceGridCommands): track_uuid = str(content.UUID) rel = new_content.anlz_rel(track_uuid) content.AnalysisDataPath = rel - content.Analysed = 105 # what a rekordbox-analysed track carries + content.Analysed = new_content.ANALYSED content.AnalysisUpdated = 1 files = new_content.anlz_files(audio, measured, [] if with_grid else None) for suffix, data in files.items(): diff --git a/backend/konduktor/adapters/traktor/adapter.py b/backend/konduktor/adapters/traktor/adapter.py index 8476db9..0db9fad 100644 --- a/backend/konduktor/adapters/traktor/adapter.py +++ b/backend/konduktor/adapters/traktor/adapter.py @@ -242,6 +242,10 @@ class TraktorAdapter: # invent one outside Auto Grid), and it occupies pad A — which # silently displaced the imported track's own pad A cue. self.replace_grid(track_id, markers) + if cues.grid_locked: + # The source's lock, or an export's "Lock beatgrids". Unlocked, an + # added entry (no AUDIO_ID) is re-analysed on its first load. + self._store.set_lock(track_id, True) slots = self.capabilities().cues.hotcue_slots taken = {c.slot for c in self.track_cues(track_id).cues if c.slot is not None} diff --git a/backend/konduktor/adapters/traktor/export.py b/backend/konduktor/adapters/traktor/export.py index 66b2739..dca95e2 100644 --- a/backend/konduktor/adapters/traktor/export.py +++ b/backend/konduktor/adapters/traktor/export.py @@ -66,6 +66,8 @@ class TraktorExporter: menu_order = 20 library_filename = "collection.nml" drive_root = False + #: `LOCK` — honoured from `TrackCues.grid_locked` by `add_tracks`. + locks_grids = True def capabilities(self): """What a Traktor library can hold — answered with no library to read. diff --git a/backend/konduktor/adapters/traktor/store.py b/backend/konduktor/adapters/traktor/store.py index dbab1f6..e9dbbeb 100644 --- a/backend/konduktor/adapters/traktor/store.py +++ b/backend/konduktor/adapters/traktor/store.py @@ -22,6 +22,7 @@ import copy import math import threading import uuid as uuidlib +from datetime import datetime, timezone from pathlib import Path from traktor_nml_utils import ( @@ -1210,9 +1211,19 @@ class TraktorStore: self.dirty = True def set_lock(self, track_id: str, locked: bool) -> None: + """Lock or unlock a track's grid. + + Locking writes what Traktor 4.5 writes (measured 2026-10-19): + ``LOCK="1"`` plus ``LOCK_MODIFICATION_TIME``, an ISO time in UTC to the + second. What Traktor leaves on UNLOCK is unmeasured, so unlocking only + removes ``LOCK``, as it always has. + """ with self._lock: entry = self._entry_or_raise(track_id) entry.lock = 1 if locked else None + if locked: + entry.lock_modification_time = ( + datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%S")) self._note("lock", "on" if locked else "off", track_id) self.dirty = True diff --git a/backend/konduktor/core/model.py b/backend/konduktor/core/model.py index 7bfe2c9..ae261cf 100644 --- a/backend/konduktor/core/model.py +++ b/backend/konduktor/core/model.py @@ -234,6 +234,9 @@ class PlatformOption(BaseModel): #: As an export TARGET: its library is only ever read on a computer, never #: from a drive — so it does nothing beside a stick format. computer_only: bool = False + #: As an export TARGET: its library can store a grid lock, so the export's + #: "Lock beatgrids" option means something there. + locks_grids: bool = False class RemapSample(BaseModel): diff --git a/backend/konduktor/exporter.py b/backend/konduktor/exporter.py index 9cebdec..e13d4c3 100644 --- a/backend/konduktor/exporter.py +++ b/backend/konduktor/exporter.py @@ -433,12 +433,30 @@ def _folder_paths(adapter) -> dict[str, list[str]]: # ---- running ----------------------------------------------------------------- +def _locked(cues, lock_grids: bool): + """The cues as exported: with `lock_grids`, a grid is LOCKED. + + The lock rides on the generic `TrackCues.grid_locked`, the same flag a + source's own lock arrives in, so a writer reads one signal and never learns + which of the two set it. Unlocked Traktor re-analyses an exported track on + its first load (it has no AUDIO_ID, which cannot be computed), re-measuring + the BPM — a 174 track can come back as 87 — and drifting the grid; a + locked grid is left alone. A track with no grid is never locked: that + would stop Traktor ever giving it one. + """ + if lock_grids and cues is not None and cues.grid_markers and not cues.grid_locked: + return cues.model_copy(update={"grid_locked": True}) + return cues + + def run(adapter, export_set, built: ExportPlan, handle: JobHandle, *, - root_folder: bool = False) -> dict: + root_folder: bool = False, lock_grids: bool = False) -> dict: """Copy what changed, then write every target's library over the audio. `root_folder` nests the playlists in a folder named after the export (the "Put exported playlists in a folder" setting); otherwise they sit at the top. + `lock_grids` locks every exported track that HAS a grid (`_locked`); off, + each track keeps the source's own lock. Rolls back EVERYTHING this run wrote on cancel or on any failure — including the libraries of targets that had already been written when a @@ -530,7 +548,7 @@ def run(adapter, export_set, built: ExportPlan, handle: JobHandle, *, ExportTrack( track=adapter.track(planned.track_id), destination=target, - cues=adapter.track_cues(planned.track_id), + cues=_locked(adapter.track_cues(planned.track_id), lock_grids), art=_cover(adapter, planned.track_id), fingerprint=_fingerprint(planned), analysis_cache=cache, diff --git a/backend/konduktor/exports.py b/backend/konduktor/exports.py index 2ae40fb..b627a41 100644 --- a/backend/konduktor/exports.py +++ b/backend/konduktor/exports.py @@ -62,6 +62,10 @@ class ExportSet: destination: str = "" # OS path of the folder the export is written into playlist_ids: list[str] = field(default_factory=list) track_ids: list[str] = field(default_factory=list) # loose tracks only + #: Lock every exported grid, so Traktor does not re-analyse a track on its + #: first load (it re-measures the BPM — 174 can come back as 87 — and the + #: grid drifts). Remembered per set: it is a decision about this stick. + lock_grids: bool = True created: float = 0.0 modified: float = 0.0 @@ -170,6 +174,7 @@ def _load(library_id: str) -> dict[str, ExportSet]: destination=values.get("destination") or "", playlist_ids=list(values.get("playlist_ids") or []), track_ids=list(values.get("track_ids") or []), + lock_grids=bool(values.get("lock_grids", True)), created=float(values.get("created") or 0.0), modified=float(values.get("modified") or 0.0), ) @@ -251,7 +256,8 @@ def create(library_id: str, *, name: str, targets: list[str], destination: str) def update(library_id: str, set_id: str, **fields) -> ExportSet | None: - """Rename, retarget or relocate a set. Unknown fields are ignored.""" + """Rename, retarget or relocate a set, or change its options. Unknown fields + are ignored.""" sets = _load(library_id) found = sets.get(set_id) if found is None: @@ -261,6 +267,8 @@ def update(library_id: str, set_id: str, **fields) -> ExportSet | None: setattr(found, key, fields[key]) if fields.get("targets"): found.targets = list(dict.fromkeys(fields["targets"])) + if fields.get("lock_grids") is not None: + found.lock_grids = bool(fields["lock_grids"]) found.modified = time.time() _save(library_id, sets) return found diff --git a/backend/konduktor/main.py b/backend/konduktor/main.py index d48cfe0..7de093c 100644 --- a/backend/konduktor/main.py +++ b/backend/konduktor/main.py @@ -78,6 +78,7 @@ from .schemas import ( FsListing, FsPlace, UpdateExportSet, + RunExport, AddGridMarker, GridMarkerEdit, ReplaceGrid, @@ -655,6 +656,7 @@ def update_export(set_id: str, body: UpdateExportSet) -> ExportSetOut: name=body.name, targets=body.targets, destination=body.destination, + lock_grids=body.lock_grids, ) return ExportSetOut(**updated.as_dict()) @@ -764,14 +766,19 @@ def preview_export(set_id: str) -> ExportPreview: @app.post("/api/exports/{set_id}/run", response_model=JobStatus) -def run_export(set_id: str) -> JobStatus: +def run_export(set_id: str, body: RunExport | None = None) -> JobStatus: """Start the export on a background thread; poll `/api/jobs/{id}`. Planned again HERE rather than trusting whatever the preview showed: a playlist can be edited, a file deleted or a drive unplugged between looking and clicking, and the plan carries the destination-safety check. + + The dialog's options arrive with the click and are remembered on the set, + so the next export of the same stick starts from the same answer. """ found = _require_set(set_id) + if body is not None and body.lock_grids is not None and body.lock_grids != found.lock_grids: + found = exports.update(_require_library_id(), set_id, lock_grids=body.lock_grids) adapter = require_adapter() built = exporter.plan(adapter, found) if built.blocked: @@ -779,7 +786,7 @@ def run_export(set_id: str) -> JobStatus: # A Konduktor setting, read when the export starts. root_folder = bool(prefs.load_prefs().get("exportRootFolder", False)) job = JOBS.submit("export", lambda handle: exporter.run( - adapter, found, built, handle, root_folder=root_folder)) + adapter, found, built, handle, root_folder=root_folder, lock_grids=found.lock_grids)) return JobStatus(**job.as_dict()) @@ -829,6 +836,7 @@ def export_targets() -> list[PlatformOption]: removable=bool(getattr(d, "removable", False)), drive_root=bool(getattr(exporter, "drive_root", False)), computer_only=bool(getattr(exporter, "computer_only", False)), + locks_grids=bool(getattr(exporter, "locks_grids", False)), )) # Targets with no reader of their own (the stick's legacy Device Library): # listed too, or registering one would not make it selectable. @@ -847,6 +855,7 @@ def export_targets() -> list[PlatformOption]: removable=bool(getattr(exporter, "drive_root", False)), drive_root=bool(getattr(exporter, "drive_root", False)), computer_only=bool(getattr(exporter, "computer_only", False)), + locks_grids=bool(getattr(exporter, "locks_grids", False)), )) # Each exporter states its own place; a platform with no exporter (not yet a # target, shown disabled) goes last. Stable, so equal places keep their order. diff --git a/backend/konduktor/schemas.py b/backend/konduktor/schemas.py index 30f8c9d..99d9619 100644 --- a/backend/konduktor/schemas.py +++ b/backend/konduktor/schemas.py @@ -347,6 +347,7 @@ class ExportSetOut(BaseModel): destination: str playlist_ids: list[str] = [] track_ids: list[str] = [] # loose tracks only + lock_grids: bool = True created: float = 0.0 modified: float = 0.0 @@ -361,6 +362,13 @@ class UpdateExportSet(BaseModel): name: str | None = None targets: list[str] | None = None destination: str | None = None + lock_grids: bool | None = None + + +class RunExport(BaseModel): + #: The run dialog's "Lock beatgrids" — remembered on the set. None keeps the + #: set's own answer. + lock_grids: bool | None = None class ExportSetMembers(BaseModel): diff --git a/backend/test_export.py b/backend/test_export.py index 0f16060..ee40e9b 100644 --- a/backend/test_export.py +++ b/backend/test_export.py @@ -174,10 +174,14 @@ check("with its tempo changes", check("and its marker positions", [round(m.start, 3) for m in out_grid.grid_markers] == [round(m.start, 3) for m in src_grid.grid_markers]) -# Ben's decision: exported grids are NOT locked, so they stay editable like any -# other track. If Traktor turns out to re-analyse and flatten them, this is what -# makes that visible rather than hidden behind a lock. -check("grids are not locked", not by_title[flexible.title].grid_locked) +# A grid crosses with the lock it had: unlocked at the source, unlocked here. +# Locking every grid is the run's "Lock beatgrids" option (below), because +# Traktor DID turn out to re-analyse an unlocked exported track on first load. +check("each track keeps its source's lock", + [by_title[t.title].grid_locked for t in chosen] == [t.grid_locked for t in chosen], + str([(t.title, t.grid_locked, by_title[t.title].grid_locked) for t in chosen])) +check("and only a locked one has LOCK written", + text.count(' LOCK="1"') == sum(1 for t in chosen if t.grid_locked)) src_cues = src.track_cues(cued.id) out_cues = back.track_cues(by_title[cued.title].id) @@ -278,6 +282,42 @@ check("the audio is really there", check("the result re-opens as a library", len(TraktorDriver().open(dest / "collection.nml").tracks) == len(built.exportable)) +print("== Lock beatgrids ==") +check("a new export set locks by default", exports.get(LIB, eset.id).lock_grids is True) +check("and remembers being told not to", + exports.update(LIB, eset.id, lock_grids=False).lock_grids is False + and exports.get(LIB, eset.id).lock_grids is False) +exports.update(LIB, eset.id, lock_grids=True) +gridded = src.track_cues(flexible.id).model_copy(update={"grid_locked": False}) +bare = gridded.model_copy(update={"grid_markers": []}) +check("on: a grid is locked", exporter._locked(gridded, True).grid_locked) +check("on: a track with no grid is not (Traktor would never give it one)", + not exporter._locked(bare, True).grid_locked) +check("off: the source's own lock is kept", + exporter._locked(gridded.model_copy(update={"grid_locked": True}), False).grid_locked + and not exporter._locked(gridded, False).grid_locked) +lock_dest = Path(tempfile.mkdtemp()) / "LOCKED" +lset = exports.create(LIB, name="LOCKED", targets=["traktor"], destination=str(lock_dest)) +exports.add(LIB, lset.id, playlist_ids=[source_pl.id], track_ids=[ad.tracks[3].id]) +lset = exports.get(LIB, lset.id) +ljob = JOBS.submit("export", lambda h: exporter.run( + ad, lset, exporter.plan(ad, lset), h, lock_grids=True)) +while not ljob.finished: + time.sleep(0.02) +check("a locked export finishes", ljob.state == "done", f"{ljob.state}: {ljob.error}") +ltext = (lock_dest / "collection.nml").read_text(encoding="utf-8") +lback = TraktorDriver().open(lock_dest / "collection.nml") +with_grid = [t for t in lback.tracks if t.grid_marker_count] +check("every exported track with a grid is locked", + with_grid and all(t.grid_locked for t in with_grid), + str([(t.title, t.grid_locked) for t in lback.tracks])) +check("none without one is", + not any(t.grid_locked for t in lback.tracks if not t.grid_marker_count)) +# Measured in Traktor 4.5: LOCK="1" then LOCK_MODIFICATION_TIME, ISO, UTC. +check("written as Traktor writes it: LOCK then an ISO LOCK_MODIFICATION_TIME", + len(re.findall(r' LOCK="1" LOCK_MODIFICATION_TIME="\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d"', + ltext)) == len(with_grid)) + print("== Konduktor only ever deletes what Konduktor wrote ==") mine = dest / "MY OWN NOTES.txt" mine.write_text("do not delete") diff --git a/backend/test_export_pioneer.py b/backend/test_export_pioneer.py index 3ad1f2d..3e05052 100644 --- a/backend/test_export_pioneer.py +++ b/backend/test_export_pioneer.py @@ -146,6 +146,16 @@ for platform, reopen in ( [by_title[t.title].color for t in chosen] == COLOURS[:len(chosen)], str([by_title[t.title].color for t in chosen])) + if platform == "rekordbox": + # Measured 2026-10-19: rekordbox 7's grid padlock sets bit 0x80 of + # `djmdContent.Analysed` (105 -> 233) and nothing else. + analysed = {c.Title: c.Analysed for c in back._store._db.get_content()} + check("a locked grid is Analysed 233, an unlocked one 105", + [analysed[t.title] for t in chosen] + == [233 if src.track_cues(t.id).grid_locked else 105 for t in chosen] + and any(src.track_cues(t.id).grid_locked for t in chosen), + str([(t.title, analysed[t.title]) for t in chosen])) + print(f"-- {platform}: the key was CONVERTED, not copied") for track in chosen: if not track.key: diff --git a/frontend/src/api.ts b/frontend/src/api.ts index 2ee17d5..0068820 100644 --- a/frontend/src/api.ts +++ b/frontend/src/api.ts @@ -334,6 +334,8 @@ export interface PlatformOption { drive_root?: boolean /** As an export target: only ever read on a computer, never from a drive. */ computer_only?: boolean + /** As an export target: its library can store a grid lock. */ + locks_grids?: boolean } export interface EditState { @@ -740,6 +742,9 @@ export interface ExportSet { playlist_ids: string[] /** LOOSE tracks only — tracks a referenced playlist supplies are not listed. */ track_ids: string[] + /** Lock every exported grid, so Traktor does not re-analyse a track when it + * is first loaded. Set from the run dialog and remembered here. */ + lock_grids: boolean created: number modified: number } @@ -982,7 +987,10 @@ export const api = { exports: () => getJSON('/api/exports'), createExport: (body: { name: string; targets: string[]; destination: string }) => send('POST', '/api/exports', body), - updateExport: (id: string, body: Partial>) => + updateExport: ( + id: string, + body: Partial>, + ) => send('PATCH', `/api/exports/${encodeURIComponent(id)}`, body), deleteExport: (id: string) => send<{ deleted: boolean }>('DELETE', `/api/exports/${encodeURIComponent(id)}`), @@ -1013,8 +1021,9 @@ export const api = { exportTargets: () => getJSON('/api/export-targets'), exportPreview: (id: string) => send('POST', `/api/exports/${encodeURIComponent(id)}/preview`, {}), - runExport: (id: string) => - send('POST', `/api/exports/${encodeURIComponent(id)}/run`, {}), + // The run dialog's options travel with the click; the set remembers them. + runExport: (id: string, body: { lock_grids?: boolean } = {}) => + send('POST', `/api/exports/${encodeURIComponent(id)}/run`, body), // ---- path remapping (per-collection OS-path prefix translation) ---- getPathMapping: () => getJSON('/api/library/path-mapping'), diff --git a/frontend/src/components/ExportRunDialog.tsx b/frontend/src/components/ExportRunDialog.tsx index 1d27bf9..53a2de3 100644 --- a/frontend/src/components/ExportRunDialog.tsx +++ b/frontend/src/components/ExportRunDialog.tsx @@ -36,11 +36,18 @@ export function ExportRunDialog({ set, onClose, onDone, onError }: Props) { const qc = useQueryClient() const [job, setJob] = useState(null) const [starting, setStarting] = useState(false) + // Remembered on the set (sent with the click), so a stick's next export + // starts from the same answer. Older sets without it read as on. + const [lockGrids, setLockGrids] = useState(set.lock_grids ?? true) const pollRef = useRef(null) // Platform names for wording the facts the preview and result carry as ids. const platforms = useQuery({ queryKey: ['export-targets'], queryFn: api.exportTargets }) const nameOf = (id: string) => platforms.data?.find((p) => p.platform === id)?.name ?? id + // Offered only where a target can store a lock — a stick format cannot. + const lockable = set.targets.some( + (id) => platforms.data?.find((p) => p.platform === id)?.locks_grids, + ) const preview = useQuery({ queryKey: ['export-preview', set.id], @@ -83,7 +90,8 @@ export function ExportRunDialog({ set, onClose, onDone, onError }: Props) { const start = async () => { setStarting(true) try { - setJob(await api.runExport(set.id)) + setJob(await api.runExport(set.id, lockable ? { lock_grids: lockGrids } : {})) + qc.invalidateQueries({ queryKey: ['exports'] }) } catch (e) { onError((e as Error).message) } finally { @@ -178,6 +186,23 @@ export function ExportRunDialog({ set, onClose, onDone, onError }: Props) { folder’s contents to a drive’s top level. )} + {lockable && ( + + )}
Writes a library for {set.targets.map(nameOf).join(' and ')}, sharing one copy of every track under Contents/, in your own