#584

fix(ui): render Warren surfaces at the display pixel ratio

Openthejustinwalshwants to merge intofrom

A 900×540 Warren window configures a 900×540 GPU attachment on a 2x display, which leaves the native UI blurred when scaled to its 1800×1080 drawable. This keeps layout in logical points and configures the built-in renderer in physical pixels, including clipping and edge antialiasing.

System

Warren selects the display with the largest window overlap and passes its scale to the built-in renderer. Window movement and resizing refresh that choice; a one-second check detects stationary scale changes. pixelRatio accepts a positive, finite number or accessor for an explicit override.

Change

ElementChangeWhy
UI mountTrack display scale and invalidate when it changes.Resize attachments without changing layout, input, or browser anchor coordinates.
Built-in rendererRound logical size × scale and convert physical fragment positions to logical clips; scale antialiasing width.Keep clipping and rounded edges aligned with the attachment.
Cocoa window geometryConvert Y using primary-screen height consistently in getWindowFrame, setWindowPosition, and setWindowFrame, matching getAllDisplays().Window/display overlap requires one global coordinate space, including vertically arranged displays.

Blast radius

Two direct import dependents: uiTagHost.ts consumes UIMountOptions, and ui/index.ts re-exports the window API. The optional renderer scale argument defaults to 1 for direct internal callers. The Cocoa coordinate correction also affects callers of getWindowFrame outside Warren.

Verify

  • From package: bun src/preload/build.ts, then node node_modules/typescript/bin/tsc --noEmit: passed.
  • node scripts/run-bun-test.js src/sdks/main/ui with the pinned Hutch Bun runner: 138 passed, 1 existing Windows-only skip, 0 failed; 1,938 assertions.
  • Compile the actual Cocoa getter/setter functions in an isolated fixture with synthetic vertically offset screens: the prior branch moved a window by 100 points; the corrected position/frame round-trips pass.
  • Rebuild the native runtime and check the built-in Warren UI at 1x/2x, fractional scale, scroll clips, and moves between monitors. Verify Cocoa frame coordinates on a secondary display.

Risks

  • Display selection depends on native window and display geometry using the same coordinate space. The Cocoa correction changes secondary-display Y values for every caller of getWindowFrame.
  • Scale changes resize the GPU attachment. Input and native browser bounds must continue to use logical dimensions.

Evidence

New pure tests cover 900×540 → 1800×1080 at 2x, fractional rounding, invalid scales, off-screen fallback, largest-overlap selection, and vertically arranged display rectangles.

Unknowns

  • Full native rendering and real secondary-monitor behavior have not been rebuilt or exercised on this isolated branch. Cocoa coordinate conversion passed the isolated source fixture above. The earlier combined prototype rendered a custom renderer at 2x; that is not validation of this built-in renderer.
  • Windows/Linux and real mixed-DPI transitions remain untested. No linked issue; #324 concerns WebView2 DPI awareness and #510 concerns Linux nested browser bounds.
Agent context
You are reviewing blackboardsh/electrobun PR #584: https://github.com/blackboardsh/electrobun/pull/584.
A 900×540 Warren window configures a 900×540 GPU attachment on a 2x display, which leaves the native UI blurred when scaled to its 1800×1080 drawable. This keeps layout in logical points and configures the built-in renderer in physical pixels, including clipping and edge antialiasing.
Task: review the isolated change and the adversarial-review corrections against the facts and remaining native-platform limitations.
Facts were collected at the commits below; check each against source before relying on it.
{
  "base": "c54c0c14876455d43a25af0f9cd41a4b14e21854",
  "head": "af7d9d69bc60bba78d2a6bbd1cef30cf93f69bcd",
  "summary": {
    "filesChanged": 6,
    "insertions": 174,
    "deletions": 30,
    "byKind": {
      "docs": 1,
      "source": 4,
      "test": 1
    },
    "elementsChanged": 2,
    "directDependents": 2,
    "exportedSignatureChanges": 2
  },
  "caveats": [
    "no symbol analysis for .mm",
    "dependents are files whose imports resolve to a changed file; calls through dependency injection, reflection, string paths or generated code are not seen",
    "edge status (added/removed) compares only the imports of files in this diff against base, resolved against the head file list",
    "transitive dependents are followed 3 import hops; a file that imports a re-exporting module counts even when it uses other names from it",
    "no CODEOWNERS file; owners are empty"
  ]
}

Review corrections
Cocoa getters and both position/frame setters now share primary-display global coordinates.
Independent adversarial re-review found no remaining P1/P2 issues after these corrections.

