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

Function migrateTerminalState

packages/app/src/context/terminal.tsx:69–86  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

67}
68
69export function migrateTerminalState(value: unknown) {
70 if (!record(value)) return value
71
72 const seen = new Set<string>()
73 const all = (Array.isArray(value.all) ? value.all : []).flatMap((item) => {
74 const next = pty(item)
75 if (!next || seen.has(next.id)) return []
76 seen.add(next.id)
77 return [next]
78 })
79
80 const active = text(value.active)
81
82 return {
83 active: active && seen.has(active) ? active : all[0]?.id,
84 all,
85 }
86}
87
88export function getWorkspaceTerminalCacheKey(dir: string, scope: ServerScopeValue = ServerScope.local) {
89 return ScopedKey.from(scope, dir, WORKSPACE_KEY)

Callers 1

terminal.test.tsFile · 0.85

Calls 4

ptyFunction · 0.85
recordFunction · 0.70
textFunction · 0.70
addMethod · 0.65

Tested by

no test coverage detected