TextFlow 交互优化:浮窗主链路、剪贴板回退与 OCR 打磨 - #1
Merged
Conversation
This reverts commit d9fd6f0.
- Replace the SwiftUI TextEditor with an AppKit-backed original text editor so Enter re-translates the current text, while marked text (IME composition) and Shift/Option+Enter keep default behavior. - Add an explicit 翻译 button as the mouse equivalent of Enter. - Offer 重试 on failed translations and 打开设置 when no translation profile is configured. Tests: xcodebuild -project TextFlow.xcodeproj -scheme TextFlow \ -configuration Debug -derivedDataPath DerivedData \ CODE_SIGNING_ALLOWED=NO test -> Executed 90 tests, 0 failures
- When accessibility and the ⌘C fallback both fail, offer the text that is already on the clipboard: it is filled into the original field with a source note and a 翻译剪贴板内容 action, next to 开始 OCR. Nothing is translated automatically unless the new setting says so. - New general settings: 无选中文字时自动翻译剪贴板 (off), OCR 完成后自动复制识别文字 (on), 翻译完成后自动复制译文 (off). - The panel view model now takes an injectable pasteboard so copy tests no longer touch the developer's clipboard. Tests: xcodebuild ... test -> Executed 97 tests, 0 failures
- The 更多 menu now shows the active language and marks it as selected instead of always reading 更多. - A pinned, already visible panel no longer jumps back to the mouse when a new task shows content; it only refreshes in place. - Streaming translations scroll to the bottom, and stop following once the user scrolls up during that run. - A target language picked inside the panel sticks for later ⌥D/⌥Q while the panel stays open, and returns to auto detection after it closes. - Added an in-panel preset menu that re-translates immediately and only affects the current panel session. Tests: xcodebuild ... test -> Executed 110 tests, 0 failures
- OCR results offer 重新框选, which re-runs the full ⌥Q flow. - The selection overlay shows 拖拽框选文字 · Esc 取消 until the drag starts. - The original field is read-only while text is being captured or recognized, so results cannot overwrite what the user is typing. - The borderless panel now dispatches ⌘A/⌘C/⌘V/⌘X/⌘Z to its first responder (an accessory app has no main menu to do it) and handles ⌘⇧C as copy translation, which the copy button's help text mentions. - New general setting 翻译完成后自动朗读译文 (off). Tests: xcodebuild ... test -> Executed 117 tests, 0 failures Build: ./scripts/build-debug.sh -> BUILD SUCCEEDED
- §3.1G: the panel now offers a session-scoped preset switch that re-translates immediately and never changes the default preset. - §3.1I: auto copy and auto speak are settings-driven; only OCR 完成后自动复制识别文字 defaults to on. - §3.1K: list the four new general settings with their defaults. Docs only; no behavior change.
- §3.1C: describe the clipboard fallback branch and its setting, and state that no clipboard history is kept. - §3.1F: list every re-translate entry (Enter with its IME and newline rules, 翻译 button, current language, 重试) and the 更多 menu title plus the session-scoped target language. - §3.1I: refresh the panel sketch and add pinned positioning, the keyboard shortcuts, the read-only capture states, and stream auto-scroll. Docs only; no behavior change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
把「编辑原文 → 重新翻译」的主链路修顺,补齐错误状态的恢复入口,并让几个高频操作少一次往返。共 18 项,按四批提交。
第一批:浮窗主链路(21ad0b1)
OriginalTextEditor,回车即翻译;正在翻译时回车会取消当前请求并用当前原文重翻。hasMarkedText())回车交给输入法,Shift/Option + 回车插入换行。判断逻辑抽成OriginalTextSubmitPolicy,可单测。第二批:剪贴板相关(d195188)
NSPasteboard,复制相关单测不再污染开发机剪贴板。第三批:浮窗行为(bf3595b)
第四批:OCR 细节与打磨(db5cb29)
文档(0292805、e66f9a1)
同步
01_PRD_v0.1.md:§3.1C 剪贴板兜底分支、§3.1F 重新翻译入口与目标语言粘性、§3.1G 浮窗预设切换、§3.1I 面板结构图与新行为、§3.1K 四个新通用设置及默认值。隐私与红线
不保存任何历史(剪贴板兜底只读当前内容);取词失败不会自动开始 OCR 或屏幕捕获;OCR 仍在本地 Vision;未新增第三方依赖;诊断日志只记长度与开关状态,不记内容。
验证
xcodebuild -project TextFlow.xcodeproj -scheme TextFlow -configuration Debug -derivedDataPath DerivedData CODE_SIGNING_ALLOWED=NO test→ Executed 117 tests, 0 failures(新增 26 个)。./scripts/build-debug.sh→ BUILD SUCCEEDED。./scripts/install-local.sh)中人工验证通过。