Skip to content

feat(desktop): Aivis ユーザー辞書 + 日別使用量ダッシュボード#288

Merged
MocA-Love merged 2 commits intomainfrom
feat/aivis-dictionary-and-usage
Apr 17, 2026
Merged

feat(desktop): Aivis ユーザー辞書 + 日別使用量ダッシュボード#288
MocA-Love merged 2 commits intomainfrom
feat/aivis-dictionary-and-usage

Conversation

@MocA-Love
Copy link
Copy Markdown
Owner

関連: #286 (#287 でマージ済みの Aivis 音声通知の続編)

概要

Settings > Notifications > Aivis セクションに、ユーザー辞書の管理と日別使用量ダッシュボードを追加。

ユーザー辞書

  • DB: settings.aivis_user_dictionary_uuid を追加 (migration 0061)
  • Main: main/lib/aivis/client.ts — Bearer 認証 + エラー型 (AivisApiKeyMissingError / AivisApiError) 付きの共通 fetch ラッパー
  • TRPC aivis ルーター: dictionary.list/get/create/update/delete/import/export + usage.daily/me + validateKey
  • 合成: user_dictionary_uuid を TTS リクエストに付与 (辞書選択中のみ)
  • UI (AivisDictionary):
    • 辞書一覧カード (ACTIVE マーカー、説明、単語数、更新日)
    • インライン編集ダイアログ: surface / 読み (カタカナ検証) / アクセント型 / 優先度 0-10 / 品詞
    • 新規作成ダイアログ、削除確認、適用切替
    • AivisSpeech 互換 JSON の import / export (ファイル選択 → blob ダウンロード)
  • UI (AivisSettings): Model UUID 直下に辞書セレクタを追加

日別使用量ダッシュボード

  • TRPC: aivis.usage.daily(startDate, endDate) — Aivis /v1/payment/usage-summaries (時間単位) をクライアント側で日別集計 + API キー別内訳を添付
  • UI (AivisUsage):
    • 7 日 / 30 日の期間タブ
    • 統計カード: Requests / Characters / Credits (残高併記)
    • 日別バーグラフ (Credits / Requests / Chars トグル、ホバーツールチップ)
    • 日別テーブル (直近 10 日)
    • API キー別内訳 (複数キー保有時のみ)
    • 5 分キャッシュ

動作確認

  • 辞書の作成 / 編集 / 削除 / import / export が動作
  • 辞書選択中は TTS に読み方が反映される
  • 使用量ダッシュボードが期間切替で更新される
  • API キー未設定時は適切なエンプティ状態が出る
  • 401 等のエラー時に UI が壊れず表示される

スキップ

  • カスタム期間ピッカー (モック上はあるが未実装。必要なら別 PR)
  • アクセントビジュアルエディタ (現状は数値入力のみ)

- local-db: settings.aivis_user_dictionary_uuid を追加 (migration 0061)
- main/lib/aivis/client.ts: Bearer 認証 + エラー型付きの fetch ラッパー
- TRPC: aivis サブルーターを新設 (dictionary.list/get/create/update/delete/import/export,
  usage.daily/me, validateKey)。API Key 未設定や 401 を型付きで返す
- aivis-tts: 合成リクエストに user_dictionary_uuid を付与
- settings TRPC: userDictionaryUuid の get/set を追加
- UI:
  - AivisDictionary: 辞書一覧カード、インライン編集ダイアログ (surface/読み/
    アクセント/優先度/品詞)、新規作成ダイアログ、AivisSpeech 互換 JSON の
    import/export、削除確認、適用中マーカー
  - AivisUsage: 7/30 日期間タブ、3 統計カード (requests/chars/credits)、
    日別バーグラフ (credits/requests/chars トグル)、日別テーブル、APIキー
    別内訳、5 分キャッシュ
  - AivisSettings: 辞書セレクタを Model UUID 下に追加
- settings 検索: RINGTONES_AIVIS_DICTIONARY / RINGTONES_AIVIS_USAGE を追加
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 17, 2026

Warning

Rate limit exceeded

@MocA-Love has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 8 minutes and 36 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 8 minutes and 36 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: edd8590c-16d2-4177-a356-cec514739c0e

📥 Commits

Reviewing files that changed from the base of the PR and between ecaef53 and b4de751.

📒 Files selected for processing (18)
  • apps/desktop/src/lib/trpc/routers/aivis/index.ts
  • apps/desktop/src/lib/trpc/routers/index.ts
  • apps/desktop/src/lib/trpc/routers/settings/index.ts
  • apps/desktop/src/main/lib/aivis/client.ts
  • apps/desktop/src/main/lib/notifications/aivis-tts.ts
  • apps/desktop/src/renderer/routes/_authenticated/settings/ringtones/components/AivisDictionary/AivisDictionary.tsx
  • apps/desktop/src/renderer/routes/_authenticated/settings/ringtones/components/AivisDictionary/CreateDictionaryDialog.tsx
  • apps/desktop/src/renderer/routes/_authenticated/settings/ringtones/components/AivisDictionary/DictionaryEditorDialog.tsx
  • apps/desktop/src/renderer/routes/_authenticated/settings/ringtones/components/AivisDictionary/index.ts
  • apps/desktop/src/renderer/routes/_authenticated/settings/ringtones/components/AivisSettings/AivisSettings.tsx
  • apps/desktop/src/renderer/routes/_authenticated/settings/ringtones/components/AivisUsage/AivisUsage.tsx
  • apps/desktop/src/renderer/routes/_authenticated/settings/ringtones/components/AivisUsage/index.ts
  • apps/desktop/src/renderer/routes/_authenticated/settings/ringtones/page.tsx
  • apps/desktop/src/renderer/routes/_authenticated/settings/utils/settings-search/settings-search.ts
  • packages/local-db/drizzle/0061_add_aivis_user_dictionary.sql
  • packages/local-db/drizzle/meta/0061_snapshot.json
  • packages/local-db/drizzle/meta/_journal.json
  • packages/local-db/src/schema/schema.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/aivis-dictionary-and-usage

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9c5343959d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

- P2: 辞書削除の失敗時にアクティブ指定を誤って解除する問題を修正
  (remove.mutate の onSuccess コールバック内で解除する)
- P2: 使用量取得エラー時にゼロ埋めダッシュボードが表示されて
  あたかも正当な 0 使用量に見える問題を修正 (data が無い時は
  エラー/ローディング表示のみ、data がある時のみ panel を描画)
@MocA-Love MocA-Love merged commit f8f1b0c into main Apr 17, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant