feat: Add toggle command to quickly enable/disable automation for active pane
Implements `autoclaude start toggle` to toggle monitoring on/off for the currently active tmux pane, making it easy to quickly switch automation on and off without specifying session and window parameters. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
+35
-1
@@ -408,6 +408,37 @@ class ClaudeCLI:
|
||||
except Exception as e:
|
||||
self.print_error(f"Failed to view logs: {e}")
|
||||
|
||||
def get_active_pane(self) -> tuple:
|
||||
try:
|
||||
result = subprocess.run(
|
||||
['tmux', 'display-message', '-p', '#{session_name}:#{window_index}'],
|
||||
capture_output=True, text=True, timeout=5
|
||||
)
|
||||
pane_id = result.stdout.strip()
|
||||
if ':' in pane_id:
|
||||
session, window = pane_id.split(':')
|
||||
return session, int(window)
|
||||
except Exception as e:
|
||||
self.print_error(f"Failed to get active pane: {e}")
|
||||
return None, None
|
||||
|
||||
def toggle_automation(self):
|
||||
session, window = self.get_active_pane()
|
||||
if session is None:
|
||||
self.print_error("Could not determine active pane")
|
||||
return
|
||||
|
||||
targets = self.load_targets()
|
||||
pane_id = f"{session}:{window}"
|
||||
|
||||
if session in targets['targets'] and window in targets['targets'][session]:
|
||||
self._remove_target(session, window)
|
||||
self.print_success(f"Automation disabled for {pane_id}")
|
||||
else:
|
||||
self.start_orchestrator()
|
||||
self._add_target(session, window)
|
||||
self.print_success(f"Automation enabled for {pane_id}")
|
||||
|
||||
def show_help(self):
|
||||
self.print_header("Autoclaude - Autonomous Claude Code Control System")
|
||||
|
||||
@@ -415,6 +446,7 @@ class ClaudeCLI:
|
||||
{Colors.BOLD}SERVICE COMMANDS:{Colors.ENDC}
|
||||
start [session] [window] Start autonomous monitoring service
|
||||
Optional: target specific panel (e.g., main 8)
|
||||
start toggle Toggle automation for the active pane
|
||||
stop [session] [window] Stop monitoring service
|
||||
Optional: stop monitoring specific panel (e.g., main 8)
|
||||
status Check service status
|
||||
@@ -584,7 +616,9 @@ Run without arguments for interactive menu.
|
||||
cli.print_error("Invalid window number")
|
||||
sys.exit(1)
|
||||
elif command == 'start':
|
||||
if len(args.args) >= 2:
|
||||
if len(args.args) >= 1 and args.args[0] == 'toggle':
|
||||
cli.toggle_automation()
|
||||
elif len(args.args) >= 2:
|
||||
session = args.args[0]
|
||||
try:
|
||||
window = int(args.args[1])
|
||||
|
||||
Reference in New Issue
Block a user