Skip to content

Implement reactive state synchronization #111

Closed

Description

@malibio

Overview

Create reactive state synchronization system that keeps desktop UI and MCP server in sync when both processes run simultaneously. This enables real-time UI updates when AI agents modify data via MCP, and ensures MCP server stays aware of UI changes.

Architecture Context

See MCP Integration Architecture for complete design details.

Key Points:

  • Desktop app and MCP server are separate processes accessing shared Turso database
  • Database handles concurrency automatically (WAL mode, automatic locking)
  • IPC required for UI reactivity - database changes don't automatically trigger UI updates
  • EventBus coordination bridges both processes via Unix Domain Sockets

Implementation Tasks

IPC Event Channel

  • Implement Unix Domain Socket server in desktop app
  • Implement Unix Domain Socket client in MCP server
  • Define shared event types (NodeCreated, NodeUpdated, NodeDeleted, NodeMoved)
  • Add bidirectional event messaging between processes

EventBus Integration

  • Extend existing EventBus to handle IPC events
  • Add event forwarding from IPC socket to EventBus in desktop app
  • Add event sending from MCP operations to IPC socket
  • Handle connection failures gracefully (MCP may not be running)

Tauri Event Bridge

  • Wire EventBus events to Tauri events for frontend
  • Emit Tauri events when IPC events received from MCP
  • Test event flow: MCP → IPC → EventBus → Tauri → Svelte

Frontend Reactive Updates

  • Listen for Tauri events in Svelte stores
  • Update node stores reactively when events received
  • Add optimistic updates for UI responsiveness
  • Handle stale data refresh when needed

Testing & Validation

  • Test concurrent operations (UI + MCP modifying same node)
  • Verify UI updates when MCP creates/updates/deletes nodes
  • Test MCP running without desktop app (no IPC failures)
  • Test desktop app without MCP (no event sending)
  • Performance testing with high-frequency updates

Acceptance Criteria

  • IPC event channel connects desktop and MCP processes
  • EventBus coordinates events between both processes
  • Svelte UI updates reactively when MCP modifies data
  • MCP gracefully handles desktop not running
  • Desktop gracefully handles MCP not running
  • No performance degradation with event coordination
  • Concurrent database access works correctly (validated by libSQL/Turso)

Dependencies

References

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions