Repository navigation
Keep Range endpoints owned by the creating document during Monaco layout #863
Description
Activity
- addedbugSomething isn't workingSomething isn't workingvscode-oss/plannedPlanned for the AppScene/WebScene VS Code OSS integrationPlanned for the AppScene/WebScene VS Code OSS integration
on Sep 20, 2026 Exact-package follow-up (2026-09-20)
The first fix in #866 correctly binds
Document.createRange()to the receiver document and its focused cross-realm test passes. The exact Release package built from AppScene52c3f302e3eb7cf3863da6f4d6b5338e5fd76853, WebScenee9e53c4edbcbab8c4d81f0c85491aa519ce7f077, and unchanged Code OSS645f29cc3176500b4b5762ba887cf2a7f0ffdf2cstill reportsWrongDocumentErrorfrom Monaco_detachRange()/selectNodeContents().The package trace narrows the remaining case: WebScene tests Range membership by walking
parentlinks to the document root. Monaco measures a node after detaching it, so connectivity is not document ownership. A detached node retains itsownerDocumentin browsers and must remain selectable by a Range from that document.Follow-up implementation:
- retain document identity for nodes independently of current tree connectivity;
- bind nodes created by top-level, iframe, and detached
Documentreceivers to the receiver document; - preserve identity while removing/reinserting a subtree and update it only for explicit adoption/import behavior;
- use document identity for Range validation while continuing to reject nodes owned by a different document;
- cover Monaco's connected → detached →
selectNodeContents()→ reinsert sequence and detached iframe/document cases.
Exact evidence retained at
artifacts/smoke-52c3f30-e9e53c4/native-smoke.jsonin the integration checkout. The same run proves extension iframe bootstrap, MessagePort transfer, Ready, and Initialized now succeed.Exact-package confirmation — 20 September 2026
Release package inputs: AppScene
52c3f302e3eb7cf3863da6f4d6b5338e5fd76853, WebScenec356c5a3eda915cd114d444ca3dccaaa02c65816, unchanged Code OSS645f29cc3176500b4b5762ba887cf2a7f0ffdf2c.The unchanged Monaco edit/render/Worker/undo path now completes with zero
WrongDocumentErrordiagnostics. The same run proves editor Worker construction/request/reply and extension iframe/MessagePort Ready/Initialized. This confirms merged #869 fixes the never-connecteddocument.createElement('div')Range endpoint used by Monaco while retaining cross-document rejection.Retained local evidence:
artifacts/smoke-52c3f30-c356c5a/native-smoke.jsonandnative-stderr.log.
Parent: #227
Release owner: SceneTech/AppScene#130
Related acceptance: #259
Reproduction
The exact packaged Code OSS release built from AppScene
15e30dedcaa7c6a0242c1929a8c8d6e47a1cc600, WebScene5b97aac934dee450ec2b01291a004b246dc08364, and unchanged Code OSS645f29cc3176500b4b5762ba887cf2a7f0ffdf2creaches the workbench, renders a real editor edit, and completes an editor-worker request/reply. During Monaco layout it repeatedly reports:The failure is distinct from the browser extension-host MessagePort blocker in #81. It happens while Monaco reuses a DOM
Rangeto measure visible text after document/realm activity.Investigation
WebScene has focused Range boundary contracts, but current acceptance does not cover moving or reusing a Range when its endpoints come from different documents or after a document replacement. The exception proves that a Range object and at least one selected node have diverged in document ownership. The implementation must preserve browser-compatible ownership and atomic failure semantics without retaining replaced documents.
Proposed fix
getClientRects()cannot observe partially updated endpoints.Gates
setStart,setEnd,selectNode,selectNodeContents, detach/reuse, adoption, and document replacement._detachRange/_readClientRectssequence.WrongDocumentError, stable editor geometry, and Chromium/AppScene visual comparison.Acceptance
WrongDocumentErrorin the unchanged package.