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

Function selectPromptTab

packages/app/src/context/prompt.tsx:183–190  ·  view source on GitHub ↗
(tabs: Tab[], scope: Scope, server: ServerConnection.Key)

Source from the content-addressed store, hash-verified

181type Scope = { draftID: string } | { dir: string; id?: string }
182
183export function selectPromptTab(tabs: Tab[], scope: Scope, server: ServerConnection.Key) {
184 if ("draftID" in scope) return tabs.find((tab) => tab.type === "draft" && tab.draftID === scope.draftID)
185 if (!scope.id) return
186 return (
187 tabs.find((tab) => tab.type === "session" && tab.server === server && tab.sessionId === scope.id) ??
188 ({ type: "session", server, sessionId: scope.id } satisfies Tab)
189 )
190}
191
192function scopeKey(scope: Scope) {
193 if ("draftID" in scope) return `draft:${scope.draftID}`

Callers 2

loadFunction · 0.85

Calls 1

findMethod · 0.65

Tested by

no test coverage detected