From 60e27bb80fbbeb2cc10e796a36db71d4fa181646 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Valverd=C3=A9?= Date: Mon, 24 Aug 2026 03:05:21 +0200 Subject: [PATCH] Improve AI docs --- packages/effect-view/AGENTS.md | 3 --- packages/effect-view/ai-docs/Refreshable.md | 7 ------- packages/effect-view/ai-docs/ScopeRegistry.md | 7 ------- packages/effect-view/ai-docs/SetStateAction.md | 9 --------- packages/effect-view/ai-docs/State.md | 2 +- 5 files changed, 1 insertion(+), 27 deletions(-) delete mode 100644 packages/effect-view/ai-docs/Refreshable.md delete mode 100644 packages/effect-view/ai-docs/ScopeRegistry.md delete mode 100644 packages/effect-view/ai-docs/SetStateAction.md diff --git a/packages/effect-view/AGENTS.md b/packages/effect-view/AGENTS.md index 59e6382..4e8d29c 100644 --- a/packages/effect-view/AGENTS.md +++ b/packages/effect-view/AGENTS.md @@ -36,9 +36,6 @@ When writing effect-view code, use the actual current source and tests in `src/` **Small utilities**: - bridging React-tracked values into an Effect `PubSub` → [PubSub.md](./ai-docs/PubSub.md) - consuming a raw Effect `Stream` as React state → [Stream.md](./ai-docs/Stream.md) -- resolving a `React.SetStateAction` against a previous value → [SetStateAction.md](./ai-docs/SetStateAction.md) - -**Building dev tooling for effect-view itself** (not application code) → [ScopeRegistry.md](./ai-docs/ScopeRegistry.md) (component scope bookkeeping), [Refreshable.md](./ai-docs/Refreshable.md) (hot-reload integration) ## Choosing between async integrations diff --git a/packages/effect-view/ai-docs/Refreshable.md b/packages/effect-view/ai-docs/Refreshable.md deleted file mode 100644 index 5e99cf0..0000000 --- a/packages/effect-view/ai-docs/Refreshable.md +++ /dev/null @@ -1,7 +0,0 @@ -# Refreshable - -**Low-level module for development-server integrations** (e.g. `@effect-view/vite-plugin`'s hot-reload support). Not used directly in application code. - -`Refreshable.attach(component, cell)` connects a `Component` descriptor to a mutable "refresh cell" (`Refreshable.makeCell(component, signature, forceReset)`) that a dev-server integration updates as source files change. The attached component renders through a stable wrapper that swaps in the cell's current implementation on each update, using `React.useSyncExternalStore` to trigger a re-render and, when `signature` changes or `forceReset` is set, remounting the component (via a changed `key`) to discard React state that can no longer be trusted to match the new code. - -If you are writing a bundler/dev-server integration for effect-view, this is the API to build on. Otherwise, ignore this module. diff --git a/packages/effect-view/ai-docs/ScopeRegistry.md b/packages/effect-view/ai-docs/ScopeRegistry.md deleted file mode 100644 index 775e015..0000000 --- a/packages/effect-view/ai-docs/ScopeRegistry.md +++ /dev/null @@ -1,7 +0,0 @@ -# ScopeRegistry - -**Internal module — not part of the application-facing API.** Do not use this directly in application code; it exists to support `Component`'s lifecycle hooks (`Component.useScope` and everything built on it). - -`ScopeRegistry` is an Effect service (auto-provided by `ReactRuntime.make` via `ReactRuntime.preludeLayer`) that tracks the `Scope.Scope` associated with each mounted component instance: `register` creates one, `commit` marks it as "React has committed this render" (cancelling its abandonment timeout), and `release` schedules it for closure after `finalizerExecutionDebounce` once the owning component/dependency-set unmounts. A background loop closes scopes whose debounce has elapsed and force-closes any scope left uncommitted past `scopeCommitTimeout` (guards against an abandoned render, e.g. one thrown away by React Strict Mode or a Suspense retry). - -Relevant only if you're building low-level tooling around effect-view's rendering internals. diff --git a/packages/effect-view/ai-docs/SetStateAction.md b/packages/effect-view/ai-docs/SetStateAction.md deleted file mode 100644 index f041bd5..0000000 --- a/packages/effect-view/ai-docs/SetStateAction.md +++ /dev/null @@ -1,9 +0,0 @@ -# SetStateAction - -A single helper for resolving React's `SetStateAction` (`S | ((prev: S) => S)`) against a previous value — the same logic `React.useState`'s setter applies internally. - -```ts -SetStateAction.value(setStateAction, prevState) // dual API, also curried: SetStateAction.value(prevState)(setStateAction) -``` - -Used internally by `Lens.useState` to support functional updates (`setValue(prev => prev + 1)`); rarely needed directly in application code unless you're building a custom hook that accepts a `React.SetStateAction`. diff --git a/packages/effect-view/ai-docs/State.md b/packages/effect-view/ai-docs/State.md index 35e4b29..63a7d1c 100644 --- a/packages/effect-view/ai-docs/State.md +++ b/packages/effect-view/ai-docs/State.md @@ -63,7 +63,7 @@ const [name, setName] = yield* Lens.useState(state.name) setName(e.currentTarget.value)} /> ``` -Calling the setter writes through the `Lens`, so every other subscriber (another `Lens.useState`, or a `View.useAll` elsewhere) sees the update. `Lens.useState(lens, { equivalence? })` controls when a change triggers a re-render. The setter accepts a plain value or a `prev => next` updater, resolved internally by `SetStateAction.value` (see `SetStateAction.md`). +Calling the setter writes through the `Lens`, so every other subscriber (another `Lens.useState`, or a `View.useAll` elsewhere) sees the update. `Lens.useState(lens, { equivalence? })` controls when a change triggers a re-render. The setter accepts a plain value or a `prev => next` updater, same as `React.useState`'s. ## Focused Lenses