Skip to content

拆分 coordinator 子状态机模块#378

Merged
H-Chris233 merged 1 commit into
Open-Less:betafrom
H-Chris233:fix/issue-296-coordinator-modules
May 9, 2026
Merged

拆分 coordinator 子状态机模块#378
H-Chris233 merged 1 commit into
Open-Less:betafrom
H-Chris233:fix/issue-296-coordinator-modules

Conversation

@H-Chris233
Copy link
Copy Markdown
Collaborator

@H-Chris233 H-Chris233 commented May 9, 2026

User description

变更说明

Closes #296

按最小改动原则,把 coordinator.rs 中已经有测试覆盖的高风险区域拆到 coordinator 私有子模块:

  • coordinator/dictation.rs:主听写 hotkey edge、begin / stop / cancel session 生命周期及错误收尾。
  • coordinator/qa.rs:QA 浮窗状态类型与 QA panel / Option edge 路由。
  • coordinator/resources.rs:ASR / Recorder session resource、录音静音、预览 recorder 清理等共享资源管理。

保留 Coordinator / Inner 作为统一 owner,外部 IPC 与跨模块 wiring 仍在 coordinator.rs,避免扩大行为变更面。

验证

  • cargo check --manifest-path openless-all/app/src-tauri/Cargo.toml
  • cargo test --manifest-path openless-all/app/src-tauri/Cargo.toml --lib
  • cargo test --manifest-path openless-all/app/src-tauri/backend-tests/Cargo.toml

PR Type

Enhancement


Description

  • Split the 3842-line coordinator.rs into three submodules

  • Move dictation session lifecycle to dictation.rs

  • Move QA panel state machine to qa.rs

  • Extract shared recording resources into resources.rs


Diagram Walkthrough

flowchart LR
A["coordinator.rs (original)"] -- "dictation lifecycle" --> B["coordinator/dictation.rs"]
A -- "QA panel state machine" --> C["coordinator/qa.rs"]
A -- "resource management" --> D["coordinator/resources.rs"]
Loading

File Walkthrough

Relevant files
Refactoring
coordinator.rs
Remove moved functions and add module declarations             

openless-all/app/src-tauri/src/coordinator.rs

  • Removed dictation, QA, and resource helper functions that have been
    moved to submodules
  • Added mod dictation; mod qa; mod resources; declarations and necessary
    imports
  • Kept cross-module wiring, public API, and test module (imports from
    new submodules)
+29/-1335
dictation.rs
Extract dictation session lifecycle into new module           

openless-all/app/src-tauri/src/coordinator/dictation.rs

  • New module containing dictation session lifecycle: begin, end, cancel,
    hotkey edge handlers
  • Includes recorder startup, error handling, transcription, polish, and
    insertion logic
  • Exports abort_recording_with_error and dictation_error_code for test
    use
+1050/-0
qa.rs
Extract QA panel state machine into qa module                       

openless-all/app/src-tauri/src/coordinator/qa.rs

  • New module with QA panel state machine: QaPhase, QaSessionState,
    open/close panel functions
  • Manages QA hotkey edge routing and floating window visibility
+124/-0 
resources.rs
Extract shared recording resources into resources module 

openless-all/app/src-tauri/src/coordinator/resources.rs

  • New module housing shared resource management: SessionResource,
    SharedRecordingMuteState
  • Provides ASR/recorder session store/retrieve helpers, mute
    acquire/release, and cleanup functions
+191/-0 

coordinator.rs had accumulated dictation lifecycle, QA panel state, and shared recording resources in one file. This split keeps behavior unchanged while moving the dictation edge/session helpers, QA panel state helpers, and resource ownership helpers into child modules under coordinator/.

Constraint: Issue Open-Less#296 asks for module boundaries after Rust state-machine coverage is in place

Rejected: Split every helper into separate public modules | larger churn with no behavior benefit

Confidence: high

Scope-risk: moderate

Directive: Keep cross-module wiring in coordinator; leaf modules should remain coordinator-private

Tested: cargo check --manifest-path openless-all/app/src-tauri/Cargo.toml

Tested: cargo test --manifest-path openless-all/app/src-tauri/Cargo.toml --lib

Tested: cargo test --manifest-path openless-all/app/src-tauri/backend-tests/Cargo.toml

Co-authored-by: OmX <omx@oh-my-codex.dev>
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 9, 2026

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

296 - Partially compliant

Compliant requirements:

  • Split dictation, QA, and resource-management code into private submodules.
  • Kept Coordinator / Inner ownership and IPC wiring in coordinator.rs.
  • Kept the refactor scoped to the existing session/state-machine behavior.

Non-compliant requirements:

  • No new or updated tests for the refactored coordinator paths are shown in the diff.

Requires further human verification:

  • Confirm the existing test suite still covers the moved dictation and QA paths after the module split.
  • Verify the cargo check / cargo test commands in the PR description were run successfully in CI or locally.
⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ No major issues detected

@H-Chris233 H-Chris233 merged commit feadbfa into Open-Less:beta May 9, 2026
4 checks passed
@H-Chris233 H-Chris233 deleted the fix/issue-296-coordinator-modules branch May 9, 2026 08:17
appergb pushed a commit that referenced this pull request May 9, 2026
Beta-6 包含的合并:
- #379 fix(recorder): watchdog 在 sleep 醒来后重检 stop_flag,消除停采误报
- #380 fix(commands): wrap tray refresh in run_on_main_thread 修主线程死锁
- #381 feat(ui): consolidate footer/nav, sliding indicator, hover cues, top-right saved toast
- #378 拆分 coordinator 子状态机模块(间接合入)

Tag: v1.2.24-6-beta-tauri 推到 main 后触发 release-tauri.yml Beta 流水线。
appergb pushed a commit that referenced this pull request May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[refactor][P1] coordinator.rs 单文件 3842 行 — 拆分 dictation / qa 子模块

1 participant