feat: Wave 3 — plugin loader + Flet GUI (parity with Rust fork)
Plugin loader (mirrors Rust #29): - plugins_store.py walks %APPDATA%\com.priler.jarvis\plugins\<name>\ for commands.yaml fragments and merges them into VA_CMD_LIST at startup. Same schema as the project root commands.yaml. Per-pack `disabled` flag file skips a pack without deletion. Built-in ids win conflicts so a malicious pack can't silently override open_browser. 9 unit tests (parity with the Rust tests). - main.py: plugin merge runs after the root yaml load; logs the number of extra commands picked up. Flet GUI (#27 — first parity with the Rust Tauri GUI): - New gui/ package: __main__.py launches via `python -m gui` (or gui.bat). app.py routes between 7 pages (Главная / Команды / Макросы / Расписание / Память / Плагины / Настройки) via NavigationRail; dark theme matching the Tauri look. - gui/services.py centralises every store-module call the pages share — single place to swap implementations later. - One file per page in gui/pages/, all expose `build(page)` and use the same card layout idiom. Pages mirror the Tauri ones feature- for-feature: home (status + counters + launcher), commands (filterable list of all VA_CMD_LIST entries), macros (list + delete + recording banner), scheduler (list + remove), memory (add/forget/search), plugins (toggle/open folder), settings (profile + LLM hot-swap). - requirements.txt: flet>=0.85 (optional; assistant runs without). - 3 smoke tests verify imports + build callables; skip cleanly when Flet isn't installed. README: documents both the GUI and the plugin layout in user-facing terms. Tests: 42 → 54 (+9 plugins +3 GUI smoke).
This commit is contained in:
parent
2bef1d5ea7
commit
59a1258dcc
19 changed files with 1233 additions and 0 deletions
90
gui/pages/macros.py
Normal file
90
gui/pages/macros.py
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
"""Macros page — list macros, show steps, delete. Recording is voice-only."""
|
||||
|
||||
import flet as ft
|
||||
|
||||
from gui import services as svc
|
||||
|
||||
|
||||
def build(page: ft.Page) -> ft.Control:
|
||||
list_view = ft.Column(spacing=8, expand=True, scroll=ft.ScrollMode.AUTO)
|
||||
|
||||
def render():
|
||||
list_view.controls.clear()
|
||||
macros = svc.macros_all()
|
||||
rec_on, rec_name = svc.macros_recording()
|
||||
if rec_on:
|
||||
list_view.controls.append(_recording_banner(rec_name))
|
||||
if not macros:
|
||||
list_view.controls.append(
|
||||
ft.Text(
|
||||
"Макросов пока нет. Запиши голосом: «Запиши макрос работа», "
|
||||
"потом скажи команды, потом «Сохрани макрос».",
|
||||
color="#8aa0a8",
|
||||
)
|
||||
)
|
||||
for m in sorted(macros, key=lambda x: x["name"]):
|
||||
list_view.controls.append(_macro_card(m, on_delete=lambda n=m["name"]: do_delete(n)))
|
||||
page.update()
|
||||
|
||||
def do_delete(name: str) -> None:
|
||||
if svc.macros_delete(name):
|
||||
page.open(ft.SnackBar(content=ft.Text(f"Удалил «{name}»", color="white"), bgcolor="#33d3a4"))
|
||||
render()
|
||||
|
||||
render()
|
||||
|
||||
return ft.Column(
|
||||
[
|
||||
ft.Row([
|
||||
ft.Text("Макросы", size=24, weight=ft.FontWeight.W_700),
|
||||
ft.FilledButton(text="Обновить", icon=ft.Icons.REFRESH, on_click=lambda e: render()),
|
||||
], alignment=ft.MainAxisAlignment.SPACE_BETWEEN),
|
||||
list_view,
|
||||
],
|
||||
expand=True,
|
||||
spacing=10,
|
||||
)
|
||||
|
||||
|
||||
def _recording_banner(name: str | None) -> ft.Control:
|
||||
return ft.Container(
|
||||
content=ft.Row([
|
||||
ft.Icon(ft.Icons.FIBER_MANUAL_RECORD, color="#ff5757"),
|
||||
ft.Text(
|
||||
f"Идёт запись макроса «{name or '—'}». "
|
||||
"Произнесите команды, затем «Сохрани макрос».",
|
||||
),
|
||||
]),
|
||||
bgcolor="#3a2020",
|
||||
border_radius=8,
|
||||
padding=10,
|
||||
)
|
||||
|
||||
|
||||
def _macro_card(m: dict, on_delete) -> ft.Control:
|
||||
steps = m.get("steps", [])
|
||||
preview = steps[:5]
|
||||
extra = len(steps) - len(preview)
|
||||
return ft.Container(
|
||||
content=ft.Column([
|
||||
ft.Row([
|
||||
ft.Text(m["name"], weight=ft.FontWeight.W_600, size=14),
|
||||
ft.Container(
|
||||
content=ft.Text(f"{m['steps_count']} шагов", size=10),
|
||||
bgcolor="#1e3a44",
|
||||
padding=ft.padding.symmetric(horizontal=8, vertical=2),
|
||||
border_radius=10,
|
||||
),
|
||||
], alignment=ft.MainAxisAlignment.SPACE_BETWEEN),
|
||||
ft.Column([
|
||||
ft.Text(f"• {s}", size=11, color="#a8b8c0") for s in preview
|
||||
] + ([ft.Text(f"+ ещё {extra}…", size=11, color="#5a6a72", italic=True)] if extra > 0 else []),
|
||||
spacing=2),
|
||||
ft.Row([
|
||||
ft.OutlinedButton(text="Удалить", icon=ft.Icons.DELETE, on_click=lambda e: on_delete()),
|
||||
]),
|
||||
], spacing=8),
|
||||
bgcolor="#15252b",
|
||||
border_radius=8,
|
||||
padding=12,
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue