Skip to content

feat: improve mocking and add react devtools#65

Draft
fwal wants to merge 5 commits into
mainfrom
claude/react-effect-atoms-mock-4lzbf8
Draft

feat: improve mocking and add react devtools#65
fwal wants to merge 5 commits into
mainfrom
claude/react-effect-atoms-mock-4lzbf8

Conversation

@fwal

@fwal fwal commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Summary

Develop pages against a static mock backend: seed hard-coded models through your real schemas, then toggle collections between data / empty / loading / error live from a devtools panel — no emulator required.

@effect-firebase/mock — implements the in-memory backend the README already described. Reactive SubscriptionRef store, so live streams re-emit on writes and state toggles. fixture() encodes models through their schema, MockController drives states/latency/seeding at runtime, and make() returns { layer, controller } for use outside the Effect runtime. Queries are evaluated in-process; server timestamps and field sentinels are honored. The existing stub stays exported.

@effect-firebase/devtools — new package: MockDevtoolsPanel (React) plus firestoreMockPlugin() for <TanStackDevtools> (structural interface, no TanStack dependency). onStateChange lets consumers re-subscribe streams that ended on a simulated error (terminal, like onSnapshot).

Example apppnpm example:mock seeds firestoreLayerAtom with the mock layer and mounts one devtools shell with the Router and Firestore Mock panels. Documented in REACT.md §7.

Testing

55 new specs (mock + devtools) and a Playwright run against pnpm example:mock covering live toggles, error recovery via refresh, and form writes flowing through the store. nx run-many -t lint,build,test green across all projects.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NFRv4LXEZkuAb5EzX5mhV6

claude added 5 commits July 19, 2026 22:44
…mulated states

Replaces the aspirational mock README with a real implementation:

- layer(): in-memory FirestoreService backed by a SubscriptionRef, so
  streamDoc/streamQuery are live — writes and state toggles re-emit
  through already-subscribed streams like onSnapshot
- fixture()/rawFixture(): seed hard-coded models encoded through the
  real schema pipeline so reads exercise actual decoding
- MockController service (provided by the same layer): toggle
  collections between data/empty/loading/error at runtime, seed docs,
  simulate latency, reset — the control surface for a future devtools
  panel
- In-process query evaluation (where/orderBy/limits/cursors/and/or)
  with Firestore type ordering
- Write fidelity: ServerTimestamp materialized via Clock, Delete/
  ArrayUnion/ArrayRemove sentinels honored, not-found on update,
  recursive delete

The existing MockFirestoreService stub remains exported for
backwards compatibility.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NFRv4LXEZkuAb5EzX5mhV6
- @effect-firebase/devtools: new package with MockDevtoolsPanel, a React
  panel that lists collections with doc counts and toggles each between
  data/empty/loading/error, picks the simulated error code, controls
  latency, and resets to fixtures — subscribed live to the mock store
- firestoreMockPlugin(controller): plugin factory for
  <TanStackDevtools plugins={[...]}>; the plugin interface is declared
  structurally so TanStack Devtools is not a dependency
- mock: add make() returning { layer, controller } so code outside the
  Effect runtime (devtools, Storybook, tests) can drive the same store
  the app's layer provides; layer() now builds on make() with
  fresh-per-provide semantics preserved
- mock: add controller.latency getter for the panel's latency display

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NFRv4LXEZkuAb5EzX5mhV6
Based on the atom-based example app from claude/vigilant-pascal-qgjsm4
(merged): the Firestore layer is swappable at the registry boundary via
firestoreLayerAtom, so mock mode is one initialValues entry.

- example/app/src/lib/mock.ts: mock backend handle with schema-encoded
  Post/Author fixtures
- app.tsx: VITE_MOCK_BACKEND=1 seeds firestoreLayerAtom with the mock
  layer instead of the emulator client; a single TanStack Devtools shell
  now hosts the router panel plus the Firestore Mock panel, with
  onStateChange refreshing latestPostsAtom so streams that ended on a
  simulated error re-subscribe
- mock: implement withTransaction/withBatch (pass-through — no
  concurrency or staging semantics to simulate)
- devtools: pin explicit heights on panel elements so shell CSS resets
  that stretch divs cannot distort the layout
- pnpm example:mock script; REACT.md section 7 documents the workflow

Verified end-to-end in a real browser: fixtures render through atoms,
empty/loading/error toggle live from the panel, data recovers after a
terminal stream error via refresh, and form writes flow through the
repository into the live stream (doc counts update in the panel).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NFRv4LXEZkuAb5EzX5mhV6
…toms-mock-4lzbf8

# Conflicts:
#	example/app/package.json
#	pnpm-lock.yaml
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5e8e06e0-5acc-41da-a0c2-a3e0c1fb7624

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@fwal fwal changed the title feat: reactive mock backend with fixtures, simulated states, and a TanStack Devtools panel feat: improve mocking and add react devtools Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants