Commit Graph
55 Commits
Author SHA1 Message Date
Doji 2c432fc1c8 refactor(stage-web,stage-ui): replace warpdrive plugin with unplugin-basemove (#1818) 2026-05-13 12:03:30 +08:00
RainbowBirdandLiet Blue 172e4ce59c feat(auth): email login & profile (#1745)
Co-authored-by: Liet Blue <127093491+lietblue@users.noreply.github.com>
2026-04-28 00:07:38 +08:00
DrHuangMHT 9d5c9e9332 chore(deps): remove deprecated unplugin-vue-router (#1664) 2026-04-15 15:02:10 +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
Neko Ayaka fe139f31cd chore(stage-*): configured https, now dev:web:https or pnpm -F @proj-airi/stage-web dev:https works 2026-04-07 01:39:49 +08:00
JasonandJasonOA888 7164318002 fix(pwa): show update toast when new version is available (#1517)
---------

Co-authored-by: JasonOA888 <JasonOA888@users.noreply.github.com>
Assume-co-authored-by-agent: Unknown <unknown@example.com>
2026-03-30 22:54:54 +08:00
Neko Ayaka 25b5de179d Revert "chore(deps): replace with unplugin-vue"
This reverts commit 3339daa746.

As unplugin-vue-i18n:

```
[unplugin-vue-i18n]  `@vitejs/plugin-vue` plugin is not found or invalid version. Please install `@vitejs/plugin-vue` v4.3.4 or later version.
```

https://github.com/intlify/bundle-tools/blob/3da4987500bbf9b398b0681852b90470968bdc8c/packages/unplugin-vue-i18n/src/core/resource.ts#L167-L168

it seems they are depending on vite:vue while https://github.com/unplugin/unplugin-vue is different on plugin resolving, yet unplugin-vue seems
lost the track of new version.
2026-03-26 18:10:30 +08:00
Neko Ayaka 3339daa746 chore(deps): replace with unplugin-vue 2026-03-26 17:22:49 +08:00
Makito 3870471c3c fix(stage-web): allow vite serving files outside of the allow list 2026-03-17 03:01:01 +09:00
Sebastián c8f679e1e4 fix(stage-*): Kokoro TTS now works in production too (#1017) 2026-02-03 05:27:06 +08:00
Neko Ayaka 7d256dabdf chore(stage-tamagotchi,stage-web,stage-pocket): exclude any nested components directory for pages 2026-01-09 18:11:24 +08:00
Neko Ayaka fe6036c51a chore(ci): add avif to ignore list of HF Space 2026-01-05 22:35:25 +08:00
LemonNeko 18a7658846 refactor(stage-*): extract shared layouts (#852) 2025-12-30 14:21:39 +08:00
Neko Ayaka 8d4855c550 fix(stage-web): ignore *.task as they are too large for HF Space 2025-12-30 12:17:24 +08:00
Neko Ayaka 6ea5f365e5 fix(stage-web): adjust maskable icons for android devices 2025-12-20 03:08:33 +08:00
Neko Ayaka a342594b9a chore(deps): migrate for vue macros 2025-12-14 20:58:45 +08:00
RainbowBird 4af8edf58b chore(CI): upload sourcemap to posthog 2025-12-14 20:30:31 +08:00
Neko Ayaka c3f7098511 refactor(ci): to not to build in PR workflow, but only initialization 2025-11-27 14:17:26 +08:00
Neko Ayaka 1ad92bec1a chore(ci): do not clean R2 upload for better reusability 2025-11-27 00:04:53 +08:00
Neko Ayaka 53e5ce6798 feat(vite-plugin-warpdrive): new Vite plugin for uploading large assets to S3 compatible storages 2025-11-26 21:46:32 +08:00
Neko Ayaka 1c26d8d7a3 chore(stage-web,stage-ui): alias for stage-shared 2025-10-12 03:32:33 +08:00
Neko Ayaka e52efebd6c refactor(stage-*): move shared pages to stage-pages package 2025-10-03 15:48:45 +08:00
Neko Ayaka 51c38c8548 fix(stage-*): not respond if no websocket works 2025-10-01 22:18:08 +08:00
Neko Ayaka 29c0fedccb style(stage-ui): use kebeb case for directories under packages 2025-09-28 15:27:59 +08:00
Neko Ayaka 4fb878e78a fix(ci): huggingface build 2025-08-16 22:24:37 +08:00
Neko Ayaka cf9f541508 fix(ci): hf build 2025-08-11 14:52:39 +08:00
Neko Ayaka 33938578f5 fix(stage-app): include .vrma 2025-08-11 02:57:42 +08:00
Neko 9dd1601555 fix(stage-web): build 2025-07-22 16:30:06 +08:00
Neko Ayaka 3ee4f3a3f7 chore(deps): bump hfup 2025-07-22 15:05:31 +08:00
Neko Ayaka db99af7a59 feat(stage-web): info action 2025-07-22 03:37:17 +08:00
Typed SIGTERM 28236e8be4 fix: pwa service worker registering (#299)
* fix: pwa service worker registering

* chore: fix

Acked-by: vite-pwa/vite-plugin-pwa#89
2025-07-19 13:38:37 +08:00
Neko Ayaka 1c371a0f6a refactor(stage-ui/scenarios/settings/model-settings): moved to new location, better swap 2025-07-17 20:34:02 +08:00
雨落 61ef007cc5 fix(stage-web): failed to launch when localhost.crt and localhost.pem is missing. (#262)
---------

Signed-off-by: 秋雨落 <i@rain.cx>
2025-07-07 23:00:38 +08:00
Neko AyakaandMakito 8301ededa6 feat(stage-web): dynamic stage-web theme color
Co-authored-by: Makito <5277268+sumimakito@users.noreply.github.com>
2025-07-07 20:38:17 +08:00
Neko Ayaka 0e907295ab fix: HuggingFace Space build 2025-07-04 02:37:25 +08:00
Neko Ayaka 15a2f8184b fix: build 2025-07-04 02:19:11 +08:00
Neko AyakaandLiliumNeko 9d51403769 fix(stage-web,stage-tamagotchi): i18n HMR & color issue
Co-authored-by: LiliumNeko <30291104+liliumneko@users.noreply.github.com>
2025-07-01 00:25:20 +08:00
Neko eb6bcaed60 feat(i18n): new package for locales (#249)
* feat(i18n): new package for locales

We are renaming from zh-CN to zh-Hans with the naming regulation of BCP 47 language tags.
For future languages, suggesting to check & lookup on

- [Language subtag lookup app](https://r12a.github.io/app-subtags/)
- [iana.org/assignments/language-subtag-registry/language-subtag-registry](https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry)

to search on.

Additionally, use `en` for English is actually enforced instead of having `en-Latin`.

More resources and citations worth to check on:
- https://developer.mozilla.org/en-US/docs/Glossary/BCP_47_language_tag
- https://en.wikipedia.org/wiki/IETF_language_tag
- https://en.wikipedia.org/wiki/ISO_15924
2025-06-30 18:48:23 +08:00
Neko Ayaka 8ee87f9e70 style(*): stronger import sort 2025-06-30 02:23:40 +08:00
Neko Ayaka 50e05b114b chore(*): use @moeru/std & cleanup code, rename 2025-06-23 15:34:07 +08:00
Neko AyakaandMakito cc449b1d0c style: use @sumimakito integrated perfectionist/sort-imports`
Co-authored-by: Makito <5277268+sumimakito@users.noreply.github.com>
2025-06-17 14:03:27 +08:00
Neko Ayaka ab4a869104 feat(workspace): use tsdown for Vue component modules 2025-06-11 02:43:25 +08:00
Neko Ayaka b5d3590618 chore(deps): remove unused depdencies 2025-05-13 13:05:47 +08:00
Neko Ayaka 8433746a6c docs: rename to AIRI 2025-05-07 16:25:44 +08:00
Neko Ayaka 3f9335089d fix: types & import 2025-04-26 16:03:38 +08:00
Neko Ayaka 9a11d1b963 fix(stage-web|stage-tamagotchi): duckdb-wasm import url 2025-04-06 01:58:28 +08:00
Neko Ayaka 64649f12a2 fix: build 2025-03-16 11:16:08 +08:00
Neko Ayaka 576502be25 fix(drizzle-duckdb-wasm): build 2025-03-13 14:05:00 +08:00
Neko Ayaka d62bb4192c style(stage-web): new transitions
Signed-off-by: Neko Ayaka <neko@ayaka.moe>
2025-03-06 21:52:38 +08:00
Neko Ayaka 581ca005e1 fix(stage-web): bad PWA options
Signed-off-by: Neko Ayaka <neko@ayaka.moe>
2025-03-05 16:04:45 +08:00