can1357/oh-my-pi · info · Error

Viewing agents is unavailable in a collab session.

Error message

Viewing agents is unavailable in a collab session.

What it means

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.

Source

Thrown at packages/coding-agent/src/modes/controllers/session-focus-controller.ts:42

	constructor(
		private ctx: InteractiveModeContext,
		private registry: AgentRegistry = AgentRegistry.global(),
		private lifecycle: () => AgentLifecycleManager = () => AgentLifecycleManager.global(),
	) {}

	get focusedAgentId(): string | undefined {
		return this.#focusedAgentId;
	}

	/** Focused live session, undefined when unfocused. */
	get target(): AgentSession | undefined {
		return this.#attachedSession;
	}

	/** Focus the main view on an agent's live session. Throws an Error with a user-displayable message. */
	async focusAgent(id: string): Promise<void> {
		if (this.ctx.collabGuest) throw new Error("Viewing agents is unavailable in a collab session.");
		if (id === MAIN_AGENT_ID) return this.unfocus();
		const session = await this.lifecycle().ensureLive(id);
		if (id === this.#focusedAgentId && session === this.#attachedSession) return;
		this.#focusedAgentId = id;
		this.#attachedSession = session;
		this.#registryUnsubscribe ??= this.registry.onChange(e => this.#onRegistryEvent(e));
		const attached = await this.#attach(session);
		if (attached && this.#focusedAgentId === id && this.#attachedSession === session) {
			this.ctx.showStatus(`Viewing agent ${id} — Esc returns to main, ←← hops to parent`);
		}
	}

	/** Focus the focused agent's parent agent, falling back to the main session. No-op when unfocused. */
	async focusParent(): Promise<void> {
		if (!this.#focusedAgentId) return;
		const parentId = this.registry.get(this.#focusedAgentId)?.parentId;
		if (parentId && parentId !== MAIN_AGENT_ID && this.registry.get(parentId)) {
			return this.focusAgent(parentId);

View on GitHub (pinned to 9690622007)

Solutions

  1. Do not call focusAgent in guest mode — guard on ctx.collabGuest before invoking
  2. 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
  3. Ask the host to focus the agent, or run the agent view from the host instance

Example fix

// before
await focusController.focusAgent(agentId);
// after
if (!ctx.collabGuest) {
  await focusController.focusAgent(agentId);
} else {
  ui.showInfo("Agent viewing is host-only in collab sessions");
}
Defensive patterns

Strategy: validation

Validate before calling

if (ctx.collabGuest) {
  // skip agent focusing entirely
  return;
}

Type guard

function canFocusAgents(ctx: { collabGuest?: unknown }): boolean {
  return !ctx.collabGuest;
}

Try / catch

try {
  await focusController.focusAgent(agentId);
} catch (err) {
  if (err.message.includes("collab session")) {
    ui.showInfo("Viewing agents is host-only in collab sessions");
  } else throw err;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/9714f86fca056481. Report an issue: GitHub.