Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/2026-11-24-octatrack-sync-before-restore.md
Original file line number Diff line number Diff line change
@@ -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.
7 changes: 5 additions & 2 deletions src/dev/octatrack-link-fake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ export interface FakeUnit {
screen?: () => Promise<DataView>
/** 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
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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;) {
Expand Down
6 changes: 6 additions & 0 deletions src/engine/elekloader/octatrack-link.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.')
Expand Down
10 changes: 7 additions & 3 deletions src/engine/elekloader/octatrack-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ const REFUSED: Partial<Record<UploadResultName, string>> = {
* loader's refusals (sdk/runtime/loader-refusals.json). A code without one shows the plain text above. */
const REJECTED: Partial<Record<number, string>> = 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). */
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down