Fix: background splitting bug

This commit is contained in:
DaZuo0122
2026-02-14 17:08:29 +08:00
parent 901bf0ffc3
commit 1fa7080210
10 changed files with 348 additions and 34 deletions

View File

@@ -16,6 +16,8 @@ P1
- `issues/screenshots/issue4.png`
- `issues/screenshots/issue4-b.png`
- `issues/screenshots/issue4-c.png`
- `issues/screenshots/issue4-after-fix2-2026-02-14-145819.png`
- `issues/screenshots/issue4-after-fix4-2026-02-14-153233.png`
## Summary
@@ -57,6 +59,17 @@ and scaling becomes ineffective after the error.
the view in a broken/cropped state on creation failures.
5. Chroma-key conversion tolerance removed most `#FF00FF` background but still left magenta fringe
on anti-aliased edges.
6. Scale fit used repeated position deltas and caused directional drift during repeated resizing.
7. API mismatch in tauri window module:
- runtime used `getCurrentWindow().currentMonitor()` but this API version exposes monitor lookup as
module function (`currentMonitor`), causing `TypeError` and skipping window fit.
8. Scale position math mixed physical window metrics (`outerPosition`/`innerSize`) with logical
set operations (`LogicalSize`/`LogicalPosition`), reintroducing cumulative drift in some DPI
contexts.
9. Ferris background keying needed adaptive key detection; fixed `#FF00FF` assumptions were still
too brittle for packaged atlas variants.
10. Scale-path physical positioning used non-integer coordinates in `setPosition`, triggering
runtime arg errors (`expected i32`) and bypassing window fit updates.
## Fix Plan
@@ -93,6 +106,32 @@ Implemented:
- Made pack reload transactional (keep old renderer until new renderer creation succeeds).
- Improved fit-window flow so scale apply continues after reload retries.
- Added targeted diagnostics for reload failures.
6. `frontend/tauri-ui/src/main.tsx`
- Changed scaling anchor to window center and clamped resized window position within current
monitor bounds.
7. `frontend/tauri-ui/src/renderer/pixi_pet.ts`
- Replaced tolerance-only chroma key with border-connected `#FF00FF` background flood-fill removal
and localized edge halo suppression.
8. `crates/sprimo-tauri/capabilities/default.json`
- Added `core:window:allow-current-monitor` permission for monitor bounds clamping.
9. `frontend/tauri-ui/src/main.tsx`
- switched monitor lookup to module-level `currentMonitor()` with safe fallback so window scaling
still applies even if monitor introspection is unavailable.
10. `frontend/tauri-ui/src/renderer/pixi_pet.ts`
- added fallback global key cleanup when border-connected background detection is too sparse.
11. `frontend/tauri-ui/src/main.tsx`
- moved scale resizing and positioning to physical units (`PhysicalSize`/`PhysicalPosition`) and
monitor selection at window-center point (`monitorFromPoint`).
12. `frontend/tauri-ui/src/renderer/pixi_pet.ts`
- added adaptive border-derived key color selection with fallback key cleanup pass.
13. `scripts/package_windows.py`
- tauri packaging now explicitly rebuilds UI bundle to avoid stale embedded `dist` output.
14. `frontend/tauri-ui/src/main.tsx`
- enforced integer physical positioning and monitor work-area size clamping to prevent set-position
arg failures and large-scale clipping.
15. `frontend/tauri-ui/src/renderer/pixi_pet.ts`
- switched ferris cleanup to hue/saturation/value magenta-band masking with connected background
removal and stronger fallback cleanup.
## Verification
@@ -122,6 +161,14 @@ Implemented:
- `2026-02-14 00:00` - codex - `Fix Implemented` - applied 8x7 generic splitter policy and pack-ID correction.
- `2026-02-14 00:00` - reporter - `In Progress` - reported `issue4-after-fix1` still failing in packaged runtime.
- `2026-02-14 00:00` - codex - `Fix Implemented` - hardened renderer reload/dispose and chroma-key edge cleanup.
- `2026-02-14 00:00` - reporter - `In Progress` - remaining magenta ferris edge + scale drift reported.
- `2026-02-14 00:00` - codex - `Fix Implemented` - switched to border-connected chroma-key removal and center-anchored, monitor-clamped scale fit.
- `2026-02-14 00:00` - reporter - `In Progress` - reported `currentMonitor` TypeError and ferris magenta background still visible.
- `2026-02-14 00:00` - codex - `Fix Implemented` - corrected monitor API call and added fallback chroma cleanup pass.
- `2026-02-14 00:00` - reporter - `In Progress` - reported ferris magenta background still visible and scale drift recurrence.
- `2026-02-14 00:00` - codex - `Fix Implemented` - switched to physical-unit resize math, adaptive key detection, and packaging UI refresh enforcement.
- `2026-02-14 00:00` - reporter - `In Progress` - reported default clipping, ferris background still present, and set_position float arg error.
- `2026-02-14 00:00` - codex - `Fix Implemented` - added integer-safe physical setPosition and HSV magenta cleanup strategy.
## Closure