URGENT-api-interception-visualization-fix.mdā¢3.37 kB
# URGENT: API Interception Visualization Fix
**Task ID**: URGENT-VIZ-FIX-001
**Status**: READY FOR EXECUTION
**Priority**: CRITICAL
**Owner**: Claude Code
**Estimated Duration**: 2-3 hours
**Dependencies**: Console log analysis complete
---
## šÆ Objective
Fix composition visualization issue by implementing API interception in the browser automation workflow.
## š Problem Identified
**Issue**: Compositions save successfully but don't render in browser after localStorage injection
**Root Cause**: Composer uses hash-based routing + API calls, not localStorage reading
**Solution**: Intercept API calls and return injected composition data
## š Implementation
### **Target File**
`/Users/ricardokawasaki/Desktop/euconquisto-composer-mcp-poc/dist/browser-automation-capture-v2.6.0.js`
### **Required Changes**
**1. Add API Interception** (before Step 6 in executeWorkflow):
```javascript
console.log('[v2.6.0] Step 6: Setup API Interception');
await page.evaluate((data) => {
window._injectedComposition = data;
const originalFetch = window.fetch;
window.fetch = function(url, options) {
if (url.includes('/storage/v1.0/content?uid=') && !url.includes('/versions/')) {
console.log('šÆ INTERCEPTED: Returning injected composition');
return Promise.resolve(new Response(JSON.stringify({
status: 'success',
data: window._injectedComposition
}), {
status: 200,
headers: { 'Content-Type': 'application/json' }
}));
}
return originalFetch.apply(this, arguments);
};
}, compositionData);
```
**2. Add Navigation Trigger** (after save workflow):
```javascript
// Get composition ID and trigger hash navigation
const compositionId = await page.evaluate(() => {
return window.location.hash.match(/composer\/([^?]+)/)?.[1] || 'test-composition';
});
// Navigate to trigger loading with interception
const compositionUrl = `http://localhost:8080/composer#/embed/composer/${compositionId}`;
await page.goto(compositionUrl);
await page.waitForTimeout(3000);
```
**3. Keep Browser Open & Update Success Response**:
```javascript
// DON'T close browser - keep it open for user interaction
if (result.success) {
return {
content: [{
type: 'text',
text: `ā
COMPOSITION CREATED AND VISIBLE!\n\nšÆ Browser kept open for immediate use\nš± Interact with your composition now\nš URL: ${page.url()}\nš Elements: ${compositionData.composition.elements.length}\n\nš” Leave browser open to view and test your educational content!`
}]
};
} else {
// Only close browser on error
await browser.close();
return errorResponse;
}
```
## ā
Success Criteria
- Compositions render visibly in browser after workflow
- **Browser remains open** for immediate user interaction
- All 6 current element types display correctly
- Workflow time remains under 45 seconds
- Users can immediately view and test educational content
## š§ Testing
**Test with**: Simple photosynthesis composition (existing data structure)
**Validate**: Browser shows rendered composition AND stays open for interaction
**Verify**: All elements (header, text, image, video, flashcards, quiz) visible and interactive
**Confirm**: Users can immediately explore the educational content
---
**URGENT - Execute immediately to unblock roadmap implementation**