The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 24, 09:00 UTC
refactor(web): observe preview tests through the live registry (#10064)
Julius Marminge committed
Sep 5, 2026 at 01:53 UTC
43700b83e73fca3af7b63769876c409b5c6f5a3f
2 files changed
+2
-15
apps/web/src/previewStateStore.test.ts
+2
-2
@@ -19,10 +19,10 @@ import {
19
reconcilePreviewServerSessions,
20
rememberPreviewUrl,
21
resetPreviewStateForTests,
22
- subscribeThreadPreviewState,
22
setActivePreviewTab,
23
updatePreviewServerSnapshot,
24
} from "./previewStateStore";
25
+import { appAtomRegistry } from "./rpc/atomRegistry";
26
27
const environmentId = "env-1" as EnvironmentId;
28
const ref = scopeThreadRef(environmentId, ThreadId.make("thread-1"));
@@ -352,7 +352,7 @@ describe("previewStateStore (single-tab)", () => {
352
},
353
};
354
let updateCount = 0;
355
- const unsubscribe = subscribeThreadPreviewState(ref, () => {
355
+ const unsubscribe = appAtomRegistry.subscribe(previewStateAtom(scopedThreadKey(ref)), () => {
356
updateCount += 1;
357
});
358
apps/web/src/previewStateStore.ts
-13
@@ -173,19 +173,6 @@ export function readThreadPreviewState(ref: ScopedThreadRef): ThreadPreviewState
173
return appAtomRegistry.get(previewStateAtom(scopedThreadKey(ref)));
174
}
175
176
-export function subscribeThreadPreviewState(
177
- ref: ScopedThreadRef,
178
- listener: (state: ThreadPreviewState, previous: ThreadPreviewState) => void,
179
-): () => void {
180
- const atom = previewStateAtom(scopedThreadKey(ref));
181
- let previous = appAtomRegistry.get(atom);
182
- return appAtomRegistry.subscribe(atom, (state) => {
183
- const prior = previous;
184
- previous = state;
185
- listener(state, prior);
186
- });
187
-}
188
-
176
export function applyPreviewServerEvent(ref: ScopedThreadRef, event: PreviewEvent): void {
177
updateThreadPreviewState(ref, (current) => {
178
if (current.serverEpoch !== null && event.serverEpoch !== current.serverEpoch) return current;