Co-Authored-By: Quentin Torroba <quentin.torroba@mistral.ai>
Co-Authored-By: Michel Thomazo <michel.thomazo@mistral.ai>
Co-Authored-By: Kracekumar <kracethekingmaker@gmail.com>
This commit is contained in:
Quentin
2025-12-14 00:54:42 +01:00
committed by Mathias Gesbert
parent 661588de0c
commit d8dbeeb31e
91 changed files with 4521 additions and 873 deletions

View File

@@ -2,24 +2,46 @@ from __future__ import annotations
from textual.widgets import Static
from vibe.core.modes import AgentMode, ModeSafety
MODE_ICONS: dict[AgentMode, str] = {
AgentMode.DEFAULT: "",
AgentMode.PLAN: "⏸︎",
AgentMode.ACCEPT_EDITS: "⏵⏵",
AgentMode.AUTO_APPROVE: "⏵⏵⏵",
}
SAFETY_CLASSES: dict[ModeSafety, str] = {
ModeSafety.SAFE: "mode-safe",
ModeSafety.NEUTRAL: "mode-neutral",
ModeSafety.DESTRUCTIVE: "mode-destructive",
ModeSafety.YOLO: "mode-yolo",
}
class ModeIndicator(Static):
def __init__(self, auto_approve: bool = False) -> None:
"""Displays the current agent mode with safety-colored indicator."""
def __init__(self, mode: AgentMode = AgentMode.DEFAULT) -> None:
super().__init__()
self.can_focus = False
self._auto_approve = auto_approve
self._mode = mode
self._update_display()
def _update_display(self) -> None:
if self._auto_approve:
self.update("⏵⏵ auto-approve on (shift+tab to toggle)")
self.add_class("mode-on")
self.remove_class("mode-off")
else:
self.update("⏵ auto-approve off (shift+tab to toggle)")
self.add_class("mode-off")
self.remove_class("mode-on")
icon = MODE_ICONS.get(self._mode, "??")
name = self._mode.display_name.lower()
self.update(f"{icon} {name} mode (shift+tab to cycle)")
def set_auto_approve(self, enabled: bool) -> None:
self._auto_approve = enabled
for safety_class in SAFETY_CLASSES.values():
self.remove_class(safety_class)
self.add_class(SAFETY_CLASSES[self._mode.safety])
@property
def mode(self) -> AgentMode:
return self._mode
def set_mode(self, mode: AgentMode) -> None:
self._mode = mode
self._update_display()