Skip to content

修复 session_id 回绕导致的迟到事件误匹配#352

Merged
H-Chris233 merged 1 commit into
Open-Less:betafrom
H-Chris233:fix/issue-297-session-uuid
May 8, 2026
Merged

修复 session_id 回绕导致的迟到事件误匹配#352
H-Chris233 merged 1 commit into
Open-Less:betafrom
H-Chris233:fix/issue-297-session-uuid

Conversation

@H-Chris233
Copy link
Copy Markdown
Collaborator

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

User description

概述

  • 将 coordinator 内部听写 / QA session 守卫从 wrapping u64 改为 UUID
  • 保留原有 captured session id 比较逻辑,避免迟到 RecorderError / startup continuation 误命中新会话
  • 同步更新 Windows IME 预备会话槽和相关回归测试里的 session id 类型

验证

  • cargo check --manifest-path openless-all/app/src-tauri/Cargo.toml
  • cargo test --manifest-path openless-all/app/src-tauri/Cargo.toml coordinator::tests:: --lib
  • git diff --check

说明

  • 额外跑过 cargo test --manifest-path openless-all/app/src-tauri/Cargo.toml --lib,当前 beta 上存在无关失败:types::tests::legacy_hotkey_trigger_still_produces_effective_key_codes。本 PR 未修改 types.rs

Closes #297


PR Type

Bug fix


Description

  • Replace wrapping u64 session_id with UUID (Uuid::new_v4)

  • Update all state structs and helpers to SessionId type

  • Adapt Windows IME prepared session slots and comparison logic

  • Update unit tests to use UUID-based session ids


Diagram Walkthrough

flowchart LR
  Old["u64 wrapping_add session_id\n(risk of stale-event collision)"] --> New["UUID-based session_id\n(Uuid::new_v4)"]
  New --> State["State structs (SessionState, QaSessionState)"]
  New --> Resource["SessionResource"]
  New --> Helper["take_session_resource, etc."]
  New --> WinIME["Windows IME slots"]
  New --> Tests["Test helpers use session_id(n)"]
Loading

File Walkthrough

Relevant files
Bug fix
coordinator.rs
Replace u64 session_id with UUID across coordinator           

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

  • Define SessionId type alias and factory functions new_session_id(),
    initial_session_id()
  • Change session_id field type in SessionResource, SessionState,
    QaSessionState, and PreparedWindowsImeSessionSlot to SessionId
  • Update all related function signatures, comparisons, and logic to use
    SessionId
  • Adapt unit tests: add session_id(n) helper, replace integer literals
    with UUID-based ids
+98/-60 

The dictation coordinator used a wrapping u64 counter to guard delayed recorder and startup events. Replacing that guard with UUID-backed session ids removes the theoretical wraparound collision while keeping the existing stale-event comparison model.

Constraint: Issue Open-Less#297 requests the UUID-based fix rather than checked arithmetic.\nRejected: checked_add with warning | still preserves a numeric boundary condition instead of eliminating the collision class.\nConfidence: high\nScope-risk: narrow\nTested: cargo check --manifest-path openless-all/app/src-tauri/Cargo.toml\nTested: cargo test --manifest-path openless-all/app/src-tauri/Cargo.toml coordinator::tests:: --lib\nNot-tested: Full cargo test --lib still has unrelated existing failure in types::tests::legacy_hotkey_trigger_still_produces_effective_key_codes.\nRelated: Open-Less#297
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

297 - Partially compliant

Compliant requirements:

  • Replaced session ids with UUIDs.
  • Preserved session-id equality checks for late-event / startup-race handling.
  • Updated Windows IME prepared-session helpers and related tests to use UUID session ids.
  • Added/updated regression tests for stale-session isolation.

Non-compliant requirements:

  • None identified from the diff.

Requires further human verification:

  • None.
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

@H-Chris233 H-Chris233 merged commit 4aa3f6c into Open-Less:beta May 8, 2026
4 checks passed
@H-Chris233 H-Chris233 deleted the fix/issue-297-session-uuid branch May 9, 2026 04:55
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.

[bug][P1] session_id 用 wrapping_add — u64 回绕时旧 session 误匹配

1 participant