Archon/archon-ui-main
Wirasm f4ad785439
refactor: Phase 2 Query Keys Standardization - Complete TanStack Query v5 patterns implementation (#692)
* refactor: complete Phase 2 Query Keys Standardization

Standardize query keys across all features following vertical slice architecture,
ensuring they mirror backend API structure exactly with no backward compatibility.

Key Changes:
- Refactor all query key factories to follow consistent patterns
- Move progress feature from knowledge/progress to top-level /features/progress
- Create shared query patterns for consistency (DISABLED_QUERY_KEY, STALE_TIMES)
- Remove all hardcoded stale times and disabled keys
- Update all imports after progress feature relocation

Query Key Factories Standardized:
- projectKeys: removed task-related keys (tasks, taskCounts)
- taskKeys: added dual nature support (global via lists(), project-scoped via byProject())
- knowledgeKeys: removed redundant methods (details, summary)
- progressKeys: new top-level feature with consistent factory
- documentKeys: full factory pattern with versions support
- mcpKeys: complete with health endpoint

Shared Patterns Implementation:
- STALE_TIMES: instant (0), realtime (3s), frequent (5s), normal (30s), rare (5m), static (∞)
- DISABLED_QUERY_KEY: consistent disabled query pattern across all features
- Removed unused createQueryOptions helper

Testing:
- Added comprehensive tests for progress hooks
- Updated all test mocks to include new STALE_TIMES values
- All 81 feature tests passing

Documentation:
- Created QUERY_PATTERNS.md guide for future implementations
- Clear patterns, examples, and migration checklist

Breaking Changes:
- Progress imports moved from knowledge/progress to progress
- Query key structure changes (cache will reset)
- No backward compatibility maintained

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: establish single source of truth for tags in metadata

- Remove ambiguous top-level tags field from KnowledgeItem interface
- Update all UI components to use metadata.tags exclusively
- Fix mutations to correctly update tags in metadata object
- Remove duplicate tags field from backend KnowledgeSummaryService
- Fix test setup issue with QueryClient instance in knowledge tests
- Add TODO comments for filter-blind optimistic updates (Phase 3)

This eliminates the ambiguity identified in Phase 2 where both item.tags
and metadata.tags existed, establishing metadata.tags as the single
source of truth across the entire stack.

* fix: comprehensive progress hooks improvements

- Integrate useSmartPolling for all polling queries
- Fix memory leaks from uncleaned timeouts
- Replace string-based error checking with status codes
- Remove TypeScript any usage with proper types
- Fix unstable dependencies with sorted JSON serialization
- Add staleTime to document queries for consistency

* feat: implement flexible assignee system for dynamic agents

- Changed assignee from restricted enum to flexible string type
- Renamed "AI IDE Agent" to "Coding Agent" for clarity
- Enhanced ComboBox with Radix UI best practices:
  - Full ARIA compliance (roles, labels, keyboard nav)
  - Performance optimizations (memoization, useCallback)
  - Improved UX (auto-scroll, keyboard shortcuts)
  - Fixed event bubbling preventing unintended modal opens
- Updated MCP server docs to reflect flexible assignee capability
- Removed unnecessary UI elements (arrows, helper text)
- Styled ComboBox to match priority selector aesthetic

This allows external MCP clients to create and assign custom sub-agents
dynamically, supporting advanced agent orchestration workflows.

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: complete Phase 2 summariesPrefix usage for cache consistency

- Fix all knowledgeKeys.summaries() calls to use summariesPrefix() for operations targeting multiple summary caches
- Update cancelQueries, getQueriesData, setQueriesData, invalidateQueries, and refetchQueries calls
- Fix critical cache invalidation bug where filtered summaries weren't being cleared
- Update test expectations to match new factory patterns
- Address CodeRabbit review feedback on cache stability issues

This completes the Phase 2 Query Keys Standardization work documented in PRPs/local/frontend-state-management-refactor.md

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: update MCP task tools documentation for Coding Agent rename

Update task assignee documentation from "AI IDE Agent" to "Coding Agent"
to match frontend changes for consistency across the system.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: implement assignee filtering in MCP find_tasks function

Add missing implementation for filter_by="assignee" that was documented
but not coded. The filter now properly passes the assignee parameter to
the backend API, matching the existing pattern used for status filtering.

Fixes documentation/implementation mismatch identified by CodeRabbit.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: Phase 2 cleanup - address review comments and improve code quality

Changes made:
- Reduced smart polling interval from 60s to 5s for background tabs (better responsiveness)
- Fixed cache coherence bug in knowledge queries (missing limit parameter)
- Standardized "Coding Agent" naming (was inconsistently "AI IDE Agent")
- Improved task queries with 2s polling, type safety, and proper invalidation
- Enhanced combobox accessibility with proper ARIA attributes and IDs
- Delegated useCrawlProgressPolling to useActiveOperations (removed duplication)
- Added exact: true to progress query removals (prevents sibling removal)
- Fixed invalid Tailwind class ml-4.5 to ml-4

All changes align with Phase 2 query key standardization goals and improve
overall code quality, accessibility, and performance.

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-09-18 11:05:03 +03:00
..
public feat: Ollama Integration with Separate LLM/Embedding Model Support (#643) 2025-09-15 06:38:02 -07:00
src refactor: Phase 2 Query Keys Standardization - Complete TanStack Query v5 patterns implementation (#692) 2025-09-18 11:05:03 +03:00
tests feat: TanStack Query Migration Phase 3 - Knowledge Base Feature (#605) 2025-09-12 16:45:18 +03:00
.dockerignore feat: TanStack Query Migration Phase 2 - Cleanup and Test Reorganization (#588) 2025-09-06 13:43:53 +03:00
.eslintrc.cjs Removing references to Archon "Alpha" 2025-09-06 14:51:02 -05:00
.gitignore The New Archon (Beta) - The Operating System for AI Coding Assistants! 2025-08-13 07:58:24 -05:00
biome.json feat: TanStack Query Migration Phase 2 - Cleanup and Test Reorganization (#588) 2025-09-06 13:43:53 +03:00
Dockerfile Improve development environment with Docker Compose profiles (#435) 2025-08-22 17:18:10 +03:00
index.html Updating the Logo for Archon 2025-08-18 13:59:49 -05:00
package-lock.json feat: Document Browser with Domain Filtering (Updated Architecture) (#564) 2025-09-06 13:27:17 +03:00
package.json feat: TanStack Query Migration Phase 3 - Knowledge Base Feature (#605) 2025-09-12 16:45:18 +03:00
postcss.config.js The New Archon (Beta) - The Operating System for AI Coding Assistants! 2025-08-13 07:58:24 -05:00
README.md The New Archon (Beta) - The Operating System for AI Coding Assistants! 2025-08-13 07:58:24 -05:00
tailwind.config.js The New Archon (Beta) - The Operating System for AI Coding Assistants! 2025-08-13 07:58:24 -05:00
tsconfig.json feat: TanStack Query Migration Phase 2 - Cleanup and Test Reorganization (#588) 2025-09-06 13:43:53 +03:00
tsconfig.node.json The New Archon (Beta) - The Operating System for AI Coding Assistants! 2025-08-13 07:58:24 -05:00
tsconfig.prod.json feat: TanStack Query Migration Phase 2 - Cleanup and Test Reorganization (#588) 2025-09-06 13:43:53 +03:00
vite.config.ts feat: Ollama Integration with Separate LLM/Embedding Model Support (#643) 2025-09-15 06:38:02 -07:00
vitest.config.ts feat: Ollama Integration with Separate LLM/Embedding Model Support (#643) 2025-09-15 06:38:02 -07:00
vitest.integration.config.ts feat: TanStack Query Migration Phase 3 - Knowledge Base Feature (#605) 2025-09-12 16:45:18 +03:00

Archon UI - Knowledge Engine Web Interface

A modern React-based web interface for the Archon Knowledge Engine MCP Server. Built with TypeScript, Vite, and Tailwind CSS.

🎨 UI Overview

Archon UI provides a comprehensive dashboard for managing your AI's knowledge base:

UI Architecture

Key Features

  • 📊 MCP Dashboard: Monitor and control the MCP server
  • ⚙️ Settings Management: Configure credentials and RAG strategies
  • 🕷️ Web Crawling: Crawl documentation sites and build knowledge base
  • 📚 Knowledge Management: Browse, search, and organize knowledge items
  • 💬 Interactive Chat: Test RAG queries with real-time responses
  • 📈 Real-time Updates: WebSocket-based live updates across the UI

🏗️ Architecture

Technology Stack

  • React 18.3: Modern React with hooks and functional components
  • TypeScript: Full type safety and IntelliSense support
  • Vite: Fast build tool and dev server
  • Tailwind CSS: Utility-first styling
  • Framer Motion: Smooth animations and transitions
  • Lucide Icons: Beautiful and consistent iconography
  • React Router: Client-side routing

Project Structure

archon-ui-main/
├── src/
│   ├── components/          # Reusable UI components
│   │   ├── ui/             # Base UI components (Button, Card, etc.)
│   │   ├── layouts/        # Layout components (Sidebar, Header)
│   │   └── animations/     # Animation components
│   ├── pages/              # Page components
│   │   ├── MCPPage.tsx     # MCP Dashboard
│   │   ├── Settings.tsx    # Settings page
│   │   ├── Crawl.tsx       # Web crawling interface
│   │   ├── KnowledgeBase.tsx # Knowledge management
│   │   └── Chat.tsx        # RAG chat interface
│   ├── services/           # API and service layers
│   │   ├── api.ts          # Base API configuration
│   │   ├── mcpService.ts   # MCP server communication
│   │   └── chatService.ts  # Chat/RAG service
│   ├── contexts/           # React contexts
│   │   └── ToastContext.tsx # Toast notifications
│   ├── hooks/              # Custom React hooks
│   │   └── useStaggeredEntrance.ts # Animation hook
│   ├── types/              # TypeScript type definitions
│   └── lib/                # Utility functions
├── public/                 # Static assets
└── test/                   # Test files

📄 Pages Documentation

1. MCP Dashboard (/mcp)

The central control panel for the MCP server.

Components:

  • Server Control Panel: Start/stop server, view status, select transport mode
  • Server Logs Viewer: Real-time log streaming with auto-scroll
  • Available Tools Table: Dynamic tool discovery and documentation
  • MCP Test Panel: Interactive tool testing interface

Features:

  • Dual transport support (SSE/stdio)
  • Real-time status polling (5-second intervals)
  • WebSocket-based log streaming
  • Copy-to-clipboard configuration
  • Tool parameter validation

2. Settings (/settings)

Comprehensive configuration management.

Sections:

  • Credentials:
    • OpenAI API key (encrypted storage)
    • Supabase connection details
    • MCP server configuration
  • RAG Strategies:
    • Contextual Embeddings toggle
    • Hybrid Search toggle
    • Agentic RAG (code extraction) toggle
    • Reranking toggle

Features:

  • Secure credential storage with encryption
  • Real-time validation
  • Toast notifications for actions
  • Default value management

3. Web Crawling (/crawl)

Interface for crawling documentation sites.

Components:

  • URL Input: Smart URL validation
  • Crawl Options: Max depth, concurrent sessions
  • Progress Monitoring: Real-time crawl status
  • Results Summary: Pages crawled, chunks stored

Features:

  • Intelligent URL type detection
  • Sitemap support
  • Recursive crawling
  • Batch processing

4. Knowledge Base (/knowledge)

Browse and manage your knowledge items.

Components:

  • Knowledge Grid: Card-based knowledge display
  • Search/Filter: Search by title, type, tags
  • Knowledge Details: View full item details
  • Actions: Delete, refresh, organize

Features:

  • Pagination support
  • Real-time updates via WebSocket
  • Type-based filtering (technical/business)
  • Metadata display

5. RAG Chat (/chat)

Interactive chat interface for testing RAG queries.

Components:

  • Chat Messages: Threaded conversation view
  • Input Area: Query input with source selection
  • Results Display: Formatted RAG results
  • Source Selector: Filter by knowledge source

Features:

  • Real-time streaming responses
  • Source attribution
  • Markdown rendering
  • Copy functionality

🧩 Component Library

Base UI Components

Button

<Button 
  variant="primary|secondary|ghost" 
  size="sm|md|lg"
  accentColor="blue|green|purple|orange|pink"
  onClick={handleClick}
>
  Click me
</Button>

Card

<Card accentColor="blue" className="p-6">
  <h3>Card Title</h3>
  <p>Card content</p>
</Card>

LoadingSpinner

<LoadingSpinner size="sm|md|lg" />

Layout Components

Sidebar

  • Collapsible navigation
  • Active route highlighting
  • Icon + text navigation items
  • Responsive design

Header

  • Dark mode toggle
  • User menu
  • Breadcrumb navigation

Animation Components

PageTransition

Wraps pages with smooth fade/slide animations:

<PageTransition>
  <YourPageContent />
</PageTransition>

🔌 Services

mcpService

Handles all MCP server communication:

  • startServer(): Start the MCP server
  • stopServer(): Stop the MCP server
  • getStatus(): Get current server status
  • streamLogs(): WebSocket log streaming
  • getAvailableTools(): Fetch MCP tools

api

Base API configuration with:

  • Automatic error handling
  • Request/response interceptors
  • Base URL configuration
  • TypeScript generics

chatService

RAG query interface:

  • sendMessage(): Send RAG query
  • streamResponse(): Stream responses
  • getSources(): Get available sources

🎨 Styling

Tailwind Configuration

  • Custom color palette
  • Dark mode support
  • Custom animations
  • Responsive breakpoints

Theme Variables

--primary: Blue accent colors
--secondary: Gray/neutral colors
--success: Green indicators
--warning: Orange indicators
--error: Red indicators

🚀 Development

Setup

# Install dependencies
npm install

# Start dev server
npm run dev

# Build for production
npm run build

# Run tests
npm test

Environment Variables

VITE_API_URL=http://localhost:8080

Hot Module Replacement

Vite provides instant HMR for:

  • React components
  • CSS modules
  • TypeScript files

🧪 Testing

Unit Tests

  • Component testing with React Testing Library
  • Service mocking with MSW
  • Hook testing with @testing-library/react-hooks

Integration Tests

  • Page-level testing
  • API integration tests
  • WebSocket testing

📦 Build & Deployment

Docker Support

FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
EXPOSE 5173
CMD ["npm", "run", "preview"]

Production Optimization

  • Code splitting by route
  • Lazy loading for pages
  • Image optimization
  • Bundle size analysis

🔧 Configuration Files

vite.config.ts

  • Path aliases
  • Build optimization
  • Development server config

tsconfig.json

  • Strict type checking
  • Path mappings
  • Compiler options

tailwind.config.js

  • Custom theme
  • Plugin configuration
  • Purge settings

🤝 Contributing

Code Style

  • ESLint configuration
  • Prettier formatting
  • TypeScript strict mode
  • Component naming conventions

Git Workflow

  • Feature branches
  • Conventional commits
  • PR templates
  • Code review process