Skip to content

feat(connectors): emit connector.activation.changed for CLI/SDK activation writes #1226

@alexey-tyurin

Description

@alexey-tyurin

Quick check

  • I've searched existing issues and didn't find a duplicate.
  • This relates to Gaia Agent UI (gaia chat --ui).
  • This relates to the SDK, CLI, or a specific agent.

What problem are you trying to solve?

Activation toggles only push live UI updates when they go through the HTTP router. The connector.activation.changed SSE event is emitted from the PUT/DELETE handlers in src/gaia/ui/routers/connectors.py, but gaia connectors activate / deactivate (CLI) and direct SDK calls write the same ~/.gaia/activations.json ledger silently.

Result: with the Agent UI Settings tab open, a CLI-driven activation change is invisible until the user navigates away and back to force a refetch. That makes CLI ↔ UI workflows confusing — the activation actually took effect, but the panel keeps lying about state. This was called out as a follow-up on PR #1219 (closes #1005).

Proposed solution

Two viable options:

  1. Route CLI/SDK writes through the router layer — share a single internal entry point (e.g. activations.set(...) / activations.delete(...)) that always emits the SSE event after a successful write, regardless of caller. Cleanest, mirrors how PR feat(connectors): per-agent MCP tool-visibility activations (#1005) #1219 centralized the MCP-only guard at connectors/api.py.
  2. File-watcher on ~/.gaia/activations.json — the FastAPI server tails the ledger and emits connector.activation.changed whenever the file mtime moves. Looser coupling, also covers third-party writes.

Option 1 is preferred — it keeps the event source authoritative and avoids the watcher race when multiple processes write the ledger concurrently (already serialized by the per-process lock from #1219).

Acceptance criteria

  • gaia connectors activate <id> --agent <agent_id> triggers a connector.activation.changed SSE event with the same payload the HTTP PUT handler emits
  • gaia connectors deactivate ... triggers the same event with active: false
  • With Agent UI Settings open, a CLI activation toggle updates the "Active for" state without requiring a navigation refresh
  • Unit test covers the CLI → SSE path (mock the event bus, assert publish was called)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions