4.7 KiB
4.7 KiB
Comprehensive Debrief: GUI Decoupling Track (Botched Implementation)
1. Track Overview
- Track Name: GUI Decoupling & Controller Architecture
- Track ID:
gui_decoupling_controller_20260302 - Primary Objective: Decouple business logic from
gui_2.py(3,500+ lines) into a headlessAppController.
2. Phase-by-Phase Failure Analysis
Phase 1: Controller Skeleton & State Migration
- Status: [x] Completed (with major issues)
- What happened: State variables (locks, paths, flags) were moved to
AppController.Appwas given a__getattr__and__setattr__bridge to delegate to the controller. - Failure: The delegation created a "Phantom State" problem. Sub-agents began treating the two objects as interchangeable, but they are not. Shadowing (where
Apphas a variable that blocksController) became a silent bug source.
Phase 2: Logic & Background Thread Migration
- Status: [x] Completed (with critical regressions)
- What happened: Async loops, AI client calls, and project I/O were moved to
AppController. - Failure 1 (Over-deletion): Tier 3 workers deleted essential UI-thread handlers from
App(like_handle_approve_script). This broke button callbacks and crashed the app on startup. - Failure 2 (Thread Violation): A "fallback queue processor" was added to the Controller thread. This caused two threads to race for the same event queue. If the Controller won, the UI never blinked/updated, causing simulation timeouts.
- Failure 3 (Property Erasure): During surgical cleanups in this high-reasoning session, the
current_providergetter/setter inAppControllerwas accidentally deleted while trying to remove a redundant method.Appnow attempts to delegate to a non-existent attribute, causingAttributeError.
Phase 3: Test Suite Refactoring
- Status: [x] Completed (fragile)
- What happened:
conftest.pywas updated to patchAppControllermethods. - Failure: The
live_guisandbox environment (isolated workspace) was broken because the Controller now eagerly checks forcredentials.tomlon startup. The previous agent tried to "fix" this by copying secrets into the sandbox, which is a security regression and fragile.
Phase 4: Final Validation
- Status: [ ] FAILED
- What happened: Integration tests and extended simulations fail or timeout consistently.
- Root Cause: Broken synchronization between the Controller's background processing and the GUI's rendering loop. The "Brain" (Controller) and "Limb" (GUI) are disconnected.
3. Current "Fucked" State of the Codebase
src/gui_2.py: Contains rendering but is missing critical property logic. It still shadows core methods that should be purely in the controller.src/app_controller.py: Missing core properties (current_provider) and has brokenstart_serviceslogic.tests/conftest.py: Has a messylive_guifixture that uses environment variables (SLOP_CREDENTIALS,SLOP_MCP_ENV) but points to a sandbox that is missing the actual files.sloppy.py: The entry point works but the underlying classes are in a state of partial migration.
4. Immediate Recovery Plan (New Phase 5)
Phase 5: Stabilization & Cleanup
- Task 5.1: AST Synchronization Audit. Manually (via AST) compare
AppandAppController. Ensure every property needed for the UI exists in the Controller and is correctly delegated byApp. - Task 5.2: Restore Controller Properties. Re-implement
current_providerandcurrent_modelinAppControllerwith proper logic (initializing adapters, clearing stats). - Task 5.3: Explicit Delegation. Remove the "magic"
__getattr__and__setattr__. Replace them with explicit property pass-throughs. This will makeAttributeErrorvisible during static analysis rather than runtime. - Task 5.4: Fix Sandbox Isolation. Ensure
live_guifixture inconftest.pycorrectly handlescredentials.tomlviaSLOP_CREDENTIALSenv var pointing to the root, and ensuresloppy.pyrespects it. - Task 5.5: Event Loop Consolidation. Ensure there is EXACTLY ONE
asyncioloop running, owned by the Controller, and that the GUI thread only reads from_pending_gui_tasks.
5. Technical Context for Next Session
- Encoding issues:
temp_conftest.pyand other git-shipped files often have UTF-16 or different line endings. Use Python-based readers to bypassread_filefailures. - Crucial Lines:
src/gui_2.pyline 180-210 (Delegation) andsrc/app_controller.pyline 460-500 (Event Processing) are the primary areas of failure. - Mocking: All
patchtargets intests/must now be audited to ensure they hit the Controller, not the App.