Skip to content

[FIX] Project-scoped bus for startup/ingest status — drop session routing #152

Description

@four-bytes-robby

Problem

Brain status during startup and auto-ingest (before any session exists) was never received by the TUI. The bus publishing logic skipped publishing when no session ID was available, and the TUI's useServiceBus bailed when sessionId was undefined.

Additionally, updateStatus("ready") fired immediately after launching auto-ingest, creating a race condition: TUI saw busy → ready → busy → success instead of a clean busy → success.

Root cause

Brain status was session-scoped (brain/{sessionId}/status) but brain state (ingest, memories, knowledge) is project-wide — one brain per directory, shared across all sessions.

Fix

  • status.ts: Always publish to brain/{projectId}/status via forProject(deriveProjectId(directory)) — no ALS session routing, no withSessionId in write()
  • tui.tsx: Use useProjectBus only — subscribes to brain/{projectId}/status for both sidebar and home slots; reads directory from api.state.path.directory
  • four-opencode-brain.ts: Fix startup race — updateStatus("ready") only fires when no ingest is running; auto-ingest transitions to ready itself. Fix timeoutMs scope, project?.id, implicit any hook params.

Requires

four-opencode-plugin-lib v0.6.7 (adds BusClient.forProject())

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions