feat(ui): Implement manual skeleton context injection

This commit is contained in:
2026-03-07 11:54:11 -05:00
parent 442d5d23b6
commit fbe02ebfd4
5 changed files with 145 additions and 5 deletions

View File

@@ -270,6 +270,11 @@ class AppController:
self.prior_session_entries: List[Dict[str, Any]] = []
self.test_hooks_enabled: bool = ("--enable-test-hooks" in sys.argv) or (os.environ.get("SLOP_TEST_HOOKS") == "1")
self.ui_manual_approve: bool = False
# Injection state
self._inject_file_path: str = ""
self._inject_mode: str = "skeleton"
self._inject_preview: str = ""
self._show_inject_modal: bool = False
self._settable_fields: Dict[str, str] = {
'ai_input': 'ui_ai_input',
'project_git_dir': 'ui_project_git_dir',
@@ -293,7 +298,10 @@ class AppController:
'mma_active_tier': 'active_tier',
'ui_new_track_name': 'ui_new_track_name',
'ui_new_track_desc': 'ui_new_track_desc',
'manual_approve': 'ui_manual_approve'
'manual_approve': 'ui_manual_approve',
'inject_file_path': '_inject_file_path',
'inject_mode': '_inject_mode',
'show_inject_modal': '_show_inject_modal'
}
self._gettable_fields = dict(self._settable_fields)
self._gettable_fields.update({
@@ -311,10 +319,40 @@ class AppController:
'prior_session_indicator': 'prior_session_indicator',
'_show_patch_modal': '_show_patch_modal',
'_pending_patch_text': '_pending_patch_text',
'_pending_patch_files': '_pending_patch_files'
'_pending_patch_files': '_pending_patch_files',
'_inject_file_path': '_inject_file_path',
'_inject_mode': '_inject_mode',
'_inject_preview': '_inject_preview',
'_show_inject_modal': '_show_inject_modal'
})
self._init_actions()
def _update_inject_preview(self) -> None:
"""Updates the preview content based on the selected file and injection mode."""
if not self._inject_file_path:
self._inject_preview = ""
return
target_path = self._inject_file_path
if not os.path.isabs(target_path):
target_path = os.path.join(self.ui_files_base_dir, target_path)
if not os.path.exists(target_path):
self._inject_preview = ""
return
try:
with open(target_path, "r", encoding="utf-8") as f:
content = f.read()
if self._inject_mode == "skeleton" and target_path.endswith(".py"):
parser = ASTParser("python")
preview = parser.get_skeleton(content)
else:
preview = content
lines = preview.splitlines()
if len(lines) > 500:
preview = "\n".join(lines[:500]) + "\n... (truncated)"
self._inject_preview = preview
except Exception as e:
self._inject_preview = f"Error reading file: {e}"
@property
def thinking_indicator(self) -> bool:
return self.ai_status in ("sending...", "streaming...")