Skip to content

Add feature-flagged optimistic updates for Check/NextClue#109

Draft
cmnord wants to merge 1 commit intomainfrom
codex/evaluate-and-plan-optimistic-updates-implementation
Draft

Add feature-flagged optimistic updates for Check/NextClue#109
cmnord wants to merge 1 commit intomainfrom
codex/evaluate-and-plan-optimistic-updates-implementation

Conversation

@cmnord
Copy link
Copy Markdown
Owner

@cmnord cmnord commented Feb 18, 2026

Motivation

  • Reduce UI latency for Check and NextClue actions by applying optimistic updates on the client while still reconciling against server-confirmed room events.
  • Provide a toggleable feature flag so optimistic behavior can be enabled per session/link without changing default behavior.
  • Avoid double-applying optimistic actions when the server echoes back the same event by reconciling via a client mutation id.

Description

  • Add optimisticDispatch plumbing and client-mutation-id tracking to useGameEngine, including pendingMutationIds bookkeeping, stale-mutation pruning, and applyServerAction that ignores server events with matching clientMutationId. (See app/engine/use-game-engine.ts.)
  • Expose optimisticDispatch on the engine context and wire useSoloGameEngine to pass a no-op implementation so solo mode remains unchanged. (See app/engine/use-engine-context.ts and app/engine/use-solo-game-engine.ts.)
  • Parse ?optimistic=1 in the room loader and pass optimisticEnabled into useGameEngine so optimistic updates can be enabled from the page. (See app/routes/room.$roomName.tsx.)
  • Update Check and NextClue UI to call optimisticDispatch before submitting and attach clientMutationId to form submissions, and extend their server routes to accept and persist an optional clientMutationId in the room event payloads. (See app/components/prompt/check-form.tsx, app/components/prompt/next-clue-form.tsx, app/routes/room.$roomId.check.tsx, and app/routes/room.$roomId.next-clue.tsx.)

Testing

  • Ran formatting with npm run format which completed successfully.
  • Ran lint with npm run lint which passed (there is one pre-existing ESLint warning in app/utils/user-settings.tsx).
  • Ran type checking with npm run typecheck which succeeded.
  • Ran unit tests with npm run test -- --run (Vitest) and all test suites passed.
  • Ran full npm run validate; E2E stage failed to start due to missing environment key SUPABASE_SERVICE_ROLE_KEY in this environment, which prevented Playwright from starting the web server (code path unrelated to these changes).

Codex Task

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 18, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
jep Ready Ready Preview, Comment Feb 18, 2026 5:06am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant