diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e3c436..6a8fbde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,24 @@ # Changelog +## 0.2.0-next.19 + +- Rows no longer pop out and back in when you add several quickly. The doorbell + says "something changed" without saying which row, so an app reloads its whole + list on every ping — and a reload issued while the app's own inserts are still + in flight comes back *without* them, replacing what's on screen with a snapshot + missing rows the user already added. Measured on a live app: a row was absent + for 200ms before reappearing. It's a lost-update race, not latency; an + instantaneous network would still return a snapshot lacking uncommitted rows. + + The SDK now withholds the reload signal while this client's own writes are + landing and fires once when they drain, plus a short trailing coalesce so a + burst collapses into one reload (the trigger fires per changed *row*, so a bulk + write produces N pings for one logical refresh). A ceiling bounds the hold so + continuous local editing can't starve the app of other users' changes. + + **No app changes needed** — the existing `subscribe(() => load())` pattern + simply stops flickering. Apps pick this up on their next publish. + ## 0.2.0-next.18 - `bool create` now verifies the new project can be developed against *before* diff --git a/package.json b/package.json index 9e7bf86..1afcd71 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bool-sdk", - "version": "0.2.0-next.18", + "version": "0.2.0-next.19", "description": "Client SDK for apps built on Bool — gateway data access, end-user auth, the AI battery, the React auth layer, and the local-dev CLI (link, types, deploy).", "type": "module", "main": "./dist/index.js", diff --git a/src/client.ts b/src/client.ts index a6e822b..5d27db9 100644 --- a/src/client.ts +++ b/src/client.ts @@ -30,6 +30,16 @@ const GATEWAY_API = "v1"; // used, and the server never returns a token), so it's never exposed there. const EU_SESSION_KEY = "bool_eu_session_token"; +/** Collapse a burst of doorbell pings into one reload. The trigger fires once per + * changed ROW, so a bulk write produces N pings for what the app should treat as + * a single refresh. */ +const PING_COALESCE_MS = 50; + +/** Never hold a ping longer than this, even with writes still in flight — + * otherwise someone editing continuously would stop seeing other people's + * changes for as long as they kept typing. */ +const MAX_HOLD_MS = 2000; + /** True when `host` is a single-label deployment subdomain of `appHost` (e.g. * "acme.bool.so" under "bool.so") — the exact shape the platform proxy rewrites * to /served/