MCPcopy
hub / github.com/pingdotgg/t3code / updateThreadPreviewState

Function updateThreadPreviewState

apps/web/src/previewStateStore.ts:94–108  ·  view source on GitHub ↗
(
  ref: ScopedThreadRef,
  update: (current: ThreadPreviewState) => ThreadPreviewState,
)

Source from the content-addressed store, hash-verified

92}
93
94function updateThreadPreviewState(
95 ref: ScopedThreadRef,
96 update: (current: ThreadPreviewState) => ThreadPreviewState,
97): void {
98 const threadKey = scopedThreadKey(ref);
99 const atom = previewStateAtom(threadKey);
100 let nextState = appAtomRegistry.get(atom);
101 const changed = appAtomRegistry.modify(atom, (current) => {
102 nextState = update(current);
103 return [nextState !== current, nextState];
104 });
105 if (!changed) return;
106 changedPreviewThreadKeys.add(threadKey);
107 syncActivePreviewThread(threadKey, nextState);
108}
109
110const dedupeRecentUrls = (existing: string[], url: string): string[] => {
111 const next = [url, ...existing.filter((entry) => entry !== url)];

Callers 9

applyPreviewServerEventFunction · 0.85
applyPreviewDesktopStateFunction · 0.85
beginPreviewSessionCloseFunction · 0.85
setActivePreviewTabFunction · 0.85
rememberPreviewUrlFunction · 0.85

Calls 4

scopedThreadKeyFunction · 0.90
syncActivePreviewThreadFunction · 0.85
getMethod · 0.80
updateFunction · 0.50

Tested by

no test coverage detected