5.8 KiB
5.8 KiB
UI Migration Summary
Overview
This document summarizes the migration from web/ directory structure to ui/ directory structure and the introduction of .gbui file format for user interface templates.
Directory Structure Changes
Before
botserver/
└── web/
├── desktop/
│ └── index.html
└── html/
After
botserver/
└── ui/
├── desktop/
│ ├── default.gbui # Full-featured interface (copy of index.html)
│ ├── single.gbui # Simplified single-page chat interface
│ └── index.html # Original file retained for compatibility
└── html/
Code Changes
1. Module Renaming
- Before:
botserver/src/core/web_server/ - After:
botserver/src/core/ui_server/
2. Import Updates
lib.rs
// Before
pub use core::web_server;
// After
pub use core::ui_server;
main.rs
// Before
use botserver::core::web_server;
.route("/", get(crate::web_server::index))
// After
use botserver::core::ui_server;
.route("/", get(crate::ui_server::index))
3. Path Updates in ui_server/mod.rs
// Before
match fs::read_to_string("web/desktop/index.html")
let static_path = PathBuf::from("./web/desktop");
// After
match fs::read_to_string("ui/desktop/index.html")
let static_path = PathBuf::from("./ui/desktop");
4. Configuration Updates
tauri.conf.json
// Before
"frontendDist": "./web/desktop"
// After
"frontendDist": "./ui/desktop"
Cargo.toml Features
# Before
default = ["web-server", ...]
desktop = [..., "web-server"]
web-server = []
minimal = ["web-server", "chat"]
lightweight = ["web-server", "chat", "drive", "tasks"]
# After
default = ["ui-server", ...]
desktop = [..., "ui-server"]
ui-server = []
minimal = ["ui-server", "chat"]
lightweight = ["ui-server", "chat", "drive", "tasks"]
5. Service Name Updates
// Before (in admin.rs)
name: "web_server".to_string()
service: "web_server".to_string()
// After
name: "ui_server".to_string()
service: "ui_server".to_string()
Documentation Updates
1. Chapter Structure
- Renamed
chapter-04/web-interface.mdtochapter-04/ui-interface.md - Renamed
chapter-09/web-automation.mdtochapter-09/ui-automation.md - Added new Chapter 10: .gbui Files Reference with comprehensive documentation
2. Terminology Updates Throughout Documentation
- "Web server" → "UI server"
- "Web interface" → "UI interface"
- "Access web interface" → "Access UI interface"
- "Starting web server" → "Starting UI server"
3. New .gbui Documentation Structure
chapter-10-gbui/
├── README.md # .gbui overview and reference
├── structure.md # Template structure details
├── components.md # Component library reference
├── javascript-api.md # JavaScript API documentation
├── mobile.md # Mobile optimization guide
├── custom-templates.md # Creating custom templates
└── embedding.md # Embedding .gbui files
New .gbui File Format
Purpose
The .gbui (General Bots User Interface) format provides HTML-based templates for bot interfaces with:
- Built-in WebSocket communication
- Theme integration
- Responsive design
- Component library
- JavaScript API
Available Templates
- default.gbui - Full-featured desktop interface with multiple apps (Chat, Drive, Tasks, Mail)
- single.gbui - Streamlined single-page chat interface with minimal footprint
Key Features
- Template variables:
{{bot_name}},{{api_endpoint}},{{websocket_url}} - Component system with
data-gb-componentattributes - CSS class prefix:
gb-for all General Bots components - Theme variables:
--gb-primary,--gb-secondary, etc.
Important Notes
Channel Names Remain Unchanged
The term "web" as a channel identifier (alongside "whatsapp", "teams", etc.) remains unchanged in:
- Channel adapter references
- Session channel identification
- Message routing logic
These refer to the communication channel type, not the server or interface.
UI Automation Clarification
The UI automation module now encompasses:
- Web Automation: Browser automation, web scraping
- Desktop Automation: Desktop application control
- Mobile Automation: Mobile app UI control
- Screen Capture: Cross-platform screenshot and recording capabilities
Migration Checklist
- Rename
web/directory toui/ - Create
default.gbuifromindex.html - Create
single.gbuisimplified template - Update module name from
web_servertoui_server - Update all import statements
- Update path references in code
- Update tauri.conf.json
- Update Cargo.toml features
- Update service names in admin endpoints
- Update documentation terminology
- Create .gbui documentation chapter
- Update SUMMARY.md with new chapter
Testing Required
After migration, test:
- UI server starts correctly on port 8080
- Static files are served from
ui/desktop/ - Both .gbui templates load correctly
- WebSocket connections work
- Theme switching functions properly
- Mobile responsiveness is maintained
- Desktop app (Tauri) builds successfully
Rollback Plan
If issues occur:
- Rename
ui/back toweb/ - Revert module name to
web_server - Restore original import statements
- Update paths back to
web/desktop - Revert configuration files
- Restore original documentation
Benefits of Migration
- Clearer Naming: "UI" better represents the interface layer
- .gbui Format: Standardized template format for bot interfaces
- Better Documentation: Dedicated chapter for UI templates
- Extensibility: Easy to add new template types (mobile, kiosk, embedded)
- Consistency: Aligns with other .gb* file formats (.gbapp, .gbot, .gbtheme, etc.)