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
14 changes: 14 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1959,6 +1959,20 @@ as are AU and CLAP hosting.
`import type` for types), Tailwind utility classes for styling, interfaces
documented with JSDoc-style comments. Features are plain callback props, not
global stores.
- **`$effect` is the last resort.** State that follows other state is
`$derived` (a *writable* `$derived` when it is set locally and resets when
its input changes); a reaction to something the user did goes in that
handler, or in a function binding's setter (`bind:x={() => x, setX}`); DOM
wiring and measurement is an `{@attach}`; an external value that changes on
its own is `createSubscriber` (see `lib/devicePixels.svelte.ts`). What is
left — timers, writes to the document or localStorage, engine requests,
latching an engine stream — carries a `// Effect: …` line in the comment
directly above it saying why, which `src/lib/effectGuard.test.ts` enforces
for `ui/` and `site/`. Check any Svelte file you touch with the Svelte MCP's
`svelte-autofixer` (or `npx @sveltejs/mcp svelte-autofixer <file>`) until
it reports no issues. Prefer the class array/object form to `class:`
directives, except on an element whose classes are also toggled with
`classList` — a class array rewrites `className` whole.
- **Formatting**: don't hand-format UI files. Run `pnpm format` in `ui/`;
Prettier formats Svelte/TypeScript/CSS at 100 columns and the Tailwind plugin
applies the canonical utility-class order.
Expand Down
2 changes: 1 addition & 1 deletion site/src/lib/components/DownloadButtons.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<div class="wrap">
<div class="row">
{#each DOWNLOADS as dl (dl.os)}
<a href={dl.url} class="dl" class:compact={size === 'compact'} data-platform={dl.platform}>
<a href={dl.url} class={['dl', { compact: size === 'compact' }]} data-platform={dl.platform}>
{#if dl.platform === 'windows'}
<svg class="glyph" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
<path
Expand Down
20 changes: 10 additions & 10 deletions site/src/lib/components/Header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@
const lifted = $derived(scrollY > 8);

// Each time the bar gains or loses its chrome, the logo coin takes another
// half turn. Only toggles count: comparing against the previous value
// keeps the mount from spending a spin on first paint. Hover is not added
// here: it is one more half turn in the CSS, so it can unwind on leave
// while these accumulate forward.
// half turn. Counted where the scroll position arrives (the binding's
// setter), and only on a toggle, so a scroll that stays on one side of the
// threshold spends nothing. Hover is not added here: it is one more half
// turn in the CSS, so it can unwind on leave while these accumulate forward.
let spins = $state(0);
let prevLifted: boolean | undefined;
$effect(() => {
if (prevLifted !== undefined && lifted !== prevLifted) spins++;
prevLifted = lifted;
});
function setScrollY(y: number) {
const wasLifted = lifted;
scrollY = y;
if (lifted !== wasLifted) spins++;
}
</script>

<svelte:window bind:scrollY />
<svelte:window bind:scrollY={() => scrollY, setScrollY} />

<header
class="sticky top-0 z-50 border-b transition-[background-color,border-color,backdrop-filter] duration-200
Expand Down
6 changes: 4 additions & 2 deletions site/src/lib/components/VideoEmbed.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@
</script>

<div
class="surface relative w-full overflow-hidden shadow-[var(--shadow-panel)]"
class:aspect-video={id !== null}
class={[
'surface relative w-full overflow-hidden shadow-[var(--shadow-panel)]',
{ 'aspect-video': id !== null },
]}
>
{#if playing && id}
<iframe
Expand Down
25 changes: 14 additions & 11 deletions ui/src/App.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script lang="ts">
<script lang="ts">
import PartnershipSplash from './features/tone3000/PartnershipSplash.svelte';
import Tone3000InstallStatus from './features/tone3000/Tone3000InstallStatus.svelte';
import { isNamPlugin, type Tone3000State } from './lib/engine/tone3000';
Expand Down Expand Up @@ -91,7 +91,7 @@
let appSettings = $state<AppSettings>({ ...DEFAULT_APP_SETTINGS, theme: bootTheme() });
let sceneState = $state<SceneState>({ scenes: [], activeSceneId: null });
// Plugin-internal drift: a plugin changed its own state (native editor edit,
// program switch) — invisible to the rack signature but part of a rig save.
// program switch) — invisible to the rack signature but part of a rig save.
let toneDirty = $state(false);
// Host version, plugin-scan state and the scanner's blacklist are owned here
// because the Info panel's diagnostics report needs all three; the rack's
Expand Down Expand Up @@ -121,7 +121,7 @@
let starterInstalling = $state(false);
// True while the tuner's MIDI learn (in the status bar's slideout) is armed.
// Owned here because two siblings need it: the status bar arms it, and the
// rack pauses live MIDI dispatch while it is armed — and disarms it when
// rack pauses live MIDI dispatch while it is armed — and disarms it when
// the MIDI settings dialog opens (one armed learn app-wide).
let tunerMidiLearning = $state(false);
// Same shape for the mute's learn, armed from the mute pill's own slideout.
Expand All @@ -139,13 +139,13 @@
let settingsMidiLearning = $state(false);
// The tool staged across the full workspace, or null. Session-only (like
// the stage tuner): raised by a panel's maximize button or by a looper
// action arriving from a MIDI pedal — a foot on the looper switch means
// action arriving from a MIDI pedal — a foot on the looper switch means
// the player's eyes are about to look for the looper's state.
let stagedTool = $state<ToolId | null>(null);
// Mirror in the other direction: true while the rack has a knob/module/lane
// learn armed, so the tuner's Learn button refuses to arm a second one.
let rackMidiLearning = $state(false);
// For rack.disarmContentLearn() — the one disarm that flows downward.
// For rack.disarmContentLearn() — the one disarm that flows downward.
let rackComponent = $state<ReturnType<typeof Rack>>();
/** True once the engine's stored preferences have actually been read. The
first-run wizard hangs off `setupCompleted`, whose *default* claims this
Expand Down Expand Up @@ -182,6 +182,8 @@
// Re-checked whenever the patch list or the download folder changes — a
// patch can arrive from a rig, an import or a fresh install, and the answer
// is only ever true of a moment.
// Effect: an engine request whose answer depends on two engine streams; the
// cleanup is what drops a superseded answer.
$effect(() => {
void patches;
void tone3000.downloads;
Expand Down Expand Up @@ -301,7 +303,7 @@
});
/** The Info panel's diagnostics report, built from the live state above.
Plugin and audio-device identities are in (they are what breaks); nothing
the user typed is — no rig, scene, lane or module names — because the
the user typed is — no rig, scene, lane or module names — because the
report is written to be pasted into a public issue. See diagnostics.ts.
The panel supplies the browser facts it measured once at mount, so the
15 Hz status stream doesn't re-measure the DOM. */
Expand All @@ -322,7 +324,7 @@
});
}

/** Open the sidebar's Info panel — the home of the diagnostics report and
/** Open the sidebar's Info panel — the home of the diagnostics report and
the issue links. Un-stages first so the panel is actually visible rather
than hidden behind a staged tool. */
function openInfoPanel() {
Expand All @@ -334,11 +336,12 @@
// this keeps <html> in step once the engine's stored value lands and on every
// later change. <html> rather than the app's own root div because <body>
// paints the page and the resize handles and tooltips render outside it.
// Effect: writes the document root and localStorage, outside this tree.
$effect(() => applyTheme(appSettings.theme));

// Auto Standby's activity ping. The engine can only see the guitar input, so
// silent interaction — editing a rig, reading the manual with the window
// focused — has to be reported from here or standby would engage mid-session.
// silent interaction — editing a rig, reading the manual with the window
// focused — has to be reported from here or standby would engage mid-session.
// Throttled hard: this fires on raw pointer/key/wheel traffic, and the engine
// only needs to know the user is present, not how busy they are.
const ACTIVITY_PING_MS = 5000;
Expand Down Expand Up @@ -383,7 +386,7 @@
/>

<!-- Owned here (state, learn bindings) but rendered inside the rack shell,
beside the viewport and *below* the toolbar — the toolbar keeps the full
beside the viewport and *below* the toolbar — the toolbar keeps the full
window width. Still a flex sibling of the viewport, never an overlay:
expanding pushes the rack narrower instead of covering modules. -->
{#snippet toolsSidebar()}
Expand Down Expand Up @@ -423,7 +426,7 @@
{/snippet}

<!-- --ui-scale drives the CSS zoom each chrome piece (toolbar, sidebar,
status bar) applies to its own root — one setting, three consumers.
status bar) applies to its own root — one setting, three consumers.
Set here rather than on <html> because everything it governs lives in
this layout column. -->
<div class="flex h-screen min-h-0 flex-col overflow-hidden" style:--ui-scale={appSettings.uiScale}>
Expand Down
1 change: 0 additions & 1 deletion ui/src/features/drawer/DrawerShelf.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
}: Props = $props();
</script>

