Commit Graph
8 Commits
Author SHA1 Message Date
baiqing 22a9885d44 feat(settings): unified 配置 Tab + add new ASR presets
- 合并 LLM Provider Tab 与 ASR Provider Tab 到同一个「配置」页:
  顶部 LLM 模型 chip 行 + 表单,下方 ASR 语音 chip 行 + provider 专属字段,
  底部 borderedProminent .large「保存」按钮统一提交。
- 切 chip 不再立即写盘——所有改动在内存草稿里积攒,点保存才写 vault / UserDefaults
  并 post .openLessCredentialsChanged。
- 火山引擎 3 字段(APP ID / Access Token / Resource ID)从 SettingsHubTab 搬到
  「配置」页 ASR 段;SettingsHubTab 简化为录音快捷键 / 授权 / 隐私 / 关于 + provider 概览。
- 侧边栏顺序调整为 首页 → 历史记录 → 词汇表 → 风格 → 配置 → 设置 → 帮助中心,
  「配置」紧靠「设置」之上。
- ASRProviderRegistry 新增两条预设:
  * aliyun-paraformer (DashScope 流式 paraformer-realtime-v2)
  * custom-openai-whisper (OpenAI 兼容批量 Whisper API)
  这两类 provider 的 chip 与表单已就绪;运行期具体识别由并行分支补齐。
- 删除 LLMProvidersTab.swift / ASRProvidersTab.swift;AddLLMProviderSheet 搬到
  ProvidersConfigTab.swift 同文件。
2026-04-29 13:02:58 +08:00
baiqing 294e53745b feat(asr): Apple Speech provider + ASR switcher tab
- 新增 AppleSpeechASRProvider:包装 SFSpeechRecognizer,on-device 优先,
  partial / final 走标准 ASRStreamingSession 协议,无需 API key
- 新增 ASRProviderRegistry:M1 预设 volcengine / apple-speech
- CredentialsVault 增加 activeASRProviderId / configuredASRProviderIds
- DictationCoordinator.makeASRProvider 改为按 vault.activeASRProviderId 路由
- 新增 ASR Tab(chip 切换 + 主操作「保存」按钮);侧边栏导航新增 .asr
- scripts/build-app.sh Info.plist 加入 NSSpeechRecognitionUsageDescription
- Tests/OpenLessCoreTests 新增 ASRProviderRegistryTests
2026-04-29 12:46:55 +08:00
baiqing 377d86c33a feat(asr): introduce ASRProvider protocol + Volcengine wrapper
Phase C-1 of provider abstraction (mirrors LLM-side B-1/B-2/B-3).

- Add ASRProvider / ASRStreamingSession / ASRProviderInfo / ASRMode /
  ASRError to OpenLessCore. Streaming and batch shapes share a single
  protocol; non-self entry throws .unsupportedMode.
- ASRStreamingSession inherits AudioConsumer; sendAudio(_:) gets a
  default impl that forwards to consume(pcmChunk:) — least-invasive
  bridge, no changes to existing AudioConsumer / Recorder /
  BufferingAudioConsumer.
- VolcengineASRProvider wraps existing VolcengineStreamingASR via a
  thin adapter (VolcengineStreamingSessionAdapter). Zero modifications
  to VolcengineStreamingASR / VolcengineFrame / VolcengineCredentials.
- DictationCoordinator now drives ASR through ASRProvider:
  makeASRProvider() returns VolcengineASRProvider when creds exist,
  nil otherwise (silent mock fallback preserved). beginSession,
  endSession, handleCancel, failSession all route through
  asrSession: ASRStreamingSession.
- Add OpenLessASRTests target with VolcengineASRProvider info /
  unsupportedMode coverage, plus ASRProviderInfo / ASRError /
  ASRMode value-shape tests.

C-3 (settings UI) will switch makeASRProvider() to read
vault.activeASRProviderId; partial results stream is wired but
empty-finished pending an internal Volcengine partial hook.
2026-04-29 12:32:49 +08:00
baiqing d8fb309feb feat(persistence): generalize providers.llm + multi-provider vault API
将 v1 schema 中 `providers.llm` 从 Ark 专用结构推广为通用
`CredentialsProviderLLMEntry`(containing displayName / temperature / extraHeaders),
为 OpenAI / DeepSeek / DashScope / Moonshot 等多 LLM provider 共用一套字段。

旧 `CredentialsProviderLLMArk` 保留为 typealias,已迁移过的 v1 文件无需再次迁移即可继续解码。

新增公开 API:
- `CredentialsVault.activeLLMProviderId` getter/setter
- `CredentialsVault.configuredLLMProviderIds`
- `CredentialsVault.llmProviderConfig(for:)`
- `CredentialsVault.setLLMProviderConfig(_:)`
- `CredentialsVault.removeLLMProvider(_:)`,禁删 active provider

`OpenLessCore` 新增 `LLMProviderRegistry`,集中维护 5 家 OpenAI 兼容供应商
预设(baseURL / model / 帮助文案 / docs URL),UI 与 vault 兜底逻辑共用。

`PolishOutputCleaner` 从 DoubaoPolishClient 内部提升为独立 public 类型,
让 `OpenAICompatibleLLMProvider` 输出统一过 boilerplate / markdown 栅栏清理。

DoubaoPolishClient.swift 已无调用方,整个文件删除。

Tests:
- LLMProviderRegistryTests:5 家预设健康检查 + 唯一性 / URL 合法性
- CredentialsVaultMultiProviderTests:active 默认 / 增删 / 往返 /
  老 `ark.*` 账号 key 路由到 active provider
2026-04-29 11:54:11 +08:00
baiqing dfcdd3184b feat: introduce LLMProvider protocol + OpenAICompatibleLLMProvider
为 polish 层引入与具体供应商解耦的抽象:
- OpenLessCore: LLMProvider 协议、OpenAICompatibleConfig、LLMError
- OpenLessPolish: 单一 OpenAICompatibleLLMProvider 实现,覆盖
  Ark / OpenAI / DashScope / DeepSeek / Moonshot 等所有 OpenAI Chat
  Completions 协议端点
- DoubaoPolishClient 标记为 @available deprecated(Phase B-3 接入新 provider 后移除)
- 新增 9 项 URLProtocol 桩测试,含 apiKey 不入日志的安全断言
2026-04-29 11:23:51 +08:00
baiqing 88a5a97812 feat: 1.0.03 — 侧边栏重构 + 词汇表 chip 布局 + 风格页 + 关掉自动学词
- 侧边栏 4 → 6 项:首页 / 历史记录 / 词汇表 / 风格 / 帮助中心 / 设置
- 词典 → 词汇表,整页改 chip 流式布局:phrase + hitCount,hover ✕ 删除,
  批量输入(每行一个),重置统计 / 清除全部
- DictionaryEntry 加 hitCount + 兼容旧 dictionary.json 解码
- DictationCoordinator 在润色后扫描最终文本递增命中数;
  删除 learnTerms 自动学词路径
- 润色模式 → 风格 (StyleTab):4 张模式卡 + 启用开关;
  关闭时跳过 Ark 直接插入原文 (UserPreferences.polishEnabled)
- 帮助中心:快速上手 4 步、快捷键速查、FAQ、GitHub 外链
- 设置 Tab 合并 Volc ASR + Ark 凭据、录音、授权、隐私、关于 + 检查更新
- 胶囊:NSPanel 220×96, hasShadow=false;macOS 26 分支去掉 SwiftUI 阴影
  → 解决"红绿灯外圈黑边"
- 侧边栏视觉:strokeBorder 0.08 → 0.04、阴影 radius 16 → 6
  → 解决"灰色边栏 + 黑色卡顿"
- 首页底部新增今日概览 + 风格预览
2026-04-28 11:16:40 +08:00
TRIPandbaiqing 56c3e09983 feat: hold-to-talk + UX fixes + structured prompt overhaul
* feat: add hold-to-talk hotkey mode (closes #1)

OpenLessHotkey now emits explicit .pressed / .released edge events on
the modifier-key trigger; the coordinator interprets them per the new
HotkeyMode preference (toggle stays the default, hold = press-and-hold).

Hold mode rules: .pressed on idle starts the session; .released stops
it from .listening; releasing during .starting cancels (no audio
useful was captured yet). Esc-cancel sets a one-shot suppress flag so
the trailing .released after a cancel does not re-trigger end.

Settings hub gets a "录音方式" segmented picker and a one-line hint
explaining the tradeoff. Bump version to 1.1.0; update README roadmap
and USAGE walkthrough to document the new mode.

* test: update HotkeyEventTests for pressed/released split

* chore: tag hold-to-talk build as 1.0.01 / A1003

* fix: stop window-background drag eating text selection; add eye toggle on secret fields

Settings window had isMovableByWindowBackground = true, so any drag
inside the content view dragged the whole window — making it
impossible to select words inside a TextField. Disable it; the native
title-bar strip (with the traffic lights) still drags the window.

PasteableCredentialField now exposes an eye / eye.slash toggle when
secure: true, so users can verify pasted API keys before saving.

* fix: stop pretending polish ran when it was skipped or errored

When the user removes the Ark API key (or the Ark call errors out),
DictationCoordinator was still showing the green "已插入" capsule and
recording the session in history under the originally-selected polish
mode. From the user's side it looked like polish had succeeded, even
though only the raw transcript reached the cursor.

Track a PolishOutcome (ok / skippedNoCredentials / failed) through
insertText. Capsule now uses a new CapsuleState.warning (orange) state
to surface honest messages — "已插入原文 · 未润色" / "润色失败 · 已用原文" —
and history saves the session as PolishMode.raw whenever polish
didn't actually run. The error capsule + 1.5s artificial sleep that
preceded a fake "success" insert is gone; warning state stays for the
normal 2.5s.

* feat(polish): make Structured mode prompt force a 1./1)/a. hierarchy

Some weaker chat models would emit a single flat list when the user
asked for Structured polish, even when the dictation clearly covered
multiple topics. The mode is meant to produce something pasteable as
an AI prompt or a working doc, not a wall of bullets.

Rewrite the .structured system prompt to be prescriptive: when the
input contains ≥2 themes, emit three explicit levels — top "1./2./3."
sections, "1)/2)/3)" sub-points indented 3 spaces, and "a./b./c."
detail items indented another 3 — and to fall back to a plain
paragraph when the input is short / single-topic. Add a concrete
format example so weaker models have a pattern to copy.

---------

Co-authored-by: baiqing <lbx12309@icloud.com>
2026-04-27 18:57:41 +08:00
baiqing f5a0c810fa feat: add dictionary hotwords and insights UI 2026-04-27 13:53:18 +08:00