The CodeGenie Web Interface provides a modern, real-time web-based UI for interacting with the AI coding agent. It features plan visualization, diff viewing, approval workflows, progress tracking, and live updates via WebSocket.
View execution plans with step-by-step progress tracking.
Features:
- Visual step indicators
- Progress bars for each step
- Dependency tracking
- Status color coding
- Timeline display
- Error messages
Usage:
from codegenie.ui.web_components import ExecutionPlan, PlanStep
plan = ExecutionPlan(
id="plan_1",
name="Build REST API",
description="Create a complete REST API",
steps=[...],
status="in_progress",
created_at=datetime.now().isoformat()
)Compare file changes before applying them.
Features:
- Side-by-side line numbers
- Syntax highlighting
- Addition/deletion colors
- File statistics
- Scrollable content
Usage:
from codegenie.ui.web_components import FileDiff
diff = FileDiff(
file_path="src/api.py",
old_content="...",
new_content="...",
diff_lines=[...],
additions=10,
deletions=5
)Interactive approval workflow for operations.
Features:
- Risk level indicators
- Operation type icons
- Detailed information
- One-click approve/reject
- Real-time updates
Usage:
from codegenie.ui.web_components import ApprovalRequest
request = ApprovalRequest(
id="approval_1",
title="Create new file",
description="Create authentication module",
operation_type="file_create",
risk_level="safe",
details={...},
status="pending",
timestamp=datetime.now().isoformat()
)Real-time progress monitoring.
Features:
- Metric cards
- Overall progress bar
- Time tracking
- Activity feed
- Auto-refresh
Usage:
from codegenie.ui.web_components import ProgressMetrics
metrics = ProgressMetrics(
total_tasks=10,
completed_tasks=5,
failed_tasks=1,
in_progress_tasks=2,
estimated_time_remaining=300,
elapsed_time=450
)WebSocket-based live updates.
Features:
- Channel subscriptions
- Progress streaming
- Command output streaming
- Plan updates
- Notifications
Usage:
from codegenie.ui.realtime_updates import RealtimeUpdateManager
manager = RealtimeUpdateManager()
await manager.start()
# Send updates
await manager.send_progress_update(update)
await manager.send_command_output(output)
await manager.send_plan_update(plan_update)GET /api/plans/{plan_id}- Get plan visualization
GET /api/diffs/{diff_id}- Get diff viewer
GET /api/approvals- Get pending approvalsPOST /api/approvals/{request_id}/approve- Approve requestPOST /api/approvals/{request_id}/reject- Reject request
GET /api/progress- Get progress dashboard
GET /ws?channels=global,progress,commands,plans,approvals- WebSocket connection
Subscribe to channels:
ws.send(JSON.stringify({
type: 'subscribe',
channels: ['progress', 'commands']
}));Send chat message:
ws.send(JSON.stringify({
type: 'chat',
message: 'Create a REST API'
}));Progress update:
{
"type": "progress_update",
"channel": "progress",
"data": {
"type": "task_progress",
"task_id": "task_1",
"task_name": "Build API",
"progress": 50,
"message": "Implementing authentication",
"timestamp": "2024-11-12T18:00:00"
}
}Command output:
{
"type": "command_output",
"channel": "commands",
"data": {
"command_id": "cmd_1",
"command": "npm install",
"output_type": "stdout",
"content": "added 50 packages",
"timestamp": "2024-11-12T18:00:00"
}
}Plan update:
{
"type": "plan_update",
"channel": "plans",
"data": {
"plan_id": "plan_1",
"step_id": "step_2",
"status": "completed",
"progress": 100,
"message": "Step completed",
"timestamp": "2024-11-12T18:00:00"
}
}Notification:
{
"type": "notification",
"channel": "global",
"data": {
"message": "Task completed successfully",
"level": "success",
"timestamp": "2024-11-12T18:00:00"
}
}from codegenie.core.agent import CodeGenieAgent
from codegenie.core.config import Config
from codegenie.ui.web_interface import WebInterface
# Create agent
config = Config()
agent = CodeGenieAgent(config)
# Create web interface
web_interface = WebInterface(agent, config)
# Start server
await web_interface.start_server(host="localhost", port=8080)# Access real-time components
progress_tracker = web_interface.progress_tracker
command_streamer = web_interface.command_streamer
plan_tracker = web_interface.plan_tracker
# Track task progress
await progress_tracker.start_task("task_1", "Build API", total_steps=5)
await progress_tracker.update_progress("task_1", 3, "Implementing auth")
await progress_tracker.complete_task("task_1", "API built successfully")
# Stream command output
await command_streamer.start_command("cmd_1", "npm install")
await command_streamer.stream_output("cmd_1", "Installing...", "stdout")
await command_streamer.complete_command("cmd_1", 0)
# Track plan execution
await plan_tracker.start_plan("plan_1", "Deploy", ["step1", "step2"])
await plan_tracker.update_step("plan_1", "step1", "completed", 100)
await plan_tracker.complete_plan("plan_1")Interactive chat interface with the AI agent.
Create and manage execution workflows.
View execution plans with live updates.
Review and approve/reject operations.
Monitor real-time progress dashboard.
Coordinate multiple specialized agents.
View learning profile and provide feedback.
Manage configuration settings.
All components come with built-in CSS. The styles are automatically included when using the WebComponentsManager:
from codegenie.ui.web_components import WebComponentsManager
manager = WebComponentsManager()
css = manager.get_all_css() # Get all component CSSYou can override styles by adding custom CSS:
.plan-visualization {
/* Your custom styles */
}
.diff-viewer {
/* Your custom styles */
}- Chrome/Edge: ✅ Full support
- Firefox: ✅ Full support
- Safari: ✅ Full support
- Opera: ✅ Full support
- WebSocket Authentication: Implement authentication for production
- CORS Configuration: Configure CORS properly for your domain
- Session Management: Use secure session storage
- Input Validation: Validate all user inputs
- Rate Limiting: Implement rate limiting for API endpoints
- Channel Subscriptions: Subscribe only to needed channels
- Update Batching: Batch multiple updates when possible
- Connection Pooling: Reuse WebSocket connections
- Lazy Loading: Load components on demand
- Caching: Cache static resources
Problem: WebSocket disconnects frequently Solution: Check network stability, implement reconnection logic
Problem: Messages not received Solution: Verify channel subscriptions, check server logs
Problem: Real-time updates not showing Solution: Check WebSocket connection, verify message handling
Problem: Components not rendering Solution: Check browser console for errors, verify data format
Problem: Slow page load Solution: Enable caching, optimize CSS, lazy load components
Problem: High memory usage Solution: Limit activity feed size, clean up old data
See demo_web_interface.py for a complete working example with:
- Server setup
- Real-time updates
- Progress tracking
- Command streaming
- Plan execution
To add new components:
- Create component class in
web_components.py - Implement
generate_html()andgenerate_css()methods - Add to
WebComponentsManager - Update API endpoints in
web_interface.py - Add JavaScript handlers
- Update documentation
Part of the CodeGenie project. See main LICENSE file.