Skip to content

Frontend: Chat UI, agent panel, model settings, and AI onboarding #1003

Closed

Description

@malibio

Overview

Build the complete frontend for interacting with both local and external agents. This includes the AI entry point in the sidebar, a first-launch onboarding dialog, the chat interface, agent management, and model settings.

Develop entirely with mock backends — wire to real Tauri commands in #1007 (Tauri Command Layer).

Acceptance Criteria

  • Side nav AI item opens the AI panel
  • First-launch onboarding dialog presents two paths: existing LLM provider (ACP) or local model download
  • ACP path shows detected agents with availability indicators
  • Local model path auto-recommends RAM-appropriate model with download button
  • Download progress bar updates in real-time (mock events for dev)
  • After onboarding, subsequent clicks go straight to chat panel
  • Chat panel renders message history with proper styling
  • Streaming text appears token-by-token (mock with setTimeout for dev)
  • Tool calls render in collapsible cards within the conversation
  • Agent selector switches between local and ACP agents
  • Model manager in Settings displays catalog models with correct status
  • Keyboard: Enter to send, Shift+Enter newline, Escape to close panel
  • All stores use Svelte 5 runes ($state, $derived, $effect)
  • Uses createLogger for logging, no raw console.log
  • Unit tests for stores and key component behaviors
  • Code passes bun run quality:fix

Technical Specifications

AI Entry Point and Onboarding

Side nav item:

  • AI icon in the left sidebar (use existing ai-icon.svelte from design system)
  • Opens AI panel in the main content area (same region as node viewers)

First-launch modal (AiOnboardingDialog.svelte):

  • Shown when: user clicks AI nav item for first time, OR no model downloaded AND no ACP agents detected
  • Two paths presented as cards:

Path 1: "Use an existing AI provider"

  • Shows detected ACP agents (Claude Code, Gemini CLI, Mistral Vibe)
  • Each with availability status (Installed/Not installed/Not configured)
  • Click an available agent to start a session
  • If none detected: show install instructions with links

Path 2: "Download a local model"

  • Auto-recommend model based on recommended_model() from backend
  • Display: model name, size, estimated download time
  • Single "Download and Start" button
  • Progress bar during download
  • Note: "You can switch models later in Settings"

Chat Interface Components

Location: packages/desktop-app/src/lib/components/chat/

  • ChatPanel.svelte — Main panel with message list and input
  • ChatMessage.svelte — Message bubble: user text, assistant text (streaming), tool calls, errors
  • ChatInput.svelte — Text input with send button, Shift+Enter for multiline, disabled during processing
  • ToolCallDisplay.svelte — Collapsible card: tool name, args, result, duration, success/failure color

Agent Management Components

Location: packages/desktop-app/src/lib/components/agents/

  • AgentSelector.svelte — Dropdown/tabs for Local Agent vs ACP agents with availability
  • AgentStatusBar.svelte — Compact indicator: current agent state (Idle, Thinking, Tool Execution)

Model Settings Components

Location: packages/desktop-app/src/lib/components/settings/

  • ModelManager.svelte — List models with status, download/delete buttons, progress bars
  • ModelPicker.svelte — Compact model selector for chat panel header

State Management (Svelte 5 Runes)

Location: packages/desktop-app/src/lib/stores/

  • chatStore.ts — Conversation history, current session, streaming state
  • agentStore.ts — Agent availability, selected agent, session state
  • modelStore.ts — Model list, download progress, loaded model, recommended model

Tauri Event Listeners (mocked for dev)

  • local-agent://chunk — streaming tokens
  • local-agent://tool — tool execution updates
  • local-agent://status — agent status changes
  • model://download-progress — model download progress
  • acp://session-state — ACP session state changes

Reference Files

Dependencies

Related Issues

Activity

  1. malibio commented on Apr 3, 2026

    @malibio
    CollaboratorAuthor

    Architecture Update (from planning session 2026-04-03)

    Based on ADR-028 and ADR-029, several aspects of this issue are refined:

    Chat UI is an AiChatNodeViewer

    The chat panel is NOT a standalone floating panel — it's an AiChatNodeViewer following the QueryNodeViewer pattern (page-level viewer, opens in a tab like any other node type). The /ai-chat slash command creates a new ai-chat node and opens it.

    Write Buffering (frontend responsibility)

    Messages are buffered in memory during active conversation. The frontend chatStore is the source of truth during active chat:

    • Debounced flush to backend every 5-10 seconds
    • Immediate flush on navigate-away, conversation close, or app exit
    • This means chatStore.ts needs to manage the buffer and flush lifecycle

    Tool Result Archival (at write time)

    When flushing messages to the backend, tool call results should be archived:

    • Keep result_summary string
    • Null out full result payload
    • Full results are kept in memory for the active session only

    Soft Message Cap UX

    At ~500 messages, show a gentle prompt suggesting a new conversation. Not a hard limit — user can dismiss and continue.

    SearchScope

    Semantic search uses SearchScope enum (not exclude_types). Default Knowledge scope excludes ai-chat. The search UI should offer scope options when available.

    References

  2. malibio commented on Apr 3, 2026

    @malibio
    CollaboratorAuthor

    Scope Boundary: #1003 vs #1017

    These two issues overlap on chat UI. Here's the delineation:

    #1003 (this issue) owns:

    • Agent selector (switch between local + ACP agents)
    • Agent status bar
    • Model manager in Settings (list/download/delete models)
    • Model picker (compact selector in chat header)
    • Stores: agentStore.ts, modelStore.ts
    • Tauri event listeners for model download progress, agent status
    • Mock backends for all of the above

    #1017 owns:

    • AiChatNodeViewer.svelte (the page-level viewer for ai-chat nodes)
    • ChatMessage.svelte, ChatInput.svelte, ToolCallDisplay.svelte
    • AiOnboardingDialog.svelte (first-launch modal)
    • chatStore.ts (conversation state, write buffering, message cap)
    • Node reference decoration in assistant messages
    • aiChatNodePlugin in core-plugins.ts (slash command, viewer registration)
    • Side nav AI item

    Shared: Both issues use the TypeScript interfaces from #998. The AiChatNodeViewer uses the agent selector and model picker from #1003.

    Implementation Guide

    Plugin Registration Pattern

    Read packages/desktop-app/src/lib/plugins/core-plugins.ts — every node type follows this:

    export const aiChatNodePlugin: PluginDefinition = {
      id: 'ai-chat',
      name: 'AI Chat',
      config: {
        slashCommands: [{ id: 'ai-chat', name: 'AI Chat', nodeType: 'ai-chat' }],
        canHaveChildren: false,
        canBeChild: true
      },
      viewer: { lazyLoad: () => import('../components/viewers/ai-chat-node-viewer.svelte') },
      node: { lazyLoad: () => import('../components/chat/chat-node.svelte'), priority: 1 },
      reference: { component: BaseNodeReference, priority: 1 }
    };

    Register it alongside other plugins in the same file.

    Tab/Navigation System

    Read packages/desktop-app/src/lib/stores/navigation.ts:

    • Tab interface (line 10) — { id, title, type: 'node', content: { nodeId, nodeType } }
    • addTab() (line 471) — creates tab, optionally makes active
    • Viewer resolved from pluginRegistry.getViewer(nodeType) — once aiChatNodePlugin is registered, tabs with nodeType: 'ai-chat' automatically route to your AiChatNodeViewer

    Existing Stores

    All stores live in packages/desktop-app/src/lib/stores/:

    • navigation.ts — tabs and panes (primary navigation)
    • collections.ts, schemas.ts, settings.ts, layout.ts
    • Your new stores (chatStore.ts, agentStore.ts, modelStore.ts) go here

    Viewer Pattern

    Read packages/desktop-app/src/lib/components/viewers/query-node-viewer.svelte — this is the closest pattern to AiChatNodeViewer:

    • Page-level viewer (does NOT wrap BaseNodeViewer)
    • Custom layout for its content type
    • Receives node data via props
  3. malibio commented on Apr 3, 2026

    @malibio
    CollaboratorAuthor

    Baseline: 119 test files, 3748 tests passed (37.73s)

  4. self-assigned this
    on Apr 3, 2026
  5. added a commit that references this issue on Apr 3, 2026
    c13fdde
  6. added a commit that references this issue on Apr 3, 2026
    556e053
  7. added a commit that references this issue on Jun 22, 2026
    aa5fa86
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions