エクスクルーシブ

Bench Sync <mv-bench-sync>

保留中の変更を明示し、休憩ポイントでのみ送信するローカルファーストの同期ステータス。

文化的リファレンス

Hollow Knight、Team Cherry(2017年、ゲーム)。探索すると新しいエリアが明らかになりますが、マップに発見が記録されるのはベンチに座って休んだときだけです。それまでの発見は保留状態で、失われる可能性があります。UI では、ローカルの変更が目に見える形でキューに溜まり、休憩ポイント(入力の一時停止、タブを離れたとき、再接続、明示的な同期)でのみサーバーにコミットされます。キー入力の途中で送信されることはなく、失敗や競合は解決されるまでキューに残ります。

仕組み

保留中の変更を明示し、休憩ポイントでのみ送信するローカルファーストの同期ステータス。アプリはすべてのローカル変更を queue({ entity, label, key, data }) で記録し(同じ key はまとめられ、「4 edits」となります)、部分的に失敗しうる非同期の sync(changes) を提供します。コンパクトなチップには Synced · 3 pending · Syncing… · Offline · 1 conflict と表示され、入力をやめるとアイコンの周りのリングが次の休憩ポイントに向かって満ちていきます。変更が送信されるのは、入力も押下もない idle 秒が経過したとき、タブが非表示になったとき、再接続時、または「Sync now」の操作時だけで、キー入力の途中には決して送信されません。max-wait は古いキューに対して待ち時間を短縮し、manual は送信を明示的な公開操作に変えます。パネルには保留中の変更がエンティティごとにまとめて、経過時間、ステータス、破棄ボタンとともに一覧表示されます。失敗した変更は理由とともにキューに残り、ジッター付きの指数バックオフで再試行されます。拒否された変更は Retry を待ちます。競合はキャンセル可能な mv-conflict を通じて、もう一方のバージョンを「Keep mine / Keep theirs」とともに表示し、その waitUntil(promise) によって処理中の状態が表示されます。接続状態は navigator.onLine と任意のハートビート URL から判断されます(またはアプリから強制指定)。キューは localStorage または IndexedDB に保存され、Web Lock によってタブ間で共有されるため、送信するのは1つのタブだけです。beforeunload ガードは保留中の変更がある間だけ設定されます。

カテゴリーフィードバック
タイプWeb Component(<mv-bench-sync>)
ステータス安定版
キット誠実なシステム状態
同時にインストールされるものbutton
Keywordsexclusive, culture, sync, offline, offline-first, local-first, pwa, queue, outbox, autosave, idle, retry, backoff, conflict, conflict-resolution, status, connectivity, indexeddb, web-locks, beforeunload

When to use

  • A field, inspection or delivery app must keep working on a flaky mobile network and show exactly what has not reached the server
  • A notes app, spreadsheet or PWA saves locally first and should sync in batches when the user pauses, not on every keystroke
  • Edits from several devices can collide and the user must choose which version wins, change by change
  • An editor publishes local changes explicitly and needs a reviewable list of what the next publish will send

Avoid when

  • The risk is leaving a form with unsaved edits that are not queued anywhere yet → use Tell-Tale instead
  • Form drafts must be restored after a crash or reload rather than pushed to a server → use Bloodstain instead
  • The app saves each change with an immediate request and can simply show a spinner or an error on failure

インストール

node scripts/add.mjs bench-sync --out ./src/marvelous

Marvelous UI の MCP サーバーを使う AI エージェント:install_components({ slugs: ["bench-sync"], target_dir: "<absolute path>/src/marvelous", framework: "react" })。

コピーされるファイル(依存関係を含む):tokens/tokens.css, core/base.css, components/button/button.css, core/dismiss.js, core/dom.js, core/element.js, core/motion.js, core/position.js, components/bench-sync/bench-sync.js, components/bench-sync/bench-sync.css。

使い方

クイックスタート、動作する最小限のマークアップ:

<mv-bench-sync persist="notes"></mv-bench-sync>
<script type="module">
  await customElements.whenDefined("mv-bench-sync"); const bench = document.querySelector("mv-bench-sync");
  bench.sync = (changes) => fetch("/api/sync", { method: "POST", body: JSON.stringify(changes) }).then((r) => { if (!r.ok) throw r; });
  bench.queue({ entity: "note", key: "title", label: "Title → Q3 plan" }); // on every local edit
</script>

基本となるマークアップです。ここから属性、data-*、CSS 変数でカスタマイズしてください:

<div id="bs-demo" style="width:min(100%,68rem);margin-inline:auto">
  <style>
    #bs-demo .bs-layout { display:grid; grid-template-columns:minmax(0,1fr) 23.5rem; gap:1.25rem; align-items:start }
    #bs-demo .bs-app { border:1px solid var(--mv-border); border-radius:var(--mv-radius-xl); background:var(--mv-surface); box-shadow:var(--mv-shadow-sm); overflow:hidden }
    #bs-demo .bs-bar { display:flex; align-items:center; gap:.875rem; height:3.5rem; padding:0 .875rem 0 1.125rem; border-bottom:1px solid var(--mv-border) }
    #bs-demo .bs-brand { display:flex; align-items:center; gap:.5rem; font-weight:650; font-size:.9375rem; letter-spacing:-.01em }
    #bs-demo .bs-logo { display:grid; place-items:center; width:1.75rem; height:1.75rem; border-radius:var(--mv-radius-md); background:var(--mv-accent); color:var(--mv-fg-on-accent) }
    #bs-demo .bs-logo svg { width:1rem; height:1rem }
    #bs-demo .bs-crumb { color:var(--mv-fg-muted); font-size:.8125rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis }
    #bs-demo .bs-end { display:flex; align-items:center; gap:.625rem; margin-inline-start:auto }
    #bs-demo .bs-me { display:grid; place-items:center; width:2rem; height:2rem; border-radius:50%; background:var(--mv-bg-emphasis); color:var(--mv-fg); font-size:.75rem; font-weight:600; flex:none }
    #bs-demo .bs-body { display:grid; gap:1rem; padding:1.125rem 1.125rem 1.25rem }
    #bs-demo .bs-title { display:flex; align-items:flex-start; justify-content:space-between; gap:.75rem }
    #bs-demo .bs-title h4 { margin:0; font-size:1rem; letter-spacing:-.01em }
    #bs-demo .bs-title p { margin:.1875rem 0 0; color:var(--mv-fg-muted); font-size:.8125rem }
    #bs-demo .bs-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:.875rem }
    #bs-demo .bs-grid .bs-wide { grid-column:1 / -1 }
    #bs-demo .bs-checks { display:flex; flex-wrap:wrap; gap:.5rem 1.25rem; margin:0; padding:.75rem .875rem; border:1px solid var(--mv-border); border-radius:var(--mv-radius-lg); background:var(--mv-bg-subtle) }
    #bs-demo .bs-checks legend { float:left; width:100%; margin:0 0 .375rem; padding:0; font-size:.8125rem; font-weight:500 }
    #bs-demo .mv-choice { font-size:.8125rem }
    #bs-demo textarea { min-height:4.5rem; resize:vertical }
    #bs-demo .bs-controls { display:grid; gap:.625rem; padding:.875rem 1.125rem; border-top:1px solid var(--mv-border); background:var(--mv-bg-subtle) }
    #bs-demo .bs-row { display:flex; align-items:center; gap:.625rem 1.25rem; flex-wrap:wrap }
    #bs-demo .bs-hint { margin:0; color:var(--mv-fg-muted); font-size:.75rem; line-height:1.45 }
    #bs-demo .bs-log { display:grid; gap:.25rem; min-height:4.25rem; margin:0; padding:0; list-style:none; font:.75rem/1.4 var(--mv-font-mono); color:var(--mv-fg-muted) }
    #bs-demo .bs-log li { display:flex; gap:.625rem; min-width:0 }
    #bs-demo .bs-log time { color:var(--mv-fg-subtle); flex:none }
    #bs-demo .bs-log b { color:var(--mv-fg); font-weight:600; flex:none }
    #bs-demo .bs-log span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap }
    #bs-demo .bs-side { display:grid; gap:.75rem }
    #bs-demo .bs-side-head { display:grid; gap:.125rem; padding:0 .25rem }
    #bs-demo .bs-side-head strong { font-size:.9375rem; letter-spacing:-.01em }
    #bs-demo .bs-side-head span { color:var(--mv-fg-muted); font-size:.8125rem }
    @media (max-width:60rem) {
      #bs-demo .bs-layout { grid-template-columns:minmax(0,1fr) }
    }
    @media (max-width:36rem) {
      #bs-demo .bs-grid { grid-template-columns:minmax(0,1fr) }
      #bs-demo .bs-crumb { display:none }
    }
  </style>

  <div class="bs-layout">
    <!-- Main: a field inspection app on a flaky network. Changes sync when the technician pauses for 4 s. -->
    <section class="bs-app" aria-label="Field inspection app">
      <header class="bs-bar">
        <span class="bs-brand">
          <span class="bs-logo" aria-hidden="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3c3 4 6 7 6 11a6 6 0 0 1-12 0c0-4 3-7 6-11Z"/></svg></span>
          Fieldbook
        </span>
        <span class="bs-crumb">Inspections / WO-3317</span>
        <span class="bs-end">
          <mv-bench-sync id="bs-main" idle="4s" max-wait="15m" retry="3s"></mv-bench-sync>
          <span class="bs-me" aria-hidden="true">AO</span>
        </span>
      </header>

      <form class="bs-body" id="bs-form" onsubmit="event.preventDefault()">
        <div class="bs-title">
          <div>
            <h4>Pump station 12 · Riverside</h4>
            <p>Quarterly inspection · Wed, Sep 24, 2026 · Amara Okafor</p>
          </div>
          <span class="mv-badge" data-variant="warning">In progress</span>
        </div>
        <div class="bs-grid">
          <div class="mv-field">
            <label class="mv-label" for="bs-pressure">Inlet pressure (bar)</label>
            <input class="mv-input" id="bs-pressure" inputmode="decimal" value="3.4" data-key="pressure" data-entity="readings" data-name="Inlet pressure" data-unit=" bar">
          </div>
          <div class="mv-field">
            <label class="mv-label" for="bs-flow">Flow rate (L/s)</label>
            <input class="mv-input" id="bs-flow" inputmode="decimal" value="18.6" data-key="flow" data-entity="readings" data-name="Flow rate" data-unit=" L/s">
          </div>
          <div class="mv-field">
            <label class="mv-label" for="bs-condition">Condition</label>
            <select class="mv-select" id="bs-condition" data-key="condition" data-entity="readings" data-name="Condition">
              <option>Good</option>
              <option selected>Needs attention</option>
              <option>Needs repair</option>
            </select>
          </div>
          <fieldset class="bs-checks bs-wide">
            <legend>Checklist</legend>
            <label class="mv-choice"><input type="checkbox" class="mv-checkbox" data-key="check-seals" data-entity="order" data-name="Valve seals inspected" checked> Valve seals inspected</label>
            <label class="mv-choice"><input type="checkbox" class="mv-checkbox" data-key="check-generator" data-entity="order" data-name="Backup generator tested"> Backup generator tested</label>
            <label class="mv-choice"><input type="checkbox" class="mv-checkbox" data-key="check-signage" data-entity="order" data-name="Safety signage in place" checked> Safety signage in place</label>
          </fieldset>
          <div class="mv-field bs-wide">
            <label class="mv-label" for="bs-notes">Technician notes</label>
            <textarea class="mv-textarea" id="bs-notes" data-key="notes" data-entity="order" data-name="Notes">Slight weep at the inlet valve gasket. Replacement ordered, revisit within 14 days.</textarea>
          </div>
        </div>
      </form>

      <div class="bs-controls">
        <div class="bs-row">
          <label class="mv-choice"><input type="checkbox" role="switch" class="mv-switch" id="bs-net" checked> Network</label>
          <label class="mv-choice"><input type="checkbox" role="switch" class="mv-switch" id="bs-fail"> Server errors</label>
          <button type="button" class="mv-button" data-variant="outline" data-size="sm" id="bs-conflict">Conflict on next sync</button>
          <button type="button" class="mv-button" data-variant="ghost" data-size="sm" id="bs-open">Open sync status</button>
        </div>
        <p class="bs-hint">Type in any field: nothing is sent while you type. Pause for 4 seconds and the ring around the cloud fills, then your changes sync as one batch. Turn the network off to keep working offline.</p>
        <ol class="bs-log" id="bs-log" aria-label="Event log"></ol>
      </div>
    </section>

    <!-- Inline + manual: a menu editor that publishes reviewed changes explicitly. -->
    <aside class="bs-side" aria-label="Menu editor">
      <div class="bs-side-head">
        <strong>Menu editor · Harbor Street Café</strong>
        <span>Drafts stay on this device until you publish.</span>
      </div>
      <mv-bench-sync id="bs-publish" inline manual guard="false"></mv-bench-sync>
    </aside>
  </div>

  <script type="module">
    await customElements.whenDefined("mv-bench-sync");
    const main = document.getElementById("bs-main");
    const publish = document.getElementById("bs-publish");
    const form = document.getElementById("bs-form");
    const net = document.getElementById("bs-net");
    const fail = document.getElementById("bs-fail");
    const log = document.getElementById("bs-log");
    const wait = (ms) => new Promise((r) => setTimeout(r, ms));
    const ago = (min) => Date.now() - min * 60_000;
    const clock = () => new Date().toLocaleTimeString("en-US", { hour: "numeric", minute: "2-digit", second: "2-digit" });
    const say = (name, text) => {
      const li = document.createElement("li");
      const t = document.createElement("time");
      const b = document.createElement("b");
      const s = document.createElement("span");
      t.textContent = clock();
      b.textContent = name;
      s.textContent = text;
      li.append(t, b, s);
      log.prepend(li);
      while (log.children.length > 3) log.lastElementChild.remove();
    };
    const plural = (n, w) => `${n} ${w}${n === 1 ? "" : "s"}`;

    /* ── Field app ─────────────────────────────────────── */
    const ENTITIES = { readings: "Pump station 12 · Readings", order: "Work order WO-3317", photos: "Photos" };
    const THEIRS = {
      pressure: "Inlet pressure → 3.1 bar",
      flow: "Flow rate → 17.9 L/s",
      condition: "Condition → Needs repair",
      notes: "Notes · “Gasket replaced on site, no leak.”",
    };
    let conflictNext = false;

    main.sync = async (changes) => {
      await wait(900);
      if (fail.checked) throw new Error("503 Service Unavailable");
      if (conflictNext) {
        conflictNext = false;
        const c = changes.find((x) => THEIRS[x.key]) ?? changes[0];
        return { conflicts: [{ id: c.id, reason: "Also changed by Priya Nair on a tablet", theirs: THEIRS[c.key] ?? `${c.label.split(" →")[0]} (their edit)` }] };
      }
    };

    main.queue({ entity: "photos", entityLabel: ENTITIES.photos, key: "photo-inlet", label: "inlet-valve.jpg · 2.1 MB", createdAt: ago(7) });
    main.queue({ entity: "readings", entityLabel: ENTITIES.readings, key: "pressure", label: "Inlet pressure → 3.4 bar", createdAt: ago(4), edits: 2 });
    main.queue({ entity: "order", entityLabel: ENTITIES.order, key: "check-seals", label: "Valve seals inspected → checked", createdAt: ago(2) });
    say("queue", "3 changes recorded offline in the basement, waiting for a pause");

    const describe = (el) => {
      const name = el.dataset.name;
      if (el.type === "checkbox") return `${name} → ${el.checked ? "checked" : "unchecked"}`;
      if (el.tagName === "TEXTAREA") {
        const v = el.value.trim().replace(/\s+/g, " ");
        return `${name} · “${v.length > 38 ? `${v.slice(0, 38)}…` : v}”`;
      }
      return `${name} → ${el.value}${el.dataset.unit ?? ""}`;
    };
    form.addEventListener("input", (e) => {
      const el = e.target.closest("[data-key]");
      if (!el) return;
      main.queue({ entity: el.dataset.entity, entityLabel: ENTITIES[el.dataset.entity], key: el.dataset.key, label: describe(el), data: { value: el.type === "checkbox" ? el.checked : el.value } });
    });

    net.addEventListener("change", () => { main.connection = net.checked ? "auto" : "offline"; });
    document.getElementById("bs-conflict").addEventListener("click", (e) => {
      conflictNext = true;
      e.currentTarget.textContent = "Conflict armed";
      if (!main.pending) main.queue({ entity: "readings", entityLabel: ENTITIES.readings, key: "condition", label: "Condition → Good" });
    });
    document.getElementById("bs-open").addEventListener("click", (e) => { e.stopPropagation(); main.open(); });

    main.addEventListener("mv-sync-start", (e) => say("sync-start", `${plural(e.detail.changes.length, "change")} · ${e.detail.reason}`));
    main.addEventListener("mv-sync-done", (e) => {
      const { synced, failed, conflicts } = e.detail;
      say("sync-done", `${synced.length} synced · ${failed.length} failed · ${conflicts.length} conflict`);
      if (conflicts.length) document.getElementById("bs-conflict").textContent = "Conflict on next sync";
    });
    main.addEventListener("mv-offline", (e) => say("offline", `${plural(e.detail.pending, "change")} kept on device`));
    main.addEventListener("mv-online", () => say("online", "syncing at the next pause"));
    main.addEventListener("mv-conflict", (e) => {
      say("conflict", `keep ${e.detail.choice}`);
      e.detail.waitUntil(wait(500));
    });

    /* ── Menu editor (manual publish) ──────────────────── */
    publish.strings = {
      syncNow: "Publish",
      syncing: "Publishing…",
      titlePending: { one: "1 change ready to publish", other: "{n} changes ready to publish" },
      textManual: "Saved as a draft on this device. Nothing goes live until you press {syncNow}.",
      statusPending: "Draft",
      titleSynced: "Menu is live and up to date",
      textSynced: "Every change is published. New edits are kept as drafts until you publish.",
    };
    publish.sync = async (changes) => { await wait(1100); };
    publish.queue({ entity: "cold-brew", entityLabel: "Cold brew", key: "cb-price", label: "Price $4.25 → $4.50", createdAt: ago(21), status: "conflict", reason: "Also changed by Marco Rossi", theirs: "Price $4.25 → $4.40 · 10 min ago" });
    publish.queue({ entity: "flat-white", entityLabel: "Oat milk flat white", key: "fw-price", label: "Price $4.50 → $4.75", createdAt: ago(14) });
    publish.queue({ entity: "flat-white", entityLabel: "Oat milk flat white", key: "fw-size", label: "New size · Large 16 oz, $5.25", createdAt: ago(12) });
    publish.queue({ entity: "pumpkin", entityLabel: "Pumpkin spice latte", key: "psl-desc", label: "Description rewritten", createdAt: ago(9), edits: 3 });
    publish.queue({ entity: "matcha", entityLabel: "Iced matcha latte", key: "ml-photo", label: "Photo · matcha-latte.png", createdAt: ago(33), status: "rejected", reason: "image is larger than 5 MB" });
    publish.addEventListener("mv-conflict", (e) => e.detail.waitUntil(wait(600)));
  </script>
</div>

API

Attributes

NameタイプDefaultDescription
idletime ("4s", "1500ms", ms number)4sRest point: how long without typing, IME composition or a pressed pointer anywhere in the page before pending changes are pushed. The ring around the chip icon fills over this time (clamped from 300 ms to 1 h).
max-waittime2mOnce the oldest pending change is this old, a brief pause (1 s) is enough instead of the full idle time, so long typing sessions still sync. Syncing never interrupts an ongoing keystroke burst. 0 disables it.
manualbooleanExplicit publish: nothing is pushed automatically (no idle, hidden-tab, reconnect or retry sync); only “Sync now” or syncNow(). Rename the button with strings.syncNow ("Publish").
inlinebooleanRenders the panel in the page flow (always visible, role="region") instead of a chip with a popover: sidebars, mobile screens, publish reviews.
persiststringStorage key for the queue and the last sync time. Pending changes survive reloads and crashes, and tabs using the same key share one queue. Without it the queue lives in memory only.
storagelocal | indexeddblocalWhere persist writes: localStorage (synchronous, shared live across tabs) or IndexedDB (larger payloads; falls back to localStorage on error). Payloads must be JSON-serializable; never queue secrets.
connectionauto | online | offlineautoauto uses navigator.onLine, the online/offline events and the optional heartbeat. online / offline force the state when the app has its own connectivity signal (native bridge, socket state).
heartbeatURLOptional same-origin endpoint probed with a HEAD request (no-store, 5 s timeout). Any answer below 500 means reachable; a network error or 5xx shows “Server unreachable” and counts as offline until a probe succeeds (backoff 3 s → 60 s).
heartbeat-intervaltime30sProbe period while reachable and visible (minimum 5 s). Probing pauses in hidden tabs.
retrytime2sBase delay of the exponential backoff after a failed sync (2 s, 4 s, 8 s… with ±20% jitter). Retries still wait for a pause in typing.
retry-maxtime5mCap of the backoff delay.
guard"true" | "false"trueAttach a beforeunload confirmation while changes are pending (only then, so the back-forward cache stays usable when everything is synced).
placementbottom-end | bottom-start | bottom | top-end | top-start | topbottom-endPreferred side of the popover panel relative to the chip (flips and shifts to stay in the viewport).
data-statesynced | pending | syncing | offline | conflict | errorSet by the component (styleable). data-offline is added whenever the connection is down, data-resting while the rest ring fills, data-manual in manual mode.

Properties

NameタイプDescription
sync(changes, { reason }) => Promise<void | false | { failed?, conflicts? }>Your push function. It receives copies of the pending and failed changes. Resolve with nothing to mark all as synced; return { failed: [id | { id, reason, retry? }], conflicts: [id | { id, reason, theirs }] } for partial results (anything not listed is synced; retry: false means refused, no automatic retry). Throwing or returning false fails the whole batch and schedules a retry. A change edited again while in flight stays pending.
changesChange[]Copies of the queued changes, oldest first (read-only): { id, entity, entityLabel, label, key, data, createdAt, updatedAt, edits, attempts, status: pending | failed | rejected | conflict, reason, theirs, resolution }.
pendingnumberNumber of changes not yet synced (read-only).
statestringCurrent data-state value (read-only).
onlinebooleanEffective connectivity (read-only).
syncingbooleanTrue while a push is in flight (read-only).
lastSyncedDate | nullTime of the last successful push (persisted with persist).
stringsPartial<Record<string, string | { zero?, one, other }>>Overrides for every visible text and announcement; plural keys take { one, other } (and zero). Keys include chipSynced, chipPending, chipSyncing, chipOffline, chipConflict, chipError, chipDone, title*, text*, syncNow, keepMine, keepTheirs, retry, discardLabel, status*, theirs, edits, lastSynced, agoNow/agoSec/agoMin/agoHour and announce*. English defaults.

Methods

NameDescription
queue(change)Records a local mutation and returns its id. change: { entity, label, entityLabel?, key?, id?, data?, createdAt? }. A queued change with the same key (or id) is updated in place (latest label and data win, edits counts up). status, reason and theirs can be passed to restore a queue from your own store.
syncNow()Pushes every pending and failed change now, ignoring the rest point and the backoff (still requires being online). Returns Promise<{ synced, failed, conflicts } | null>.
discard(id)Drops a change without syncing it, after a cancelable mv-discard (revert your local state there). Not possible while the change is in flight.
resolve(id, "mine" | "theirs")Answers a conflict like the panel buttons: emits the cancelable mv-conflict, waits for its waitUntil promises, then mine re-queues the change with resolution "mine" (your sync should overwrite) and pushes it, theirs drops it. Returns Promise<boolean>.
retryChange(id)Puts a failed or refused change back in line and syncs now.
clear()Empties the queue without events (e.g. on sign-out).
open() / close()Opens or closes the popover panel.

Events

NameDescription
mv-queueA change was queued. detail: { change, coalesced }.
mv-sync-startCancelable, before a push. detail: { changes, reason: "idle" | "max-wait" | "hidden" | "online" | "retry" | "manual" | "resolve", waitUntil(promise) }. Without a sync property, push from here and pass the promise (its result has the same shape). preventDefault() skips this rest point until there is new work.
mv-sync-doneA push settled. detail: { synced, failed, conflicts, reason, duration } (arrays of change copies).
mv-conflictCancelable, when the user picks Keep mine / Keep theirs (or resolve() is called). detail: { change, choice, theirs, waitUntil(promise) }. Apply the server version for theirs here; a rejected promise keeps the conflict and shows an error. preventDefault() leaves it unresolved.
mv-discardCancelable, before a change is dropped. detail: { change }.
mv-offlineThe connection went down. detail: { reason: "network" | "unreachable" | "forced", pending }.
mv-onlineThe connection is back (a sync follows at the next brief pause). detail: { offlineFor, pending }.
mv-statedata-state changed. detail: { state, pending }.

CSS classes

NameDescription
mv-bench-sync-chipThe status chip (<button>, aria-expanded): -chip-icon (with the .mv-bench-sync-rest ring svg and .mv-bench-sync-icon), -chip-text, -chip-more (secondary count).
mv-bench-sync-panelPopover panel (or inline region): -head, -head-icon, -title, -text, -list, -empty, -foot, -net (+ -net-dot, -net-text), -now (Sync now button).
mv-bench-sync-groupOne entity: -group-head (-group-name, -group-count) and the -items list.
mv-bench-sync-itemOne change, data-status="pending | syncing | failed | rejected | conflict | resolving": -mark (status shape), -item-label, -item-edits, -item-meta (age · status), -item-extra (other version or error), -item-actions, -discard.

CSS variables

NameDefaultDescription
--mv-bench-sync-syncedvar(--mv-success)Synced tone (chip icon, online dot).
--mv-bench-sync-pendingvar(--mv-accent)Pending and syncing tone (rest ring, pending marks).
--mv-bench-sync-offlinevar(--mv-fg-muted)Offline tone.
--mv-bench-sync-conflictvar(--mv-warning)Conflict tone (chip tint, diamond marks).
--mv-bench-sync-errorvar(--mv-danger)Failed and refused tone.
--mv-bench-sync-list-height19remMax height of the scrollable change list.

Accessibility

The chip is a real <button> whose accessible name is its visible text (“3 pending”, “Offline · 3 pending”, “1 conflict”) with aria-expanded / aria-controls, and it is described by a visually hidden summary (“3 changes waiting to sync. Online. Last synced 2 min ago.”) that is read on demand, never live. A separate visually hidden role="status" region speaks only on transitions: going offline (with the number of changes kept on the device), back online, a completed sync with its count (routine idle syncs at most once a minute), the first failure of a streak with the retry delay, refused changes and discards; conflicts go to an assertive region. Pending counts and the rest ring never announce. The popover panel is a labelled non-modal dialog placed right after the chip in the DOM, so Tab reaches it naturally; Escape closes it and returns focus to the chip, an outside click closes it. The inline variant is a labelled region. Each entity is a labelled group and each change a list item with native buttons: “Keep mine / Keep theirs”, Retry, and a discard button named after the change (“Discard change: Inlet pressure → 3.4 bar”); buttons that cannot act (in flight, resolving, offline Sync now) stay focusable with aria-disabled, and a pending resolution sets aria-busy. When the focused row leaves (synced or discarded), focus moves to the next row’s discard button, then to Sync now or the chip. State is never color-only: every state has its own icon and words, row marks differ in shape (dot, ring, hollow dot, square, diamond) and the meta line names the status. Reduced motion (OS or data-motion="reduce"): no spinning icons, the rest ring shows as a static dotted ring, rows appear and leave without animation. Forced colors keep the ring, marks and dots visible with system colors. Times older than a day show as a short date in the language of the nearest lang attribute (en-US by default).

このページは AI で翻訳されています。翻訳の問題を報告