Commit Graph
1696 Commits
Author SHA1 Message Date
Makito dbe85583bf feat(stage-pages,stage-shared,stage-ui): better OTel identifiers 2026-04-15 02:17:09 +09:00
Makito 7d544d03a1 feat(stage-shared,stage-ui): add store and integrations for IO tracer 2026-04-15 02:17:09 +09:00
0c3655ee8d refactor(inference): replace custom AsyncMutex with async-mutex package (#1660)
## Summary

Address maintainer feedback from #1622 ([@nekomeowww's
comment](https://github.com/moeru-ai/airi/pull/1622#discussion_r2342632282)).

The project already uses `async-mutex` in other packages
(`stage-tamagotchi`, `electron-screen-capture`), and it's in the
workspace catalog. This replaces the custom `AsyncMutex` implementation
with the shared dependency.

- Replace `AsyncMutex.run()` → `Mutex.runExclusive()`
- Replace `AsyncMutex.reset()` → `Mutex.cancel()`
- Remove `async-mutex.ts` and its unit tests
- Remove `AsyncMutex` from inference barrel exports
- Add `async-mutex` as direct dependency of `@proj-airi/stage-ui`

**Regarding `@moeru/eventa` suggestion**
([comment](https://github.com/moeru-ai/airi/pull/1622#discussion_r2342631692)):
The `waitForMessage` pattern is a thin request-response abstraction over
`postMessage`, where the worker is driven by `@huggingface/transformers`
internally. Eventa's transport-agnostic RPC is better suited for
bidirectional channels (Electron IPC, WebSocket) than for this one-way
"post and wait" pattern. No change for now.

## Test plan

- [x] `pnpm exec vitest run packages/stage-ui/src/libs/inference/` — 11
tests pass (4 removed with custom impl)
- [x] `pnpm -F @proj-airi/stage-ui typecheck` — no errors
- [x] `pnpm lint:fix` — no new errors in changed files

---------

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-14 11:47:33 +08:00
github-actions[bot]andCrowdin Bot 803442f5d8 chore(i18n): update translations (#1659)
This PR contains updated translations from Crowdin. Created from [GitHub
Actions](https://github.com/moeru-ai/airi/blob/main/.github/workflows/crowdin-cron-sync.yml).

You can review the source of translations
[here](https://crowdin.com/project/proj-airi)

Co-authored-by: Crowdin Bot <support+bot@crowdin.com>
2026-04-14 10:07:31 +08:00
Makito 826861f9c9 feat(stage-layouts): add an optional disableBackButton to route metadata 2026-04-14 01:12:48 +09: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
Lulu 9bc2d718b6 fix(stage-ui): fit scroll visualizer metrics and scroller in fixed he… (#1632)
Co-authored-by-agent: Cursor <unknown@example.com>
2026-04-13 14:33:38 +08:00
Lulu bc94ba480b fix(stage-pages): allow clearing OpenAI-compatible speech model field (#1644) 2026-04-13 13:55:00 +08:00
github-actions[bot] 1ca3a72394 chore(i18n): update translations (#1650) 2026-04-13 13:54:14 +08:00
github-actions[bot]andCrowdin Bot 977a8e4f57 chore(i18n): update translations (#1641)
This PR contains updated translations from Crowdin. Created from [GitHub
Actions](https://github.com/moeru-ai/airi/blob/main/.github/workflows/crowdin-cron-sync.yml).

You can review the source of translations
[here](https://crowdin.com/project/proj-airi)

Co-authored-by: Crowdin Bot <support+bot@crowdin.com>
2026-04-12 17:03:13 +08:00
RainbowBird b7f9ff2749 chore(stage-ui): enhance flux package display and add recommended badge 2026-04-12 05:30:55 +08:00
RainbowBird 671517864a feat(flux): update transaction stats to use capacity from latest credit/initial transaction 2026-04-12 04:52:42 +08:00
RainbowBird 93888e6935 feat(server): use stripe product as flux pricing (#1640) 2026-04-12 04:32:42 +08:00
Makito bc5397b3f5 feat(stage-ui): add OTel deps and IO tracer helpers 2026-04-11 19:05:38 +09:00
Makito dd9cc0942b feat(stage-shared): add types for IO tracing 2026-04-11 18:25:19 +09:00
github-actions[bot]andCrowdin Bot 978009a13c chore(i18n): update translations (#1629)
This PR contains updated translations from Crowdin. Created from [GitHub
Actions](https://github.com/moeru-ai/airi/blob/main/.github/workflows/crowdin-cron-sync.yml).

You can review the source of translations
[here](https://crowdin.com/project/proj-airi)

Co-authored-by: Crowdin Bot <support+bot@crowdin.com>
2026-04-11 10:39:16 +08:00
Neko Ayaka b18158bce2 chore(computer-use-mcp): remove all hardcoded file path 2026-04-11 05:13:55 +08:00
Neko Ayaka 87f719272a fix(stage-layouts): prevent using :global(...) as they gets compiled into .dark without the children selector 2026-04-11 04:22:34 +08:00
Neko Ayaka 95eac8e41c chore(deps): bump dependencies 2026-04-11 04:00:49 +08:00
yewu 4da6fd3672 fix(stage-pages): persist default Kokoro model on first visit (#1624)
Co-authored-by-agent: Unknown <unknown@example.com>
2026-04-11 03:18:27 +08:00
Makito ccba8fbe65 fix(stage-ui): shrink icon size to better fit the button 2026-04-11 03:03:29 +09:00
Iro adcfcd9399 fix(stage-ui): resolve critical state and initialization issues (#1614) 2026-04-11 01:02:16 +08:00
Nashchennc 933ef01b10 test(stage-ui): add contract test (#1487) 2026-04-11 00:49:13 +08:00
LemonNeko c8a01e7a3b feat(stage-pocket): allow to set transparent background 2026-04-10 17:51:09 +08:00
Neko Ayaka fb3f54699b chore(18n): unified to use sign in / sign out 2026-04-10 16:25:11 +08:00
Neko Ayaka dd284f0f27 release: v0.9.0 2026-04-10 14:48:30 +08:00
github-actions[bot]andCrowdin Bot c05fd13545 chore(i18n): update translations (#1616)
Co-authored-by: Crowdin Bot <support+bot@crowdin.com>
2026-04-10 14:42:10 +08:00
Neko Ayaka 3962139b93 chore(stage-tamagotchi,ui): improved about page 2026-04-10 13:54:22 +08:00
github-actions[bot]andCrowdin Bot 558bd282b0 chore(i18n): update translations (#1613)
Co-authored-by: Crowdin Bot <support+bot@crowdin.com>
2026-04-10 11:14:38 +08:00
Neko f65a67f543 fix(ui): incorrect round and default shape of button 2026-04-10 03:50:35 +08:00
Neko Ayaka a0caaf3214 release: v0.9.0-rc.1 2026-04-10 03:40:59 +08:00
Neko Ayaka b1a4eac605 feat(stage-ui): new BugReporterDialog component 2026-04-10 03:40:10 +08:00
Neko Ayaka 90294ce15c refactor(stage-*): use new InputFileCard 2026-04-10 03:40:10 +08:00
Neko Ayaka 14f8275fa7 feat(ui,stage-ui): FieldInput, InputFileCard, and story update 2026-04-10 03:40:09 +08:00
Neko Ayaka ec4d1998d7 feat(ui): error container 2026-04-10 03:40:09 +08:00
Neko Ayaka 6c366915c9 chore(ci): rollback package.json 2026-04-09 17:52:58 +08:00
Neko Ayaka 1be6defb08 chore(ci): updated tsconfig.json 2026-04-09 17:22:13 +08:00
LemonNeko a786e4c228 fix(stage-pocket): position of status icons 2026-04-09 16:53:21 +08:00
github-actions[bot]andCrowdin Bot bbf69d8805 chore(i18n): update translations (#1608)
Co-authored-by: Crowdin Bot <support+bot@crowdin.com>
2026-04-09 16:08:43 +08:00
RainbowBird d212da146a fix(stage-ui): improve LLM KV-cache compatibility for XML context injection (#1593) 2026-04-08 23:24:53 +08:00
Lovehsigure_520andClaude Opus 4.6 7b1041fa8e perf(vishot): compress and downscale AVIF screenshots (#1598)
* perf(vishot-runner-electron): compress and downscale AVIF screenshots

The capture pipeline was emitting AVIF at default quality with no
resolution cap, so 4K displays produced ~800KB per screenshot (~42MB
total for the tamagotchi manual). Add quality 50, speed 6, and a
1920px max-width downscale — expected output drops to ~20-40KB each
with no visible quality loss for UI documentation.

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

* perf(docs): regenerate manual screenshots with compression

Re-capture all 27 tamagotchi manual screenshots using the new AVIF
pipeline settings (quality 50, max-width 1920px, speed 6).

Before: ~800KB per image, ~42MB total (4K @ default quality)
After:  ~15-38KB per image, ~1MB total (1920px @ quality 50)

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

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By-Agent: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 10:11:18 +08:00
github-actions[bot]andCrowdin Bot 52eff227de chore(i18n): update translations (#1603)
Co-authored-by: Crowdin Bot <support+bot@crowdin.com>
2026-04-08 09:58:07 +08:00
Neko Ayaka dc7132bb91 release: v0.9.0-beta.7 2026-04-08 04:17:03 +08:00
Neko Ayaka 4179365baa refactor(ui,stage-ui): FieldSelect, FieldComboSelect split 2026-04-08 03:28:11 +08:00
286cc33d0e feat(stage-ui): let AIRI see tool failures in LLM context (captureToolErrors + xsai patches) (#1602)
---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Cursor
Co-authored-by-agent: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2026-04-08 01:29:17 +08:00
Neko Ayaka 9be9bb6a18 fix(stage-ui,ui): RoundRange updated, onboarding props corrected 2026-04-08 01:06:41 +08:00
Neko Ayaka 160176b33a fix(stage-*): qr should have dark mode adapted, connection component moved 2026-04-08 01:06:40 +08:00
LemonNeko 0cd095b323 feat(stage-pocket): scan qr code to connect to tamagotchi 2026-04-07 19:04:59 +08:00
RainbowBird 6541969fdb fix(stage-ui): disable coupon 2026-04-07 18:31:34 +08:00
Neko Ayaka d107fadcb9 chore(docs,scenarios-*): better structure 2026-04-07 14:22:51 +08:00