Skip to content

將 AppDelegate 接線到 RecordingCoordinator #11

Description

@Jian-Min-Huang

What to build

將 AppDelegate 的錄音→轉錄→貼上流程改為委派給 RecordingCoordinator#10 建立的 module),移除 AppDelegate 裡的舊狀態機程式碼。

Adapter 實作(executable target):

  • AudioRecorder conform AudioRecording(方法簽名已吻合,只需宣告 conformance 並處理 AudioStopResult 型別對應)
  • PasteService conform TextPasting(方法簽名已吻合,只需宣告 conformance)

AppDelegate 改造:

  • 建立 RecordingCoordinator 實例,注入 AudioRecorder(as AudioRecording)和 PasteService(as TextPasting
  • 實作 RecordingCoordinatorDelegate
    • coordinatorDidChangeState(_:) — 更新 status 文字、icon、播放對應音效(recording → Glass、transcribing → Bottle、cancel → Funk)
    • coordinatorDidProduceText(_:)refreshProviderLabel()
    • coordinatorDidFail(_:context:) — 顯示 error icon、更新 status
    • coordinatorDidSkipSilence()refreshProviderLabel()
    • coordinatorDidSkipRecording(_:) — 顯示 error icon、更新 status
  • handleToggle()coordinator.toggle()
  • handleCancel()coordinator.cancel()
  • 在 config 載入後設定 coordinator 的 providerpromptTemplatevoiceCommandsEnabledprefix
  • provider / prompt 切換時同步更新 coordinator 屬性

移除 AppDelegate 裡的舊程式碼:

  • State enum 和 state 屬性
  • startRecording()
  • stopRecordingAndTranscribe()
  • handleToggle()handleCancel() 的原始實作(改為轉發給 coordinator)

驗證:

  • make build 成功
  • make test 通過(Core 測試不受影響)
  • make run 啟動 app,手動驗證:快捷鍵錄音→轉錄→貼上、Esc 取消、太短/太安靜跳過、provider 切換

Acceptance criteria

  • AudioRecorder conform AudioRecordingPasteService conform TextPasting
  • AppDelegate 實作 RecordingCoordinatorDelegate,所有 UI 回饋(音效、icon、status)正確觸發
  • AppDelegate 不再直接持有 State enum 或狀態機邏輯
  • make buildmake test 通過
  • App 手動測試:錄音→轉錄→貼上、取消、太短/太安靜、provider 切換全部正常運作

Blocked by

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agentFully specified, ready for an AFK agent

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions