MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / getKeySnapshot

Function getKeySnapshot

cli/src/hooks/use-activity-query.ts:81–97  ·  view source on GitHub ↗

* Snapshot includes BOTH entry + isFetching, and is memoized so Object.is only changes * when either changes. This fixes "notify but no rerender" when only fetch-status changes.

(key: string)

Source from the content-addressed store, hash-verified

79 * when either changes. This fixes "notify but no rerender" when only fetch-status changes.
80 */
81function getKeySnapshot<T>(key: string): KeySnapshot<T> {
82 const entry = cache.entries.get(key) as CacheEntry<T> | undefined
83 const fetching = cache.fetchingKeys.has(key)
84
85 const memo = snapshotMemo.get(key)
86 if (memo && memo.entryRef === (entry as any) && memo.fetching === fetching) {
87 return memo.snap as KeySnapshot<T>
88 }
89
90 const snap: KeySnapshot<T> = { entry, isFetching: fetching }
91 snapshotMemo.set(key, {
92 entryRef: entry as any,
93 fetching,
94 snap: snap as any,
95 })
96 return snap
97}
98
99function setCacheEntry<T>(key: string, entry: CacheEntry<T>): void {
100 cache.entries.set(key, entry as CacheEntry<unknown>)

Callers 1

useActivityQueryFunction · 0.85

Calls 2

setMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected