fix(cli): use subprocess IPC for non-blocking native calls
Closed
JU
1y ago+145+145+012345678901234567890123456789-9-9-0123456789
Summary
Fixes the TUI loader freezing during data loading by running heavy native Rust functions in a subprocess.
Problem
The CLI TUI loader/spinner would freeze for 100-500ms while native Rust functions executed, blocking the Node.js event loop.
Solution
- Add
native-runner.ts: subprocess that reads method/args from stdin, executes native function, writes result to stdout - Add
*NativeAsync()wrappers that spawn subprocess and communicate via stdin/stdout pipes - Update
useData.tsto use async subprocess versions
Benefits over temp file approach
| Aspect | Temp Files | stdin/stdout |
|---|---|---|
| File I/O | 2 writes + 2 reads | None |
| Cleanup | Manual unlinkSync | Automatic |
| Crash safety | Leftover files | Clean |
| Security | Data on disk | In memory |
Testing
The spinner now animates smoothly throughout the entire data loading process.