Verification
node node_modules/typescript/bin/tsc --noEmit
HUTCH_HOME=/Users/tjw/Developer/agent-deck/.tools/hutch HUTCH_BINARY=/Users/tjw/Developer/agent-deck/.tools/hutch/bin/hutch node scripts/run-bun-test.js src/sdks/main/ui
138 pass, 1 existing skip, 1938 assertions. Actual Cocoa function source fixture passed synthetic screen coordinate round-trips.
Full native runtime rebuild and real multi-monitor/platform execution remain pending; no such coverage is claimed.

Diagram spec
{
  "title": "Warren keeps layout logical and renders physical pixels",
  "type": "component",
  "scope": "native window scale through the built-in Warren renderer",
  "elements": [
    {
      "id": "screen",
      "type": "component",
      "name": "Window and display geometry",
      "technology": "Screen API, Cocoa",
      "description": "Reports rectangles in one logical coordinate space",
      "status": "changed"
    },
    {
      "id": "mount",
      "type": "component",
      "name": "Warren mount",
      "technology": "uiwindow.ts",
      "description": "Chooses and refreshes the display scale",
      "status": "changed"
    },
    {
      "id": "renderer",
      "type": "component",
      "name": "Built-in Warren renderer",
      "technology": "renderer.ts, pixelSize.ts",
      "description": "Scales attachments and converts fragment clips",
      "status": "changed"
    },
    {
      "id": "gpu",
      "type": "component",
      "name": "Native GPU drawable",
      "technology": "Dawn, platform surface",
      "description": "Receives physical attachment dimensions"
    }
  ],
  "relationships": [
    {
      "from": "screen",
      "to": "mount",
      "label": "Supplies logical window bounds and display scales",
      "technology": "FFI, Screen API",
      "status": "changed"
    },
    {
      "from": "mount",
      "to": "renderer",
      "label": "Supplies logical dimensions and pixel ratio",
      "technology": "resize and render arguments",
      "status": "changed"
    },
    {
      "from": "renderer",
      "to": "gpu",
      "label": "Configures rounded physical dimensions and draws",
      "technology": "WebGPU surface and shader",
      "status": "changed"
    }
  ]
}

Full impact facts, lossless gzip+base64
Decoded SHA-256: a5cdcb929bbb4ce7be4cbe41f2c51f2eea3446c1ae67aa72a33a493942cb3167
Decode base64 then gunzip to obtain JSON.
BEGIN_GZIP_BASE64_FACTS
H4sIAAAAAAAAE+1dWXPbOBJ+z69A6WWdKduybDmHvDOzju3MeOMc5WNctZlUCgKbJGISYAGgZG3W/30LIEWRInRGlGVFTzZBHI0P3Y1Go6n+/gyhmiQ+hLjW
Qo1t/djGEmotVCOHTbJHGs1XL180Dw+d5gHeP8TunvuaOM0GbrYbTdhvvDps1kwrH7CjW2H3pfPaefG6TV7stdv45StnH79ot50GAfdgj7ivD1z90klaCcw8
Pdj3ZwilQ1+Cq/vhgnqU1UNMmamaDpG+/fPs+LRf3OXijjLvWoDuycWBhP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151l40nbbN5ZG1QLZH6IOqwCSXA7lmEvAM0pWSbPv5nA076upkXPYe07ifUzJJ3kiZN9jcPg9SOxJ+0ncefS7m
USUUcpTqrTmAe6p6gzKuv/rM18EdwDkXUo1xlGTURJjhoCepRC4XaDfsc3Zuc0VYADKbMOr6XAJKk06iFGqdKBijFCFT8QgRHAQSKV/w2PNRRngPUfYNTPZs
na3XDfr/J6l+UYSVLxEXyAMG2i/gIMIdMBQwrpAc/Eys2dhRwhhoy4Ro1QWEvAPOc6QxwQJkkgpYZxju08zddCqUIeVTndXYdRH2MGVSoTaWsN2fl5MV6w58
wMnkUEAzl0MuLSgaBowHAe+Cgw7SsZHPI3mEcNKJ8rHKiMJIwE6S7lqjEHInDgCZpKFSp0xmSTZjqlAs9aSUDwIZ7ynS4oUy80qv68nH07OPtx/OLq/StUiY
wRAFYaSMU/rLs4dn/we5YIozh5gAAA==
END_GZIP_BASE64_FACTS

Activity

3
thejustinwalsh11d ago

Addressed adversarial review: both Cocoa position/frame setters now use the same global primary-display coordinate conversion as the getter. The actual-function fixture reproduces a 100-point move on the previous code and passes position/frame round-trips after the fix. Warren tests and package typecheck pass; full native/multi-monitor validation is still pending.