Skip to content

Phase 4A:建立受控 ASR consumer routing 与语音设置 - #2396

Merged
wehos merged 21 commits into
Project-N-E-K-O:mainfrom
MomiJiSan:codex/phase4-a-voice-settings
Jul 31, 2026
Merged

Phase 4A:建立受控 ASR consumer routing 与语音设置#2396
wehos merged 21 commits into
Project-N-E-K-O:mainfrom
MomiJiSan:codex/phase4-a-voice-settings

Conversation

@MomiJiSan

@MomiJiSan MomiJiSan commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

改动概述 / Summary

Phase 4A 已按最新 main 重新实现,不复用旧 PR 的 Core/runtime 历史。该 PR 只收敛语音识别设置、turn identity、受控 transcript consumer registry,以及 Core/game 内建接线。

共 6 个阶段提交、36 个文件:

  1. fix(voice): align ASR defaults and optimization semantics
  2. feat(voice): add shared recognition settings popover
  3. refactor(voice): attach turn identity to partial transcripts
  4. feat(voice): add controlled transcript consumer registry
  5. feat(asr): route Core and game transcripts through registry
  6. test(voice): enforce cancellation and empty-final barriers

冻结语义

  • 新用户默认启用独立 ASR 与资源优化;显式保存的 false 保持不变。
  • Web/Electron 共用同一语音识别设置 popover,覆盖 8 个 locale,并完整清理 DOM、listener 与 ARIA 状态。
  • VoicePartialEvent 和 final 使用完整 VoiceTurnToken;任一 lease、route 或 audio generation 不匹配时都 fail-closed。
  • VoiceInputRegistryLLMSessionManager 同生命周期,内建 core_chatgame consumer 只注册一次。
  • MicLease owner 决定激活的 consumer;game 不可用时不回落聊天,切换、注销、迟到或重复事件不会串投递。
  • partial/final/empty-final/cancel 均按 token 精确路由;final 在 callback 前消费 route,empty-final 仍完成一次终止与清理。
  • cancel/abort/suspend/close/failure 会等待 terminal cancellation,并精确清理原 Core preview/turn;不使用模糊 abandon(None)
  • consumer callback 被阻塞时不会阻塞下一轮 registry 生命周期。

依赖与硬边界

  • 新增 voice_input 依赖方向合同:仅允许依赖自身包、voice_turn.contractsutils.game_route_state;同时禁止 asr_client 反向导入 voice_input。静态和动态 import 都覆盖。
  • 未修改 Provider worker/policy、TTS、Omni、WebSocket PCM、SmartTurn 4B 生命周期、speaker shadow 或 game router 实现。
  • Core/game 接线只通过既有 utils.game_route_state 边界完成。
  • 插件侧只定义 registrar/handle/SPI 与受控生命周期;不接入插件 SDK、IPC/RPC、插件进程管理或 MicLease 权限。

回归报告 / Regression Report

  • 改动内容:将 partial/final/cancel 的 transcript 投递统一收口到 token-bound VoiceInputRegistry,完成 Core/game consumer 与 MicLease owner 接线,并补齐默认设置、共享 popover 和依赖方向合同。
  • 理由与必要性:旧实现缺少 partial 的完整 turn identity,也没有受控 consumer 生命周期,切换、迟到、重复或取消事件存在错误投递/模糊清理风险;Phase 4A 需要在不改变 Provider、TTS 和路由边界的前提下建立 fail-closed 控制面。
  • 改动前:partial 只携带文本;Core 接收路径与 consumer identity 隐式耦合;取消和旧事件无法全部按 lease/route/audio generation 精确隔离。
  • 改动后:每轮准备时固定完整 VoiceTurnToken 与 consumer;所有事件按同一 identity barrier 校验,final/empty-final 只终止一次,切换或不可用路径直接丢弃且不回退;Core preview/turn 按原 token 精确清理。
  • 潜在回归点:ASR turn 生命周期、MicLease owner 切换、Core preview/turn 清理、game consumer 可用性、popover 生命周期。已用 default chat、active/unavailable game、partial/final/empty-final/cancel、late/duplicate、callback 阻塞、registration 失效和同-token retry 回归覆盖。

不拆分理由 / Why Not Split

该改动按 6 个独立提交分阶段审阅,但必须作为一个原子 PR 合入:设置默认值、前端入口、turn token 合同、registry、Core/game 接线和竞态/结构合同共同定义同一 fail-closed 语义。拆成可独立合入的 PR 会在中间状态留下 partial 无身份、registry 未接线或取消屏障不完整的组合。36 个文件中还包含 8 个同步 locale 文件、新增模块和集中测试,实际生产改动仍保持在 Phase 4A 冻结边界内。

测试 / Testing

  • 完整 unit 回归:8445 passed, 46 skipped;rebase 后 Phase 4A 聚焦回归:494 passed
  • Chromium popover 回归:8 passed;i18n sync gate 通过。
  • 重点回归:Core independent ASR 215 passed、audio stream queue 119 passed、Registry 24 passed、preview 专项 14 passed
  • Core contract gate、Ruff、前端脚本 node --checkgit diff --check 均通过。
  • 最终 GitNexus detect_changes(upstream/main...HEAD):风险 LOW,545 个映射符号、0 条受影响执行流;禁止路径命中 0。

Summary by CodeRabbit

  • 新功能
    • 语音转写按回合严格路由,支持命名空间注册语音消费者,覆盖核心与游戏场景。
    • 新增“智能资源优化”开关、待生效状态及跨窗口同步;新配置默认启用。
  • 改进
    • 强化 Partial/Final、空 Final、取消及会话切换的投递与清理一致性。
    • 优化麦克风语音设置弹窗、生命周期管理及多语言文案。
  • 测试
    • 补充资源优化、语音路由、取消流程、弹窗生命周期与静态契约校验。
  • 文档
    • 更新语音输入合约与路由边界说明。

@MomiJiSan
MomiJiSan requested a review from wehos as a code owner July 18, 2026 15:47
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1fa027ac-4233-4d4d-870f-9dcf994ea7eb

📥 Commits

Reviewing files that changed from the base of the PR and between 7267d6e and 137d1de.

📒 Files selected for processing (1)
  • tests/unit/test_app_websocket_static.py
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • Project-N-E-K-O/N.E.K.O.-PC (manual)

Walkthrough

该 PR 引入 VoiceInputRegistry 统一管理语音转录路由、消费者生命周期与完整 turn token,并同步改造 ASR 会话握手、资源优化设置、前端语音面板、跨窗口同步、分层校验及多语言文案喵。

Changes

语音输入与资源优化系统喵

Layer / File(s) Summary
Registry、消费者与 Core/ASR 生命周期
main_logic/voice_input/*, main_logic/core/asr_runtime.py, main_logic/asr_client/*, main_logic/voice_turn/contracts.py
新增 token 驱动的消费者契约、注册与分发流程,并接入 Core/Game 路由、partial/final、取消、租约切换和热切换屏障喵。
会话握手与资源优化
main_logic/core/lifecycle.py, main_routers/websocket_router.py, main_logic/asr_client/detector_runtime.py, main_logic/core/_shared.py
新增资源优化握手覆盖值,并将其传递至独立 ASR 与 DetectorRuntime,控制 quiet skip 行为喵。
前端设置与多语言文案
static/app/*, static/locales/*
新增 portal popover、代际清理、pending epoch 状态、资源优化决议、跨窗口同步和语音设置文案喵。
分层校验与回归测试
scripts/check_core_contracts.py, tests/unit/*, tests/frontend/*
扩展动态导入解析、voice_input allowlist 校验,并覆盖路由失效、空 final、热切换、握手顺序、弹窗生命周期和设置同步喵。

Estimated code review effort: 5 (Critical) | ~150 minutes

Possibly related PRs

Suggested labels: Needs Check!, enhancement

Poem

Token 排队不迷路喵,
Registry 守住每条路喵。
空 final 安静落,
Popover 闪亮亮喵。
握手带着优化开关,
stale turn 乖乖退场喵。

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed 标题清晰概括了受控 ASR consumer 路由与语音设置这两项主要改动,和 PR 内容高度相关喵。
Description check ✅ Passed 描述完整包含改动概述、回归报告、不拆分理由和测试结果,并详细说明了变更边界与验证情况喵。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

@greptile-apps

greptile-apps Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR centralizes voice transcript routing and recognition settings. The main changes are:

  • Adds token-bound Core and game transcript consumers.
  • Routes partial, final, and cancellation events through a controlled registry.
  • Adds shared voice-recognition settings and resource-optimization synchronization.
  • Extends routing, lifecycle, and static contract coverage.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
main_logic/voice_input/registry.py Adds token-pinned consumer registration, dispatch, and invalidation.
main_logic/core/asr_runtime.py Connects Core ASR lifecycle callbacks to the controlled consumer registry.
main_logic/asr_client/runtime.py Associates partial transcripts with the prepared turn token.
static/app/app-audio-capture.js Adds the shared voice-recognition settings popover and setting synchronization.

Sequence Diagram

sequenceDiagram
    participant Mic as Microphone
    participant ASR as Independent ASR
    participant Registry as Voice Input Registry
    participant Consumer as Core or Game Consumer

    Mic->>ASR: PCM with ingress identity
    ASR->>Registry: Prepare turn token
    ASR->>Registry: Partial or final transcript
    Registry->>Consumer: Deliver only pinned route
    Consumer-->>Registry: Complete or cancel route
Loading

Reviews (28): Last reviewed commit: "test(settings): strengthen reset default..." | Re-trigger Greptile

@MomiJiSan
MomiJiSan marked this pull request as draft July 18, 2026 16:58
@MomiJiSan
MomiJiSan force-pushed the codex/phase4-a-voice-settings branch 2 times, most recently from c24fdf7 to 99b67c3 Compare July 20, 2026 02:22
@MomiJiSan
MomiJiSan force-pushed the codex/phase3-segmented-smart-turn branch from fc68230 to 9730015 Compare July 20, 2026 02:22
@MomiJiSan MomiJiSan changed the title 修复语音识别默认值并接入资源优化设置 Phase 4A:收敛独立 ASR 默认值与资源优化设置 Jul 20, 2026
@MomiJiSan
MomiJiSan marked this pull request as ready for review July 20, 2026 02:59
@MomiJiSan

Copy link
Copy Markdown
Contributor Author

@codex 全面审查一下

@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: 99b67c358f

ℹ️ 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 static/app/app-audio-capture.js Outdated

Copy link
Copy Markdown
Contributor Author

已处理 Codex P1 review(139369a8):

  • 关闭独立 ASR 后,UI 摘要与状态提示现在准确说明语音输入仍走 Omni 原生语音识别路径;
  • 同步修正 8 个 locale 以及旧 independentAsrNative 兼容文案;
  • 更新静态契约测试,防止再次出现“语音识别已关闭 / 不会切换 Omni”的误导文案;
  • 相关 ASR detector、core 与静态设置回归共 108 项通过,8 个 locale JSON 和 diff 检查通过。

PR 描述中的对应路由说明也已同步修正。

Copy link
Copy Markdown
Contributor Author

本次已按 #2345 的最终架构重新收敛并更新堆叠基线:Phase 4A 的 ASR 运行时改动现位于 main_logic/asr_client/runtime.py,设置读取保持走 utils.preferences;未恢复 core/asr_runtime.py,也未增加兼容壳。专项回归 111 passed,Ruff、compileall、core contracts 通过;GitNexus 为 LOW、0 affected processes。

@MomiJiSan
MomiJiSan marked this pull request as draft July 21, 2026 13:30

Copy link
Copy Markdown
Contributor Author

两个 P2 已在 14fe8f5a 收敛并推入当前 PR:

  1. 并发渲染资源泄漏

    • renderFloatingMicList() 增加 render generation;
    • 麦克风权限异步返回后校验 generation 与 popup 可用性,过期渲染不再创建 portal、Observer 或监听器;
    • disposer 改为幂等,并仅由当前 owner 清理全局引用。
  2. 设置 Pending 状态长期覆盖

    • Pending 改为目标 session epoch;
    • 普通 lifecycle 变化与启动失败不清除;
    • 仅下一次成功的 neko:voice-session-started 达到目标 epoch 后清除,并恢复 Ready / Blocked / Native 实际状态;
    • dispose 同步移除新增事件监听器。

边界保持不变:只修改 static/app/app-audio-capture.js 并新增真实行为测试;未修改后端、设置协议、i18n、Provider、Electron 原生层或四种模型调用方。

验证结果:

  • 新增行为测试:3 passed;
  • 既有前端/static contracts:43 passed;
  • ASR 回归:106 passed;
  • Ruff、JS 语法、diff check:通过;
  • 完整启动 N.E.K.O 后再启动 N.E.K.O-PC Electron 验收通过,//chat 无本次相关页面/控制台错误;
  • GitNexus compare:low risk,0 affected processes。

堆叠检查:#2398#2408 均未单独修改该前端文件,不应复制同一修复;后续只需按 #2396#2398#2408 顺序继承新基线。

@MomiJiSan
MomiJiSan force-pushed the codex/phase4-a-voice-settings branch from 14fe8f5 to 0fb3c77 Compare July 22, 2026 02:38

MomiJiSan commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Stacked rebase / Provider recovery owner 边界

本 PR 已纯 rebase 到修复后的 #2345 e5336cfb4,当前 head 为 2d6a6bec3

精确组合验证:129 passed;Core package contract、Ruff 与 diff check 通过。前端浏览器测试 2 项通过,剩余 1 项仅因本地未生成 React chat bundle 而出现既有静态资源 404,与设置或 Soniox recovery 无关。

@MomiJiSan
MomiJiSan force-pushed the codex/phase4-a-voice-settings branch 2 times, most recently from 2d6a6be to 392e89e Compare July 23, 2026 02:59
@MomiJiSan MomiJiSan changed the title Phase 4A:收敛独立 ASR 默认值与资源优化设置 Phase 4A:建立受控 ASR consumer routing 与语音设置 Jul 23, 2026
@MomiJiSan

Copy link
Copy Markdown
Contributor Author

ASR consumer routing 最终边界补充

本 PR 的最终职责已收敛为:在最新版 #2345 之上建立统一、受控的 ASR consumer routing;#2345 不再扩容。

  • MicLease owner 只负责麦克风占用与 ASR 生命周期;Consumer identity 只决定 transcript 投递目标。聊天/游戏切换不会重新申请 MicLease。
  • 首版实际接入 core_chatgame:默认聊天,进入游戏切到游戏,退出恢复聊天;不允许双投递。
  • 每个 utterance 开始时固定 ConsumerHandle。consumer 中途失效后,迟到的 partial/final 直接丢弃,不回落到聊天,也不影响 MicLease。
  • 插件侧只提供受控契约:PluginVoiceInputConsumerPluginVoiceInputRegistrar、capabilities 与 registration/handle 生命周期;插件身份必须由宿主验证和分配,不能用任意字符串冒充 core_chatgame 或其他插件。
  • 本 PR 不接入插件 SDK、IPC/RPC、插件进程生命周期或伴学 adapter;不允许插件直接申请 MicLease;不修改 TTS,也不修改 ASR Provider 协议。

验证结果:consumer routing/core 单测 97 passed,main_logic.voice_input 覆盖率 86.69%;扩展回归中的 Python 路径通过。现存的一个前端浏览器失败来自仓库缺少预构建 React chat bundle(静态资源 404),与本次 Python routing 改动无关。

后续堆叠 PR #2398#2408 将依次 restack 到本 PR 的新历史上。

Copy link
Copy Markdown
Contributor Author

Restack 完成回执

已按上面的收敛边界完成实现整理和依次 restack:

GitHub 上的 stacked base 镜像分支已经同步。目前三层 PR 均为 Draft / CLEAN,祖先关系为:

#2396 392e89e0a
  └─ #2398 b35c3251f
       └─ #2408 a4899c2b1

边界核对:

验证结果:

@MomiJiSan
MomiJiSan force-pushed the codex/phase4-a-voice-settings branch from 392e89e to 9a58231 Compare July 24, 2026 01:51
@MingTianSang

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 9a58231804

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Copy link
Copy Markdown
Contributor Author

Review feedback follow-up

已在 8526e93d 处理本轮 6 条未解决 review threads:

  1. _suspend_independent_asr() 改为先推进 runtime suspend() barrier,再 invalidate PCM sync,最后等待 registry cancellation idle,与 abort 路径顺序对齐。
  2. GameVoiceInputConsumer.on_final() 现在检查 route_external_voice_transcript() 的布尔结果;返回 False 时抛出 GAME_VOICE_TRANSCRIPT_NOT_ROUTED,使 registry 记录 callback failure,不再静默标记为 delivered。
  3. optimizationDecision.writeId 改为复用 _isValidAsrWriteId(),与 ASR decision 一致地限制安全整数、未来时钟偏移及 MAX_SAFE_INTEGER 边界;新增超大 ID 无法阻塞后续本地选择的行为回归。
  4. popover listener key 提取为单一 VOICE_POPOVER_GLOBAL_LISTENERS,三条 cleanup 路径共同复用;移除重复项并补齐 host removal 对 pending-changed listener 的校验。
  5. Scenario 8 去掉 makeContext(JSON.stringify(...)) 的双重序列化;同时补入明确更新的 server decision,先证明设置真实切到 server 值,再验证用户返回旧值会生成新 decision,消除假阳性。
  6. resource-optimization handshake 的 AST 顺序断言改为 max(snapshot_lines) < min(await_lines),确保所有同名赋值都发生在首次 await 前。

验证结果:

  • 扩大回归:470 passed(Core independent ASR、voice-input consumers/registry、settings、audio queue、Chromium popover)。
  • 聚焦回归:22 passed
  • Ruff、全部相关 JavaScript node --checkgit diff --check 通过。
  • GitNexus detect_changes:风险 LOW,8 files、17 mapped symbols、0 affected processes。

本轮未修改 Provider worker/policy、TTS、Omni、SmartTurn 4B 或 speaker shadow 边界。

@coderabbitai coderabbitai Bot added enhancement New feature or request and removed Needs Check! need doctor to check labels Jul 30, 2026
@wehos

wehos commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

@codex review

@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: 8526e93d1d

ℹ️ 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 main_logic/core/asr_runtime.py Outdated
Comment thread static/app/app-settings.js
Comment thread main_logic/voice_input/registry.py

Copy link
Copy Markdown
Contributor Author

Latest review follow-up (bf600b98)

已处理本轮 3 条新增 review feedback:

  • 将资源优化选择固定到已接受的 live session,provider hot swap/reconcile 不再受其他窗口被 dedup 请求覆盖的 manager handshake 影响。
  • reset tombstone 默认快照补齐 voiceInputResourceOptimizationEnabled: true,运行时与完整 writeback 均恢复默认值。
  • consumer 在 begin 后、prepare 前失效时立即消费 pinned route,并完成 consumer_unavailable terminal cancellation,允许同 token 在恢复后重试。

验证:聚焦回归 28 passed;Ruff、node --checkgit diff --check 通过。GitNexus detect_changes:LOW,6 files / 9 mapped symbols / 0 affected processes。3 个对应 review threads 均已回复并 resolved。

@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: b97e73667a

ℹ️ 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 main_logic/core/asr_runtime.py

@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: 70e8793095

ℹ️ 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 main_logic/voice_input/consumers/game.py
Comment thread static/app/app-state.js
Comment thread main_logic/core/asr_runtime.py Outdated
Comment thread main_logic/core/asr_runtime.py Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
main_logic/core/asr_runtime.py (1)

2345-2467: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

final_swap_task 加个等待超时兜底喵。

_dispatch_core_asr_transcript 这里用的是无超时 asyncio.wait((swap_task,)),而 final_swap_taskprime_context(...) / close() / flush... 等链路没有统一的 wait_for 保护;如果热切换卡住,这个 serial dispatch worker 也会被拖死喵。可以加一个合理的整体熔断超时,或让 _perform_final_swap_sequence 对关键外部 await 统一设定时限喵。

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@main_logic/core/asr_runtime.py` around lines 2345 - 2467, 为
_dispatch_core_asr_transcript 中等待 final_swap_task 的逻辑增加合理的整体超时熔断,避免热切换链路卡住时阻塞
serial dispatch worker;使用超时等待并在超时后继续执行现有的失效路由检查与安全返回流程,保持正常完成的 swap_task 行为不变。
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@main_logic/core/asr_runtime.py`:
- Around line 2345-2467: 为 _dispatch_core_asr_transcript 中等待 final_swap_task
的逻辑增加合理的整体超时熔断,避免热切换链路卡住时阻塞 serial dispatch
worker;使用超时等待并在超时后继续执行现有的失效路由检查与安全返回流程,保持正常完成的 swap_task 行为不变。

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 559bf839-ed7d-47a8-97d7-3408d15ec3bf

📥 Commits

Reviewing files that changed from the base of the PR and between bf600b9 and 70e8793.

📒 Files selected for processing (2)
  • main_logic/core/asr_runtime.py
  • tests/unit/test_core_independent_asr.py
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • Project-N-E-K-O/N.E.K.O.-PC (manual)

wehos commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Addressed the latest CodeRabbit outside-diff concern in a34df02 without using autofix. The unbounded asyncio.wait(final_swap_task) path was removed. Final delivery now waits on the same lock that guards lifecycle close→promote, with a 5-second timeout and fail-closed drop, so the serial dispatcher cannot wait indefinitely on a stuck swap. Focused validation: 401 tests passed; Ruff, JS syntax, and git diff --check passed.

@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: 437da12a5e

ℹ️ 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 static/app/app-settings.js

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/unit/test_app_websocket_static.py (1)

1539-1615: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

resetPriorDecision.value 没跟着默认值翻转改喵,三处「重置到默认值」断言可能测不出真的 bug 喵!

independentAsrEnabled 的默认值已经从 false 改成 true,但 resetPriorDecision.value(Line 1542)还是硬编码的 true,没有同步调整喵。这样一来:

  • Line 1558 reset.S.independentAsrEnabled === true
  • Line 1589 resetBody.independentAsrEnabled === true
  • Line 1612 resetPersisted._sharedWriteMeta.asrDecision.value === true

这三条纯值比较,就算重置逻辑压根没生效、只是把 resetPriorDecision 的旧值原样带过去,结果碰巧也是 true,断言照样能通过,起不到「验证真的 rebase 到新默认值」的作用了喵。对比之下 Line 1576 因为多了 resetWritebackDecision.writeId > resetPriorDecision.writeId 的顺序校验,才真正能抓出「没有 rebase」这种 bug 喵~

建议把 resetPriorDecision.value 改回和新默认值相反的 false,让这几条值断言重新具备区分度,但因为这是个巨长的测试函数、后面还复用了 resetPriorDecisionresetRace 场景,改完请务必跑一遍确认下游断言没被连带带偏喵。

🔍 建议改动
 const resetPriorDecision = {
   writeId: Date.now() + 1000,
   writerId: 'server-before-reset',
-  value: true,
+  value: false,
 };
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unit/test_app_websocket_static.py` around lines 1539 - 1615, Update the
resetPriorDecision fixture in the reset test scenario so its value is false,
opposite to the current independentAsrEnabled default of true. Keep the reset.S,
resetBody, and resetPersisted assertions validating true, and verify the later
resetRace reuse of resetPriorDecision still has the intended expectations after
this fixture change.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/unit/test_app_websocket_static.py`:
- Around line 1539-1615: Update the resetPriorDecision fixture in the reset test
scenario so its value is false, opposite to the current independentAsrEnabled
default of true. Keep the reset.S, resetBody, and resetPersisted assertions
validating true, and verify the later resetRace reuse of resetPriorDecision
still has the intended expectations after this fixture change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 035c6635-a994-4332-a6b0-97b434e68619

📥 Commits

Reviewing files that changed from the base of the PR and between 437da12 and 7267d6e.

📒 Files selected for processing (2)
  • static/app/app-settings.js
  • tests/unit/test_app_websocket_static.py
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • Project-N-E-K-O/N.E.K.O.-PC (manual)

@MomiJiSan

Copy link
Copy Markdown
Contributor Author

已处理 CodeRabbit 最新 outside-diff 测试建议,提交为 \137d1deae\。
esetPriorDecision.value\ 现在使用与启用默认值相反的 \ alse\,并新增显式前置断言,确保重置逻辑若只是沿用旧 tuple 会稳定失败;后续 reset-race 场景仍验证 reset rebase 后用户再次切回 \ alse\ 的新决议排序。定点 Node harness 1 passed,Ruff 与 \git diff --check\ 通过。

@coderabbitai coderabbitai Bot added the Needs Check! need doctor to check label Jul 31, 2026

@wehos wehos left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

火速合并

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

Labels

enhancement New feature or request Needs Check! need doctor to check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants