Commit 40c0338
committed
fix(ModelPicker): prevent useInput during model loading to avoid yoga-layout WASM error
Error:
```
⠋ Loading models...
Mode: Safe (Shift+Tab to toggle) ❖ Model: gemma4:latest
wasm://wasm/000460e2:1
RuntimeError: memory access out of bounds
at wasm://wasm/000460e2:wasm-function[215]:0xd5ef
at wasm://wasm/000460e2:wasm-function[185]:0xcf8c
at X.getComputedWidth (file:///code-ollama/node_modules/yoga-layout/dist/binaries/yoga-wasm-base64-esm.js:33:52)
at renderer (code-ollama/node_modules/ink/src/renderer.ts:50:37)
at onRender (code-ollama/node_modules/ink/src/ink.tsx:533:48)
at debounce$1.edges.edges (file:///code-ollama/node_modules/es-toolkit/dist/compat/function/debounce.mjs:18:23)
at invoke (file:///code-ollama/node_modules/es-toolkit/dist/function/debounce.mjs:8:18)
at onTimerEnd (file:///code-ollama/node_modules/es-toolkit/dist/function/debounce.mjs:15:13)
at Timeout._onTimeout (file:///code-ollama/node_modules/es-toolkit/dist/function/debounce.mjs:26:13)
at listOnTimeout (node:internal/timers:605:17)
```
Cause:
The yoga-layout WASM memory error occurs because the `useInput` hook in
ModelPicker was active even while models were loading. When users
pressed navigation keys during the "Loading models..." Spinner state, it
triggered re-renders that conflicted with yoga-layout's layout
calculations, causing the memory access out of bounds error.
Fix:
Added `isActive: Boolean(options.length)` to the useInput hook to only register
keyboard input handling after models are loaded. This prevents the
Spinner animation from being interrupted by keyboard events.1 parent 0dc059c commit 40c0338
1 file changed
Lines changed: 10 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
| |||
0 commit comments