feat(editor): reset the playhead when a different model loads

This commit is contained in:
Julien Calixte
2026-06-20 14:39:06 +02:00
parent 1d65383bbf
commit ed6f011e69

View File

@@ -61,6 +61,17 @@ export const useSimulationStore = defineStore("simulation", () => {
if (playhead.value > n - 1) playhead.value = Math.max(0, n - 1) if (playhead.value > n - 1) playhead.value = Math.max(0, n - 1)
}) })
// Loading a different document (sample / import / new) restarts playback from the
// top. Editing the current one keeps the same id, so the playhead stays put — and
// undo/redo restore snapshots in place (same id), so they don't jump it either.
watch(
() => modelStore.model.id,
() => {
playing.value = false
playhead.value = 0
},
)
/** A node's value at the current playhead, or null when there's nothing to show. */ /** A node's value at the current playhead, or null when there's nothing to show. */
function valueAt(id: string): number | null { function valueAt(id: string): number | null {
if (!active.value) return null if (!active.value) return null