Monorepo for Aesthetic.Computer aesthetic.computer
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 58 lines 3.3 kB view raw view rendered
1# KidLisp Embedding Fix Plan 2 3## Problem Analysis 4 5Based on the console logs and code investigation, I've identified several critical issues with the current KidLisp embedding system: 6 7### 1. **API Parameter Mismatch in disk.mjs** 8- **Issue**: `disk.mjs` calls `kidlispInstance.module(source, kidlispAPI)` but the `module()` method expects `(source, isLispFile)` as parameters 9- **Root Cause**: The KidLisp `module()` method returns a piece object with `boot`, `paint`, and `sim` functions that receive the API, rather than accepting the API directly 10- **Impact**: The kidlispAPI is being passed as `isLispFile` parameter, breaking the execution flow 11 12### 2. **Async $code Fetching Not Handled Properly** 13- **Issue**: When `$bop` is detected, it starts an async fetch but the current frame returns before the code is loaded 14- **Root Cause**: The `module()` method in KidLisp tries to handle $codes by redirecting to navigation instead of waiting for async resolution 15- **Impact**: $codes never execute, causing infinite "loading" state 16 17### 3. **Buffer Context vs Piece Context Mismatch** 18- **Issue**: KidLisp is designed to run as a full piece, but disk.mjs is trying to run it in a limited buffer context 19- **Root Cause**: The embedded kidlisp() function creates a painting buffer but doesn't provide the full piece lifecycle (boot/paint/sim) 20- **Impact**: KidLisp initialization and state management is broken 21 22## Fix Strategy 23 24### Phase 1: Immediate API Fix (disk.mjs) 251. **Fix the module() call**: Change `kidlispInstance.module(source, kidlispAPI)` to properly handle the returned piece object 262. **Create proper piece lifecycle**: Call boot, then paint with the API 273. **Handle API parameter correctly**: Pass `false` for `isLispFile` parameter 28 29### Phase 2: Async $code Support 301. **Implement proper async handling**: Modify the embedded KidLisp to wait for $code resolution 312. **Add loading states**: Show loading indicator while fetching cached codes 323. **Cache management**: Ensure proper cache invalidation and memory management 33 34### Phase 3: Buffer Context Enhancement 351. **Minimal piece environment**: Create a lightweight piece environment for embedded contexts 362. **State isolation**: Ensure embedded instances don't interfere with main piece state 373. **Performance optimization**: Minimize overhead of embedded executions 38 39## Implementation Order 40 411. **Fix API parameter issue** (immediate - will fix both inline KidLisp and start fixing $codes) 422. **Add async $code support** (high priority - will fix $code embeds) 433. **Enhance buffer context** (medium priority - performance and stability) 444. **Add comprehensive testing** (ongoing - prevent regressions) 45 46## Files to Modify 47 481. `/workspaces/aesthetic-computer/system/public/aesthetic.computer/lib/disk.mjs` - Fix API parameter issue 492. `/workspaces/aesthetic-computer/system/public/aesthetic.computer/lib/kidlisp.mjs` - Async $code support 503. Test with `/workspaces/aesthetic-computer/system/public/aesthetic.computer/disks/kidlisp-in-js.mjs` 51 52## Expected Outcomes 53 54After fixes: 55- `(wipe blue)` should show blue background on left side 56- `$bop` should load and execute cached code on right side (once it exists) 57- No infinite console logging 58- Proper error handling for missing cached codes