<!-- svelte-ignore a11y_no_static_element_interactions -->
<div
class="drawer-shelf flex flex-none flex-col"
bind:clientHeight={null, (px) => onMeasure(px ?? 0)}
Expand Down
8 changes: 4 additions & 4 deletions ui/src/features/info/updateStore.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ export function latestVersion(): string {
* case, and by the time the user opens About the network may well be back. */
export async function checkForUpdate(force = false): Promise<void> {
// Untracked, and this must stay the only read of `phase` in this function:
// both callers run it from an `$effect`, so a tracked read would make that
// effect depend on the phase this function immediately sets. The effect
// re-runs, calls in again — and because 'failed' is not a terminal phase,
// a failing check would retry forever instead of once.
// both callers run it from `onMount`, which tracks nothing, but a caller in a
// reactive context would otherwise come to depend on the phase this function
// immediately sets. It would re-run, call in again — and because 'failed' is
// not a terminal phase, a failing check would retry forever instead of once.
const current = untrack(() => phase);
if (current === 'checking' || (current === 'checked' && !force)) return;
phase = 'checking';
Expand Down
12 changes: 6 additions & 6 deletions ui/src/features/knob/Knob.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,10 @@
<div class="flex w-16 flex-col items-center gap-2 text-center select-none">
<button
type="button"
class="knob-container relative grid size-11 cursor-ns-resize place-items-center transition-transform duration-300 ease-[cubic-bezier(.34,1.56,.64,1)] hover:scale-[1.08] focus:outline-none focus-visible:scale-[1.08] focus-visible:outline-none"
class:dragging
class:fine
class={[
'knob-container relative grid size-11 cursor-ns-resize place-items-center transition-transform duration-300 ease-[cubic-bezier(.34,1.56,.64,1)] hover:scale-[1.08] focus:outline-none focus-visible:scale-[1.08] focus-visible:outline-none',
{ dragging, fine },
]}
onkeyup={syncModifier}
onblur={() => (shiftHeld = false)}
onpointerdown={down}
Expand All @@ -150,12 +151,11 @@
{#if text}
<span class="knob-tooltip" role="tooltip">{text}</span>
{/if}
<span class="knob-ring" class:discrete={isDiscrete}>
<span class={['knob-ring', { discrete: isDiscrete }]}>
{#if isDiscrete}
{#each logicalSteps as stepValue, index (index)}
<span
class="detent"
class:active={index === activeDetent()}
class={['detent', { active: index === activeDetent() }]}
style="--detent-angle: {-135 + stepValue * 270}deg"
{@attach tooltip(valueStrings?.[index])}
></span>
Expand Down
31 changes: 14 additions & 17 deletions ui/src/features/knob/Switch.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,24 @@

const on = $derived(value >= 0.5);

let toggleText = $state<HTMLElement>();
let twoLines = $state(false);

// CSS cannot transition between an intrinsic one-line height and a wrapped
// two-line height. Measure the rendered text and switch between explicit
// heights so both expansion and contraction animate.
function updateTextHeight() {
if (!toggleText) return;
const lineHeight = Number.parseFloat(getComputedStyle(toggleText).lineHeight);
twoLines = toggleText.scrollHeight > lineHeight + 1;
}

$effect(() => {
text;
on;
// A frame late, so the new text has been laid out before it is measured;
// cancelled on teardown so a re-run or an unmount cannot measure a stale
// (or detached) element.
const frame = requestAnimationFrame(updateTextHeight);
// heights so both expansion and contraction animate. Attached to the text
// span, and re-attached whenever the text or the state changes (both are read
// here): a frame late, so the new text has been laid out before it is
// measured, and cancelled on teardown so a re-run or an unmount cannot
// measure a stale (or detached) element.
function measureLines(node: HTMLElement) {
void text;
void on;
const frame = requestAnimationFrame(() => {
const lineHeight = Number.parseFloat(getComputedStyle(node).lineHeight);
twoLines = node.scrollHeight > lineHeight + 1;
});
return () => cancelAnimationFrame(frame);
});
}
</script>

<div class="flex w-16 flex-col items-center gap-2 text-center select-none">
Expand All @@ -55,7 +52,7 @@
)}
>
<span
bind:this={toggleText}
{@attach measureLines}
class="line-clamp-2 max-w-full overflow-hidden leading-[1.15] [overflow-wrap:anywhere]"
>{text ?? (on ? 'ON' : 'OFF')}</span
>
Expand Down
Loading
Loading