High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
docs: update memory with Phase 2 completion and Phase 3-5 planning
Marioddfa0edad06d
diff --git a/memory/2026-02-28.md b/memory/2026-02-28.mdindex 66664474..dde6e25b 100644--- a/memory/2026-02-28.md+++ b/memory/2026-02-28.md@@ -83,7 +83,31 @@ Dashboard (9867) manages:- ✅ Created EnsureChrome() method stub- ✅ All tests passing (192+ tests)-### 📋 Phase 2: Browser Initialization at Instance Creation (NEXT - Estimated 2-3 commits)+### ✅ Phase 2: Browser Initialization at Instance Creation (COMPLETED)++#### Phase 2 Part 1 (Commit 56491d2) - Chrome Init Functions+- ✅ Created internal/bridge/init.go with InitChrome() function+- ✅ Extracted setupAllocator() from cmd/pinchtab/browser.go+- ✅ Extracted startChrome() from cmd/pinchtab/browser.go+- ✅ InitChrome() returns 4 contexts: allocCtx, allocCancel, browserCtx, browserCancel+- ✅ Implemented Bridge.EnsureChrome() to call InitChrome()+- ✅ TabManager initialization deferred until Chrome is ready+- ✅ All tests passing (192+ tests)++#### Phase 2 Part 2 (Commit a4ec3ee) - Handler Integration+- ✅ Added EnsureChrome() to BridgeAPI interface+- ✅ Added ensureChrome() helper method to Handlers+- ✅ Updated HandleNavigate to call ensureChrome()+- ✅ Updated HandleSnapshot to call ensureChrome()+- ✅ Updated HandleAction and HandleActions to call ensureChrome()+- ✅ Updated HandleScreenshot to call ensureChrome()+- ✅ Updated HandlePDF to call ensureChrome()+- ✅ Updated HandleText to call ensureChrome()+- ✅ Updated all test mocks to implement EnsureChrome()+- ✅ All 195+ tests passing+- ✅ All pre-commit checks passing++### 📋 Phase 3: Instance-Scoped Endpoints (NEXT - Estimated 3-4 commits)1. **Create bridge initialization in orchestrator**- When instance.Launch() creates a new Pinchtab process via runner- After process starts listening on port, orchestrator must:@@ -104,26 +128,50 @@ Dashboard (9867) manages:- orchestrator initializes Chrome using the extracted helper- orchestrator returns initialized instance with Chrome running-### 📋 Phase 3: Instance-Scoped Endpoints (After Phase 2)-1. **Register new routes in handlers.go**- - POST /instances/{id}/navigate- - GET /instances/{id}/tabs- - POST /instances/{id}/tabs/{tabId}/navigate- - POST /instances/{id}/snapshot- - POST /instances/{id}/action- - GET /instances/{id}/screenshot- - GET /instances/{id}/pdf- - GET /instances/{id}/text- - POST /instances/{id}/execute--2. **Keep backward-compat endpoints**- - /navigate, /snapshot, /action → route to default/first instance- - /tabs → aggregate all tabs--3. **Update CLI to use new endpoints**- - CLI commands should target specific instance (or use default)--### 📋 Phase 4: Testing & Validation (After Phase 3)+### 📋 Phase 3: Instance-Scoped Endpoints (NEXT - Estimated 3-4 commits)++**Key insight**: Each instance already runs on its own port (9868, 9869, etc.) with its own Bridge.+The handler routes on that port don't need `/instances/{id}` prefix - just register at `/navigate`, `/snapshot`, etc.+Requests to port 9868 automatically go to that instance's Bridge.++1. **Verify instance-port mapping works**+ - Each spawned instance already on separate port ✓+ - Each port gets its own Bridge instance ✓+ - Routes on that Bridge's handlers.go are isolated ✓++2. **Backward-compat routes on dashboard (port 9867)**+ - Dashboard port 9867 runs its own handlers+ - Could keep old `/navigate`, `/snapshot`, etc. routing to orchestrator's default instance+ - Or update CLI to use specific instance port directly++3. **Testing approach**+ - Create instance via POST http://localhost:9867/instances → returns port (e.g., 9868)+ - Navigate via POST http://localhost:9868/navigate+ - No need for `/instances/{id}` prefix - port already targets instance+ - Dashboard can proxy to instance ports if needed for UI++### 📋 Phase 4: Orchestrator Integration (Phase 3 continuation - Estimated 2-3 commits)++**Goal**: Make POST /instances call Chrome initialization++1. **Update orchestrator.Launch() to initialize Chrome**+ - After spawning instance process+ - After health check passes+ - Call bridge.InitChrome() for that instance+ - Return initialized instance with Chrome running++2. **Test POST /instances endpoint**+ - Create instance with {profile: "work", headless: false}+ - Verify Chrome window opens (headless=false)+ - Verify returned instance has port and status="running"+ - Verify subsequent POST /navigate works immediately++3. **Test headless instances**+ - Create instance with headless=true+ - Verify no Chrome window+ - Verify Chrome still responds to navigate/snapshot calls++### 📋 Phase 5: Testing & Validation (After Phase 4)1. **Test headed vs headless**- Launch instance with headless=false → Chrome window should appear- Launch instance with headless=true → No window