MCPcopy
hub / github.com/anomalyco/opencode / load

Function load

packages/app/src/context/prompt.tsx:329–354  ·  view source on GitHub ↗
(scope: Scope)

Source from the content-addressed store, hash-verified

327 const scope = () =>
328 search.draftId ? { draftID: search.draftId } : { dir: base64Encode(sdk().directory), id: params.id }
329 const load = (scope: Scope) => {
330 const current = settings.general.newLayoutDesigns() ? selectPromptTab(tabs.store, scope, serverKey()) : undefined
331 if (current) {
332 return createTabPromptState(tabs, current, serverSDK().scope, scope)
333 }
334
335 const key = scopeKey(scope)
336 const existing = cache.get(key)
337 if (existing) {
338 cache.delete(key)
339 cache.set(key, existing)
340 return existing.value
341 }
342
343 const entry = createRoot(
344 (dispose) => ({
345 value: createPromptSession(serverSDK().scope, scope),
346 dispose,
347 }),
348 owner,
349 )
350
351 cache.set(key, entry)
352 prune()
353 return entry.value
354 }
355
356 const session = createMemo(() => load(scope()))
357 const pick = (scope?: Scope) => (scope ? load(scope) : session())

Callers 2

prompt.tsxFile · 0.70
pickFunction · 0.70

Calls 10

selectPromptTabFunction · 0.85
createTabPromptStateFunction · 0.85
scopeKeyFunction · 0.85
createPromptSessionFunction · 0.85
serverKeyFunction · 0.70
serverSDKFunction · 0.70
pruneFunction · 0.70
getMethod · 0.65
deleteMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected