Skip to content

feat: generative background music & notification sound system#3588

Open
ttmouse wants to merge 1 commit into
esengine:main-v2from
ttmouse:pr/music-sound
Open

feat: generative background music & notification sound system#3588
ttmouse wants to merge 1 commit into
esengine:main-v2from
ttmouse:pr/music-sound

Conversation

@ttmouse

@ttmouse ttmouse commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

生成式背景音乐 & 通知音效系统

生成式背景音乐

  • Token 驱动的实时音乐引擎,每 4 个 AI Token 触发一个音符
  • C Major 五声音阶,听感舒适不干扰
  • 4 种音色预设:Classic (三角波)、Ethereal (正弦波, 默认)、Digital (方波)、Retro (锯齿波)
  • 设置面板可切换预设、预览、关闭

通知音效

  • Success 音效:AI 完成生成时播放
  • Attention 音效:AI 提问时播放
  • 各 5 种音效可选:合成音 + 4 种 WAV 音效素材
  • 设置面板即时选择 + 预览

后端改动

  • 新增 agent:turn-done 事件,前端据此触发成功音效
  • 新增 onTurnDone() bridge 方法

- Token-driven generative music engine with 4 presets (Classic/Ethereal/Digital/Retro)
- Notification sound system with Success and Attention events
- 5 sound effects per event (synthesized + WAV files from Mixkit)
- Settings UI for sound/music preferences with preview buttons
- agent:turn-done backend event for frontend sound triggering
@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development desktop Wails desktop app (desktop/**) labels Jun 8, 2026

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

Copy link
Copy Markdown

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: 85159f971a

ℹ️ 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".

Comment thread desktop/tabs.go
// Emit a dedicated "generation complete" event so the frontend can play a
// success sound without mis-firing on tab switches.
if e.Kind == event.TurnDone && s.ctx != nil {
runtime.EventsEmit(s.ctx, "agent:turn-done")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Carry turn errors into the chime event

When a run fails, TurnDone carries Err (documented in internal/event/event.go), but this new side-channel drops the payload and App.tsx plays playSuccessChime() for every agent:turn-done. In that failure scenario the UI still emits the success chime, unlike the existing notification path that distinguishes failed turns; include the error/status or consume the typed event so failures can be handled separately.

Useful? React with 👍 / 👎.

onChange={(e) => {
const next = e.target.value as GenerativePreset;
setGenMusicPreset(next);
setGenerativePreset(next);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Honor music changes during active turns

When the user changes this setting while a turn is already running, this only updates localStorage; the App.tsx effect that starts/stops the engine is keyed solely on state.running, so choosing Off (or switching presets) does not affect the currently playing engine until the turn ends. Stop the singleton immediately for off, and apply the new preset to the running engine for non-off choices, so the setting takes effect during active generations.

Useful? React with 👍 / 👎.

Comment on lines +670 to +671
if (state.running && isGenerativeMusicEnabled()) {
generativeMusic.start();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Track background tab runs for generative music

This starts the music engine from the currently active tab's state.running, but the desktop supports multiple tabs whose controllers keep running after the user switches tabs. If tab A is generating and the user switches to idle tab B, the active state becomes false and this effect stops the music even though an agent is still generating; conversely token events are subscribed globally. Base the engine on the tab list/controller running state for any running tab, or filter token playback to the same tab state.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

desktop Wails desktop app (desktop/**) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant