Skip to content

Add dedicated error display panel to TUI for DevHub core errors #2

@diyor28

Description

@diyor28

Add Dedicated Error Display Panel to TUI

Problem

Currently, DevHub TUI has limited error visibility:

  • Service errors are only shown inline with service status (ErrorMsg field)
  • Core DevHub errors (MCP server, state manager, etc.) are silently ignored or logged to stderr
  • No centralized error view for debugging issues
  • Users have no way to see system-level errors within the TUI

Proposed Solution

Add a dedicated error panel to the TUI that displays:

  1. Service-level errors - Current ErrorMsg from services
  2. Core system errors - MCP server, StateManager, ServiceManager errors
  3. Application errors - Configuration, dependency resolution, etc.
  4. Historical error log - Recent errors with timestamps

Relevant Files

  • devhub.go - Main application entry point where core errors are silently ignored
  • view.go - TUI rendering logic that needs error panel
  • types.go - Data structures for UI state
  • update.go - Key handling for error panel navigation
  • mcp_server.go - MCP server errors that need capturing
  • state_manager.go - State management errors
  • service_manager.go - Service management errors

Proposed ASCII Layout

╭──────────────────────────────────────────────────────────────────────────────╮
│                          🚀 DevHub - Error Panel                            │
│                       Development Tools Manager                              │
├──────────────────────────────────────────────────────────────────────────────┤
│ 📦 5 services  •  ✅ 3 running  •  ❌ 2 errors                              │
├──────────────────────────────────────────────────────────────────────────────┤
│ Services:  ⚡ 45.2%  💾 512.3 MB                                            │
│ System:    ⚡ 23.1%  💾 8.2 GB (68%)                                        │
╰──────────────────────────────────────────────────────────────────────────────╯

┌─ Errors (E to toggle) ─────────────────────────────────────────────────────┐
│ 🔴 [18:01:45] MCP Server: Failed to bind to port 8765 (address in use)    │
│ ⚠️  [18:01:23] postgres: Health check timeout after 30s                   │
│ 🔴 [18:00:12] redis: Process terminated unexpectedly (exit code 1)        │
│ ⚠️  [17:59:45] StateManager: Resource monitoring failed for service 'api'  │
└────────────────────────────────────────────────────────────────────────────┘

▶ postgres (Failed)                                    🔴 Error
  PostgreSQL Database Server
  PID: 1234 | Uptime: 5m23s | CPU: 2.1% | Mem: 45.2MB
  Dependencies: none

  redis (Running)                                      ◉ Running  
  Redis Cache Server
  PID: 5678 | Uptime: 10m12s | CPU: 1.5% | Mem: 23.1MB

↑/↓: Navigate • Space: Toggle • r: Restart • Enter: View Logs • E: Errors • q: Quit

Implementation Details

1. Error Collection System

type ErrorEntry struct {
    Timestamp time.Time
    Source    string // "service:postgres", "mcp", "state", etc.
    Level     ErrorLevel // Error, Warning, Info
    Message   string
}

type ErrorManager struct {
    errors []ErrorEntry
    mu     sync.RWMutex
    maxEntries int
}

2. UI State Updates

// In types.go
type UIState struct {
    Width         int
    Height        int
    SelectedIndex int
    ViewMode      ViewMode
    ShowErrors    bool  // New: toggle error panel
    ErrorScroll   int   // New: scroll position in error panel
    // ... existing fields
}

// New view mode
const (
    ServiceView ViewMode = iota
    LogView
    ErrorView  // New: dedicated error view
)

3. Key Bindings

  • E: Toggle error panel visibility
  • Shift+E: Switch to full error view
  • In error view: ↑/↓ scroll, Enter for details, C to clear

4. Error Sources to Capture

  • MCP Server errors: Port binding, request handling
  • Service Manager errors: Start/stop failures, dependency issues
  • State Manager errors: Resource monitoring, update failures
  • Configuration errors: Invalid YAML, missing dependencies
  • Health Check errors: Timeout, connection failures

Acceptance Criteria

  • Error panel toggles with E key
  • Shows recent errors with timestamps and sources
  • Color-coded by severity (red=error, yellow=warning, blue=info)
  • Scrollable when more errors than display space
  • Integrates with existing service error display
  • Error panel auto-shows when new errors occur
  • Errors are categorized by source (service, core, system)
  • Historical error persistence during session
  • Clear errors functionality

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions