MCPcopy Create free account
hub / github.com/anomalyco/opencode / warmSessions

Function warmSessions

packages/app/src/context/global-sync/bootstrap.ts:161–179  ·  view source on GitHub ↗
(input: {
  ids: string[]
  store: Store<State>
  setStore: SetStoreFunction<State>
  sdk: OpencodeClient
})

Source from the content-addressed store, hash-verified

159}
160
161function warmSessions(input: {
162 ids: string[]
163 store: Store<State>
164 setStore: SetStoreFunction<State>
165 sdk: OpencodeClient
166}) {
167 const known = new Set(input.store.session.map((item) => item.id))
168 const ids = [...new Set(input.ids)].filter((id) => !!id && !known.has(id))
169 if (ids.length === 0) return Promise.resolve()
170 return Promise.all(
171 ids.map((sessionID) =>
172 retry(() => input.sdk.session.get({ sessionID })).then((x) => {
173 const session = x.data
174 if (!session?.id) return
175 mergeSession(input.setStore, session)
176 }),
177 ),
178 ).then(() => undefined)
179}
180
181export const loadProvidersQuery = (scope: ServerScope, directory: string | null, sdk: OpencodeClient) =>
182 queryOptions({

Callers 1

bootstrapDirectoryFunction · 0.85

Calls 4

retryFunction · 0.90
mergeSessionFunction · 0.85
getMethod · 0.65
allMethod · 0.45

Tested by

no test coverage detected