Skip to content

armgit / nota

Public Imported from GitHub
0

Nota — a free DAW for macOS, Windows and Linux. No subscription, no account — just open it and make music.

(fix) Nota Remote: launch several Session clips at once on iOS (#513)

Egor Khindikaynene3a6a382b0c9
diff --git a/.specify/bugs/remote-scenes-multitouch/assessment.md b/.specify/bugs/remote-scenes-multitouch/assessment.md
new file mode 100644
index 00000000..a966f2d1
--- /dev/null
+++ b/.specify/bugs/remote-scenes-multitouch/assessment.md
@@ -0,0 +1,93 @@
+# Bug Assessment: Nota Remote (iOS) can't launch several Session clips at once
+
+- **Slug**: remote-scenes-multitouch
+- **Created**: 2026-11-05
+- **Source**: https://github.com/nota-daw/nota/issues/512 (host: github.com — allowlisted; read with `gh issue view`)
+- **Verdict**: valid
+- **Severity**: medium
+
+## Report (verbatim or summarized)
+
+Issue #512, "Nota Remote (iOS): can't launch several Session clips at once with multi-touch":
+in Nota Remote on an iPhone/iPad, the Scenes screen (the Session grid) only takes one clip at a
+time. Touching two or more clips together launches none of them, or only one. Expected: every
+clip touched launches, as Pads and Keys already take several fingers at once. While fixing, a
+finger that drags to scroll the grid must not launch the clip it started on.
+
+## Symptom
+
+Two fingers landing on two clips on the Scenes screen send at most one `launch` message to Nota
+(often none); one finger at a time works. Expected: one `launch` per clip touched.
+
+## Reproduction
+
+1. A project with Session clips on at least two tracks.
+2. Pair Nota Remote from iOS Safari (or the home-screen app), open **Scenes**.
+3. Touch two clips on different tracks at the same time and lift.
+4. Nota queues one clip or none.
+
+## Suspected Code Paths
+
+- `src/web/remote/src/screens/Scenes.svelte` — the clip buttons (and the scene, Stop and
+ Stop-all buttons) act in `onclick`. Nothing else on the screen handles pointers.
+- `src/web/remote/src/app.css:32` — `button { touch-action: manipulation }`, and
+ `Scenes.svelte` `.scroll { touch-action: pan-x pan-y }`: the grid is a native scroller, so
+ touches stay under the browser's gesture recogniser.
+- For contrast, `src/web/remote/src/screens/Pads.svelte:38` (`press` on `onpointerdown`, a
+ pointer → note map) and `Keys.svelte` track each pointer themselves, which is why they work
+ with several fingers.
+- Server side is not involved: `src/managed/Nota.Remote/RemoteHub.Apply.cs:128` applies every
+ `launch` / `scene` / `stopSlot` message on its own, with no debounce.
+
+## Root Cause Hypothesis
+
+WebKit on iOS synthesises a `click` only for a single-finger tap. When a second finger is down,
+the touch sequence is a multi-finger gesture and no `click` is dispatched for either finger (or
+only for the one that lifts last, once alone). Since the Scenes buttons only react to `click`,
+simultaneous touches are lost. Confidence: high — it is documented WebKit behaviour and matches
+the contrast with Pads/Keys, which use Pointer Events.
+
+## Proposed Remediation
+
+**Preferred**: give the Scenes buttons their own per-pointer tap handling. A small shared Svelte
+action (`src/web/remote/src/lib/tap.ts`, `use:tap={fn}`) tracks each `pointerdown` by
+`pointerId` with its start point, and fires `fn` on that pointer's `pointerup` if the pointer
+stayed within a small slop (~10 px) and was not cancelled. A pointer that starts a scroll gets
+`pointercancel` from the browser (the grid keeps `touch-action: pan-x pan-y`) or moves past the
+slop, so it does not fire. Firing on release keeps scrolling safe; Session launches are
+quantised, so clips released a few milliseconds apart still start together. `click` stays as the
+path for keyboard and assistive-technology activation, ignored when a pointer has just fired the
+same button, so a single tap never launches twice.
+
+**Alternatives**:
+- Fire on `pointerdown` (as Pads do): instant, but any scroll that starts on a clip would launch
+ it, and the grid scrolls on phones with more than a few tracks. Rejected.
+- Use `touchstart`/`touchend` directly: iOS-only semantics; Pointer Events already cover iOS
+ 13+ and the other browsers. Rejected.
+
+**Files likely to change**:
+- `src/web/remote/src/lib/tap.ts` (new)
+- `src/web/remote/src/screens/Scenes.svelte`
+- `CHANGELOG.md` (Fixed)
+
+**Tests to add or update**:
+- The remote page has no unit-test harness; verify by driving the built page against the mock
+ server with two simultaneous touch points (Chromium touch emulation via CDP, and iOS Safari in
+ the Simulator with a two-finger touch), checking one `launch` per touched clip, and that a
+ drag-to-scroll starting on a clip sends nothing. `svelte-check` and `scripts/build.sh` must
+ pass.
+
+## Risks & Considerations
+
+- Double fire: a single-finger tap produces both `pointerup` and `click`; the guard must
+ suppress the click that follows a pointer fire.
+- VoiceOver activation sends a `click` without a matching pointer sequence — it must still work
+ (it does, through the click path).
+- A held finger that slides off a button and lifts elsewhere must not fire (use the slop and
+ check the release point is still within the button).
+- Applies to the scene, Stop and Stop-all buttons too, for consistency — same screen, same
+ gesture.
+
+## Open Questions
+
+- None blocking.
diff --git a/.specify/bugs/remote-scenes-multitouch/fix.md b/.specify/bugs/remote-scenes-multitouch/fix.md
new file mode 100644
index 00000000..84f6dd97
--- /dev/null
+++ b/.specify/bugs/remote-scenes-multitouch/fix.md
@@ -0,0 +1,61 @@
+# Bug Fix: Nota Remote (iOS) can't launch several Session clips at once
+
+- **Slug**: remote-scenes-multitouch
+- **Fixed**: 2026-11-05
+- **Assessment**: ./assessment.md
+- **Status**: applied
+
+## Summary
+
+The Scenes screen's buttons acted in `onclick`, which iOS Safari only sends for a single-finger
+tap. They now use a shared `use:tap` action that follows each pointer itself and fires on that
+pointer's release, so every clip under a finger launches, while a drag that scrolls the grid
+still launches nothing.
+
+## Changes
+
+| File | Change | Notes |
+|------|--------|-------|
+| `src/web/remote/src/lib/tap.ts` | added | `tap` Svelte action: per-pointer tap with a 10 px slop, release must land over the button, `pointercancel` (browser scroll) drops it; `click` kept for keyboard / VoiceOver, ignored right after a pointer lifted |
+| `src/web/remote/src/screens/Scenes.svelte` | modified | clip, scene, Stop and Stop-all buttons: `onclick` → `use:tap` |
+| `CHANGELOG.md` | modified | `[Unreleased]` → Fixed entry |
+
+## Diff Highlights (optional)
+
+```svelte
+<button class="clip" …
+ use:tap={() => guard() && app.send({ t: 'launch', id: c.id, i: si })}
+```
+
+```ts
+const onUp = (e: PointerEvent) => {
+ const p = down.get(e.pointerId);
+ lifted = performance.now();
+ if (!p) return;
+ down.delete(e.pointerId);
+ …
+ if (!far(e, p) && over) act();
+};
+const onClick = () => { if (performance.now() - lifted > SAME_TAP_MS) act(); };
+```
+
+## Tests Added or Updated
+
+- The phone page has no unit-test harness (the assessment noted this). The behaviour is pinned
+ by the manual multi-touch checks recorded in `test.md` (two simultaneous touch points against
+ the mock server, scroll-drag, single tap, keyboard activation).
+
+## Local Verification
+
+- Commands run: `npm run check` (src/web/remote) → 0 errors, 0 warnings; `npm run build` → built
+ into `Nota.Remote/wwwroot`.
+- Manual checks: see `test.md`.
+
+## Deviations from Assessment
+
+None.
+
+## Follow-ups
+
+- Other screens with `onclick` buttons (Mixer M/S/Arm, transport) have the same single-finger
+ limitation; they are rarely pressed together, so they stay as they are unless someone asks.
diff --git a/.specify/bugs/remote-scenes-multitouch/test.md b/.specify/bugs/remote-scenes-multitouch/test.md
new file mode 100644
index 00000000..e2764f89
--- /dev/null
+++ b/.specify/bugs/remote-scenes-multitouch/test.md
@@ -0,0 +1,74 @@
+# Bug Verification: Nota Remote (iOS) can't launch several Session clips at once
+
+- **Slug**: remote-scenes-multitouch
+- **Tested**: 2026-11-05
+- **Assessment**: ./assessment.md
+- **Fix**: ./fix.md
+- **Result**: verified
+
+## Summary
+
+Reproduced on iOS Safari (iOS Simulator, iPhone 17 Pro) before the fix: a two-finger touch on two
+clips sent no `launch` at all. After the fix the same gesture sends one `launch` per clip; a
+single tap still sends exactly one, a scroll that starts on a clip sends none, and keyboard
+activation still works.
+
+## Checks Performed
+
+Setup: the page built from `HEAD` (pre-fix) and from the working tree (post-fix), each served
+by a scratch copy of `src/web/remote/mock/nota-mock.mjs` that logs every `launch` / `scene` /
+`stopSlot` / `stopAll` message it receives (ports 7791 / 7792).
+
+| Check | Command / Action | Result | Notes |
+|-------|------------------|--------|-------|
+| Reproduction (pre-fix), iOS Safari | Simulator two-finger touch on Drums/Scene 2 + Keys/Scene 3, twice | fail as expected | 0 messages both times; a single tap sent 1 |
+| Reproduction (post-fix), iOS Safari | same two-finger touch | pass | `launch 1/1` and `launch 3/2` |
+| Single tap, iOS Safari | one tap on Bass/Scene 1 | pass | exactly one `launch` — no click double-fire |
+| Scroll drag from a clip, iOS Safari | horizontal swipe starting on Keys/Scene 3 | pass | grid scrolled, nothing sent |
+| Held two fingers on clip + Stop, iOS Safari | 400 ms two-finger hold, Strings/Scene 1 + Keys Stop | pass | `launch 6/0`, `stopSlot 3` |
+| Chromium touch emulation (CDP) | staggered fingers, simultaneous, single, slide-off, keyboard Enter | pass | post-fix: 2 / 2 / 1 / 0 / 1 (scene); pre-fix: 0 / 0 / 1 / 0 / 1 |
+| Type-check | `npm run check` (src/web/remote) | pass | 0 errors, 0 warnings |
+| Page build | `npm run build` | pass | built into `Nota.Remote/wwwroot` |
+| Full build + smoke test | `scripts/build.sh` | pass | first run failed one timing check (render pool "at most 6 late blocks within 50 ms") while the Simulator, two mocks and headless Chromium loaded the machine (load average 58); re-run on a quiet machine: all checks pass |
+
+## Output Excerpts
+
+```text
+iOS, pre-fix, two fingers: (nothing)
+iOS, post-fix, two fingers: CMD {"t":"launch","id":1,"i":1}
+ CMD {"t":"launch","id":3,"i":2}
+
+CDP post-fix
+staggered two fingers ["launch 3/2","launch 1/1"]
+simultaneous two fingers ["launch 1/1","launch 3/2"]
+single tap ["launch 1/1"]
+finger slides off []
+keyboard Enter on Scene 1 ["scene 0"]
+```
+
+## Residual Risks
+
+- Verified in the iOS Simulator, not on a physical iPhone/iPad; the Simulator runs the real
+ WebKit, but touch timing on hardware may differ.
+- VoiceOver activation was not exercised; it reaches the button as a `click`, which the action
+ still handles (covered by the keyboard check, which takes the same path).
+- Verified against the mock server, not a running Nota; the desktop side applies each message
+ independently (`RemoteHub.Apply.cs`), so nothing there changes.
+
+## Recommendation
+
+Close the bug once the PR lands — verified end-to-end on iOS Safari and Chromium.
+
+## Review follow-up (PR #513)
+
+A keyboard activation within 800 ms of a pointer tap on the same button was dropped as if it
+were the tap's own click. The click guard now drops only pointer clicks (`detail > 0`) right
+after a pointer lifted; a keyboard click (`detail === 0`) always acts.
+
+| Check | Command / Action | Result | Notes |
+|-------|------------------|--------|-------|
+| Tap then Enter 100 ms later, Chromium (CDP) | touch tap on Scene 2, focus, Enter | pass | `scene 1` × 2 (the previous guard would drop the Enter by its 800 ms window — inferred from the code, not run) |
+| Earlier CDP scenarios, Chromium | staggered / simultaneous / single / slide-off / Enter | pass | 7 runs in a row identical to the first report; one cold first run after a mock restart lost one staggered launch and did not recur |
+| Single tap, iOS Safari (Simulator) | one tap on Drums/Scene 2 | pass | exactly one `launch` — WebKit's tap click carries `detail > 0`, so it is still dropped |
+| Two fingers + scene tap, iOS Safari | two clips together, then Scene 1 | pass | `launch` × 2, then `scene 0` |
+| Type-check / build | `npm run check`, `npm run build` | pass | 0 errors |
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 43159632..37b8ef40 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -22,6 +22,12 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.
## [Unreleased]
+### Fixed
+- **Nota Remote on iPhone and iPad launches several clips at once** (#512): touching two or
+ more clips on the Scenes screen together launched none of them, or only one — iOS Safari
+ only sends a tap for a single finger. Every clip, scene and Stop button now takes its own
+ finger, and a drag that scrolls the grid still launches nothing.
+
## [0.59.1] — 2026-11-05
### Added
diff --git a/src/web/remote/src/lib/tap.ts b/src/web/remote/src/lib/tap.ts
new file mode 100644
index 00000000..8ef28e01
--- /dev/null
+++ b/src/web/remote/src/lib/tap.ts
@@ -0,0 +1,62 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+// use:tap — a tap that works with several fingers at once. iOS Safari synthesises `click` only
+// for a single-finger tap, so a button that acts in onclick loses every touch made while another
+// finger is down (two clips launched together launched one, or none). This follows each pointer
+// itself and fires on that pointer's release, if it stayed near where it landed, lifted over the
+// button, and wasn't taken by the browser for a scroll (pointercancel). Firing on release keeps
+// a scrollable grid safe to drag. Keyboard and assistive-technology activation still come as a
+// plain click and always act; only the click a browser synthesises right after a pointer lifted
+// on the button (detail > 0) is that same tap again, and is dropped.
+import type { Action } from 'svelte/action';
+
+const SLOP = 10; // px a finger may wander and still count as a tap
+const SAME_TAP_MS = 800; // a pointer click this soon after a pointer lifted belongs to that pointer
+
+export const tap: Action<HTMLElement, () => void> = (node, fn) => {
+ let act = fn;
+ const down = new Map<number, [number, number]>(); // pointer → where it landed
+ let lifted = -Infinity;
+
+ const far = (e: PointerEvent, p: [number, number]) => Math.hypot(e.clientX - p[0], e.clientY - p[1]) > SLOP;
+ const onDown = (e: PointerEvent) => {
+ if (e.button === 0) down.set(e.pointerId, [e.clientX, e.clientY]);
+ };
+ const onMove = (e: PointerEvent) => {
+ const p = down.get(e.pointerId);
+ if (p && far(e, p)) down.delete(e.pointerId);
+ };
+ const onUp = (e: PointerEvent) => {
+ const p = down.get(e.pointerId);
+ lifted = performance.now();
+ if (!p) return;
+ down.delete(e.pointerId);
+ const r = node.getBoundingClientRect();
+ const over = e.clientX >= r.left && e.clientX <= r.right && e.clientY >= r.top && e.clientY <= r.bottom;
+ if (!far(e, p) && over) act();
+ };
+ const onCancel = (e: PointerEvent) => {
+ if (down.delete(e.pointerId)) lifted = performance.now();
+ };
+ const onClick = (e: MouseEvent) => {
+ // A keyboard click (Enter / Space) has detail 0 and is never a pointer tap's echo.
+ if (e.detail > 0 && performance.now() - lifted <= SAME_TAP_MS) return;
+ act();
+ };
+
+ node.addEventListener('pointerdown', onDown);
+ node.addEventListener('pointermove', onMove);
+ node.addEventListener('pointerup', onUp);
+ node.addEventListener('pointercancel', onCancel);
+ node.addEventListener('click', onClick);
+ return {
+ update(f) { act = f; },
+ destroy() {
+ node.removeEventListener('pointerdown', onDown);
+ node.removeEventListener('pointermove', onMove);
+ node.removeEventListener('pointerup', onUp);
+ node.removeEventListener('pointercancel', onCancel);
+ node.removeEventListener('click', onClick);
+ },
+ };
+};
diff --git a/src/web/remote/src/screens/Scenes.svelte b/src/web/remote/src/screens/Scenes.svelte
index 41f7672e..eb721cc2 100644
--- a/src/web/remote/src/screens/Scenes.svelte
+++ b/src/web/remote/src/screens/Scenes.svelte
@@ -2,11 +2,12 @@
<!-- Scenes: the Session grid, tracks across and scenes down, in the project's colours. Tap a clip
to launch it, a scene name to launch the row, Stop to stop a track. A queued clip blinks
until the launch point; a playing one shows a play mark and a progress line — readable at
- arm's length. -->
+ arm's length. Every button takes its own finger (use:tap), so several clips launch at once. -->
<script lang="ts">
import { app } from '../lib/app.svelte';
import type { Form } from '../lib/device.svelte';
import { look } from '../lib/theme.svelte';
+ import { tap } from '../lib/tap';
let { form }: { form: Form } = $props();
const s = $derived(app.ses);
@@ -34,7 +35,7 @@
<div class="th"><span style:background={t?.color}></span><b>{t?.name ?? ''}</b></div>
{/each}
{#each Array.from({ length: s.n }, (_, i) => i) as si (si)}
- <button class="scene" style:height="{rowH}px" onclick={() => guard() && app.send({ t: 'scene', i: si })} aria-label="Launch scene {si + 1}">
+ <button class="scene" style:height="{rowH}px" use:tap={() => guard() && app.send({ t: 'scene', i: si })} aria-label="Launch scene {si + 1}">
<span class="tri"></span>Scene {si + 1}
</button>
{#each cols as c (c.id)}
@@ -44,7 +45,7 @@
<div class="clip empty" style:height="{rowH}px"></div>
{:else}
<button class="clip" class:playing={st === 3} class:queued={st === 2} class:rec={st === 4} style:height="{rowH}px" style:--tc={t?.color} style:--tc-ink={t ? look.inkOn(t.color) : undefined}
- onclick={() => guard() && app.send({ t: 'launch', id: c.id, i: si })}
+ use:tap={() => guard() && app.send({ t: 'launch', id: c.id, i: si })}
aria-label="{t?.name} scene {si + 1}: {st === 3 ? 'playing' : st === 2 ? 'queued' : st === 4 ? 'recording' : 'stopped'}">
<span class="cn">{#if st === 3}<span class="ptri"></span>{/if}<span><span class="mono">{bars(len)[0]}</span> {bars(len)[1]}</span></span>
<span class="cs">{st === 3 ? 'Playing' : st === 2 ? 'Queued' : st === 4 ? 'Recording' : ''}</span>
@@ -53,9 +54,9 @@
{/if}
{/each}
{/each}
- <button class="stopall" onclick={() => guard() && app.send({ t: 'stopAll' })}><span class="sq"></span>All</button>
+ <button class="stopall" use:tap={() => guard() && app.send({ t: 'stopAll' })}><span class="sq"></span>All</button>
{#each cols as c (c.id)}
- <button class="stop" onclick={() => guard() && app.send({ t: 'stopSlot', id: c.id })} aria-label="Stop {tracks.get(c.id)?.name}"><span class="sq"></span>Stop</button>
+ <button class="stop" use:tap={() => guard() && app.send({ t: 'stopSlot', id: c.id })} aria-label="Stop {tracks.get(c.id)?.name}"><span class="sq"></span>Stop</button>
{/each}
</div>
{/if}