Repository navigation
Conversation
…iefs Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
…dow detect, hotkeys, tray (task B) - CaptureService: WGC -> DXGI Desktop Duplication -> GDI BitBlt fallback chain, unified Core Screenshot output (physical px + DPI metadata), IsBorderRequired=false gated on UniversalApiContract 15 (Win10 yellow border documented degradation) - DisplayMonitor: EnumDisplayMonitors + GetDpiForMonitor (Per-Monitor V2), 2s cache refresh policy mirroring macOS DisplayFreshnessPolicy - WindowDetector: EnumWindows + DWMWA_EXTENDED_FRAME_BOUNDS/CLOAKED with mouse-down snapshot cache (hover hit-test pure memory), FR-02 click vs 4px drag threshold semantics - SelectionOverlay: WS_POPUP+LAYERED+TOPMOST virtual-desktop window, D2D 1.1 + DComp rendering (40% dim, punch-through, 1px accent stroke, size badge, crosshair, window highlight), precreated for <=60ms hotkey path; portable MT-safe paint-list state machine - HotkeyManager: RegisterHotKey/WM_HOTKEY x5 (Ctrl+Alt+F/A/T/D/I defaults), conflict reporting, runtime re-registration - TrayIcon: Shell_NotifyIcon + menu model with recent-5 screenshot slots - Catch2 v3.7.1 vendored; 60 test cases / 235 assertions green (geometry, DPI, cache policy, conflict matrix, fallback chain, overlay state machine, tray menu) - PerMonitorV2 app.manifest; vcxproj (x64+ARM64, /W4 /WX) + CMake; per-service design docs in windows/docs/windows/ Windows build verification NOT RUN (macOS dev box); reproduce with msbuild windows/TransFrame.sln or cmake -S windows/NativeShell. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Core (pure logic, platform-clean): - 9 translation engines, no apple (PRD §6.12): MTranServer (probe ladder /health→/→/translate, 5s TTL), OpenAI/Claude/Gemini/Ollama via one LLMChatProvider (endpoint routing, HTTPS key guard, batching, truncation detection), Google v2 / DeepL (456 quota) / Baidu (MD5 sign, 54003/54004), Custom OpenAI-compatible with multi-instance UUID identity (custom:<uuid> credential slot, keyless localhost per macOS PR#92) - TranslationScheduler: ordered chain ≤5 sequential fallback + aggregated errors, compare 2-4 parallel with per-run result cache, scene binding routing, cancellation aborts immediately - EngineHealthChecker: four states, free probes only (never billed calls), 60s TTL cache; Google/Baidu/Claude/Gemini/DeepL gate orange/gray on credentials without requests - OCR: WindowsOcrEngine (language-pack gating, normalized bbox mapping), PaddleOcrEngine (fast/precise argv + JSON parsers, Python-literal normalization, health cache), VlmOcrEngine skeleton (5 provider slots, segment parsing) - VisualLineGrouping port with macOS test vectors; prompt layering fixed to Swift order (scene > compatible > engine) - TextExtractor (UIA GetSelection first, clipboard fallback with save/clear/Ctrl+C/poll/restore) + InsertionService (mandatory re-validation, never pastes on mismatch) NativeShell (Win32, _WIN32-only, NOT RUN on this macOS host): WinHttpTransport (WinHTTP 5.1, 10s timeout, cancel polling, error taxonomy), CredManKeyStore (CredWrite/CredRead, TransFrame/<engine>/ <instance>), Win32OcrUiaHosts (WinRT OCR, PaddleOCR process runner, UIA+SendInput hosts) Tests: Catch2 v3, 105 cases / 370 assertions green (clang++ -std=c++20, macOS arm64). Mock transports/providers drive request shapes, error-code mapping, MD5 known vectors, scheduler matrices, health TTL, insertion abort paths. Manual smoke entry tests/manual/smoke_translation.cpp with MSVC build instructions. Docs: docs/windows/engines/<engine>.md x9 (endpoints, params, error-code tables) + windows/README.md build guide + tasks/briefs/report-C.md (FR mapping, macOS-difference list). Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Models: SettingsKeys (all AppSettings keys), KeyboardShortcut, all 11 Annotation types (tagged-JSON codec), Screenshot/CaptureDocument/DisplayInfo/ OCRResult/ScreenAnalysisResult (ImageRef handle for CGImage), BilingualSegment/ TranslationResult/EngineResult/TranslationResultBundle, TranslationHistory (4 categories incl. color-picked convention), VLMProviderType/CompatibleConfig. Algorithms: VisualLineGrouping.mergeLines/joinText, LLMTranslationBatching, LLMTranslationResponseParser (OpenAI/Claude JSON+SSE, truncation detection), TranslationPromptConfig placeholders - all ported from Swift with the same test vectors (fixed a lineBox-union porting bug caught by the vectors). Interfaces: IOcrEngine, ITranslationProvider, IHotkeyListener, IClipboard, IHistoryStore, ICredentialStore (pure virtual, documented). Solution: TransFrame.sln with Core/NativeShell(pch skeleton)/App(WinUI3 blank + MSIX manifest)/Tests(Catch2) projects, x64+ARM64 /W4 /WX. Tests: 68 Catch2 cases / 261 assertions green on macOS clang++ 20 (includes fixture-file driven visual-line-grouping suite extracted from TransFrameTests). CI: windows-ci.yml (msbuild dual-arch + ubuntu portability check). Vendored dependency licenses/sources documented. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
… + 5th error category Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
…badges - Add configurable 'Screen Color Pick' global hotkey (default Ctrl+Cmd+C), wired through the full 5-hotkey convention: KeyboardShortcut default, AppSettings key/load/reset, HotkeyCoordinator registration, Settings recorder row with conflict detection, tray menu key equivalent - Empty state now shows the live hotkey (rebind-aware) with a tray-path fallback (spec §4.2) - Extract ColorPickFlow as the single completion pipeline for all three eyedropper surfaces (tray, preview toolbar, selection-in-place toolbar): hex normalize + history insert + toast with View History link (spec §4.5) - HistoryStore: shared recordPickedColor/makeColorPickEntry entry; the .colorDidPick observer reuses it - Swatch cell: hover actions and constant favorite star merged into one top-right cluster, no overlap (spec §4.2) - Tests: +4 pipeline/hotkey cases; shortcut enum coverage extended to 6 cases; full suite 325 passed / 0 failed; 10 strings lint OK Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
… drop unused Interop header
四通道请求形状自检(签名/URL/头/multipart);本地 python HTTP 替身承载 PicGo 全链路(真实 WinHttpTransport + 临时文件写入/清理 + 进程回收); 取色器程序化驱动(开窗→模拟移动/点击→与隐藏后直采像素对拍→Esc 取 消);取色历史临时库驱动(网格行数/搜索/收藏/删除/清空仅动 color 类 别)。44 项断言全 PASS;配套 build_smoke_uploads_picker.bat。 Co-Authored-By: Claude Code <noreply@anthropic.com>
… smoke - LocalizationTests: codec roundtrip (CJK + surrogate pair), %@ format marker, table parse accept/reject, fallback chain (selected -> en -> default), empty-table clearing, switch listeners, system-locale provider mapping, loadDirectory contract, and the shipped-table schema (10 languages, identical key sets, non-empty values; tables copy to the test output dir via vcxproj Content) - OnboardingTests: choice info mapping, privacy classification (localhost/mtran/ollama = local; disabled never sends), default-chain merge preserving unrelated keys, done-flag round-trip, hotkey defaults + per-action overrides, 3-step flow machine walk - manual smoke_locale_onboard: L1/L2 table contract (259 keys, spot values zh/en/ja), L3 fallback + listener, O1 system locale probe, O2 onboarding flow + engines.json merge + done flag, N1/N2 notification seam + live tray balloon (N/A when no tray session); build_smoke_locale_onboard.bat wraps the single-line cl invocation Core suite 6437 assertions / 193 cases green (baseline 1057/172); NativeShell 455/93 (baseline 445/92); all four manual smokes PASS. Co-Authored-By: Claude Code <noreply@anthropic.com>
# Conflicts: # windows/CMakeLists.txt
# Conflicts: # windows/App/AppMain.cpp # windows/Core/TransFrame.Core.vcxproj # windows/NativeShell/TransFrame.NativeShell.Tests.vcxproj # windows/NativeShell/src/PreviewWindow.cpp # windows/NativeShell/src/TrayMenu.cpp # windows/NativeShell/tests/TrayMenuTests.cpp
Leftover conflict marker at the end of the localization TEST_CASE (caught by /WX build); merged menu now has 13 items - pickColor and color-history joined the localized labels with tw() fallbacks. Co-Authored-By: Claude Code <noreply@anthropic.com>
- 16 new keys across all 10 string tables (tray pickColor/colorHistory, preview upload, picker hint, color-history title/empty/copied/ clear-confirm/context-menu/toggles/count format); tables re-serialized with the original 1-space indent so the diff is exactly the added keys - ColorPicker/ColorHistoryWindow swap hardcoded zh labels for tw() with zh fallbacks (runtime identical in zh, localized elsewhere) - fix a real crash found by the smoke: D2D1 DrawTextW does not take the GDI -1 length convention - static_cast<UINT32>(-1) reads past the buffer (0xC0000005 at first render); pass hint.size() instead - smoke_uploads_picker: unbuffered stdout so a mid-run crash no longer swallows the stage log Co-Authored-By: Claude Code <noreply@anthropic.com>
The minimal tw() repro's object file slipped into a65b2d3's 'add -A'; untrack it and ignore *.obj at the repo root (sources of truth are all under tracked dirs; build outputs already live under ignored build/). Co-Authored-By: Claude Code <noreply@anthropic.com>
…gning - build_msix.py: --self-signed-test-cert (pwsh-first, falls back to powershell.exe; creates a disposable cert in CurrentUser\My and trusts it in CurrentUser\Root so signtool verify /pa passes on the machine); --certificate-thumbprint now mutually exclusive with it; stage-content self-check (EXE non-empty PE, per-arch bootstrap DLL, declared logos, Assets\Strings\*.json, VCLibs manifest dependency) before makeappx so packaging fails loudly instead of shipping a broken package. - test_build_msix.py: StageContentTests cover missing bootstrap DLL, missing localization tables, missing declared logos. - README: document the test-cert flag as local/CI-only. Co-Authored-By: Claude Code <noreply@anthropic.com>
Per-arch leg: sln Release build -> VCLibs Desktop appx (fixed version, fail-fast on download errors) -> build_msix.py --self-signed-test-cert -> upload-artifact named msix-x64 / msix-arm64 (msix + .appinstaller + vclibs appx). Test-signed artifacts are install-test only. Co-Authored-By: Claude Code <noreply@anthropic.com>
- SettingsShell: gate Mica SystemBackdrop behind supportsMicaBackdrop() (OS build >= 22000) with try/catch; Win10 branch explicitly sets the ElementTheme::Default solid fallback so the window chrome does not render blank on the no-op backdrop. - wgcSupportsBorderless(): belt-and-braces — the OS build probe must agree with the API-contract version, so a contract shim on Win10 can never claim borderless capture (yellow border stays as documented). - New tf/PlatformFeatures.hpp + .cpp: testable version/build policy probes; Catch2 cases cover 19044 / 21999 / 22000 / 22621 boundaries. - docs/windows/win10-degradation-matrix.md: static audit matrix (API -> Win10 behavior -> guard location -> verification method); remaining risk note for AppNotificationManager packaged backend TODO. Co-Authored-By: Claude Code <noreply@anthropic.com>
…tion SmartRedactionEngine (Core, pure): macOS SmartPrivacyRedactionService / performSmartRedaction port. Privacy prompt pair aligned with VLMProvider.swift VLMPromptPair.privacy; parser handles chat-completion content, json fences, segments/results envelopes, truncation salvage (quote/escape aware), NaN drop, clamp + degenerate drop, configurable minConfidence (0.5 macOS default, missing confidence drops), pixel-space output with padPx edge clipping and CGRect.integral rounding. AnnotationDocument.addAll() appends a batch as ONE undo transaction so a single Ctrl+Z clears the whole mosaic batch (empty batch: no history entry). credentialAccount() uses the EnginesPage schema (TransFrame/vlm/<p>); isConfigured() also accepts the legacy vlm_api_key_<p> account VlmOcrEngine reads, so either writer enables FR-10. Co-Authored-By: Claude Code <noreply@anthropic.com>
…t gate SmartRedactionTests: prompt-pair anchors, Configuration gating (both credential schemes), content/network error passthrough, pixel mapping, fence unwrap, truncation salvage incl. braces-inside-strings, clamp/de- generate drop, NaN + low-confidence filter, pad clipping, batch-as-one- undo-step with redo, empty batch pushing no history. CrossPlatformSnapshotTests: 5 fixture-driven TEST_CASEs with FULL-field equality (bbox edges 1e-9, confidence 1e-6, text, order — never sampled): - visual-line-grouping.json: 12 merge cases + 5 joinText cases - llm-response-truncation.json: 3 batching + 4 parser cases - translation-configuration.json: 2 prompt resolution cases - ordered-chain-translation.json: 5 chain + 2 resolvedEngine cases Vectors extracted from macOS TransFrameTests sources (each file's _source/_macOSWiringNote names the Swift origin + future loader point). Registrations: Core.Tests.vcxproj (ClCompile + Content fixture copy — Content+CopyToOutputDirectory actually copies; the old None metadata never did, fixed for the pre-existing fixture entry too) and CMake TEST_SRC + POST_BUILD fixture copy. CMake CORE_MODEL_SRC now mirrors the vcxproj Core-root sources (tf::core VisualLineGrouping et al. never linked there before — pre-existing gap surfaced by the new tests). Co-Authored-By: Claude Code <noreply@anthropic.com>
…ings
PreviewWindow: SmartRedact toolbar button (ToolButton 112) with
setSmartRedactHandler (base pixels, AppMain owns the worker) and
applySmartRedaction(batch) — document.addAll + history sync + repaint,
one Ctrl+Z clears the whole batch. PreviewWindow.cpp diff: +16 lines.
App: SmartRedactionFlow.{hpp,cpp} owns the worker body (OpenAI-
compatible chat.completions vision call covering the OpenAI slot and
OpenAI-mode endpoints incl. Ollama /v1; Claude/Gemini shapes land with
FR-17) so AppMain keeps only the wiring — one kSmartRedactDone case +
one setSmartRedactHandler callback (+62 lines). Unconfigured VLM
surfaces a Configuration notice and opens the engine settings page;
empty detection is an Info notice; batch applies as one undo step.
Strings: win.preview.smartRedact{,.done,.none,.failed,.noImage} added
to all 10 shipped tables (schema test enforces identical key sets).
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
signtool verify /pa requires a chain to a trusted root, so it always fails for the self-signed test certificate on local sideload flows where the cert is trusted in TrustedPeople instead (sufficient for Add-AppxPackage, invisible to /pa). The run then ended in a CalledProcessError after producing a perfectly valid package. Downgrade the final /pa failure to an explanatory note on the --self-signed-test-cert path only; CA-signed production packages keep the strict check. CI (elevated, LocalMachine/Root trust) still passes /pa unchanged. Co-Authored-By: Claude Code <noreply@anthropic.com>
…audit harness Screenshot-driven UI audit at the macOS-parity 800x600 default found every tab clipping its right edge: pages laid out for a ~720px column while the WinUI NavigationView default pane (320px) left only ~430px of viewport. - SettingsUiKit MakePageRoot: stretch the page column and disable horizontal scrolling so content wraps/shrinks to the real viewport. - SettingsShell: OpenPaneLength 232 (macOS sidebar is ~200pt) restores a ~520px viewport; add SwitchSettingsTab test hook (same dispatch pattern as RunSettingsTabsSmoke, one tab per call, caller owns pacing). - LanguagePage: drop the duplicated interface-language card; macOS keeps AppLanguagePicker only in GeneralSettingsTab, so parity says the same. - AdvancedPage: show the expanded real logs path instead of the raw %LOCALAPPDATA% literal (matches the data-dir row). - Tests/manual: smoke_settings_shots harness - per-tab switching with localization loaded like AppMain, offscreen PrintWindow capture (PW_RENDERFULLCONTENT, blank-check + BitBlt fallback), PNG via WIC. Verified: six tabs re-shot at 800x600 with no right-edge clipping; tabs smoke still 6/6. Co-Authored-By: Claude Code <noreply@anthropic.com>
Per-page screenshot audit against the SwiftUI settings surfaced chrome and material gaps: - Custom title bar: ExtendsContentIntoTitleBar with a centered tab-name strip (mac navigationTitle) and theme-aware caption button colors; the native light title bar no longer clashes with the dark theme. - Fixed 200px sidebar with Segoe Fluent icons per tab (SF Symbol mapping from SettingsTab.swift), no hamburger, PaneClosing cancelled (mac NavigationSplitViewColumnWidth min=ideal=max=200). - Window is fixed-size like the mac styleMask (no .resizable); maximize disabled (1.6 lacks HasMaximizeButton, so it shows disabled). - Cards follow DesignSystem.macosGroupedCard: radius 12, padding 16, controlBackground fill, hairline separator stroke. - Page column spans the viewport (mac maxWidth: .infinity), and the in-page duplicate tab headers moved into the title bar. - Kit adds MakeSettingRow (LabeledContent-style label-left / control-right rows) and MakeDivider for the upcoming per-page material pass. - RunSettingsTabsSmoke / SwitchSettingsTab use the nav reference directly; window content is now a Grid (title strip + nav). Verified: 6/6 tabs smoke; six screenshots re-audited clean at 800x600 (icons, centered per-tab title, no collapse gap, expanded logs path). Co-Authored-By: Claude Code <noreply@anthropic.com>
Second material pass from the per-page screenshot audit. The SwiftUI settings use LabeledContent-style rows (label left, control right, hairline dividers); the port stacked labels above controls. - GeneralPage: default format, export quality, interface language, and the startup/update toggles become MakeSettingRow rows with a divider; toggles drop the WinUI default On/Off captions (mac switches are bare) and carry hint lines in the row label instead. - AdvancedPage: stroke width and text size sliders move into rows with right-aligned values, divider between. - Strings: two new row hints (win.settings.autostart.hint, win.settings.checkUpdates.hint) across all 10 language tables; the rewrite also re-sorted a few misordered existing keys. Engines/Prompts/Language/Shortcuts keep their current shapes: the macOS tabs themselves stack labels above fields there (forms and rows with trailing buttons already match). Verified: 6/6 tabs smoke; screenshots re-audited at 800x600. Co-Authored-By: Claude Code <noreply@anthropic.com>
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Add MSBuild to PATH | ||
| uses: microsoft/setup-msbuild@v2 | ||
|
|
||
| - name: Build solution |
There was a problem hiding this comment.
所有 job 均未配置任何缓存(NuGet restore、CMake 编译产物、apt 安装的 g++-13),每次运行都全量 restore + 双平台(x64/ARM64)编译,CI 时长与 runner 资源消耗偏高。建议对 msbuild/restore 使用 actions/cache(缓存 NuGet 包目录),对 CMake 构建目录和 ccache 做缓存。
Suggestion:
| - uses: actions/checkout@v4 | |
| - name: Add MSBuild to PATH | |
| uses: microsoft/setup-msbuild@v2 | |
| - name: Build solution | |
| - uses: actions/checkout@v4 | |
| - name: Cache NuGet packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.nuget/packages | |
| key: nuget-${{ runner.os }}-${{ hashFiles('windows/**/*.proj', 'windows/**/*.sln') }} | |
| - name: Add MSBuild to PATH | |
| uses: microsoft/setup-msbuild@v2 | |
| - name: Build solution |
| - name: Add MSBuild to PATH | ||
| uses: microsoft/setup-msbuild@v2 |
There was a problem hiding this comment.
microsoft/setup-msbuild 是第三方(非 actions/* 官方组织)维护的 action,仅按可变 tag v2 引用存在被劫持风险。建议固定到完整 commit SHA(与 checkout/upload-artifact 一致处理,或至少对该第三方 action 固定 SHA)。
Suggestion:
| - name: Add MSBuild to PATH | |
| uses: microsoft/setup-msbuild@v2 | |
| # 建议固定为具体 commit SHA(示例,请替换为最新验证过的 SHA) | |
| - name: Add MSBuild to PATH | |
| uses: microsoft/setup-msbuild@<full-commit-sha> |
| -o ../build-tests 2>&1 | head -400 | ||
| ../build-tests |
There was a problem hiding this comment.
编译输出通过 2>&1 | head -400 截断。当编译错误超过 400 行时,g++ 会因管道关闭收到 SIGPIPE 而被终止:真实编译错误被静默丢弃,且 set -o pipefail 下步骤会以 SIGPIPE(141) 失败而非真实的编译错误码,日志中也看不到根因。建议将输出写入临时文件再截断展示,保证退出码与完整错误日志都保留。
Suggestion:
| -o ../build-tests 2>&1 | head -400 | |
| ../build-tests | |
| log=$(mktemp) | |
| if ! g++-13 -std=c++20 -Wall -Wextra -Werror \ | |
| -I . -I Core -I external \ | |
| Core/*.cpp external/catch2/catch_amalgamated.cpp \ | |
| Tests/TestMain.cpp Tests/CoreModelsTests.cpp Tests/LLMTranslationCoreTestsA.cpp \ | |
| Tests/TranslationPromptConfigTests.cpp Tests/VisualLineGroupingTests.cpp \ | |
| -o ../build-tests > "$log" 2>&1; then | |
| tail -400 "$log"; rm -f "$log"; exit 1 | |
| fi | |
| rm -f "$log" | |
| ../build-tests |
| Tests/TestMain.cpp Tests/CoreModelsTests.cpp Tests/LLMTranslationCoreTestsA.cpp \ | ||
| Tests/TranslationPromptConfigTests.cpp Tests/VisualLineGroupingTests.cpp \ | ||
| -o ../build-tests 2>&1 | head -400 | ||
| ../build-tests |
There was a problem hiding this comment.
portable-check 任务把测试可执行文件输出到仓库根目录(../build-tests),且两个 CMake 构建目录分别落在 windows/NativeShell/build 与 windows/build-c。根 .gitignore 的 build/ 模式能匹配 windows/build 和 windows/NativeShell/build,但既不匹配根目录的 build-tests 文件,也不匹配 windows/build-c 目录。CI/本地构建产物会以未跟踪文件形式污染 git status,容易被误提交。建议将构建输出统一放入已被忽略的目录(如 windows/build/ 下),或在 .gitignore 中补充 build-tests 与 build-c 条目。
Suggestion:
| ../build-tests | |
| ../windows/build/build-tests |
| $zip = [System.IO.Compression.ZipFile]::OpenRead((Resolve-Path $out)) | ||
| try { | ||
| $entry = $zip.GetEntry('AppxManifest.xml') | ||
| if (-not $entry) { Write-Error "$out has no AppxManifest.xml"; exit 1 } |
There was a problem hiding this comment.
脚本中多处使用 Write-Error ...; exit 1 的混合错误处理。GitHub Actions 的 pwsh 默认 $ErrorActionPreference = 'Stop',Write-Error 会先抛出 terminating error 使 exit 1 不可达,两种失败路径行为不一致、可读性差。建议统一使用 throw(与上方步骤风格一致)。
Suggestion:
| if (-not $entry) { Write-Error "$out has no AppxManifest.xml"; exit 1 } | |
| if (-not $entry) { throw "$out has no AppxManifest.xml" } |
| // Placeholder until NativeShell exposes image info; dims flow through | ||
| // CaptureDocument::baseImage instead. | ||
| return Size{0, 0}; |
There was a problem hiding this comment.
Screenshot::dimensions() 在 image != 0 时仍恒返回 Size{0, 0}(占位实现),导致 estimatedFileSize / formattedFileSize / aspectRatio 全部返回 0 或 "0 B"。注释说明依赖任务 B 接线,但在接线前所有调用方会得到错误的文件大小估算;建议加显式 TODO 并在上层避免使用这些结果,或直接断言未实现以暴露误用。
Suggestion:
| // Placeholder until NativeShell exposes image info; dims flow through | |
| // CaptureDocument::baseImage instead. | |
| return Size{0, 0}; | |
| // TODO(task B): wire real ImageRef -> dimension lookup via NativeShell. | |
| // Interim: always 0x0 so callers must not treat these values as real. | |
| return Size{0, 0}; |
| if (kind.contains("builtin")) { | ||
| const std::string raw = kind.at("builtin").at("_0").get<std::string>(); |
There was a problem hiding this comment.
fromJson 在 kind 为 {"builtin": null} 或缺少 "_0" 键时,kind.at("builtin").at("_0") 会抛出底层库异常,异常信息缺乏上下文且调用方难以区分是配置损坏还是代码缺陷。建议对两个分支的 "_0" 访问做存在性检查并抛出带说明的 std::invalid_argument,与下方 builtin 引擎名校验风格保持一致。
Suggestion:
| if (kind.contains("builtin")) { | |
| const std::string raw = kind.at("builtin").at("_0").get<std::string>(); | |
| if (kind.contains("builtin")) { | |
| if (!kind.at("builtin").contains("_0")) { | |
| throw std::invalid_argument("EngineChainItem builtin kind missing payload"); | |
| } | |
| const std::string raw = kind.at("builtin").at("_0").get<std::string>(); |
| static KeyboardShortcut translateAndInsertDefault() { | ||
| return {0x22, CarbonModifiers::cmdKey | CarbonModifiers::shiftKey}; | ||
| } |
There was a problem hiding this comment.
C++ 侧缺少与 macOS 对齐的取色快捷键:Swift 的 KeyboardShortcut.pickColorDefault 与 AppSettings.Keys.pickColorShortcut 已存在(本次 macOS 变更中新增),但这里没有对应的 default 工厂方法,SettingsKeys.h 也没有 pickColorShortcut 键。从 macOS 导出的设置在 Windows 还原时该项会被静默丢弃,且后续 Windows 取色热键功能(B 任务)接入时需要回补此模型。建议同步补充。
Suggestion:
| static KeyboardShortcut translateAndInsertDefault() { | |
| return {0x22, CarbonModifiers::cmdKey | CarbonModifiers::shiftKey}; | |
| } | |
| static KeyboardShortcut translateAndInsertDefault() { | |
| return {0x22, CarbonModifiers::cmdKey | CarbonModifiers::shiftKey}; | |
| } | |
| static KeyboardShortcut pickColorDefault() { | |
| return {0x2E /* c */, CarbonModifiers::cmdKey | CarbonModifiers::shiftKey}; | |
| } |
| static KeyboardShortcut fromJson(const Json& j) { | ||
| KeyboardShortcut s; | ||
| s.keyCode = static_cast<std::uint32_t>(j.at("keyCode").get<std::uint64_t>()); | ||
| s.modifiers = static_cast<std::uint32_t>(j.at("modifiers").get<std::uint64_t>()); | ||
| return s; | ||
| } |
There was a problem hiding this comment.
fromJson 对所有字段使用 j.at(key).get(),在键缺失或类型不匹配时抛出 nlohmann 异常。该函数用于解析持久化设置(可能来自 macOS 导出、旧版本或手改文件),若调用方未捕获,单个坏字段会导致设置加载整体失败甚至启动崩溃。文件内已有 getOptional/getOptionalOr 辅助,建议对可回退字段使用缺省值,或在调用点统一 try/catch 并回退到默认快捷键。
Suggestion:
| static KeyboardShortcut fromJson(const Json& j) { | |
| KeyboardShortcut s; | |
| s.keyCode = static_cast<std::uint32_t>(j.at("keyCode").get<std::uint64_t>()); | |
| s.modifiers = static_cast<std::uint32_t>(j.at("modifiers").get<std::uint64_t>()); | |
| return s; | |
| } | |
| static KeyboardShortcut fromJson(const Json& j) { | |
| KeyboardShortcut s; | |
| s.keyCode = static_cast<std::uint32_t>(getOptionalOr<std::uint64_t>(j, "keyCode", 0)); | |
| s.modifiers = static_cast<std::uint32_t>(getOptionalOr<std::uint64_t>(j, "modifiers", 0)); | |
| return s; | |
| } |
| static CodableColor fromJson(const Json& j) { | ||
| return {j.at("red").get<double>(), j.at("green").get<double>(), | ||
| j.at("blue").get<double>(), j.at("opacity").get<double>()}; | ||
| } |
There was a problem hiding this comment.
fromJson 同样依赖 j.at(...).get(),styles 数据(如 shapeFillColor、strokeColor)损坏时会抛异常;这些默认值本可安全回退(红色/白色等),建议用 getOptionalOr 兜底,避免设置加载因局部损坏而整体失败。
Suggestion:
| static CodableColor fromJson(const Json& j) { | |
| return {j.at("red").get<double>(), j.at("green").get<double>(), | |
| j.at("blue").get<double>(), j.at("opacity").get<double>()}; | |
| } | |
| static CodableColor fromJson(const Json& j) { | |
| return {getOptionalOr<double>(j, "red", 0.0), getOptionalOr<double>(j, "green", 0.0), | |
| getOptionalOr<double>(j, "blue", 0.0), getOptionalOr<double>(j, "opacity", 1.0)}; | |
| } |
…+ key hints
The selection overlay self-dismissed on WM_KILLFOCUS: under the Win32
foreground lock the SetFocus/SetForegroundWindow grab right after
ShowWindow bounces and the focus loss killed every session within
milliseconds - hotkeys and the tray menu's capture items ran but looked
completely dead. Remove the focus-loss dismissal (mac nonactivating
NSPanel parity; Esc / click-away / explicit cancel remain) and grab
keyboard focus via AttachThreadInput so Esc reliably reaches the
overlay.
Tray menu styling on dark systems: opt the HMENU into the Win11 dark
context menu via SetPreferredAppMode following AppsUseLightTheme, and
render each capture row's live key equivalent right-aligned
("全屏截图\tCtrl+Alt+F") like the mac status menu; hints refresh after
applySpecs and hotkey settings saves.
Verified live: 5/5 hotkeys registered, 3/3 injected region sessions
stay visible past the 2s focus-bounce window and dismiss on Esc.
Co-Authored-By: Claude Code <noreply@anthropic.com>
| <script type="text/x-dc" data-dc-script data-props='{"$preview":{"width":880,"height":560}}'>class Component extends DCLogic {}</script> | ||
| </body></html> No newline at end of file |
There was a problem hiding this comment.
文件末尾缺少换行符(EOF newline)。建议在文件结尾补上换行,避免在版本控制与文本工具中产生 "\ No newline at end of file" 提示,也与常见代码规范保持一致。
Suggestion:
| <script type="text/x-dc" data-dc-script data-props='{"$preview":{"width":880,"height":560}}'>class Component extends DCLogic {}</script> | |
| </body></html> | |
| +<script type="text/x-dc" data-dc-script data-props='{"$preview":{"width":880,"height":560}}'>class Component extends DCLogic {}</script> | |
| +</body></html> |
| - name: Build solution | ||
| # -restore: the solution references WASDK/CppWinRT via | ||
| # PackageReference (WinUI3Shell + App); a fresh runner has no | ||
| # packages until NuGet restore runs. | ||
| working-directory: windows | ||
| run: msbuild TransFrame.sln /m /restore /p:Configuration=${{ matrix.configuration }} /p:Platform=${{ matrix.platform }} /warnaserror /verbosity:minimal |
There was a problem hiding this comment.
三个 Windows job 每次 /restore 全量拉取 WASDK/CppWinRT NuGet 包,CMake leg 也无任何构建目录缓存,windows-latest 上这类大型依赖还原显著拖慢 CI。建议为 NuGet 引入 actions/cache(缓存 %LOCALAPPDATA%\NuGet\packages,key 基于 windows//.csproj/**.vcxproj 哈希)或使用 setup-msbuild 之后配合 NuGet cache;CMake 构建目录缓存收益有限,可不做。
Suggestion:
| - name: Build solution | |
| # -restore: the solution references WASDK/CppWinRT via | |
| # PackageReference (WinUI3Shell + App); a fresh runner has no | |
| # packages until NuGet restore runs. | |
| working-directory: windows | |
| run: msbuild TransFrame.sln /m /restore /p:Configuration=${{ matrix.configuration }} /p:Platform=${{ matrix.platform }} /warnaserror /verbosity:minimal | |
| - name: Cache NuGet packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~\AppData\Local\NuGet\packages | |
| key: nuget-${{ matrix.platform }}-${{ hashFiles('windows/**/*.proj', 'windows/**/*.vcxproj') }} | |
| restore-keys: nuget-${{ matrix.platform }}- | |
| - name: Build solution | |
| working-directory: windows | |
| run: msbuild TransFrame.sln /m /restore /p:Configuration=${{ matrix.configuration }} /p:Platform=${{ matrix.platform }} /warnaserror /verbosity:minimal |
| g++-13 -std=c++20 -Wall -Wextra -Werror \ | ||
| -I . -I Core -I external \ | ||
| Core/*.cpp external/catch2/catch_amalgamated.cpp \ | ||
| Tests/TestMain.cpp Tests/CoreModelsTests.cpp Tests/LLMTranslationCoreTestsA.cpp \ | ||
| Tests/TranslationPromptConfigTests.cpp Tests/VisualLineGroupingTests.cpp \ | ||
| -o ../build-tests 2>&1 | head -400 |
There was a problem hiding this comment.
portable-check 的 "Core (task A)" 步骤用内联 g++ 命令只编译了 5 个测试 TU,实际只覆盖极少量 Core 源文件;而 windows/CMakeLists.txt 中 translation_tests 通过 file(GLOB Core/src/*.cpp) + CORE_MODEL_SRC 已包含全部可移植源(HistoryStore.cpp、EngineConfigStore.cpp、OcrEngines.cpp、SmartRedaction.cpp 等均在 CMake leg 中构建)。结果是:-Werror(无 Win32 泄漏的强保证)只作用于这一小撮文件,而完整源集只在无 -Werror 的 CMake leg 中编译——可移植性检查的强度与覆盖面错位。此外 2>&1 | head -400 在 pipefail 下,编译器因 head 提前退出收到 SIGPIPE 被杀时退出码语义混乱,可能掩盖真实编译错误或产生误导性失败。建议:要么让 task A leg 直接复用 CMake 并加 -Werror(如 -DCMAKE_CXX_FLAGS=-Werror),要么把完整源清单写入脚本并移除 head 截断(改用输出重定向到文件再 tail)。
Suggestion:
| g++-13 -std=c++20 -Wall -Wextra -Werror \ | |
| -I . -I Core -I external \ | |
| Core/*.cpp external/catch2/catch_amalgamated.cpp \ | |
| Tests/TestMain.cpp Tests/CoreModelsTests.cpp Tests/LLMTranslationCoreTestsA.cpp \ | |
| Tests/TranslationPromptConfigTests.cpp Tests/VisualLineGroupingTests.cpp \ | |
| -o ../build-tests 2>&1 | head -400 | |
| # 让 GCC leg 覆盖与 CMake 相同的完整可移植源集,并保留 -Werror | |
| # (源清单维护在 windows/CMakeLists.txt 或独立脚本中,避免两处漂移) | |
| g++-13 -std=c++20 -Wall -Wextra -Werror ... -o ../build-tests | |
| ../build-tests |
| g++-13 -std=c++20 -Wall -Wextra -Werror \ | ||
| -I . -I Core -I external \ | ||
| Core/*.cpp external/catch2/catch_amalgamated.cpp \ | ||
| Tests/TestMain.cpp Tests/CoreModelsTests.cpp Tests/LLMTranslationCoreTestsA.cpp \ | ||
| Tests/TranslationPromptConfigTests.cpp Tests/VisualLineGroupingTests.cpp \ | ||
| -o ../build-tests 2>&1 | head -400 |
There was a problem hiding this comment.
portable-check 的 g++ 步骤用 2>&1 | head -400 截断输出:当编译错误超过 400 行时,位于前面的关键报错(MSVC/GCC 通常第一条错误在最前,尚可保留,但后续模板展开类错误会被截断),更重要的是 head 提前退出会触发 SIGPIPE,配合上面 set -euo pipefail 时,即使 g++ 正常完成、仅因输出量大被 head 掐断管道,整个步骤也可能以非零退出误报失败。建议去掉 head 截断(CI 日志本身会完整留存),或改用 g++ ... || { tail -n 400 g++.log; exit 1; } 这类先落盘再截取的方式。
Suggestion:
| g++-13 -std=c++20 -Wall -Wextra -Werror \ | |
| -I . -I Core -I external \ | |
| Core/*.cpp external/catch2/catch_amalgamated.cpp \ | |
| Tests/TestMain.cpp Tests/CoreModelsTests.cpp Tests/LLMTranslationCoreTestsA.cpp \ | |
| Tests/TranslationPromptConfigTests.cpp Tests/VisualLineGroupingTests.cpp \ | |
| -o ../build-tests 2>&1 | head -400 | |
| g++-13 -std=c++20 -Wall -Wextra -Werror \ | |
| -I . -I Core -I external \ | |
| Core/*.cpp external/catch2/catch_amalgamated.cpp \ | |
| Tests/TestMain.cpp Tests/CoreModelsTests.cpp Tests/LLMTranslationCoreTestsA.cpp \ | |
| Tests/TranslationPromptConfigTests.cpp Tests/VisualLineGroupingTests.cpp \ | |
| -o ../build-tests | |
| ../build-tests |
| $hashes = @{ | ||
| x64 = 'b56a9101f706f9d95f815f5b7fa6efbac972e86573d378b96a07cff5540c5961' | ||
| arm64 = '9a7f6d69ea6cf042ea8680b7cd0bfaa9c04f0f6cc89055d43f7f6cd0250508d3' | ||
| } |
There was a problem hiding this comment.
VCLibs 的 SHA-256 哈希是脚本内联字面量,而错误信息引用 $env:VCLIBS_VERSION(env 中只定义了版本号、未定义哈希);哈希与版本两处需要同步更新却只有版本进了 env,升级 VCLibs 时容易只改 env 忘改哈希导致 CI 永久失败且报错信息误导。建议把哈希也提升到 job 级 env(如 VCLIBS_HASH_X64 / VCLIBS_HASH_ARM64),或抽到受控的清单/脚本文件并在 workflow 中引用。
Suggestion:
| $hashes = @{ | |
| x64 = 'b56a9101f706f9d95f815f5b7fa6efbac972e86573d378b96a07cff5540c5961' | |
| arm64 = '9a7f6d69ea6cf042ea8680b7cd0bfaa9c04f0f6cc89055d43f7f6cd0250508d3' | |
| } | |
| env: | |
| VCLIBS_VERSION: 14.0.33321.0 | |
| VCLIBS_SHA256_X64: b56a9101f706f9d95f815f5b7fa6efbac972e86573d378b96a07cff5540c5961 | |
| VCLIBS_SHA256_ARM64: 9a7f6d69ea6cf042ea8680b7cd0bfaa9c04f0f6cc89055d43f7f6cd0250508d3 |
| AtomicWriteResult out; | ||
| std::error_code ec; | ||
|
|
||
| const std::filesystem::path tmp = filePath.string() + ".tmp"; |
There was a problem hiding this comment.
writeEngineConfigFileAtomic 使用 filePath.string()(窄字符,Windows 下为 ANSI 代码页)构造临时文件路径,并用 std::remove(tmp.string().c_str()) 删除。当 %APPDATA% 路径包含非 ASCII 字符(如中文用户名)时,string() 转换可能失败或产生错误编码,导致临时文件创建失败或残留。std::filesystem 在 Windows 上原生支持宽字符,应直接使用 path 拼接(filePath += ".tmp" 或 filePath.wstring()),删除用 std::filesystem::remove 并传入 path 对象。
Suggestion:
| const std::filesystem::path tmp = filePath.string() + ".tmp"; | |
| std::filesystem::path tmp = filePath; | |
| tmp += ".tmp"; |
| // rename over an existing file may fail via std::filesystem's strict | ||
| // mapping; remove-then-rename matches MOVEFILE_REPLACE_EXISTING. | ||
| std::error_code removeEc; | ||
| std::filesystem::remove(filePath, removeEc); | ||
| std::filesystem::rename(tmp, filePath, ec); |
There was a problem hiding this comment.
writeEngineConfigFileAtomic 在 rename 失败时先 std::filesystem::remove(filePath) 再重试 rename;若删除成功但第二次 rename 失败(磁盘满、权限、句柄占用等),原有 engines.json 已被永久删除且临时文件随后也被 remove,用户数据丢失。真正的 MOVEFILE_REPLACE_EXISTING(或 POSIX rename)本身支持原子覆盖,不会出现『目标已删、新文件未落盘』的窗口。建议改为直接调用 Win32 MoveFileExW(MOVEFILE_REPLACE_EXISTING) 实现 Windows 覆盖语义,或至少在 remove 前保留备份。另外 tmp 路径固定为 filePath + ".tmp",多进程/多页面并发保存时会互相覆盖临时文件。
Suggestion:
| // rename over an existing file may fail via std::filesystem's strict | |
| // mapping; remove-then-rename matches MOVEFILE_REPLACE_EXISTING. | |
| std::error_code removeEc; | |
| std::filesystem::remove(filePath, removeEc); | |
| std::filesystem::rename(tmp, filePath, ec); | |
| // Windows 上用 MoveFileExW(MOVEFILE_REPLACE_EXISTING) 做原子覆盖, | |
| // 避免先删除目标文件导致二次 rename 失败时数据丢失。 | |
| #ifdef _WIN32 | |
| if (!MoveFileExW(tmp.wstring().c_str(), filePath.wstring().c_str(), | |
| MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH)) { | |
| out.error = "原子替换失败: " + std::to_string(GetLastError()); | |
| std::error_code rmEc; | |
| std::filesystem::remove(tmp, rmEc); | |
| return out; | |
| } | |
| #else | |
| std::filesystem::rename(tmp, filePath, ec); | |
| if (ec) { ... } | |
| #endif |
| case TranslationEngineType::Google: | ||
| case TranslationEngineType::Baidu: | ||
| // No free probe endpoint: orange without keys, gray with. | ||
| if (credentials_ && credentials_->has(credentialAccount(key.builtin))) { | ||
| return EngineHealth::Unverified; | ||
| } | ||
| return EngineHealth::Unconfigured; | ||
| case TranslationEngineType::Claude: | ||
| case TranslationEngineType::Gemini: | ||
| case TranslationEngineType::DeepL: |
There was a problem hiding this comment.
Google/Baidu 与 Claude/Gemini/DeepL 两个分支代码完全相同(有凭证→Unverified,否则→Unconfigured),可合并为一个 case 列表;OpenAI/Ollama 分支内部再嵌套 if (key.builtin == OpenAI) 的写法也较绕,可拆分为独立 case。
Suggestion:
| case TranslationEngineType::Google: | |
| case TranslationEngineType::Baidu: | |
| // No free probe endpoint: orange without keys, gray with. | |
| if (credentials_ && credentials_->has(credentialAccount(key.builtin))) { | |
| return EngineHealth::Unverified; | |
| } | |
| return EngineHealth::Unconfigured; | |
| case TranslationEngineType::Claude: | |
| case TranslationEngineType::Gemini: | |
| case TranslationEngineType::DeepL: | |
| case TranslationEngineType::Google: | |
| case TranslationEngineType::Baidu: | |
| case TranslationEngineType::Claude: | |
| case TranslationEngineType::Gemini: | |
| case TranslationEngineType::DeepL: | |
| if (credentials_ && credentials_->has(credentialAccount(key.builtin))) { | |
| return EngineHealth::Unverified; | |
| } | |
| return EngineHealth::Unconfigured; |
| std::lock_guard<std::mutex> lock(mutex_); | ||
| auto it = cache_.find(key); | ||
| if (it != cache_.end() && clock_() - it->second.at < ttl_) { | ||
| return it->second.health; | ||
| } | ||
| } | ||
| return refresh(key, token); |
| if (c == '{' || c == '[') ++depth; | ||
| else if (c == '}' || c == ']') --depth; | ||
| ++i; | ||
| if (depth == 0) { |
There was a problem hiding this comment.
手写截断恢复扫描器在遇到多余关闭符时 depth 可能减为负数,此后所有 '{'/'[' 会被当作新 item 重新以 depth=1 开始,畸形输入可能切分出错误项;建议在 depth 变为负值时终止扫描(视为尾部垃圾)。
Suggestion:
| if (c == '{' || c == '[') ++depth; | |
| else if (c == '}' || c == ']') --depth; | |
| ++i; | |
| if (depth == 0) { | |
| if (c == '{' || c == '[') ++depth; | |
| else if (c == '}' || c == ']') { | |
| if (--depth < 0) return std::nullopt; // 多余关闭符:尾部垃圾,终止 | |
| } | |
| ++i; | |
| if (depth == 0) { |
| auto readBox = [&b](const char* key) -> double { | ||
| if (!b.contains(key)) return 0.0; | ||
| const Json& v = b.at(key); | ||
| if (!finiteNumber(v)) return std::numeric_limits<double>::quiet_NaN(); | ||
| return v.get<double>(); | ||
| }; |
There was a problem hiding this comment.
readBox 在键缺失时返回 0.0 而非标记无效,导致 boundingBox 缺少 x/y 字段的项被当作原点处宽高正常的框参与打码,可能误覆盖左上角无关内容。在“VLM 输出不可信”的健壮性契约下,缺失关键字段应视为无效项丢弃:让 readBox 返回 optional(或 NaN),并统一走已有的 isfinite 丢弃分支。
Suggestion:
| auto readBox = [&b](const char* key) -> double { | |
| if (!b.contains(key)) return 0.0; | |
| const Json& v = b.at(key); | |
| if (!finiteNumber(v)) return std::numeric_limits<double>::quiet_NaN(); | |
| return v.get<double>(); | |
| }; | |
| auto readBox = [&b](const char* key) -> double { | |
| if (!b.contains(key)) return std::numeric_limits<double>::quiet_NaN(); // 缺字段即无效,走统一丢弃分支 | |
| const Json& v = b.at(key); | |
| if (!finiteNumber(v)) return std::numeric_limits<double>::quiet_NaN(); | |
| return v.get<double>(); | |
| }; |
| double confidence = 0.0; // missing confidence → 0 → dropped by the | ||
| // macOS >= 0.5 default filter | ||
| if (item.contains("confidence") && item["confidence"].is_number()) { |
There was a problem hiding this comment.
parseRegions 中 confidence 字段存在但为非 number 类型(如字符串 "0.9")时被静默置 0 丢弃,与 boundingBox 缺失字段的处理路径混杂,容易掩盖模型输出的格式漂移。建议至少在非 number 的 confidence 上与其他无效字段一致地直接 continue(跳过该项),避免依赖隐式默认值的副作用。
Suggestion:
| double confidence = 0.0; // missing confidence → 0 → dropped by the | |
| // macOS >= 0.5 default filter | |
| if (item.contains("confidence") && item["confidence"].is_number()) { | |
| double confidence = 0.0; | |
| if (item.contains("confidence") && item["confidence"].is_number()) { |
| std::string TranslationScheduler::hashTexts(const std::vector<std::string>& texts) { | ||
| // FNV-1a over the joined texts — collision-safe enough as a cache key | ||
| // discriminant alongside language + engine identity. |
| if (request.texts.empty()) { | ||
| SchedulerOutcome out; | ||
| TranslationResultBundle bundle; | ||
| bundle.primaryEngine = | ||
| chain.empty() ? TranslationEngineType::MtranServer : chain.front().resolvedEngine(); | ||
| bundle.selectionMode = EngineSelectionMode::PrimaryWithFallback; | ||
| bundle.scene = static_cast<int>(request.scene); | ||
| out.bundle = bundle; | ||
| return out; | ||
| } |
There was a problem hiding this comment.
texts 为空时返回一个带 bundle 的"成功"结果,与上方注释 "empty means nothing to try, reported as an aggregated failure" 自相矛盾。调用方可能把空结果误判为翻译成功,导致空翻译结果被写入历史或 UI。建议返回聚合失败(或显式错误态)而不是空 bundle。
Suggestion:
| if (request.texts.empty()) { | |
| SchedulerOutcome out; | |
| TranslationResultBundle bundle; | |
| bundle.primaryEngine = | |
| chain.empty() ? TranslationEngineType::MtranServer : chain.front().resolvedEngine(); | |
| bundle.selectionMode = EngineSelectionMode::PrimaryWithFallback; | |
| bundle.scene = static_cast<int>(request.scene); | |
| out.bundle = bundle; | |
| return out; | |
| } | |
| if (request.texts.empty()) { | |
| SchedulerOutcome out; | |
| out.failures.push_back({TranslationEngineType::MtranServer, "", "no texts to translate"}); | |
| return out; | |
| } |
| out.failures.push_back({item.resolvedEngine(), "", "cancelled"}); | ||
| return out; |
| const std::string raw = j.at("id").get<std::string>(); | ||
| c.id = fromRaw(TranslationEngineType{}, raw); | ||
| if (c.id == TranslationEngineType::Invalid) { | ||
| throw std::invalid_argument("unknown engine id: " + raw); | ||
| } |
There was a problem hiding this comment.
fromJson 对缺失 "id" 直接 j.at("id") 抛异常,未知 engine id 也抛 std::invalid_argument。与同分支 EngineConfigStore.cpp『容错回退、不因单个字段失败』的解析策略不一致;engines.json 与 mac 共享,数组中单个损坏条目(人工编辑或 mac 端新增枚举)会导致整份配置解析失败。建议单条目损坏时跳过该条目而非抛出。
Suggestion:
| const std::string raw = j.at("id").get<std::string>(); | |
| c.id = fromRaw(TranslationEngineType{}, raw); | |
| if (c.id == TranslationEngineType::Invalid) { | |
| throw std::invalid_argument("unknown engine id: " + raw); | |
| } | |
| const auto idIt = j.find("id"); | |
| if (idIt == j.end() || !idIt->is_string()) { return c; } // 跳过损坏条目 | |
| c.id = fromRaw(TranslationEngineType{}, idIt->get<std::string>()); | |
| if (c.id == TranslationEngineType::Invalid) { return c; } |
| c.options = getOptional<EngineOptions>(j, "options"); | ||
| c.customName = getOptional<std::string>(j, "customName"); |
There was a problem hiding this comment.
fromJson 对缺失 "options" 字段时 getOptional(j, "options") 的行为依赖 Json 辅助实现;若 options 字段存在但类型不为对象(如写成了字符串),嵌套的 EngineOptions::fromJson 内部 j.find 等访问是否安全需要确认,避免对畸形配置抛异常。同理 toJson 中 options/customName 为空时写出 Json()(null),from_json 反序列化 null 值时也应验证不会抛出。
Suggestion:
| c.options = getOptional<EngineOptions>(j, "options"); | |
| c.customName = getOptional<std::string>(j, "customName"); | |
| if (auto it = j.find("options"); it != j.end() && it->is_object()) { | |
| c.options = EngineOptions::fromJson(*it); | |
| } |
| static constexpr const char* kDefaultPrompt = | ||
| "Translate the following text from {source_language} to {target_language}.\n" | ||
| "Provide only the translation without any explanations or additional text.\n\n" | ||
| "Text to translate:\n" | ||
| "{text}"; |
There was a problem hiding this comment.
默认提示词模板在本文件(kDefaultPrompt/kDefaultInsertPrompt constexpr)与 CoreModels.cpp 的 TranslationPromptConfig::defaultPrompt()/defaultInsertPrompt() 静态字符串两处重复定义(CompatibleChatProvider.cpp、LLMChatProvider.cpp 还有第三、四处内联拼接)。目前内容一致但无单一来源,未来任何一处修改都会造成静默分叉、两端提示词不一致。建议收敛到一个共享常量(如 CoreModels 中的 static 函数,或独立 PromptTemplates.h)。
Suggestion:
| static constexpr const char* kDefaultPrompt = | |
| "Translate the following text from {source_language} to {target_language}.\n" | |
| "Provide only the translation without any explanations or additional text.\n\n" | |
| "Text to translate:\n" | |
| "{text}"; | |
| // 引用唯一来源,避免多处拷贝导致分叉: | |
| static const std::string& defaultPrompt(); | |
| static const std::string& defaultInsertPrompt(); |
| if (auto it = j.find("enginePrompts"); it != j.end() && it->is_array()) { | ||
| for (size_t i = 0; i + 1 < it->size(); i += 2) { | ||
| if (!(*it)[i].is_string() || !(*it)[i + 1].is_string()) { continue; } |
There was a problem hiding this comment.
TranslationPromptConfig::fromJson 中 fromRaw 失败返回 Invalid 后被跳过,这个容错是对的;但结合本文件 toJson 的写法:enginePrompts 以扁平的 [key1, value1, key2, value2, ...] 数组序列化(模拟 Swift enum-keyed dictionary),如果 value 本身是字符串这没问题;但若 JSON 中数组元素个数为奇数(外部工具手工编辑导致),循环条件 i + 1 < it->size() 会静默丢弃最后一项,行为可接受但没有任何日志/错误提示,排查线上配置问题时难以定位。建议至少在 debug 断言或注释中说明该容错语义。
Suggestion:
| if (auto it = j.find("enginePrompts"); it != j.end() && it->is_array()) { | |
| for (size_t i = 0; i + 1 < it->size(); i += 2) { | |
| if (!(*it)[i].is_string() || !(*it)[i + 1].is_string()) { continue; } | |
| if (auto it = j.find("enginePrompts"); it != j.end() && it->is_array()) { | |
| // Flat key/value pairs; odd trailing entry or non-string pairs are | |
| // silently skipped (tolerant decode, mirrors EngineConfigStore). | |
| for (size_t i = 0; i + 1 < it->size(); i += 2) { | |
| if (!(*it)[i].is_string() || !(*it)[i + 1].is_string()) { continue; } |
| std::unique_ptr<DisplayMonitorService> makeDisplayMonitorService() { | ||
| static auto enumerator = makeWin32DisplayEnumerator(); | ||
| static auto clock = makeSteadyClock(); | ||
| return std::make_unique<DisplayMonitorService>(*enumerator, *clock); | ||
| } |
There was a problem hiding this comment.
工厂返回的 Service 通过裸引用持有函数级 static 的 enumerator/clock/lister/registrar,生存期依赖 exit-time 析构顺序恰好安全,属于另一处隐性生存期契约;若 Service 生命周期变化(静态单例/跨 exit 复用)将悬空。建议依赖对象改用 shared_ptr 由 Service 持有。
Suggestion:
| std::unique_ptr<DisplayMonitorService> makeDisplayMonitorService() { | |
| static auto enumerator = makeWin32DisplayEnumerator(); | |
| static auto clock = makeSteadyClock(); | |
| return std::make_unique<DisplayMonitorService>(*enumerator, *clock); | |
| } | |
| std::unique_ptr<DisplayMonitorService> makeDisplayMonitorService() { | |
| static auto enumerator = makeWin32DisplayEnumerator(); | |
| static auto clock = makeSteadyClock(); | |
| auto service = std::make_unique<DisplayMonitorService>(*enumerator, *clock); | |
| // Document/own the dependency lifetime explicitly rather than relying on | |
| // exit-time destruction order. | |
| return service; | |
| } |
…ows below The selection overlay created a WS_EX_LAYERED window but never initialized the layered surface (SetLayeredWindowAttributes / UpdateLayeredWindow). An uninitialized layered window is mouse click-through everywhere - hit testing treats the never-set alpha surface as fully transparent - so the DComp dim kept rendering while real clicks and drags passed straight to the windows underneath (WindowFromPoint returned Chrome). The color picker already initializes alpha 255; do the same here. Verified live: WindowFromPoint now resolves to the overlay at 4/4 probe points, the dim still renders, and an injected press-move-release sequence parks the session on the in-place toolbar (Confirmed). Co-Authored-By: Claude Code <noreply@anthropic.com>
| - name: Add MSBuild to PATH | ||
| uses: microsoft/setup-msbuild@v2 |
There was a problem hiding this comment.
microsoft/setup-msbuild@v2 是第三方 action,仅按可变 tag 引用;tag 可被移动,存在供应链劫持风险(checkout/upload-artifact 属第一方 actions/*,按惯例可接受)。建议将 setup-msbuild 固定到完整 commit SHA。
Suggestion:
| - name: Add MSBuild to PATH | |
| uses: microsoft/setup-msbuild@v2 | |
| - name: Add MSBuild to PATH | |
| uses: microsoft/setup-msbuild@<full-commit-sha> |
| - name: Install compiler | ||
| run: sudo apt-get update && sudo apt-get install -y g++-13 cmake |
There was a problem hiding this comment.
portable-check 与各 MSBuild/CMake job 每次运行都重新 apt-get install g++-13、NuGet restore 和完整 CMake 配置,未配置任何 actions/cache(NuGet 包缓存、CMake ccache、apt 缓存),拖慢 CI 并在外部源不可用时增加脆弱性。建议为 NuGet(~/.nuget/packages)和 apt 包添加缓存步骤。
Suggestion:
| - name: Install compiler | |
| run: sudo apt-get update && sudo apt-get install -y g++-13 cmake | |
| - name: Cache apt packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: /var/cache/apt/archives | |
| key: apt-g++13-cmake | |
| - name: Install compiler | |
| run: sudo apt-get update && sudo apt-get install -y g++-13 cmake |
| g++-13 -std=c++20 -Wall -Wextra -Werror \ | ||
| -I . -I Core -I external \ | ||
| Core/*.cpp external/catch2/catch_amalgamated.cpp \ | ||
| Tests/TestMain.cpp Tests/CoreModelsTests.cpp Tests/LLMTranslationCoreTestsA.cpp \ | ||
| Tests/TranslationPromptConfigTests.cpp Tests/VisualLineGroupingTests.cpp \ | ||
| -o ../build-tests 2>&1 | head -400 | ||
| ../build-tests |
There was a problem hiding this comment.
编译错误输出经 | head -400 截断:真正的首个编译错误可能位于 400 行之后而被掩盖;若首个错误恰在末尾,则诊断信息完全丢失(只显示警告/中间噪声)。建议先输出到日志文件再 tail/grep 'error',或至少改为 tail 而非 head。
Suggestion:
| g++-13 -std=c++20 -Wall -Wextra -Werror \ | |
| -I . -I Core -I external \ | |
| Core/*.cpp external/catch2/catch_amalgamated.cpp \ | |
| Tests/TestMain.cpp Tests/CoreModelsTests.cpp Tests/LLMTranslationCoreTestsA.cpp \ | |
| Tests/TranslationPromptConfigTests.cpp Tests/VisualLineGroupingTests.cpp \ | |
| -o ../build-tests 2>&1 | head -400 | |
| ../build-tests | |
| g++-13 -std=c++20 -Wall -Wextra -Werror ... -o ../build-tests 2> compile.log || { grep -m 20 -E 'error' compile.log; tail -50 compile.log; exit 1; } | |
| ../build-tests |
| # scratch repro binaries | ||
| *.obj |
| /// Columns currently laid out, derived from the measured grid width. | ||
| private var columnCount: Int { | ||
| max(1, Int(gridWidth / (cellSize + 12))) | ||
| } |
| for shell in ('pwsh.exe', 'powershell.exe'): | ||
| if shutil.which(shell): | ||
| result = subprocess.run([shell, '-NoProfile', '-NonInteractive', '-Command', script], | ||
| capture_output=True, text=True, check=True, timeout=60) | ||
| break |
There was a problem hiding this comment.
注释声明“当 pwsh 所在环境的 Certificate PSDrive 失败时回退 powershell.exe”,但实现是 for-else + check=True:只有 shell 不在 PATH 时才会前进到下一个候选;pwsh.exe 存在但执行失败(非零退出)会直接抛 CalledProcessError 终止,不会回退到 powershell.exe,与注释描述的回退语义不符。trust_test_cert_in_root 中存在同样的模式。建议捕获 subprocess.CalledProcessError 后继续尝试下一个 shell。
Suggestion:
| for shell in ('pwsh.exe', 'powershell.exe'): | |
| if shutil.which(shell): | |
| result = subprocess.run([shell, '-NoProfile', '-NonInteractive', '-Command', script], | |
| capture_output=True, text=True, check=True, timeout=60) | |
| break | |
| result = None | |
| for shell in ('pwsh.exe', 'powershell.exe'): | |
| if not shutil.which(shell): | |
| continue | |
| proc = subprocess.run([shell, '-NoProfile', '-NonInteractive', '-Command', script], | |
| capture_output=True, text=True, timeout=60) | |
| if proc.returncode == 0: | |
| result = proc | |
| break | |
| if result is None: | |
| raise RuntimeError('certificate creation failed in every available shell') |
| for shell in ('pwsh.exe', 'powershell.exe'): | ||
| if shutil.which(shell): | ||
| subprocess.run([shell, '-NoProfile', '-NonInteractive', '-Command', script], | ||
| check=True, timeout=90) | ||
| return | ||
| raise RuntimeError('Neither pwsh.exe nor powershell.exe is available') |
There was a problem hiding this comment.
trust_test_cert_in_root 会无条件把一次性自签名代码签名证书写入 LocalMachine/Root(提权环境)或 CurrentUser/Root 信任存储,且脚本没有任何清理/撤销步骤(全文件无 Remove/CertUtil -delstore 等删除逻辑)。该证书在 1 天有效期内可签署任意代码并被系统完全信任;每次运行都会生成并信任一张新证书,累积污染根信任库。建议:签名完成后在 finally 中从 Root 存储移除该证书,或改为信任到 TrustedPeople(足以满足 Add-AppxPackage 侧载校验),并文档化手动清理方式。
Suggestion:
| for shell in ('pwsh.exe', 'powershell.exe'): | |
| if shutil.which(shell): | |
| subprocess.run([shell, '-NoProfile', '-NonInteractive', '-Command', script], | |
| check=True, timeout=90) | |
| return | |
| raise RuntimeError('Neither pwsh.exe nor powershell.exe is available') | |
| try: | |
| subprocess.run(['signtool.exe', 'sign', '/sha1', thumbprint, | |
| '/fd', 'SHA256', str(package)], check=True, timeout=60) | |
| finally: | |
| untrust_test_cert_in_root(thumbprint) # remove from Root store after signing |
| files = [p for root in roots for p in root.rglob('*.[ch]pp') | ||
| if 'build' not in p.parts and 'external' not in p.parts | ||
| and 'vendor' not in p.parts] |
There was a problem hiding this comment.
--check-code 的文件收集使用 rglob('.[ch]pp'),该模式只匹配 .cpp/.hpp,不会匹配纯 .h 头文件。若字符串 key 只在头文件中通过 loc::t(...) 使用(例如内联函数或模板定义在 .h 中),这里会漏检,check-code 声称的"验证所有代码 key"承诺失效。建议改为 rglob('') 后按后缀集合过滤,或显式包含 *.h。
Suggestion:
| files = [p for root in roots for p in root.rglob('*.[ch]pp') | |
| if 'build' not in p.parts and 'external' not in p.parts | |
| and 'vendor' not in p.parts] | |
| files = [p for root in roots for p in root.rglob('*') | |
| if p.suffix in ('.h', '.hpp', '.cpp', '.cc') | |
| and 'build' not in p.parts and 'external' not in p.parts | |
| and 'vendor' not in p.parts] |
| "settings.section.prompts": "Prompt Configuration", | ||
| "settings.section.shortcuts": "Keyboard Shortcuts", | ||
| "settings.shortcut.fullscreen": "Full Screen Capture", | ||
| "settings.shortcut.pick.color": "Screen Color Pick", |
| "settings.section.prompts": "Prompt Configuration", | ||
| "settings.section.shortcuts": "Keyboard Shortcuts", | ||
| "settings.shortcut.fullscreen": "Full Screen Capture", | ||
| "settings.shortcut.pick.color": "Screen Color Pick", |
There was a problem hiding this comment.
Host the selection swap chain in a WS_EX_NOREDIRECTIONBITMAP window so DirectComposition controls per-pixel alpha without an opaque layered redirection surface. The selection remains a rectangular mouse target. Upload the actual captured BGRA pixels when compositing preview exports, using a separate WIC source and explicit PBGRA conversion. The old path read the newly created empty destination instead of the source image. Add a GUI regression driver for real mouse drags, transparent selection content, and clipboard pixels across two sessions. Detect a locked WTS session before driving the desktop. Add exporter pixel regressions for annotations, padded rows, alpha conversion, and PNG round trips. Validation: Release x64 solution build, Core 7351 assertions / 234 cases, NativeShell 542 assertions / 106 cases, exporter 11 checks passed. Live GUI regression is pending desktop unlock. Co-Authored-By: Claude Code <noreply@anthropic.com>
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Add MSBuild to PATH | ||
| uses: microsoft/setup-msbuild@v2 |
There was a problem hiding this comment.
多个 job(msbuild /restore 全解决方案、三个独立 CMake 配置构建)每次 CI 都从零执行,且三套 CMake 构建目录(windows/NativeShell/build、windows/build、windows/build-c)互不复用,无任何 actions/cache。windows-latest 上全量构建 + 测试在 30 分钟超时内有超时风险,也造成明显资源浪费。建议为 NuGet(actions/setup-java 类似的 actions/cache 缓存 ~/.nuget/packages)和 pip 缓存,或至少合并重复的 CMake 配置。
Suggestion:
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Add MSBuild to PATH | |
| uses: microsoft/setup-msbuild@v2 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Cache NuGet packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.nuget/packages | |
| key: nuget-${{ runner.os }}-${{ hashFiles('windows/**/*.csproj', 'windows/**/project.json') }} | |
| - name: Add MSBuild to PATH | |
| uses: microsoft/setup-msbuild@v2 |
| - name: Add MSBuild to PATH | ||
| uses: microsoft/setup-msbuild@v2 |
There was a problem hiding this comment.
第三方 action microsoft/setup-msbuild@v2 未固定到完整 commit SHA。tag 是可变的,一旦上游被劫持(或维护者误移动 tag),本工作流会在拥有 checkout 代码上下文的 runner 上执行任意代码。建议改为 microsoft/setup-msbuild@<full-sha> 并在注释中标注版本。actions/checkout 属第一方可接受,但 setup-msbuild 应固定。
Suggestion:
| - name: Add MSBuild to PATH | |
| uses: microsoft/setup-msbuild@v2 | |
| - name: Add MSBuild to PATH | |
| # v2.0.0 (示例,请替换为实际 SHA) | |
| uses: microsoft/setup-msbuild@<full-commit-sha> |
| g++-13 -std=c++20 -Wall -Wextra -Werror \ | ||
| -I . -I Core -I external \ | ||
| Core/*.cpp external/catch2/catch_amalgamated.cpp \ | ||
| Tests/TestMain.cpp Tests/CoreModelsTests.cpp Tests/LLMTranslationCoreTestsA.cpp \ | ||
| Tests/TranslationPromptConfigTests.cpp Tests/VisualLineGroupingTests.cpp \ | ||
| -o ../build-tests 2>&1 | head -400 |
There was a problem hiding this comment.
编译输出通过 | head -400 截断,在 set -euo pipefail 下有双重问题:(1) head 读满 400 行后退出,g++ 继续写 stdout/stderr 会收到 SIGPIPE,pipefail 会将非零管道状态视为步骤失败——即使编译实际成功也会偶发误报;(2) 真正的编译错误若出现在 400 行之后会被吞掉。建议移除管道(依赖 msbuild/cmake 失败时的日志裁剪可改用 2>&1 | tail -n 400 配合管道前先落盘,或直接全量输出)。
Suggestion:
| g++-13 -std=c++20 -Wall -Wextra -Werror \ | |
| -I . -I Core -I external \ | |
| Core/*.cpp external/catch2/catch_amalgamated.cpp \ | |
| Tests/TestMain.cpp Tests/CoreModelsTests.cpp Tests/LLMTranslationCoreTestsA.cpp \ | |
| Tests/TranslationPromptConfigTests.cpp Tests/VisualLineGroupingTests.cpp \ | |
| -o ../build-tests 2>&1 | head -400 | |
| g++-13 -std=c++20 -Wall -Wextra -Werror \ | |
| -I . -I Core -I external \ | |
| Core/*.cpp external/catch2/catch_amalgamated.cpp \ | |
| Tests/TestMain.cpp Tests/CoreModelsTests.cpp Tests/LLMTranslationCoreTestsA.cpp \ | |
| Tests/TranslationPromptConfigTests.cpp Tests/VisualLineGroupingTests.cpp \ | |
| -o build-tests |
| -o ../build-tests 2>&1 | head -400 | ||
| ../build-tests |
There was a problem hiding this comment.
| # Windows installer output and Python packaging tools | ||
| windows/dist/ | ||
| __pycache__/ | ||
| hubert/ |
There was a problem hiding this comment.
hubert/ 是一条无任何注释说明的忽略规则,来源不明(可能是本地开发者目录误提交到全局 .gitignore)。全局 .gitignore 只应包含与项目构建产物相关的通用规则,个人本地目录应放进 .git/info/exclude 或全局用户配置,否则会静默忽略其他开发者可能需要的同名目录。建议删除或加注释说明用途。
Suggestion:
| # Windows installer output and Python packaging tools | |
| windows/dist/ | |
| __pycache__/ | |
| hubert/ | |
| # Windows installer output and Python packaging tools | |
| windows/dist/ | |
| __pycache__/ |
| try { | ||
| winrt::init_apartment(winrt::apartment_type::multi_threaded); | ||
| } catch (...) { | ||
| } |
There was a problem hiding this comment.
winrt::init_apartment(multi_threaded) 在线程池线程上成功初始化后没有对应的 CoUninitialize 恢复,线程复用时会累积 apartment 泄漏;同时 catch(...) 静默吞掉所有初始化异常,违反异常处理完整性原则。建议使用 RAII 包装(构造时 init_apartment,析构时 CoUninitialize),并至少记录失败的异常。
Suggestion:
| try { | |
| winrt::init_apartment(winrt::apartment_type::multi_threaded); | |
| } catch (...) { | |
| } | |
| struct ApartmentScope { | |
| ApartmentScope() { winrt::init_apartment(winrt::apartment_type::multi_threaded); } | |
| ~ApartmentScope() { ::CoUninitialize(); } | |
| } apartment; |
| const auto launched = ::ShellExecuteW(nullptr, L"open", uri.c_str(), nullptr, nullptr, SW_SHOWNORMAL); | ||
| if (reinterpret_cast<std::intptr_t>(launched) <= 32) { |
There was a problem hiding this comment.
ShellExecuteW 返回值大于 32 表示成功的约定用 reinterpret_caststd::intptr_t(launched) <= 32 表达,可读性差;且 HINSTANCE 返回值强转为 intptr_t 属于实现细节依赖。建议封装具名辅助函数并加注释说明约定,提升可维护性。
Suggestion:
| const auto launched = ::ShellExecuteW(nullptr, L"open", uri.c_str(), nullptr, nullptr, SW_SHOWNORMAL); | |
| if (reinterpret_cast<std::intptr_t>(launched) <= 32) { | |
| const auto launched = ::ShellExecuteW(nullptr, L"open", uri.c_str(), nullptr, nullptr, SW_SHOWNORMAL); | |
| // ShellExecuteW: 返回值 <= 32 表示失败 | |
| if (reinterpret_cast<std::intptr_t>(launched) <= 32) { |
| const std::string sceneRaw = j.at("scene").get<std::string>(); | ||
| b.scene = fromRaw(TranslationScene{}, sceneRaw); |
There was a problem hiding this comment.
fromJson 中 j.at("scene")/j.at("primaryEngine") 在键缺失时抛 nlohmann json::out_of_range、类型不匹配时抛 json::type_error;与文件中 defaultFor/错误路径使用的 std::invalid_argument 语义不一致,调用方若只捕获 std::invalid_argument 会漏掉这两类异常(nlohmann 的异常派生自 std::runtime_error/exception,而非 invalid_argument)。迁移损坏的历史设置文件时容易产生意外的异常传播。建议统一转换为 std::invalid_argument,或补充测试覆盖 fromJson 的缺失键/坏类型路径(当前测试只覆盖 round-trip 与 null optional)。
Suggestion:
| const std::string sceneRaw = j.at("scene").get<std::string>(); | |
| b.scene = fromRaw(TranslationScene{}, sceneRaw); | |
| const auto sceneIt = j.find("scene"); | |
| if (sceneIt == j.end() || !sceneIt->is_string()) { | |
| throw std::invalid_argument("SceneEngineBinding missing string field 'scene'"); | |
| } | |
| b.scene = fromRaw(TranslationScene{}, sceneIt->get<std::string>()); |
| "prompt.scene.title": "Scene Prompts", | ||
| "save.success.message": "Saved to %@", | ||
| "save.success.title": "Saved Successfully", | ||
| "settings.format": "Default Format", |
There was a problem hiding this comment.
键前缀风格不统一:settings.format/settings.language/settings.* 与 win.settings.* 并存,history.copy.translation 与 win.tray.history 等也分属不同前缀体系。键集已验证跨 10 个语言文件完全一致(无拼写问题),但前缀混用会使后续新增键的归属不明确。建议在迁移脚本(migrate_localizable.py)或文档中约定统一前缀规则,避免长期键集漂移。
Suggestion:
| "settings.format": "Default Format", | |
| "settings.format": "Default Format", // 建议统一为 win.settings.* 前缀或在新键中遵循单一前缀约定 |
| "win.shortcuts.title": "Global shortcuts", | ||
| "win.tray.checkUpdates": "Check for updates", | ||
| "win.tray.closeAll": "Close all", | ||
| "win.tray.colorHistory": "Color history", |
There was a problem hiding this comment.
键名命名风格不一致:"win.tray.colorHistory" 使用驼峰式(colorHistory),而同组其它键均为全小写点分风格(如 "win.colorhistory.*"、"win.tray.pickColor" 除外一致)。两个前缀 "win.colorhistory" 与 "win.tray.colorHistory" 还分别指代同一功能的窗口标题与托盘菜单项,后续维护易混淆或拼错。建议统一为小写点分(如 win.tray.colorhistory),并在 migrate_localizable.py 的键映射表中同步修正。
Suggestion:
| "win.tray.colorHistory": "Color history", | |
| "win.tray.colorhistory": "Color history", |
What
Two commits:
1.
e1875ccfeat(windows): app icon, tray refinements, update service, MSIX packagingApp.rc+ Assets (16–256px), wired into the window class and packaged manifestTaskbarCreated(explorer restart),CheckUpdatesmenu command viaUpdateServicebuild_msix.py(stage/sign/feed) + test/utf-8on all vcxproj — fixes C4819→hard-error on zh-CN systems (code page 936); CI adjustments2.
02ad4fffix(windows): clipboard timeouts + shell-foreground guard prevent taskbar freezeRoot cause (reproduced on hardware): Ctrl+Alt+D/I text selection always takes the clipboard fallback (UIA is not wired yet).
EmptyClipboard/GetClipboardDataissue synchronous cross-process sends to the clipboard owner (WM_DESTROYCLIPBOARD/ delayed-renderWM_RENDERFORMAT) with no timeout. When the owner is explorer, the worker thread wedges forever and drags the shell UI thread (taskbar) down with it. Reproduced twice: worker thread stuck inWait/Suspendedwith 0 CPU, taskbar unresponsive until the process is killed.Fixes:
Win32TextExtractorHost: every clipboard transaction wrapped inRunClipboardOp— sacrificial detached thread, 800ms cap, abandoned thread parks in the system call instead of blockingAppMain: text selection refused with a clear popup when the foreground process is a shell surface (explorer / start menu / search / input host / dwm) — Ctrl+C there copies files, never selectable textAppMain:pipelineBusywatchdog re-arms after 15s so a dead worker can no longer lock out all hotkeysWin32OcrUiaHosts.cpp→OcrUiaHostsWin32.cpp(was a scratch file name that snuck into the project)Testing
CN=TransFrame Devin TrustedPeople, no timestamp — RFC3161 server unreachable there)tray_hung=Falsethroughout: desktop Ctrl+Alt+D → refusal popup; 5× rapid-fire Ctrl+Alt+D; desktop Ctrl+Alt+I — app responsive, thread count stable, no shell freezeNotes / remaining
focusedElement) is still unwired — text selection relies on the clipboard fallback; wiring it up will further reduce clipboard churn (follow-up)