Archon/archon-ui-main
Wirasm b383c8cbec
refactor: remove ETag Map cache layer for TanStack Query single source of truth (#676)
* refactor: remove ETag Map cache layer for TanStack Query single source of truth

- Remove Map-based cache from apiWithEtag.ts to eliminate double-caching anti-pattern
- Move apiWithEtag.ts to shared location since used across multiple features
- Implement NotModifiedError for 304 responses to work with TanStack Query
- Remove invalidateETagCache calls from all service files
- Preserve browser ETag headers for bandwidth optimization (70-90% reduction)
- Add comprehensive test coverage (10 test cases)
- All existing functionality maintained with zero breaking changes

This addresses Phase 1 of frontend state management refactor, making TanStack Query
the sole authority for cache decisions while maintaining HTTP 304 performance benefits.

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

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

* fix: increase API timeout to 20s for large delete operations

Temporary fix for database performance issue where DELETE operations on
crawled_pages table with 7K+ rows take 13+ seconds due to sequential scan.

Root cause analysis:
- Source '9529d5dabe8a726a' has 7,073 rows (98% of crawled_pages table)
- PostgreSQL uses sequential scan instead of index for large deletes
- Operation takes 13.4s but frontend timeout was 10s
- Results in frontend errors while backend eventually succeeds

This prevents timeout errors during knowledge item deletion until we
implement proper batch deletion or database optimization.

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

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

* refactor: complete simplification of ETag handling (Option 3)

- Remove all explicit ETag handling code from apiWithEtag.ts
- Let browser handle ETags and 304 responses automatically
- Remove NotModifiedError class and associated retry logic
- Simplify QueryClient retry configuration in App.tsx
- Add comprehensive tests documenting browser caching behavior
- Fix missing generic type in knowledgeService searchKnowledgeBase

This completes Phase 1 of the frontend state management refactor.
TanStack Query is now the single source of truth for caching,
while browser handles HTTP cache/ETags transparently.

Benefits:
- 50+ lines of code removed
- Zero complexity for 304 handling
- Bandwidth optimization maintained (70-90% reduction)
- Data freshness guaranteed
- Perfect alignment with TanStack Query philosophy

* fix: resolve DOM nesting validation error in ProjectCard

Changed ProjectCard from motion.li to motion.div since it's already
wrapped in an li element by ProjectList. This fixes the React warning
about li elements being nested inside other li elements.

* fix: properly unwrap task mutation responses from backend

The backend returns wrapped responses for mutations:
{ message: string, task: Task }

But the frontend was expecting just the Task object, causing
description and other fields to not persist properly.

Fixed by:
- Updated createTask to unwrap response.task
- Updated updateTask to unwrap response.task
- Updated updateTaskStatus to unwrap response.task

This ensures all task data including descriptions persist correctly.

* test: add comprehensive tests for task service response unwrapping

Added 15 tests covering:
- createTask with response unwrapping
- updateTask with response unwrapping
- updateTaskStatus with response unwrapping
- deleteTask (no unwrapping needed)
- getTasksByProject (direct response)
- Error handling for all methods
- Regression tests ensuring description persistence
- Full field preservation when unwrapping responses

These tests verify that the backend's wrapped mutation responses
{ message: string, task: Task } are properly unwrapped to return
just the Task object to consumers.

* fix: add explicit event propagation stopping in ProjectCard

Added e.stopPropagation() at the ProjectCard level when passing
handlers to ProjectCardActions for pin and delete operations.

This provides defense in depth even though ProjectCardActions
already stops propagation internally. Ensures clicking action
buttons never triggers card selection.

* refactor: consolidate error handling into shared module

- Create shared/errors.ts with APIServiceError, ValidationError, MCPToolError
- Move error classes and utilities from projects/shared/api to shared location
- Update all imports to use shared error module
- Fix cross-feature dependencies (knowledge no longer depends on projects)
- Apply biome formatting to all modified files

This establishes a clean architecture where common errors are properly
located in the shared module, eliminating feature coupling.

🤖 Generated with Claude Code

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

* test: improve test isolation and clean up assertions

- Preserve and restore global AbortSignal and fetch to prevent test pollution
- Rename test suite from "Simplified API Client (Option 3)" to "apiWithEtag"
- Optimize duplicate assertions by capturing promises once
- Use toThrowError with specific error instances for better assertions

This ensures tests don't affect each other and improves test maintainability.

🤖 Generated with Claude Code

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

* refactor: Remove unused callAPI function and document 304 handling approach

- Delete unused callAPI function from projects/shared/api.ts (56 lines of dead code)
- Keep only the formatRelativeTime utility that's actively used
- Add comprehensive documentation explaining why we don't handle 304s explicitly
- Document that browser handles ETags/304s transparently and we use TanStack Query for cache control
- Update apiWithEtag.ts header to clarify the simplification strategy

This follows our beta principle of removing dead code immediately and maintains our simplified approach to HTTP caching where the browser handles 304s automatically.

* docs: Fix comment drift and clarify ETag/304 handling documentation

- Update header comment to be more technically accurate about Fetch API behavior
- Clarify that fetch (not browser generically) returns cached responses for 304s
- Explicitly document that we don't add If-None-Match headers
- Add note about browser's automatic ETag revalidation

These documentation updates prevent confusion about our simplified HTTP caching approach.

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-09-17 16:45:23 +03:00
..
public feat: Ollama Integration with Separate LLM/Embedding Model Support (#643) 2025-09-15 06:38:02 -07:00
src refactor: remove ETag Map cache layer for TanStack Query single source of truth (#676) 2025-09-17 16:45:23 +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