Skip to content

feat(windows): app icon + update service; fix taskbar freeze in text-selection flow - #100

Closed
lkl-hubo wants to merge 44 commits into
hubo1989:mainfrom
lkl-hubo:hubo/feat-windows
Closed

lkl-hubo wants to merge 44 commits into
hubo1989:mainfrom
lkl-hubo:hubo/feat-windows

Conversation

@lkl-hubo

@lkl-hubo lkl-hubo commented Nov 3, 2026

Copy link
Copy Markdown

What

Two commits:

1. e1875cc feat(windows): app icon, tray refinements, update service, MSIX packaging

  • App icon: App.rc + Assets (16–256px), wired into the window class and packaged manifest
  • Tray: icon restore on TaskbarCreated (explorer restart), CheckUpdates menu command via UpdateService
  • Packaging: build_msix.py (stage/sign/feed) + test
  • Build: /utf-8 on all vcxproj — fixes C4819→hard-error on zh-CN systems (code page 936); CI adjustments

2. 02ad4ff fix(windows): clipboard timeouts + shell-foreground guard prevent taskbar freeze

Root cause (reproduced on hardware): Ctrl+Alt+D/I text selection always takes the clipboard fallback (UIA is not wired yet). EmptyClipboard/GetClipboardData issue synchronous cross-process sends to the clipboard owner (WM_DESTROYCLIPBOARD / delayed-render WM_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 in Wait/Suspended with 0 CPU, taskbar unresponsive until the process is killed.

Fixes:

  • Win32TextExtractorHost: every clipboard transaction wrapped in RunClipboardOp — sacrificial detached thread, 800ms cap, abandoned thread parks in the system call instead of blocking
  • AppMain: 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 text
  • AppMain: pipelineBusy watchdog re-arms after 15s so a dead worker can no longer lock out all hotkeys
  • Renamed Win32OcrUiaHosts.cpp → OcrUiaHostsWin32.cpp (was a scratch file name that snuck into the project)

Testing

  • Full MSVC Release x64 build green, Core tests pass
  • Signed MSIX (1.0.5.1) installed on the target Windows machine (zh-CN, self-signed CN=TransFrame Dev in TrustedPeople, no timestamp — RFC3161 server unreachable there)
  • Post-fix verification on that machine, tray_hung=False throughout: desktop Ctrl+Alt+D → refusal popup; 5× rapid-fire Ctrl+Alt+D; desktop Ctrl+Alt+I — app responsive, thread count stable, no shell freeze

Notes / remaining

  • No RFC3161 timestamp on the signature (network-blocked test box); renewal due 2027-09, distribution needs a real cert
  • UIA text-pattern extraction (focusedElement) is still unwired — text selection relies on the clipboard fallback; wiring it up will further reduce clipboard churn (follow-up)

hubo1989 and others added 30 commits November 2, 2026 02:20
…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>
hubo1989 and others added 14 commits November 2, 2026 09:22
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>
Resolve add/add conflicts: combine CI jobs (core-tests + native-shell-tests +
shared portable-check with both legs) and take task B's NativeShell vcxproj
(cppwinrt + B source set on A's project frame, A GUID kept).

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Resolve add/add conflicts: CI gains the translation-tests job alongside
core/native-shell jobs and a third portable leg; LLMTranslationCoreTests and
windows/README take task C's CI-verified versions (C's tf/ include-tree).

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>
Replaces the blank-window skeleton with the integrated app:
- AppMain: hidden message window + tray icon (callback-routed) +
  Ctrl+Alt+F/A/T/D/I hotkeys (thread-message dispatch) + overlay
  selection + capture->OCR->translate->result pipeline on worker threads
- GDI capture engine: full BitBlt/CAPTUREBLT implementation as the
  working tail of the WGC->GDI chain (DXGI engine still probe-only)
- ResultWindow: borderless topmost popup (source/translation/copy,
  Esc/kill-focus close) anchored below the captured region
- TrayIconService::setCallbackWindow routes NIM callbacks to the app
  window instead of GetForegroundWindow
- WinRT OCR glue: build SoftwareBitmap directly from the BGRA buffer
  (BitmapDecoder cannot parse header-less pixels — was always failing)
- Projects: App links NativeShell+Core with include paths; NativeShell
  gains ResultWindow/WinHttpTransport/CredManKeyStore/WinRT-OCR TUs

Known v1 limits: MTranServer is the only wired engine (default
localhost:8989, TRANSFRAME_MTRAN_URL overrides); WGC captureOnce is
still a stub so GDI serves all captures; settings UI/pinning/history
remain later milestones.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
- ResultWindow: release Impl via unique_ptr (no manual delete)
- WinRT OCR TU: include project pch (fixes C1010 + macro redefinition)
- NativeShellInit.hpp: include WindowDetector.hpp + <memory>
- Fix MakeWinRt* seam names in NativeShellInit.cpp
- CMake native_shell: Core/include + Core/vendor on include path
- AppMain: construct MTranServer via (configuration, transport)
- SelectionOverlay: attach WindowDetectorService for hover highlight +
  mouse-down snapshot refresh; click-without-drag now captures the window
  under cursor (FR-02 was dead-ending to cancel)

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>
TransFrame.Core.vcxproj only built the task-A root sources; the App
link failed on 13 task-C symbols (providers, scheduler, HttpTransport,
parseUrl, InsertionService...). Add Core/src/*.cpp to the project
(mirrors the CMake CORE_SRC glob; namespaces tf::core vs tf stay apart).

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
- Core/include was missing from the project include path (tf/*.hpp)
- src\LLMTranslationCore.obj collided with root LLMTranslationCore.obj
  (MSB8027); route src/ objects into $(IntDir)src
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
tf::VisualLineGrouping::mergeLines is defined in Core/src (task C port);
the root VisualLineGrouping.cpp is the tf::core variant.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
…ging

- App icon: App.rc + Assets (16-256px ICO/PNG), wired into the window
  class and packaged manifest assets
- Tray: restore icon on TaskbarCreated (explorer restart), CheckUpdates
  menu command backed by UpdateService (AppInstallerInfo flow)
- Packaging: build_msix.py (stage/sign/feed) + test, verified by
  building, signing and installing 1.0.5.x on a zh-CN Windows box
- Build: add /utf-8 to all vcxproj so Chinese-system code page 936 no
  longer turns C4819 into a hard error; CI workflow adjustments

Commit: 1/2 — taskbar-freeze fix follows separately
…kbar freeze

Ctrl+Alt+D/I (text selection) could freeze the taskbar when the
clipboard owner was the shell:

- EmptyClipboard/GetClipboardData issue synchronous cross-process sends
  to the clipboard owner (WM_DESTROYCLIPBOARD / delayed-render
  WM_RENDERFORMAT) with no timeout; with explorer as owner the worker
  thread wedged forever and dragged the shell down with it (reproduced
  on hardware: worker thread stuck Wait/Suspended, taskbar
  unresponsive; verified across two independent repro runs)
- Win32TextExtractorHost: wrap every clipboard transaction
  (backup/restore/clear/set/read) in RunClipboardOp — runs on a
  sacrificial detached thread, gives up after 800ms, abandoned thread
  parks inside the system call instead of blocking the pipeline
- AppMain: refuse text-selection flows when the foreground process is
  a shell surface (explorer/start menu/search/input host/dwm) with a
  clear popup — Ctrl+C there copies files, never selectable text
- AppMain: pipelineBusy watchdog re-arms after 15s so a dead worker
  can no longer lock out every hotkey
- Rename the UIA/OCR host source Win32OcrUiaHosts.cpp ->
  OcrUiaHostsWin32.cpp (was a random scratch name)

Verified on the target machine (MSIX 1.0.5.1, tray_hung=False
throughout): desktop Ctrl+Alt+D, 5x rapid-fire Ctrl+Alt+D, desktop
Ctrl+Alt+I — app stays responsive, thread count stable, no shell
freeze.
@coderabbitai

coderabbitai Bot commented Nov 3, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 99890eb5-1c91-425b-a1fe-4f6203f886c4
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Tip

🎯 Customize your risk assessments

Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.

✅ Automatic approvals, with your rules

Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@lkl-hubo lkl-hubo closed this by deleting the head repository Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants