[PR #1841] [MERGED] Fix off-chat generation notifications #5311

Closed
opened 2026-10-22 04:15:09 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1841
Author: @cha1latte
Created: 6/1/2026
Status: ✅ Merged
Merged: 6/1/2026
Merged by: @cha1latte

Base: refactor ← Head: fix/issue-1808-notifications


📝 Commits (3)

  • cb7e405 Fix off-chat generation notifications
  • 770d78e Fix notification test teardown
  • 819b444 Handle interrupted notification audio contexts

📊 Changes

4 files changed (+411 additions, -12 deletions)

View changed files

➕ src/features/runtime/generation/hooks/use-generate.test.ts (+220 -0)
📝 src/features/runtime/generation/hooks/use-generate.ts (+74 -0)
➕ src/shared/lib/notification-sound.test.ts (+77 -0)
📝 src/shared/lib/notification-sound.ts (+40 -12)

📄 Description

Linked issue

Closes #1808

Why this change

  • Refactor generation saved off-chat Conversation and Roleplay replies without restoring legacy unread state, floating avatar bubbles, or Roleplay notification pings.
  • Notification audio also created a fresh AudioContext on every ping and did not fail quietly if Web Audio was unavailable or blocked.

What changed

  • Added off-chat assistant-message notification handling in the shared generation runtime for Conversation and Roleplay chats.
  • Persisted autonomous unread metadata best-effort, updated local unread counts, and added the existing floating avatar notification bubble.
  • Wired Conversation replies to the existing Conversation sound/native notification settings and Roleplay replies to rpNotificationSound.
  • Reused a single notification AudioContext and wrapped Web Audio setup/playback in a quiet best-effort guard.
  • Added focused regression coverage for off-chat notification behavior, active-chat negative controls, an async return-before-metadata guard, and audio helper safety.

Refactor impact

Primary owner:

  • Runtime generation

Impact areas reviewed:

  • App shell notification bubbles
  • Chat/Roleplay notification settings
  • Chat unread state and autonomous unread persistence
  • Shared notification audio helper

Boundary notes:

  • Kept notification wiring in src/features/runtime/generation; no engine imports of React, stores, Tauri, or feature internals were added.
  • Persistence uses the existing src/shared/api/chat-command-api.ts wrapper instead of a raw Tauri call.
  • Native local notifications remain Conversation-only, matching the current settings copy.

Pressure points touched:

  • src/features/runtime/generation/hooks/use-generate.ts
  • src/shared/lib/notification-sound.ts

Validation

  • Matching validation command passes locally (for example pnpm typecheck, pnpm build, pnpm check:architecture, pnpm check:docs, or full pnpm check when warranted)
  • Full pnpm check passes before PR push/handoff
  • Human/manual validation completed by contributor or reviewer

Manual verification notes

  • Codex ran pnpm exec vitest run src/features/runtime/generation/hooks/use-generate.test.ts src/shared/lib/notification-sound.test.ts; 6 tests passed.
  • Codex ran pnpm typecheck; passed.
  • Codex ran pnpm check; passed line endings, architecture, frontend typecheck, Rust check, docs, discovery, and unused-code checks.
  • Codex ran node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json; passed.
  • Live screenshot proof was not captured because a provider-backed end-to-end generation setup with seeded chats is needed. The focused tests prove the runtime notification contract directly.

Feature Discoverability

Check exactly one:

  • Updated src/features/shell/discovery/ because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool.
  • N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find.

Reason:

  • Bugfix for existing notification settings and shell notification behavior.

Docs and release impact

  • No docs changes needed
  • Updated README.md
  • Updated CONTRIBUTING.md
  • Updated docs/developer/
  • Updated repo skills or AGENTS.md
  • Confirmed this PR does not restore old staging/package-workspace/release claims

UI evidence

  • No screenshots attached. The visible UI result depends on a live generation finishing after navigation, and this draft keeps that limitation explicit while the runtime contract is covered by focused automated tests.

Summary by CodeRabbit

  • New Features

    • Notifications for messages arriving in conversations you're not actively viewing: unread indicators, metadata (name/avatar), local notification tags, and optional notification sounds.
  • Improvements

    • Notification sound system now reuses audio context, is more resilient across browsers, and fails silently on unsupported environments.
  • Tests

    • Added end-to-end tests covering off-chat notification behavior and audio playback resilience.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/1841 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 6/1/2026 **Status:** ✅ Merged **Merged:** 6/1/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `fix/issue-1808-notifications` --- ### 📝 Commits (3) - [`cb7e405`](https://github.com/Pasta-Devs/Marinara-Engine/commit/cb7e4050b863dafb32d1fe5c86ae189788579e69) Fix off-chat generation notifications - [`770d78e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/770d78e97e8ddfecd7cf5013f9dac02202b8110c) Fix notification test teardown - [`819b444`](https://github.com/Pasta-Devs/Marinara-Engine/commit/819b444fa29fd4d06cd63538ecfbc5d085b5e44d) Handle interrupted notification audio contexts ### 📊 Changes **4 files changed** (+411 additions, -12 deletions) <details> <summary>View changed files</summary> ➕ `src/features/runtime/generation/hooks/use-generate.test.ts` (+220 -0) 📝 `src/features/runtime/generation/hooks/use-generate.ts` (+74 -0) ➕ `src/shared/lib/notification-sound.test.ts` (+77 -0) 📝 `src/shared/lib/notification-sound.ts` (+40 -12) </details> ### 📄 Description <!-- Target branch: `refactor`. Change the base to `refactor` before submitting unless a maintainer explicitly asked for another base. --> <!-- Keep all checkboxes unchecked until a human has actually verified them. --> ## Linked issue Closes #1808 ## Why this change - Refactor generation saved off-chat Conversation and Roleplay replies without restoring legacy unread state, floating avatar bubbles, or Roleplay notification pings. - Notification audio also created a fresh `AudioContext` on every ping and did not fail quietly if Web Audio was unavailable or blocked. ## What changed - Added off-chat assistant-message notification handling in the shared generation runtime for Conversation and Roleplay chats. - Persisted autonomous unread metadata best-effort, updated local unread counts, and added the existing floating avatar notification bubble. - Wired Conversation replies to the existing Conversation sound/native notification settings and Roleplay replies to `rpNotificationSound`. - Reused a single notification `AudioContext` and wrapped Web Audio setup/playback in a quiet best-effort guard. - Added focused regression coverage for off-chat notification behavior, active-chat negative controls, an async return-before-metadata guard, and audio helper safety. ## Refactor impact Primary owner: - Runtime generation Impact areas reviewed: - App shell notification bubbles - Chat/Roleplay notification settings - Chat unread state and autonomous unread persistence - Shared notification audio helper Boundary notes: - Kept notification wiring in `src/features/runtime/generation`; no engine imports of React, stores, Tauri, or feature internals were added. - Persistence uses the existing `src/shared/api/chat-command-api.ts` wrapper instead of a raw Tauri call. - Native local notifications remain Conversation-only, matching the current settings copy. Pressure points touched: - `src/features/runtime/generation/hooks/use-generate.ts` - `src/shared/lib/notification-sound.ts` ## Validation <!-- Check only what you personally ran or manually verified. Treat unchecked items as explicit TODOs. --> <!-- Do not submit *.test.ts or *.test.tsx files as PR proof; cite existing checks, command output, app/browser/Tauri verification, or manual notes instead. --> - [ ] Matching validation command passes locally (for example `pnpm typecheck`, `pnpm build`, `pnpm check:architecture`, `pnpm check:docs`, or full `pnpm check` when warranted) - [ ] Full `pnpm check` passes before PR push/handoff - [ ] Human/manual validation completed by contributor or reviewer ### Manual verification notes - Codex ran `pnpm exec vitest run src/features/runtime/generation/hooks/use-generate.test.ts src/shared/lib/notification-sound.test.ts`; 6 tests passed. - Codex ran `pnpm typecheck`; passed. - Codex ran `pnpm check`; passed line endings, architecture, frontend typecheck, Rust check, docs, discovery, and unused-code checks. - Codex ran `node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json`; passed. - Live screenshot proof was not captured because a provider-backed end-to-end generation setup with seeded chats is needed. The focused tests prove the runtime notification contract directly. ## Feature Discoverability Check exactly one: - [ ] Updated `src/features/shell/discovery/` because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool. - [x] N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find. Reason: - Bugfix for existing notification settings and shell notification behavior. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated `README.md` - [ ] Updated `CONTRIBUTING.md` - [ ] Updated `docs/developer/` - [ ] Updated repo skills or `AGENTS.md` - [ ] Confirmed this PR does not restore old staging/package-workspace/release claims ## UI evidence - No screenshots attached. The visible UI result depends on a live generation finishing after navigation, and this draft keeps that limitation explicit while the runtime contract is covered by focused automated tests. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Notifications for messages arriving in conversations you're not actively viewing: unread indicators, metadata (name/avatar), local notification tags, and optional notification sounds. * **Improvements** * Notification sound system now reuses audio context, is more resilient across browsers, and fails silently on unsupported environments. * **Tests** * Added end-to-end tests covering off-chat notification behavior and audio playback resilience. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:15:09 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#5311
No description provided.