Web GUI Parity¶
Status: 🟡 Planning Phase
Date: November 16, 2025
Priority: High
Complexity: Very High
Summary¶
Deliver a browser-based control surface that mirrors the desktop GUI pixel-for-pixel in layout, flows, and behaviours. The WebGUI must expose every control, panel, status indicator, and workflow currently available through the Tk-based app, while remaining in sync with the existing state management, background workers, and analytics pipelines. Users will launch it locally via aios web, which should start a web server, open (or log) a URL, and run alongside the existing core services without requiring the desktop GUI to be present.
Success Criteria¶
- Functional parity: All panels (
Chat,Brains,Datasets,Training,Evaluation,Resources,Debug,Settings,MCP Manager,Help,Output) behave identically, surface the same live data, and update in real time. - Single source of truth: State mutations performed through the browser immediately propagate to
gui_state.jsonand the in-memory structures that the Tk GUI uses; no divergence when both UIs run simultaneously. - Cross-platform:
aios webworks on Windows and Linux with Python-only dependencies plus a Node toolchain for front-end builds; optional Mac support documented. - Security baseline: Local-only access by default with optional authentication and TLS knobs for remote deployment.
- Observability: Structured logs and metrics that distinguish WebGUI events from Tk GUI events without breaking the existing analytics pipeline.
- Testing: Automated parity regression test suite proving behaviour equivalence for critical workflows, and Playwright smoke tests for the WebGUI.
Constraints & Considerations¶
- UI fidelity: Visual design must match colours, typography, spacing, and component behaviour of the Tk app. Introduce a design token map sourced from the existing theme configuration so that any future theme tweaks propagate to both UIs.
- Shared runtime: Reuse existing services in
src/aios/gui/appandsrc/aios/gui/componentsrather than duplicating business logic. Where Tk widgets hold state, extract presenter/view-model layers so they can feed both Tk and web surfaces. - Async-first: All new server components must use
asyncio, integrate with the existingsetup_resourcesloop, and avoid blocking the worker pools that power agents and training operations. - No breaking change: Tk GUI must continue to run unchanged; users can run either UI independently or both concurrently.
- Asset bundling: Front-end assets must be buildable offline and distributable with the Python package; avoid heavyweight runtime dependencies.
Proposed Architecture¶
┌─────────────────────────────┐ ┌────────────────────────────┐
│ aios web (CLI entrypoint) │ │ Front-end (React/Vite) │
│ • loads headless app core │ │ • UI clone of Tk panels │
│ • boots FastAPI+Socket.IO │◀──────▶│ • State synced via WS/REST│
│ • serves static assets │ │ • Theming via design tokens│
└──────────────┬──────────────┘ └──────────┬─────────────────┘
│ │
▼ │
┌────────────────────┐ │
│ Shared GUI Core │◀──────────────────────┘
│ • Panel presenters│ Web view-models reuse│
│ • State adapters │ Tk services & storage│
└─────────┬──────────┘
│
▼
Existing services, threads,
async loop, analytics, etc.
Backend Service (Python)¶
- Framework: FastAPI (for REST) +
uvicornrunner with ASGI lifespan hooks tied intosetup_resources. - Reuse
setup_resources,setup_event_handlers, and panel initialization to build a headlessAiosTkApp-derived context without instantiating Tk widgets. - Expose REST endpoints per panel (e.g.,
/api/chat/send,/api/brains/list) and WebSocket channels for event-driven updates (log stream, training progress, background tasks). - Implement a state sync layer that watches
schedule_state_saveand repository-specific caches, emitting change diffs to clients.
Front-End (TypeScript)¶
- Stack: React 18 + Vite + React Query/Zustand for state management; Tailwind or CSS modules constrained by design tokens extracted from Tk theme definitions.
- Component library: Build custom components that match Tk layouts; consider using Blueprint.js or Ant Design only if they can be themed precisely; otherwise, bespoke components ensure parity.
- Navigation: Mirror Tk notebook tabs as horizontal navigation; subpanels map 1:1.
- Real-time data: WebSocket subscriptions for logs, progress bars, chat streaming; REST for CRUD operations.
CLI Entry (aios web)¶
- Add subcommand in
src/aios/cli/aios.pywiring toaios.cli.web_cli:run. - Responsibilities: ensure venv dependencies, start FastAPI service, build (or verify) front-end assets, optionally open the browser (respect
--no-openflag), log host/port. - Flags:
--host,--port,--theme,--open/--no-open,--auth-token,--certfile,--keyfile,--allow-remote(with warnings).
Implementation Phases¶
Phase 0 – Discovery & Parity Mapping¶
- Catalogue every panel, widget, and command in the Tk UI; produce a JSON inventory describing fields, events, validation rules, and dependencies.
- Document where state lives (e.g.,
state_management, panel-specific caches) and identify Tk-only code paths that must be abstracted. - Identify blocking dependencies (e.g., direct Tk widget calls inside services) and plan refactors to extract logic into reusable classes.
Phase 1 – Core Refactor for Shared State¶
- Introduce a
src/aios/gui/core(or expand existingcore) module that exposes headless presenters/controllers for each panel. - Update Tk panels to consume the new presenters via dependency injection so they remain functional.
- Ensure presenters expose async-safe methods and emit typed events (e.g., via
asyncio.Queueor RxPy) that the Web backend can subscribe to. - Extend state persistence to broadcast diffs whenever
schedule_state_saveruns, enabling live reload in the browser.
Phase 2 – Web Backend Skeleton¶
- Scaffold FastAPI app under
src/aios/webui/server.pyintegrating shared presenters. - Implement auth middleware (token header) and optional HTTPS.
- Provide endpoints per panel in read/write parity (e.g., GET
/api/settings, POST/api/settings/theme). - Set up Socket.IO or Starlette WebSocket endpoints for:
- Log/event stream (
/ws/logs) - Status updates (resources, training progress)
- Chat streaming (token-by-token)
- Add background tasks that bridge presenter events to WebSocket broadcasts.
Phase 3 – Front-End Application¶
- Create
webui/directory (ignored by lint when not built) containing Vite project with React + TypeScript + ESLint/Prettier. - Define design tokens JSON generated from Tk theme definitions; load at runtime to guarantee parity.
- Build tab components mimicking Tk layout; incorporate virtualization where Tk uses scrollable lists.
- Implement data bindings with React Query for REST (CRUD) and custom hooks for WebSocket streams.
- Provide fallback skeleton states replicating Tk loading overlays.
Phase 4 – Packaging & CLI Integration¶
- Integrate Vite build into Python packaging via
pyproject.tomloptional dependencies (webui). - Update
setup.cfg/ entry points to includeaios webcommand; ensureaiosconsole script imports minimal dependencies until the command runs. - Provide
scripts/build_webui.shand.ps1for dev ergonomics; integrate into CI using npm caches. - Ensure built assets land under
src/aios/webui/static/and are included withpkgutil.get_datafor offline use.
Phase 5 – Verification & Docs¶
- Implement automated parity tests:
- Presenter unit tests covering CRUD flows.
- Snapshot/state diff tests comparing Tk + Web responses given identical fixtures.
- Playwright smoke suite covering critical workflows (chat generation, brain selection, dataset upload, training start/stop, settings save).
- Update
docs/guide/with WebGUI usage, security warnings, remote deployment guide. - Record demo walkthrough once stable.
Testing Strategy¶
- Unit tests: For presenters and API contracts using pytest + httpx AsyncClient.
- Integration tests: Launch FastAPI app in-process, run Playwright headless tests to validate UI flows; reuse fixtures to ensure deterministic data.
- Concurrency tests: Simulate simultaneous Tk + Web interactions to verify lock-free state updates and absence of race conditions (use
pytest-asynciowithasyncio.Eventbarriers). - Performance tests: Benchmark WebSocket throughput and latency for chat streaming; ensure under-load behaviour matches Tk event loop responsiveness.
Security & Deployment Notes¶
- Default bind:
127.0.0.1:8123. Require explicit--allow-remoteto bind to0.0.0.0and show warning banner in UI. - Token-based auth stored in
~/.config/ai-os/webgui_token; optionalAIOS_WEB_TOKENenv override. - Optional TLS via user-provided
--certfile/--keyfile. - Document reverse-proxy guidance (Caddy/Nginx) for secure remote access.
Open Questions / Risks¶
- Tk dependency: Some panels might rely on direct widget references; refactor effort may be substantial.
- Theme fidelity: Tk theming primitives differ from CSS; will need a reliable mapping process.
- Front-end build size: Need to ensure packaged assets keep overall wheel size acceptable; may need optional extra.
- Simultaneous sessions: Determine how to handle multiple browsers; probably allow read-only by default, configurable to accept multi-writer with event conflict resolution.
- Accessibility: Evaluate if Tk shortcuts (e.g., keyboard accelerators) must be mapped to the Web UI for parity.
Deliverables Checklist¶
- Shared presenter layer with parity coverage for each panel.
- FastAPI WebGUI server with REST + WebSocket endpoints.
- React/Vite front-end that mirrors the Tk UI.
- CLI command
aios webwith documented options. - Parity test suite and Playwright automation in CI.
- Updated documentation in
docs/guide/and release notes. - Security review artefacts (threat model, auth configuration).
Next Steps¶
- Approve architecture direction (shared presenters + FastAPI + React).
- Spin up Phase 0 discovery ticket to inventory Tk components.
- Allocate resources for refactor + front-end build, including Node environment setup in CI.