- ✅ Enhanced accessibility features (focus states, reduced motion) - ✅ Added connection status component styles - ✅ Improved responsive design - ✅ Added utility classes for common patterns - ✅ Added semantic HTML5 elements (`<header>`, `<main>`, `<nav>`) - ✅ Comprehensive ARIA labels and roles for accessibility - ✅ Keyboard navigation support (Alt+1-4 for sections, Esc for menus) - ✅ Better event handling and state management - ✅ Theme change subscriber with meta theme-color sync - ✅ Online/offline connection monitoring - ✅ Enhanced console logging with app info - ✅ `THEMES.md` (400+ lines) - Complete theme system guide - ✅ `README.md` (433+ lines) - Main application documentation - ✅ `COMPONENTS.md` (773+ lines) - UI component library reference - ✅ `QUICKSTART.md` (359+ lines) - Quick start guide for developers - ✅ `REBUILD_NOTES.md` - This summary document **Theme files define base colors:** ```css :root { --primary: 217 91% 60%; /* HSL: blue */ --background: 0 0% 100%; /* HSL: white */ } ``` **App.css bridges to working variables:** ```css :root { --accent-color: hsl(var(--primary)); --primary-bg: hsl(var(--background)); --accent-light: hsla(var(--primary) / 0.1); } ``` **Components use working variables:** ```css .button { background: var(--accent-color); color: hsl(var(--primary-foreground)); } ``` - ✅ Keyboard shortcuts (Alt+1-4, Esc) - ✅ System dark mode detection - ✅ Theme change event subscription - ✅ Automatic document title updates - ✅ Meta theme-color synchronization - ✅ Enhanced console logging - ✅ Better error handling - ✅ Improved accessibility - ✅ Theme switching via dropdown - ✅ Theme persistence to localStorage - ✅ Apps menu with section switching - ✅ Dynamic section loading (Chat, Drive, Tasks, Mail) - ✅ WebSocket chat functionality - ✅ Alpine.js integration for other modules - ✅ Responsive design - ✅ Loading states - [x] Theme switching works across all 19 themes - [x] All sections load correctly - [x] Keyboard shortcuts functional - [x] Responsive on mobile/tablet/desktop - [x] Accessibility features working - [x] No console errors - [x] Theme persistence works - [x] Dark mode detection works ``` documentation/ ├── README.md # Main docs - start here ├── QUICKSTART.md # 5-minute guide ├── THEMES.md # Theme system details ├── COMPONENTS.md # UI component library └── REBUILD_NOTES.md # This summary ``` 1. **HSL Bridge System**: Allows theme files to use shadcn-style HSL variables while the app automatically derives working CSS properties 2. **No Breaking Changes**: All existing functionality preserved and enhanced 3. **Developer-Friendly**: Comprehensive documentation for customization 4. **Accessibility First**: ARIA labels, keyboard navigation, focus management 5. **Performance Optimized**: Instant theme switching, minimal reflows - **Rebuild**: ✅ Complete - **Testing**: ✅ Passed - **Documentation**: ✅ Complete - **Production Ready**: ✅ Yes The rebuild successfully integrates the theme system throughout the UI while maintaining all functionality and adding comprehensive documentation for future development.
172 lines
7.3 KiB
Rust
172 lines
7.3 KiB
Rust
use crate::basic::keywords::add_suggestion::clear_suggestions_keyword;
|
|
use crate::basic::keywords::set_user::set_user_keyword;
|
|
use crate::shared::models::UserSession;
|
|
use crate::shared::state::AppState;
|
|
use log::info;
|
|
use rhai::{Dynamic, Engine, EvalAltResult};
|
|
use std::sync::Arc;
|
|
pub mod compiler;
|
|
pub mod keywords;
|
|
use self::keywords::add_kb::register_add_kb_keyword;
|
|
use self::keywords::add_suggestion::add_suggestion_keyword;
|
|
use self::keywords::add_tool::add_tool_keyword;
|
|
use self::keywords::add_website::add_website_keyword;
|
|
use self::keywords::bot_memory::{get_bot_memory_keyword, set_bot_memory_keyword};
|
|
use self::keywords::clear_kb::register_clear_kb_keyword;
|
|
use self::keywords::clear_tools::clear_tools_keyword;
|
|
#[cfg(feature = "email")]
|
|
use self::keywords::create_draft_keyword;
|
|
use self::keywords::create_site::create_site_keyword;
|
|
use self::keywords::find::find_keyword;
|
|
use self::keywords::first::first_keyword;
|
|
use self::keywords::for_next::for_keyword;
|
|
use self::keywords::format::format_keyword;
|
|
use self::keywords::get::get_keyword;
|
|
use self::keywords::hear_talk::{hear_keyword, talk_keyword};
|
|
use self::keywords::last::last_keyword;
|
|
use self::keywords::list_tools::list_tools_keyword;
|
|
use self::keywords::llm_keyword::llm_keyword;
|
|
use self::keywords::on::on_keyword;
|
|
use self::keywords::print::print_keyword;
|
|
use self::keywords::set::set_keyword;
|
|
use self::keywords::set_context::set_context_keyword;
|
|
use self::keywords::set_kb::{add_kb_keyword, set_kb_keyword};
|
|
use self::keywords::wait::wait_keyword;
|
|
pub struct ScriptService {
|
|
pub engine: Engine,
|
|
}
|
|
impl ScriptService {
|
|
pub fn new(state: Arc<AppState>, user: UserSession) -> Self {
|
|
let mut engine = Engine::new();
|
|
engine.set_allow_anonymous_fn(true);
|
|
engine.set_allow_looping(true);
|
|
#[cfg(feature = "email")]
|
|
create_draft_keyword(&state, user.clone(), &mut engine);
|
|
set_bot_memory_keyword(state.clone(), user.clone(), &mut engine);
|
|
get_bot_memory_keyword(state.clone(), user.clone(), &mut engine);
|
|
create_site_keyword(&state, user.clone(), &mut engine);
|
|
find_keyword(&state, user.clone(), &mut engine);
|
|
for_keyword(&state, user.clone(), &mut engine);
|
|
let _ = register_add_kb_keyword(&mut engine, state.clone(), Arc::new(user.clone()));
|
|
let _ = register_clear_kb_keyword(&mut engine, state.clone(), Arc::new(user.clone()));
|
|
first_keyword(&mut engine);
|
|
last_keyword(&mut engine);
|
|
format_keyword(&mut engine);
|
|
llm_keyword(state.clone(), user.clone(), &mut engine);
|
|
get_keyword(state.clone(), user.clone(), &mut engine);
|
|
set_keyword(&state, user.clone(), &mut engine);
|
|
wait_keyword(&state, user.clone(), &mut engine);
|
|
print_keyword(&state, user.clone(), &mut engine);
|
|
on_keyword(&state, user.clone(), &mut engine);
|
|
hear_keyword(state.clone(), user.clone(), &mut engine);
|
|
talk_keyword(state.clone(), user.clone(), &mut engine);
|
|
set_context_keyword(state.clone(), user.clone(), &mut engine);
|
|
set_user_keyword(state.clone(), user.clone(), &mut engine);
|
|
clear_suggestions_keyword(state.clone(), user.clone(), &mut engine);
|
|
set_kb_keyword(state.clone(), user.clone(), &mut engine);
|
|
add_kb_keyword(state.clone(), user.clone(), &mut engine);
|
|
add_tool_keyword(state.clone(), user.clone(), &mut engine);
|
|
clear_tools_keyword(state.clone(), user.clone(), &mut engine);
|
|
list_tools_keyword(state.clone(), user.clone(), &mut engine);
|
|
add_website_keyword(state.clone(), user.clone(), &mut engine);
|
|
add_suggestion_keyword(state.clone(), user.clone(), &mut engine);
|
|
ScriptService { engine }
|
|
}
|
|
fn preprocess_basic_script(&self, script: &str) -> String {
|
|
let mut result = String::new();
|
|
let mut for_stack: Vec<usize> = Vec::new();
|
|
let mut current_indent = 0;
|
|
for line in script.lines() {
|
|
let trimmed = line.trim();
|
|
if trimmed.is_empty() || trimmed.starts_with("//") {
|
|
continue;
|
|
}
|
|
if trimmed.starts_with("FOR EACH") {
|
|
for_stack.push(current_indent);
|
|
result.push_str(&" ".repeat(current_indent));
|
|
result.push_str(trimmed);
|
|
result.push_str("{\n");
|
|
current_indent += 4;
|
|
result.push_str(&" ".repeat(current_indent));
|
|
result.push('\n');
|
|
continue;
|
|
}
|
|
if trimmed.starts_with("NEXT") {
|
|
if let Some(expected_indent) = for_stack.pop() {
|
|
if (current_indent - 4) != expected_indent {
|
|
panic!("NEXT without matching FOR EACH");
|
|
}
|
|
current_indent = current_indent - 4;
|
|
result.push_str(&" ".repeat(current_indent));
|
|
result.push_str("}\n");
|
|
result.push_str(&" ".repeat(current_indent));
|
|
result.push_str(trimmed);
|
|
result.push(';');
|
|
result.push('\n');
|
|
continue;
|
|
} else {
|
|
panic!("NEXT without matching FOR EACH");
|
|
}
|
|
}
|
|
if trimmed == "EXIT FOR" {
|
|
result.push_str(&" ".repeat(current_indent));
|
|
result.push_str(trimmed);
|
|
result.push('\n');
|
|
continue;
|
|
}
|
|
result.push_str(&" ".repeat(current_indent));
|
|
let basic_commands = [
|
|
"SET",
|
|
"CREATE",
|
|
"PRINT",
|
|
"FOR",
|
|
"FIND",
|
|
"GET",
|
|
"EXIT",
|
|
"IF",
|
|
"THEN",
|
|
"ELSE",
|
|
"END IF",
|
|
"WHILE",
|
|
"WEND",
|
|
"DO",
|
|
"LOOP",
|
|
"HEAR",
|
|
"TALK",
|
|
"SET CONTEXT",
|
|
"SET USER",
|
|
"GET BOT MEMORY",
|
|
"SET BOT MEMORY",
|
|
];
|
|
let is_basic_command = basic_commands.iter().any(|&cmd| trimmed.starts_with(cmd));
|
|
let is_control_flow = trimmed.starts_with("IF")
|
|
|| trimmed.starts_with("ELSE")
|
|
|| trimmed.starts_with("END IF");
|
|
if is_basic_command || !for_stack.is_empty() || is_control_flow {
|
|
result.push_str(trimmed);
|
|
result.push(';');
|
|
} else {
|
|
result.push_str(trimmed);
|
|
if !trimmed.ends_with(';') && !trimmed.ends_with('{') && !trimmed.ends_with('}') {
|
|
result.push(';');
|
|
}
|
|
}
|
|
result.push('\n');
|
|
}
|
|
if !for_stack.is_empty() {
|
|
panic!("Unclosed FOR EACH loop");
|
|
}
|
|
result
|
|
}
|
|
pub fn compile(&self, script: &str) -> Result<rhai::AST, Box<EvalAltResult>> {
|
|
let processed_script = self.preprocess_basic_script(script);
|
|
info!("Processed Script:\n{}", processed_script);
|
|
match self.engine.compile(&processed_script) {
|
|
Ok(ast) => Ok(ast),
|
|
Err(parse_error) => Err(Box::new(parse_error.into())),
|
|
}
|
|
}
|
|
pub fn run(&self, ast: &rhai::AST) -> Result<Dynamic, Box<EvalAltResult>> {
|
|
self.engine.eval_ast(ast)
|
|
}
|
|
}
|