Files
hyperframes/packages/studio/src/utils/optimisticUpdate.ts
T
Miguel ÁngelandClaude Opus 4.8 adb40321d6 chore(studio): remove all console.* calls from studio package (#1691)
* chore(studio): remove all console.* calls from studio package

* chore(studio): address review — remove dead stubs, restore consent notice

- Delete empty if-blocks left after console removal (snapTargetCollection,
  Player asset-poll, useTimelineSyncCallbacks 5s probe, useGestureRecording
  dev guard + now-unused isDevBuild) and the stale "surface in dev" comment.
- Drop the dangling no-console pragma + dead duplicate-id branch in sourcePatcher.
- Restore the one-time telemetry consent disclosure in showNoticeOnce (kept
  behind a pragma — it is a user-facing notice, not debug noise).
- Remove the missed timelineIcons console.warn while preserving the
  `tag || "div"` null-safety fallback.
- Route caption auto-save failures (a data-loss path) through telemetry
  instead of swallowing silently.
- Restore the accidentally-clobbered css-var-fonts output.mp4 fixture.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 17:49:36 -04:00

18 lines
575 B
TypeScript

export interface OptimisticUpdateOptions<TSnapshot> {
/** Apply the change to local state immediately. Return a snapshot for rollback. */
apply: () => TSnapshot;
/** Persist the change to the server. */
persist: () => Promise<unknown>;
/** Revert local state using the snapshot if persist fails. */
rollback: (snapshot: TSnapshot) => void;
}
export async function executeOptimistic<T>(options: OptimisticUpdateOptions<T>): Promise<void> {
const snapshot = options.apply();
try {
await options.persist();
} catch {
options.rollback(snapshot);
}
}