feat(app-controller): modularize handlers and enforce 1-space indentation

This commit is contained in:
2026-05-13 21:26:29 -04:00
parent 34b1349c4f
commit fa4388bbe0
5 changed files with 1041 additions and 842 deletions
+20
View File
@@ -0,0 +1,20 @@
import sys
def check_indent(file_path):
with open(file_path, 'r', encoding='utf-8') as f:
lines = f.readlines()
last_indent = 0
for i, line in enumerate(lines):
stripped = line.lstrip()
if not stripped:
continue
indent = len(line) - len(line.lstrip())
if indent > last_indent + 1:
print(f"Jump at line {i+1}: '{line.rstrip()}' (Indent: {indent}, Last: {last_indent})")
last_indent = indent
if __name__ == '__main__':
check_indent('src/app_controller.py')
+38
View File
@@ -0,0 +1,38 @@
import sys
def fix_indentation(file_path):
with open(file_path, 'r', encoding='utf-8') as f:
lines = f.readlines()
fixed_lines = []
indent_map = {0: 0}
for i, line in enumerate(lines):
stripped = line.lstrip()
if not stripped:
fixed_lines.append('\n')
continue
old_indent = len(line) - len(stripped)
# Remove larger indents from map if we dedent below them
for k in list(indent_map.keys()):
if k > old_indent:
del indent_map[k]
if old_indent not in indent_map:
# Find the closest smaller indent
known = sorted([k for k in indent_map.keys() if k < old_indent])
parent_new = indent_map[max(known)]
indent_map[old_indent] = parent_new + 1
new_indent = indent_map[old_indent]
fixed_lines.append(' ' * new_indent + stripped)
with open(file_path, 'w', encoding='utf-8') as f:
f.writelines(fixed_lines)
if __name__ == '__main__':
fix_indentation('src/app_controller.py')
print("Indentation fixed v3.")
-5
View File
@@ -523,11 +523,6 @@ def list_models(provider: str) -> list[str]:
"""
[C: src/app_controller.py:AppController.do_fetch, tests/test_agent_capabilities.py:test_agent_capabilities_listing, tests/test_ai_client_list_models.py:test_list_models_gemini_cli, tests/test_deepseek_infra.py:test_deepseek_model_listing, tests/test_minimax_provider.py:test_minimax_list_models]
"""
proxy = _get_proxy()
if proxy and proxy.status == "ready":
result = proxy.send_command("list_models", {"provider": provider})
if "result" in result:
return result["result"].get("models", [])
creds = _load_credentials()
if provider == "gemini":
return _list_gemini_models(creds["gemini"]["api_key"])
+971 -837
View File
File diff suppressed because it is too large Load Diff
+12
View File
@@ -43,11 +43,23 @@ import tomllib
import datetime
from dataclasses import dataclass, field
from typing import List, Optional, Dict, Any, Union
from pydantic import BaseModel
from pathlib import Path
from src.paths import get_config_path
PROVIDERS: List[str] = ["gemini", "anthropic", "gemini_cli", "deepseek", "minimax"]
class GenerateRequest(BaseModel):
prompt: str
auto_add_history: bool = True
temperature: float | None = None
top_p: float | None = None
max_tokens: int | None = None
class ConfirmRequest(BaseModel):
approved: bool
script: Optional[str] = None
CONFIG_PATH = get_config_path()
def _clean_nones(data: Any) -> Any: