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

Function loadWorkspace

packages/app/src/context/terminal.tsx:406–424  ·  view source on GitHub ↗
(dir: string, legacySessionID: string | undefined, serverScope: ServerScopeValue)

Source from the content-addressed store, hash-verified

404 }
405
406 const loadWorkspace = (dir: string, legacySessionID: string | undefined, serverScope: ServerScopeValue) => {
407 // Terminals are workspace-scoped so tabs persist while switching sessions in the same directory.
408 const key = getWorkspaceTerminalCacheKey(dir, serverScope)
409 const existing = cache.get(key)
410 if (existing) {
411 cache.delete(key)
412 cache.set(key, existing)
413 return existing.value
414 }
415
416 const entry = createRoot((dispose) => ({
417 value: createWorkspaceTerminalSession(sdk(), dir, serverScope, legacySessionID),
418 dispose,
419 }))
420
421 cache.set(key, entry)
422 prune()
423 return entry.value
424 }
425
426 const workspace = createMemo(() => loadWorkspace(directory(), params.id, scope()))
427

Callers 1

terminal.tsxFile · 0.70

Calls 7

sdkFunction · 0.85
pruneFunction · 0.70
getMethod · 0.65
deleteMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected