{"record":{"id":"9714f86fca056481","repo":"can1357/oh-my-pi","slug":"viewing-agents-is-unavailable-in-a-collab-session","errorCode":null,"errorMessage":"Viewing agents is unavailable in a collab session.","messagePattern":"Viewing agents is unavailable in a collab session\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"info","filePath":"packages/coding-agent/src/modes/controllers/session-focus-controller.ts","lineNumber":42,"sourceCode":"\n\tconstructor(\n\t\tprivate ctx: InteractiveModeContext,\n\t\tprivate registry: AgentRegistry = AgentRegistry.global(),\n\t\tprivate lifecycle: () => AgentLifecycleManager = () => AgentLifecycleManager.global(),\n\t) {}\n\n\tget focusedAgentId(): string | undefined {\n\t\treturn this.#focusedAgentId;\n\t}\n\n\t/** Focused live session, undefined when unfocused. */\n\tget target(): AgentSession | undefined {\n\t\treturn this.#attachedSession;\n\t}\n\n\t/** Focus the main view on an agent's live session. Throws an Error with a user-displayable message. */\n\tasync focusAgent(id: string): Promise<void> {\n\t\tif (this.ctx.collabGuest) throw new Error(\"Viewing agents is unavailable in a collab session.\");\n\t\tif (id === MAIN_AGENT_ID) return this.unfocus();\n\t\tconst session = await this.lifecycle().ensureLive(id);\n\t\tif (id === this.#focusedAgentId && session === this.#attachedSession) return;\n\t\tthis.#focusedAgentId = id;\n\t\tthis.#attachedSession = session;\n\t\tthis.#registryUnsubscribe ??= this.registry.onChange(e => this.#onRegistryEvent(e));\n\t\tconst attached = await this.#attach(session);\n\t\tif (attached && this.#focusedAgentId === id && this.#attachedSession === session) {\n\t\t\tthis.ctx.showStatus(`Viewing agent ${id} — Esc returns to main, ←← hops to parent`);\n\t\t}\n\t}\n\n\t/** Focus the focused agent's parent agent, falling back to the main session. No-op when unfocused. */\n\tasync focusParent(): Promise<void> {\n\t\tif (!this.#focusedAgentId) return;\n\t\tconst parentId = this.registry.get(this.#focusedAgentId)?.parentId;\n\t\tif (parentId && parentId !== MAIN_AGENT_ID && this.registry.get(parentId)) {\n\t\t\treturn this.focusAgent(parentId);","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/modes/controllers/session-focus-controller.ts#L24-L60","documentation":"focusAgent refuses to change the main view's focus when running as a collab guest. In a collab session the guest cannot attach to and view an individual agent's live session; the operation is intentionally disabled, and the thrown message is meant to be shown to the user.","triggerScenarios":"Calling focusAgent(id) on SessionFocusController while this.ctx.collabGuest is truthy — i.e. any attempt (slash command, UI click on an agent) to focus an agent view from a guest side of a collab session.","commonSituations":"A user in a shared/collab OMP session clicking an agent entry to view its live session; an RPC/automation client issuing a focus-agent command from a guest instance.","solutions":["Do not call focusAgent in guest mode — guard on ctx.collabGuest before invoking","If you need the agent's output as a guest, read the agent's status/summary through the collab channel instead of attaching to its session","Ask the host to focus the agent, or run the agent view from the host instance"],"exampleFix":"// before\nawait focusController.focusAgent(agentId);\n// after\nif (!ctx.collabGuest) {\n  await focusController.focusAgent(agentId);\n} else {\n  ui.showInfo(\"Agent viewing is host-only in collab sessions\");\n}","handlingStrategy":"validation","validationCode":"if (ctx.collabGuest) {\n  // skip agent focusing entirely\n  return;\n}","typeGuard":"function canFocusAgents(ctx: { collabGuest?: unknown }): boolean {\n  return !ctx.collabGuest;\n}","tryCatchPattern":"try {\n  await focusController.focusAgent(agentId);\n} catch (err) {\n  if (err.message.includes(\"collab session\")) {\n    ui.showInfo(\"Viewing agents is host-only in collab sessions\");\n  } else throw err;\n}","preventionTips":["Gate all agent-focus UI/commands behind a collabGuest check","Hide agent-focus affordances in guest UI so users never trigger it","Provide an alternative read-only summary for guests","Document the host-only capability in collab docs"],"tags":["collab","permissions","unsupported-operation"],"backgroundTag":"operation-unavailable-in-collab","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}