diff --git a/changelog/2026-11-24-octatrack-sync-before-restore.md b/changelog/2026-11-24-octatrack-sync-before-restore.md new file mode 100644 index 0000000000..6cff0676f0 --- /dev/null +++ b/changelog/2026-11-24-octatrack-sync-before-restore.md @@ -0,0 +1 @@ +Octatrack: a sync sent in the first moments after the Octatrack starts, before it has loaded its saved modules, now says so: "The Octatrack hasn't loaded its saved modules yet, so nothing changed", and to wait until Status shows them. Before, it said the Octatrack can't run the module file, although nothing was wrong with the modules and the unit loaded them a moment later. diff --git a/src/dev/octatrack-link-fake.ts b/src/dev/octatrack-link-fake.ts index a51a8d69fa..20d14f8379 100644 --- a/src/dev/octatrack-link-fake.ts +++ b/src/dev/octatrack-link-fake.ts @@ -59,6 +59,9 @@ export interface FakeUnit { screen?: () => Promise /** The loader refuses the next load with this reason (loader.h runtime_refusal), as the base's record reports it. */ refusal?: number + /** This start's restore has not run: the base rejects every change with no loader refusal, its record's `saved` 0 + * (modset.c modwerk_modset_check_set). */ + restoring?: boolean /** The loader refuses the next publications with this reason, after staging (a resident controller quiescing: 5); * the base then drops the staged package. */ publishRefusal?: number @@ -151,7 +154,7 @@ export function fakeUnit(kind: 'base' | 'stock' | 'none' = 'base'): FakeUnit { ;[380 + wave(0), 520 + wave(2), 640, 260 + wave(4), 410].forEach((value, i) => load.setUint32(28 + 4 * i, value)) return { status: 'ok', data: load } } - const refusal = unit.refusal ?? unit.publishRefusal ?? (unit.writeRefusal ? 100 + unit.writeRefusal : unit.flashed === '' ? 107 : undefined) + const refusal = unit.refusal ?? unit.publishRefusal ?? (unit.restoring ? 0 : undefined) ?? (unit.writeRefusal ? 100 + unit.writeRefusal : unit.flashed === '' ? 107 : undefined) if (setup.request === 21 && unit.status && refusal === undefined) { // passed, peaks, saved on the card and read back const record = new DataView(new ArrayBuffer(SELFTEST_BYTES)), count = unit.installed.moduleIds.length ;[[0, 2], [3, count], [7, 410], [8, 655], [9, 470], [14, 47900], [15, 7], [16, count], [17, count]].forEach(([at, value]) => record.setUint32(4 * at, value)) @@ -203,7 +206,7 @@ export function fakeSession(unit: FakeUnit, delay = 0) { get status() { return status }, connectionTrusted: true, async stage(pkg, { signal, progress } = {}) { if (unit.playing) return step('normal', 'unsafe') - if (unit.refusal) return step('normal', 'rejected') + if (unit.refusal || unit.restoring) return step('normal', 'rejected') if (unit.stageLosses && String.fromCharCode(...pkg.data.subarray(0, 4)) === 'ELEK' && unit.stageLosses-- > 0) { await wait(); throw new UploadUnconfirmedError('hello was not confirmed', status) } staged = pkg.sha256; data = pkg.data for (let sent = 0; sent < pkg.data.length;) { diff --git a/src/engine/elekloader/octatrack-link.test.ts b/src/engine/elekloader/octatrack-link.test.ts index ec9df85d57..c0df0d33b7 100644 --- a/src/engine/elekloader/octatrack-link.test.ts +++ b/src/engine/elekloader/octatrack-link.test.ts @@ -414,6 +414,12 @@ describe('sending a module', () => { await link.update('PREVIEW VOL', one) expect(link.getState().notice?.text).toBe('The Octatrack can’t run this module file.') }) + it('says the saved modules are still loading when a sync comes before this start’s restore', async () => { + const { unit, link } = await linked() + unit.restoring = true // rejected with no loader refusal, the record's saved still 0 + await link.update('PREVIEW VOL', one) + expect(link.getState().notice?.text).toMatch(/hasn’t loaded its saved modules yet, so nothing changed/) + }) it('names the modules a track may be using, once each and at most five', () => { expect(inUseHint([])).toBe('') expect(inUseHint(['Tape Echo', 'Tape Echo'])).toBe(' Look for Tape Echo on the tracks.') diff --git a/src/engine/elekloader/octatrack-link.ts b/src/engine/elekloader/octatrack-link.ts index 3aa89621d9..9e6a1c25d1 100644 --- a/src/engine/elekloader/octatrack-link.ts +++ b/src/engine/elekloader/octatrack-link.ts @@ -159,6 +159,10 @@ const REFUSED: Partial> = { * loader's refusals (sdk/runtime/loader-refusals.json). A code without one shows the plain text above. */ const REJECTED: Partial> = Object.fromEntries( loaderRefusals.refusals.flatMap(refusal => 'musician' in refusal && refusal.musician ? [[refusal.code, refusal.musician]] : [])) +/** A "rejected" with no loader refusal while the record's `saved` is still 0: this start's restore has not run, and the + * base takes no change until it has (modset.c modwerk_modset_check_set). In November 2026 three units synced their whole + * set into that window, read "can't run this module file", and had it back from the restore moments later. */ +const NOT_RESTORED = 'The Octatrack hasn’t loaded its saved modules yet, so nothing changed. It loads them a few seconds after it starts, while nothing plays or records. Wait until Status shows them, then sync again if anything is missing.' const RUNTIME_IN_USE = 7 /** After refusal 7, the modules the sync removes or replaces: one of them is on a track. The base does not say which * track (November 2026: testers were refused several times in a row looking for it). */ @@ -889,8 +893,8 @@ export class OctatrackLink { try { clean = await this.cleanUp(settled) } catch { clean = false } } if (connection !== this.connection) return - const why = error instanceof UploadDeviceError && ['rejected', 'backend'].includes(error.status.result) ? - (await this.transport?.selftest(false).catch(() => undefined))?.refusal : undefined + const record = error instanceof UploadDeviceError && ['rejected', 'backend'].includes(error.status.result) ? + await this.transport?.selftest(false).catch(() => undefined) : undefined, why = record?.refusal if (connection !== this.connection) return const label = error instanceof UploadDeviceError ? 'device' : error instanceof UploadUnconfirmedError ? 'transport' : error instanceof StaleLoadError ? 'stale' : error instanceof DOMException && error.name === 'AbortError' ? 'cancelled' : 'unknown' // An unclassified failure names its error type (never the message), so the diagnostics can tell a bug from a refusal; @@ -908,7 +912,7 @@ export class OctatrackLink { this.session = undefined await this.release() // An untrusted connection that could not be read again leaves the running set unknown. - const text = recovered && clean ? RECOVERED : (REJECTED[why ?? 0] ?? explainLinkError(error)) + + const text = recovered && clean ? RECOVERED : (why === 0 && record?.saved === 0 ? NOT_RESTORED : REJECTED[why ?? 0] ?? explainLinkError(error)) + (why === RUNTIME_IN_USE ? inUseHint(this.replaced) : '') + (clean ? '' : ' ' + UNPLUG) if (this.device && connection === this.connection) { const notice = { tone: 'error', text } as const