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

Function ensureBlockerTab

packages/opencode/src/cli/cmd/run/subagent-data.ts:434–473  ·  view source on GitHub ↗
(
  data: SubagentData,
  sessionID: string,
  title: string | undefined,
  kind: "permission" | "question",
)

Source from the content-addressed store, hash-verified

432}
433
434function ensureBlockerTab(
435 data: SubagentData,
436 sessionID: string,
437 title: string | undefined,
438 kind: "permission" | "question",
439) {
440 const current = data.tabs.get(sessionID)
441 if (current) {
442 ensureDetail(data, sessionID)
443 if (current.status !== "running") {
444 return false
445 }
446
447 const next = {
448 ...current,
449 description: kind === "permission" ? "Pending permission" : "Pending question",
450 status: "running" as const,
451 title: current.title ?? title,
452 lastUpdatedAt: Date.now(),
453 }
454 if (sameSubagentTab(current, next)) {
455 return false
456 }
457
458 data.tabs.set(sessionID, next)
459 return true
460 }
461
462 data.tabs.set(sessionID, {
463 sessionID,
464 partID: `bootstrap:${sessionID}`,
465 callID: `bootstrap:${sessionID}`,
466 label: text(title) ?? Locale.titlecase(kind),
467 description: kind === "permission" ? "Pending permission" : "Pending question",
468 status: "running",
469 lastUpdatedAt: Date.now(),
470 })
471 ensureDetail(data, sessionID)
472 return true
473}
474
475function isAbortedAssistantMessage(info: Message) {
476 return info.role === "assistant" && info.error?.name === "MessageAbortedError"

Callers 1

bootstrapSubagentDataFunction · 0.85

Calls 5

ensureDetailFunction · 0.85
sameSubagentTabFunction · 0.85
textFunction · 0.70
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected