Private
Public Access
0
0

feat(palette): define 11 core commands in commands.py

This commit is contained in:
2026-06-02 21:44:31 -04:00
parent 63b67be5b1
commit 57d0329951
2 changed files with 97 additions and 0 deletions
+88
View File
@@ -0,0 +1,88 @@
from __future__ import annotations
from typing import TYPE_CHECKING
from src.command_palette import CommandRegistry
if TYPE_CHECKING:
from src.gui_2 import App
registry = CommandRegistry()
@registry.register
def reset_session(app: "App") -> None:
"""Reset Session — Reset the AI session and clear discussion history."""
from src import ai_client
ai_client.reset_session()
if hasattr(app, "_handle_reset_session"):
app._handle_reset_session()
@registry.register
def clear_discussion(app: "App") -> None:
"""Clear Discussion — Clear all entries in the current discussion."""
if hasattr(app, "discussion_history"):
app.discussion_history = []
@registry.register
def toggle_diagnostics(app: "App") -> None:
"""Toggle Diagnostics — Show/hide the Diagnostics panel."""
if hasattr(app, "show_diagnostics"):
app.show_diagnostics = not app.show_diagnostics
@registry.register
def add_all_files_to_context(app: "App") -> None:
"""Add All Files to Context — Add all tracked files to the context."""
if hasattr(app, "_add_all_files_to_context"):
app._add_all_files_to_context()
@registry.register
def open_project(app: "App") -> None:
"""Open Project — Open a different project TOML."""
if hasattr(app, "_show_project_picker"):
app._show_project_picker()
@registry.register
def save_project(app: "App") -> None:
"""Save Project — Save the current project state to TOML."""
if hasattr(app, "_save_project_state"):
app._save_project_state()
@registry.register
def trigger_hot_reload(app: "App") -> None:
"""Hot Reload — Reload the GUI module to pick up code changes."""
from src.hot_reloader import HotReloader
HotReloader.reload("src.gui_2", app)
@registry.register
def show_documentation(app: "App") -> None:
"""Show Documentation — Open the documentation index in the browser."""
import webbrowser
webbrowser.open("https://git.cozyair.dev/ed/manual_slop/")
@registry.register
def switch_to_dark_theme(app: "App") -> None:
"""Switch to Dark Theme."""
from src import theme_2
theme_2.apply_dark_theme()
@registry.register
def switch_to_light_theme(app: "App") -> None:
"""Switch to Light Theme."""
from src import theme_2
theme_2.apply_light_theme()
@registry.register
def switch_to_nerv_theme(app: "App") -> None:
"""Switch to NERV Theme."""
from src.theme_nerv import apply_nerv
apply_nerv()
+9
View File
@@ -43,3 +43,12 @@ def test_fuzzy_match_score_higher_for_exact_prefix():
]
results = fuzzy_match("fin", candidates, top_n=10)
assert results[0].command.id == "a"
def test_commands_registry_has_core_commands():
from src.commands import registry
all_ids = {c.id for c in registry.all()}
assert "reset_session" in all_ids
assert "clear_discussion" in all_ids
assert "trigger_hot_reload" in all_ids
assert "show_documentation" in all_ids