Commit Graph
45 Commits
Author SHA1 Message Date
RainbowBird 742bb80ca5 feat(stage): add global button analytics directive (#2146) 2026-07-29 15:59:53 +08:00
RainbowBird 3543a60d3c feat(auth): integrate useAuthProviderSync across multiple components and add tests 2026-07-15 17:26:05 +08:00
Nekoandautofix-ci[bot] 47bfe02a87 feat(better-ws): added new package (#1989)
---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by-agent: Codex
2026-06-18 15:11:35 +08:00
Neko Ayaka 92b20b0dd2 fix(stage-*): many live2d and vrm issues, default values were missing 2026-05-21 02:25:04 +08:00
hahaqwq 4ecd51076d fix(stage-pocket,stage-server): correct Android deep link scheme (#1794) 2026-05-08 20:48:55 +08:00
hahaqwq ef54ce0c7c feat(stage-pocket,stage-server): support Android deep link for official server login (#1786) 2026-05-08 18:38:03 +08:00
DrHuangMHT 85627d34ad feat(stage-*): allow setting character offset in landscape (#1696) 2026-05-06 17:04:18 +08:00
RainbowBird 40284514d4 fix(stage-*): isDev constant 2026-05-04 20:04:24 +08:00
RainbowBird 7edfa4291e chore(stage-*): only show status-island in dev mode 2026-05-04 19:56:59 +08:00
akrlin e75b6618b3 fix(stage-ui,i18n) fix a bug when change language (#1666) 2026-04-15 14:47:26 +08:00
147d077aa7 feat(inference): unify and optimize WebGPU inference pipeline (#1622)
## Problem

The WebGPU inference pipeline had several structural issues:

1. **No unified protocol** — Kokoro TTS, Whisper ASR, and Background
Removal workers each used their own ad-hoc message formats. Adding a new
model meant reinventing worker communication from scratch.
2. **Infrastructure existed but was disconnected** —
`GPUResourceCoordinator`, `LoadQueue`, `InferenceWorkerManager`, and
`protocol.ts` were all implemented but had zero consumers. The adapters
duplicated the same lifecycle/timeout/mutex patterns independently.
3. **Performance gaps** — Kokoro only offered fp32 on WebGPU (no fp16),
Whisper warm-up compiled shaders for 187.5s of dummy audio, audio
transfer went through unnecessary WAV blob encode/decode, and
`listVoices` reloaded the model every time.
4. **Silent failures** — Whisper worker's `generate()` had no try-catch;
errors were swallowed and the main thread waited until timeout.
5. **No graceful degradation** — Whisper and Background Removal workers
hardcoded `device: 'webgpu'` with no WASM fallback.
6. **No observability** — Only Kokoro had performance tracing. No
adapter reported status to `useInferenceStatus`. No cache management UI
existed.
7. **Dead code accumulation** — Old `KokoroWorkerManager` (232 lines),
legacy Whisper message types, and scattered duplicate constants.

## Changes

### Phase 0 — Critical Performance & Bugs
- Add `fp16-webgpu` dtype for Kokoro TTS (~2x inference speed on
supported GPUs)
- Fix Whisper warm-up tensor from `[1, 128, 3000]` → `[1, 128, 1]`
(minimal shader compilation)
- Fix Whisper worker silent error bug (add try-catch to `generate()` and
`load()`)

### Phase 1 — Data Transfer & Caching
- Switch Kokoro audio to Float32Array transferable (skip WAV blob encode
in worker, lightweight WAV encode on main thread)
- Cache `listVoices` results (skip redundant model reload when adapter
state is `ready`)
- Normalize progress reporting to 0-100 across all adapters,
differentiate `warmup` phase

### Phase 2 — Protocol Unification & Infrastructure
- Migrate all 3 workers + 3 adapters to unified `protocol.ts` message
types (`load-model`, `run-inference`, `model-ready`, `inference-result`,
`progress`, `error`)
- Wire `GPUResourceCoordinator` into all adapters (VRAM allocation
tracking, LRU ordering, memory pressure events)
- Wire `LoadQueue` into all adapters (priority-based sequential model
loading: TTS=10 > ASR=5 > BG_REMOVAL=1)
- Add `coordinator.ts` global singleton for GPU coordinator + load queue
- Add WebGPU detection + WASM fallback in Whisper and Background Removal
workers

### Phase 3 — Error Recovery & Observability
- Add restart logic with exponential backoff to Whisper adapter
(matching Kokoro's existing pattern)
- Integrate `classifyError()` (OOM / DEVICE_LOST / TIMEOUT
classification) in Whisper adapter
- Extend `defaultPerfTracer` to Whisper `transcribe()` and Background
Removal `processImage()`
- Wire `useInferenceStatus` into all 3 adapters (downloading → ready →
terminated lifecycle)

### Phase 4 — Tests
- Add unit tests for `AsyncMutex` (4 tests), `LoadQueue` (4 tests),
`GPUResourceCoordinator` (7 tests) — all 15 passing

### Phase 5 — Cleanup & Features
- Delete old `KokoroWorkerManager` (232 lines, zero consumers)
- Delete orphaned `libs/workers/types.ts` (old Whisper message types)
- Clean up `workers/kokoro/types.ts` (remove legacy message types, keep
domain types)
- Create centralized `constants.ts` (MODEL_IDS, MODEL_NAMES, TIMEOUTS,
MAX_RESTARTS)
- Remove hardcoded WebGPU check from background-removal devtools pages
(worker auto-detects)
- Add `useModelPreload` composable for generic idle-time preloading
- Add `useInferencePreload` composable that reads provider config and
preloads configured local models
- Wire preloading into both `stage-web` and `stage-tamagotchi` App.vue
(Kokoro TTS preloads 3s after init)
- Add `ModelCacheManager.vue` settings component (cache size display,
per-model status, clear cache)
- Document GPU Device isolation architecture in protocol.ts

## After This PR

- All inference workers speak the same protocol → adding a new model
adapter is straightforward
- GPU memory is tracked across all models with automatic pressure
warnings at 80%/95% of VRAM budget
- Models load sequentially via priority queue → no bandwidth/VRAM
contention
- Workers auto-detect WebGPU and fall back to WASM → works on browsers
without WebGPU
- Kokoro TTS preloads during idle time → "instant" first use for
configured users
- All adapters auto-restart on worker crashes (max 3 attempts,
exponential backoff)
- 15 unit tests cover core infrastructure (mutex, queue, coordinator)
- Zero dead code remains in the inference pipeline

## Test Plan

- [x] `pnpm exec vitest run packages/stage-ui/src/libs/inference/` — 15
tests pass
- [x] `pnpm -F @proj-airi/stage-ui exec tsc --noEmit` — no TypeScript
errors
- [x] `pnpm lint:fix` — no lint errors in changed files
- [ ] Manual: verify Kokoro TTS works with fp16-webgpu on a supported
browser
- [ ] Manual: verify Whisper ASR loads and transcribes correctly
- [ ] Manual: verify Background Removal works in devtools page
- [ ] Manual: verify preloading triggers in console (`[Preload] Loading
kokoro-...`)

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-04-13 23:19:27 +08:00
LemonNeko c8a01e7a3b feat(stage-pocket): allow to set transparent background 2026-04-10 17:51:09 +08:00
Neko Ayaka 90294ce15c refactor(stage-*): use new InputFileCard 2026-04-10 03:40:10 +08:00
LemonNeko a786e4c228 fix(stage-pocket): position of status icons 2026-04-09 16:53:21 +08:00
Neko Ayaka 92b42b9454 fix(stage-pocket): outdated import 2026-04-08 01:25:39 +08:00
LemonNeko 0cd095b323 feat(stage-pocket): scan qr code to connect to tamagotchi 2026-04-07 19:04:59 +08:00
LemonNeko 883ec945d2 feat(stage-pocket): WebSocket status indicator + shared i18n (#1586) 2026-04-06 19:54:21 +08:00
LemonNeko e35b3d228c fix(stage-pocket-android): bridge the websocket connection to android native 2026-04-06 19:41:17 +08:00
Neko Ayaka 248e28412a wip(ui-server-auth): basic ui, not yet finalized 2026-04-03 15:43:28 +08:00
Neko Ayaka 5f07b68876 fix(stage-*): should not wait until context bridge 2026-03-30 20:18:55 +08:00
LemonNekoandautofix-ci[bot] 38f0306100 fix(stage-*): remove unused json format and platform checking (#1523)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-03-30 17:03:00 +08:00
Neko Ayaka 46147b0f8b fix(stage-*): incorrect use of useAudioDevices hook 2026-03-26 19:05:54 +08:00
f85a809d7c refactor(stage-*): analytics and telemetry, including consent (#1414)
---------

Co-authored-by-agent: Codex <267193182+codex@users.noreply.github.com>
Co-authored-by-agent: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: RainbowBird <rbxin2003@outlook.com>
Co-authored-by: Neko <neko@ayaka.moe>
2026-03-24 13:01:39 +08:00
Neko Ayaka 1bd3472246 fix: many type errors 2026-03-23 14:17:06 +08:00
Neko Ayaka ce60323d8a style: lint 2026-03-23 02:16:10 +08:00
RinandClaude Opus 4.6 688836912d chore: disable PostHog telemetry in development mode (#1365)
* chore: disable PostHog telemetry in development mode

Skip posthog.init() when import.meta.env.DEV is true to avoid
sending telemetry data during local development.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Apply suggestions from code review

Co-authored-by: Rin <shinohara-rin@users.noreply.github.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-15 09:39:54 +08:00
LemonNekoandautofix-ci[bot] 589553c0e3 feat(stage-pocket): request permissions onboarding (#1292)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-03-12 14:49:39 +08:00
dec2b04924 refactor: vrm performance tracing and better lifecycle management (#1194)
* refactor: vrm performance tracing and better lifecycle management

* Apply suggestion from @Lilia-Chen

* Apply suggestion from @Lilia-Chen

* Apply suggestion from @Lilia-Chen

* Apply suggestion from @Lilia-Chen

* Rename lag-visualizer.vue to performance-visualizer.vue

* Apply suggestion from @Lilia-Chen

* Apply suggestion from @Lilia-Chen

* Apply suggestion from @Lilia-Chen

* Apply suggestion from @sumimakito

Co-authored-by: Makito <i@maki.to>

* Apply suggestion from @sumimakito

Co-authored-by: Makito <i@maki.to>

* Apply suggestion from @sumimakito

Co-authored-by: Makito <i@maki.to>

* Apply suggestion from @Lilia-Chen

* Apply suggestion from @Lilia-Chen

* [autofix.ci] apply automated fixes

* Apply suggestion from @Lilia-Chen

* [autofix.ci] apply automated fixes

* Apply suggestion from @Lilia-Chen

* Apply suggestion from @Lilia-Chen

* Apply suggestion from @Lilia-Chen

* Apply suggestion from @Lilia-Chen

* Apply suggestion from @Lilia-Chen

* Apply suggestion from @Lilia-Chen

* Apply suggestion from @Lilia-Chen

* Apply suggestion from @Lilia-Chen

* Apply suggestion from @Lilia-Chen

* Apply suggestion from @Lilia-Chen

* Apply suggestion from @Lilia-Chen

* Apply suggestion from @Lilia-Chen

* Apply suggestion from @Lilia-Chen

* [autofix.ci] apply automated fixes

* Apply suggestion from @Lilia-Chen

* Apply suggestion from @Lilia-Chen

* [autofix.ci] apply automated fixes

* Apply suggestion from @Lilia-Chen

* Apply suggestion from @Lilia-Chen

* Apply suggestion from @Lilia-Chen

* fix: some tiny bugs and model URL lifecycle

* fix: TresCanvas size=0 bug

* Delete .claude/settings.json

* fix: some clean-up

* [autofix.ci] apply automated fixes

* fix: use screen to wrap up TresCanvas

* Delete .claude/settings.json

---------

Co-authored-by: Makito <i@maki.to>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Neko <neko@ayaka.moe>
2026-03-12 09:20:20 +08:00
LemonNeko f2d517ad64 fix(stage-pocket): missing general settings 2026-03-08 18:33:58 +08:00
Neko Ayaka 3605548973 chore: lint & lock 2026-03-06 16:49:31 +08:00
Makito 920a21b1c1 fix(stage-pocket): temporarily inline isEnvTruthy in vite.config.ts 2026-03-05 03:13:10 +07:00
Makito 87f43c7aa6 feat(stage-pocket,stage-web,stage-shared): add isEnvTruthy for safer env var checks 2026-03-05 03:03:57 +07:00
Makito 07f7bb58dc feat(stage-pocket): respect safe area in the main stage 2026-03-05 03:03:57 +07:00
lockrush-dev 4cac97937f fix(stage-ui): fix transcription session callback reuse and auto-send issues (#996) 2026-01-26 14:59:50 +08:00
Lilia_Chenandautofix-ci[bot] 0093803920 feat(stage-ui-*): ACT special tokens for future motion gen (#974)
* feat(stage-ui*):ACT special tokens

* test(stage-ui): llm-marker-parser test updates for ACT tokens

* [autofix.ci] apply automated fixes

* style(stage-ui): apply gemini code review notes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-01-20 09:32:47 +08:00
Neko Ayaka e5a86e78ae refactor(stage-ui): better chat store structure 2026-01-11 21:48:08 +08:00
a7d7c1631e feat(stage-*): devtool for websocket (#932)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-01-11 02:23:18 +08:00
Neko Ayaka 3c68172442 fix(stage-tamagotchi,stream-kit,pipelines-audio): couldn't handle spark:notify and has elegant way of handling tts & playback 2026-01-11 00:13:14 +08:00
Neko Ayaka 56d321f39c refactor(stage-ui,stage-pages): improve structure of character & character-orchestrator 2026-01-10 03:15:04 +08:00
Neko Ayaka 77045c4b98 refactor(stage-ui,ui): promote Collapsible and Screen to ui package 2026-01-07 21:03:02 +08:00
Neko Ayaka ded5d718de chore(stage-*): update how vue-sonner style imported 2026-01-07 20:42:59 +08:00
Neko Ayaka 17b0bd54b7 feat(stage-*): process spark:notify & emitting spark:command 2026-01-06 02:46:18 +08:00
Makitoandautofix-ci[bot] 00d3105719 refactor(apps/*,docs): unify PostHog config (#875)
* refactor(apps/*,docs): unify PostHog config

* [autofix.ci] apply automated fixes

* refactor: remove ImportMeta and keep ImportMetaEnv only

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-01-04 23:58:03 +09:00
Neko Ayaka c1984806a9 feat(stage-*): v2 provider catalog for managing providers 2026-01-03 22:09:00 +08:00
LemonNeko 61cf0aa88a refactor(stage-pocket): rename stage-capacitor to stage-pocket 2025-12-31 17:38:45 +08:00