# Driving egui apps: FunGen worked example

Full session transcript of driving **FunGen 2.5.3-beta** (a Rust/egui haptic-script
editor, `/home/ragecks/下载/FunGen/fungen`) from SSH-spawned Hermes via
computer_use, including a SIGILL debugging path. Reusable patterns, not app trivia.

## Why the SOM tree was empty

`capture mode=som` on the FunGen window returned exactly one element
(`#0 window 'FunGen - Pro - ...'`) with zero children. The app is egui —
everything is custom-rendered, nothing registered with AT-SPI. This is normal
for egui apps; the UI is still fully clickable by coordinates.

## Clicks: foreground required

- `computer_use click` with default `delivery_mode=background` returned
  `ok: true` but the UI never reacted (menus didn't open).
- Same click with `delivery_mode='foreground'` worked — menus opened, tabs
  switched. Use foreground delivery for ALL egui interactions.

## Menu navigation pattern (probe coordinates)

FunGen window was 1006x600 at screen +10+40. Menu bar items across the top:

| Attempt | Click (window-local) | Result |
|---|---|---|
| x=415, y=20 (bg) | nothing | background ignored |
| x=430, y=20 (fg) | opened "串流/Stream" menu | x too far left — 设置 is further right |
| x=490, y=20 (fg) | opened "设置/Settings" menu | hit |
| x=490, y=55 (fg) | selected "偏好设置..." → Preferences | hit |

Settings sidebar items: 通用≈y145, 编辑≈y175, 媒体与AI≈y205, 播放与视频≈y235,
AI与设备≈y265. Menu dropdown items sit ~25-35px below their trigger.

Keymap fallback: `prefs.ron` showed `OpenPreferences: Ctrl+,` — but the
synthetic `ctrl+,` hotkey did nothing until the window had been focused by a
foreground click. Prefer menu clicks; keep the keymap as a backup.

## Model download races

FunGen auto-downloaded its YOLO ONNX model on every launch while the cache was
empty ("Downloading detection model (10 MB)..." → `ml: loading ... onnx on
Auto` → `CUDA GPU runtime not found ... using CPU` → SIGILL). The `.part` file
grew to ~10.4MB of 10.5MB — deleting it mid-download interrupted the fetch and
the UI degraded gracefully ("下载失败: No such file or directory",
detector shows "未找到"), keeping the app alive. Whenever an app re-downloads
a model you're trying to block, move the `.part`/`.onnx` out of the cache dir
during the download rather than once.

## SIGILL diagnosis (instruction-set mismatch)

- No panic report file → not a Rust panic; kernel killed it.
- `dmesg | grep "trap invalid opcode"` → `traps: fungen-ml[pid] trap invalid
  opcode ip:...` — the crashing thread is `fungen-ml`.
- `grep -oE "avx2|avx|sse4_2" /proc/cpuinfo` → host is i3-3240 (Ivy Bridge):
  AVX but **no AVX2**. ONNX Runtime is statically linked into the binary
  (`strings` shows onnxruntime source paths); its AVX2 kernels are the SIGILL
  source. ML features are simply unusable on this CPU.
- Env-var toggles found via `strings fungen | grep -oE "FUNGEN_[A-Z_]+"`:
  `FUNGEN_GPU_NO_YOLO`, `FUNGEN_ML_CHAPTERS`, `FUNGEN_ORT_MEMPATTERN`,
  `FUNGEN_GPU_ALLOW_SOFTWARE` — none of them prevented the ORT CPU path from
  executing (SIGILL persisted). Blocking the model file was the only reliable
  way to keep the app running; ML features stay off.
- The Preferences > AI与设备 panel exposes Processor (Auto/GPU/CPU) and the
  YOLO detector — the UI-level off-switch, reachable once the app survives
  without a model.

## Launch-mode asymmetry

- Launch with NO args → welcome screen, stable (ML worker starts but doesn't
  load a model until a video opens).
- Launch WITH a video path → video+funscript load fine (logs show
  `Auto-loaded ...funscript (689 stroke + 1 axes)`) but then ML loads the
  ONNX model → SIGILL.
- `pkill -x fungen` (exact name) is safe; `pkill -f "FunGen/fungen"` matched
  the Hermes wrapper shell's own argv and killed the session (exit -9).
