Skip to content

Qualify VS Code file edit, save, revert, and hot-exit recovery #269

Open
4 of 4 issues completed
Open

Description

@wieslawsoltes

Current save/recovery checkpoint — 21 September 2026

Exact heads are unchanged Code OSS 645f29cc, WebScene d3c030fa, and AppScene 080ee9c. Local vscode-demo commit 25bbdc92 is intentionally unpushed with Actions disabled.

The successful remote file lifecycle now passes edit, Save, Save All, delayed Auto Save, Revert, close, and reopen. Save All persists exact replacement bytes for dirty README.md and unicodé.txt models and clears both dirty states in 1,788.90 ms. Resource-scoped in-memory configuration reports effective files.autoSave=afterDelay and files.autoSaveDelay=100; the real working-copy scheduler persists exact bytes and clears dirty state in 1,896.13 ms. Both fixtures are restored exactly. Earlier Save/Revert/close/reopen evidence remains valid.

The initial explicit Auto Save probe used a global memory update, but resource-effective configuration remained off with the default 1,000 ms delay. Passing the remote resource to IConfigurationService.updateValue corrected the gate. No WebScene or AppScene defect appeared in this successful lifecycle slice. Source contract tests pass 25/25 on Node 24.18.1. Evidence: vscode-demo/docs/validation/remote-save-revert-d3c030fa-20260921.md.

Remaining #269 work is canceled/error Auto Save outcomes, remote/native Save As, overwrite/cancel/error/conflict injection, watcher/model reconciliation, encoding and large-file fixtures, working-copy backup, crash/hot-exit recovery, visual/accessibility comparison, and repeated resource/performance bounds.

Parent epic: SceneTech/AppScene#122
Workspace/provider prerequisite: #252
Navigation prerequisite: SceneTech/AppScene#124
Native/local picker stack: SceneTech/AppScene#123 → #248
Release-wide acceptance: #260

Problem

Opening a selected folder and rendering Explorer does not prove that unchanged VS Code OSS can maintain file models safely. The current focused hierarchy has no owner for the complete remote editor lifecycle: open bytes, dirty state, Save, Save As, revert, conflict handling, backups/hot exit, and recovery after reload, navigation, crash, or restart.

The broad AppScene storage issue #33 proves durable browser storage for a typed record, and AppScene #32 covers app-corpus file transfer. Neither proves VS Code's text-file model, remote file-service writes, backup metadata, overwrite/error UX, or watcher/model reconciliation.

Investigation

Trace unchanged VS Code 1.137 from Explorer/file activation through ITextFileService, model creation, encoding/EOL detection, dirty-state transitions, IFileService read/write/stat, backup working copies, dialogs, and final watcher refresh. Record the exact reusable WebScene/AppScene contract at the first failure; keep raw paths limited to isolated fixtures.

Cover:

  • existing remote file open, edit, Save, Save All, Auto Save, Save As, revert, close-dirty prompt, and working-copy backup;
  • untitled-to-file, read-only, permission denied, missing/deleted, renamed, externally modified, stale etag, symlink, disk-full/short-write, disconnect/reconnect, and canceled overwrite flows;
  • UTF-8/BOM/UTF-16, EOL preservation, Unicode normalization, empty/binary/large/sparse files, long names, percent-encoded URI components, case-sensitive roots, and platform path separators;
  • atomic create/replace semantics, flush/durability expectations, no partial target on failure, own-write watcher de-duplication, and exact-once dirty/model/view updates;
  • backup/hot-exit restoration across reload, folder A → B → A, same-window navigation, host termination, crash recovery, profile restart, and unavailable original paths;
  • language-service/diagnostic/SCM/Search state after save, revert, rename, and recovery.

Ownership boundaries

Acceptance

  • Opening a remote fixture yields byte-exact editor content, encoding, EOL, language mode, resource URI, and one model.
  • Edit → Save → close → reopen preserves bytes and clears dirty state exactly once; Save All and Auto Save have explicit successful/canceled/error outcomes.
  • Remote and native/local Save As preserve the selected URI, requested target, overwrite policy, and grant lifetime without a VS Code source patch.
  • Revert and external-change conflicts match Chromium semantics and never silently discard unsaved bytes.
  • Failed, canceled, denied, stale, short, or disconnected writes leave the prior durable file intact and expose the correct recoverable error/focus state.
  • Hot exit restores every dirty working copy and untitled resource after reload/crash/restart, including multi-root workspaces; successful save removes obsolete backups.
  • Watcher events caused by the app and externally are reconciled once without duplicate models, prompts, Explorer rows, SCM entries, or diagnostics.
  • Path/URI, Unicode, symlink, encoding, large-file, and platform-separator fixtures pass with explicit supported/unsupported declarations.
  • Chromium/AppScene semantic, visual, focus, and accessibility comparisons pass for dirty tabs, prompts, conflicts, errors, and recovery.
  • Record cold/warm p50/p95 for open-to-editor, edit-to-dirty, save, revert, backup, and restore. Bound copied bytes, filesystem calls, DOM/scene publications, CPU, RSS, models, backups, watches, and handles over 100 cycles and representative large files.
  • WPT-derived file/stream/storage contracts, native failure-injection tests, unchanged packaged Code OSS acceptance, and final installed-SDK release gates pass.

Proposed PR stack

  1. Investigation-only correlated observer and product-neutral file-model/read/write fixture.
  2. Smallest provider/stream/write/error contract fix, if reproduced, with direct failure-injection and byte-integrity gates.
  3. Backup/hot-exit/restart contract over the durable storage primitives from AppScene [GPU 11/20] Complete WebGPU async errors, mapping, copies and device-loss semantics #33.
  4. Native/local Save As integration after AppScene Support nested CSS rules in modal layouts #123 and Implement File System Access pickers and handles over AppScene native panels #248, preserving the same file-model gates.
  5. Unchanged Code OSS cumulative acceptance plus visual/accessibility/performance/lifecycle gates; release qualification remains AppScene Keep captured Performance methods on one timeline #130.

Schedule

Start the remote open/edit/save slice after #247 and the minimal #252 provider/root path are proven. Run backup/recovery investigation in parallel with AppScene #33's released-SDK cleanup. Add native/local Save As only after the #123 → #248 stack. Merge focused reusable fixes before cumulative product acceptance.

Sub-issues

Sub-issues

4 of 4 Issues completed
Loading 4 sub-issues

Activity

  1. added
    vscode-oss/planned
    on Sep 17, 2026
  2. wieslawsoltes commented on Sep 18, 2026

    @wieslawsoltes
    CollaboratorAuthor

    The first concrete file-model prerequisite found by the unchanged VS Code audit is now implemented: #441 merged as WebScene 622a955c512dbf1853a042effe6a5b41cad53052.

    VS Code routes local file watches through HTMLFileSystemProvider.watch() and FileSystemObserver. Before this merge WebScene had no FileSystemObserver, so local watches were silently disabled. The new opaque-handle observer supplies appeared/disappeared/modified/errored records, recursive relative components, non-overlapping bounded polling, and unobserve/disconnect/document-lifecycle cleanup. This unblocks external-edit/conflict and post-save reconciliation without a VS Code source change.

    Validation was intentionally skipped under the current implementation-only priority. #438 retains the exact browser/native/performance/lifecycle/product debt. #269 remains open for unchanged-product open/edit/save/revert/Save As, own-write de-duplication, dirty conflict UX, IndexedDB backup/hot-exit recovery, reload/crash/restart, encoding/error cases, and resource bounds.

  3. wieslawsoltes commented on Sep 18, 2026

    @wieslawsoltes
    CollaboratorAuthor

    Post-#441 hot-exit ownership trace — no second implementation

    A source-level trace of unchanged VS Code 1.137 does not prove another reusable runtime primitive is missing after the watcher merge.

    • BrowserWorkingCopyBackupService always roots browser backups at vscode-userdata:/Backups/<workspace-id>.
    • web.main.ts registers vscode-userdata through IndexedDBFileSystemProvider backed by the durable vscode-web-db / vscode-userdata-store database. WebScene PR Add durable IndexedDB storage for Code OSS browser profiles #94 already owns and implements durable, partitioned IndexedDB across engine/process restart.
    • BrowserWorkingCopyBackupTracker schedules backups while the page is live and synchronously vetoes final shutdown when a modified working copy lacks the current content-version backup. It does not require an async native shutdown write.
    • BrowserLifecycleService consumes beforeunload for the veto and pagehide for terminal notification. WebScene already implements both native/script close paths with one terminal pagehide.
    • IndexedDBFileSystemProvider uses BroadcastDataChannel only when watchCrossWindowChanges is enabled to publish live provider change notifications. If BroadcastChannel is absent, VS Code falls back to storage events. Neither route writes or restores backup bytes, and the current AppScene package has one workbench document/window for this scenario.

    Therefore a realm-local BroadcastChannel shim or new AppScene persistence ABI would be speculative and would not prove cross-window/process semantics. No code or new issue is justified until unchanged-product tracing shows a failed backup write/load/restore, content-version veto, lifecycle event, or an actual second-window invalidation requirement.

    Remaining #269 work is product evidence: dirty saved and untitled backup creation, IndexedDB durable bytes/metadata, current-version veto, reload/navigation/host termination/crash/restart restoration, successful-save cleanup, corruption/quota/unavailable-original handling, and only then a focused fix at the earliest observed failing boundary. Validation remains skipped under the current implementation-only priority.

  4. wieslawsoltes commented on Sep 19, 2026

    @wieslawsoltes
    CollaboratorAuthor

    Implementation-first re-audit at WebScene 9f2d4830 confirms the generic recovery prerequisites are present: bounded FileSystemObserver (#441), durable partitioned IndexedDB, persisted opaque handles, and exact-once close lifecycle. The latest owner trace requires an actual failing unchanged-product backup/restore/save/corruption/quota case before another runtime change; realm-local BroadcastChannel would be speculative. Remaining work is package acceptance. No code or runtime validation was run; git diff --check passed.

  5. wieslawsoltes commented on Sep 20, 2026

    @wieslawsoltes
    CollaboratorAuthor

    2026-09-20 checkpoint: top-level storage flush blocker fixed in #874

    The current Code OSS release acceptance isolated a concrete hot-exit/storage failure:

    • the unchanged MCP registry saves workspace-scoped mcpInputs from IStorageService.onWillSaveState;
    • its secret provider persisted the encrypted key immediately;
    • WebScene emitted WEBSCENE_HOST_REQUEST_WINDOW_RELOAD_V1 without beforeunload or pagehide;
    • after realm replacement the key survived, but MCP input metadata was absent, so editSavedInput() dereferenced a missing entry.

    PR #874 makes reload and same-origin top-level navigation reuse the existing bounded close-decision lifecycle before host handoff. It includes cancellation, exact event-shape, and focused performance-lane coverage. The Release V8 focused gate passed locally.

    This resolves the diagnosed top-level lifecycle sub-blocker. The broader edit/save/revert/hot-exit acceptance in this issue remains scheduled after the current runtime is repackaged into the Code OSS release.

  6. wieslawsoltes commented on Sep 20, 2026

    @wieslawsoltes
    CollaboratorAuthor

    2026-09-20 exact-package checkpoint: concurrent IndexedDB commit blocker

    The exact Release package built from AppScene cd0a02e and WebScene 98077f23 proves that #874 now dispatches beforeunload and pagehide on both reload transitions. The first MCP password entry succeeds and the encrypted secret key persists. The reopened workbench still cannot edit the saved input because workspace-scoped mcpInputs was not committed.

    Retained evidence identifies the next boundary before navigation:

    • WebScene reports CodeExpectedError: IndexedDB database changed before this transaction committed about 204 ms before the first beforeunload;
    • VS Code creates overlapping readwrite transactions in its IndexedDB storage layer;
    • WebScene's compatibility layer begins each transaction from the same database revision and lets their native commits race;
    • it retries conflicts only four times, so normal overlapping VS Code writes can exhaust the retry limit and abort one transaction;
    • Flush lifecycle before top-level navigation #874 correctly emits the lifecycle after this earlier transaction has already failed.

    I am implementing database-scoped read/write commit serialization in WebScene's reusable IndexedDB compatibility layer. This preserves async transaction behavior, replays mutations on the latest committed revision, and removes the arbitrary conflict race for one runtime while retaining native optimistic concurrency for separate processes. A focused concurrent-transaction regression will cover more than the old four-retry limit. The broader #269 acceptance remains open after this focused fix.

  7. wieslawsoltes commented on Sep 20, 2026

    @wieslawsoltes
    CollaboratorAuthor

    2026-09-20 checkpoint: lifecycle task-boundary fix merged

    The exact AppScene cd0a02e / WebScene f5df884a package confirmed #875 removed the IndexedDB conflict, then isolated the remaining missing mcpInputs record to navigation task ordering: unchanged VS Code schedules its storage commit from onWillSaveState with a zero-delay task, while WebScene made the native reload request visible immediately after beforeunload/pagehide. AppScene could retire the realm before that task ran.

    #876 tracked the focused defect. PR #877 is merged at a7943723. WebScene now reserves bounded host-request capacity, drains timers queued through lifecycle microtask checkpoints, and publishes terminal navigation/reload from a later browser task. Recursive navigation coalesces, veto/error/teardown release ownership, and timers created later cannot starve navigation.

    The focused Release V8 gate passed. It covers listener and Promise-microtask timers, reload/navigation ordering, veto behavior, exact-once lifecycle, and 1,000 ordered terminal requests in 0.0058 seconds. The next gate is an exact SDK/package rebuild and the unchanged Code OSS two-navigation MCP persistence smoke; this parent stays open until that product acceptance passes.

  8. wieslawsoltes commented on Sep 20, 2026

    @wieslawsoltes
    CollaboratorAuthor

    2026-09-21 checkpoint: lifecycle-descended IndexedDB persistence merged

    The exact AppScene cd0a02e / WebScene a7943723 Release package confirmed that the first lifecycle task boundary from #877 was still too shallow: VS Code enters its workspace IndexedDB transaction from that task, then completes native load/store work and Promise continuations asynchronously. AppScene could receive reload before that lineage became durable.

    #878 captured the isolated runtime contract. PR #879 is merged at a39280e4.

    WebScene now:

    • tags bounded zero-delay work descended from terminal lifecycle listeners;
    • propagates the tag through native IndexedDB operations and their Promise continuations;
    • keeps reload/navigation private until that persistence lineage drains;
    • excludes intervals, delayed timers, animation frames, pre-existing work, and unrelated IndexedDB operations;
    • caps the lineage at 1,024 tasks so a self-refilling timer cannot starve handoff.

    The focused durable restart gate passed in 0.0036 seconds and proved the record is readable from a fresh engine and port before host handoff. The related 1,000-request navigation gate passed in 0.0044 seconds. Superseded branch CI was canceled after the related local Release gates passed under the agreed fast-merge policy.

    Next: rebuild the exact AppScene/WebScene SDK and unchanged Code OSS Release, then repeat the two-realm MCP persistence smoke. This parent remains open until that installed-package acceptance passes.

  9. wieslawsoltes commented on Sep 20, 2026

    @wieslawsoltes
    CollaboratorAuthor

    Exact-product checkpoint: pagehide cancellation boundary fixed

    The AppScene cd0a02e / WebScene a39280e4 Release with PR #879 still failed the real MCP reopen path. The new in-product probe and a preserved copy of the transient native database proved the failure was before IndexedDB:

    • reopened IMcpRegistry.getSavedInputs(StorageScope.WORKSPACE) returned [];
    • the .wsidb inventory contained no mcpInputs record;
    • VS Code schedules flush(0) from beforeunload, then its synchronous pagehide teardown cancels that timer.

    Issue #880 and merged PR #881 (ba71aa1b) now split this terminal lifecycle at the existing bounded persistence boundary. The focused regression models the cancellation and requires beforeunload,flush-timer,commit,continuation,pagehide before reload publication; durable restart and the 1,024-task starvation bound pass in 1.21 seconds.

    The exact AppScene SDK/package rebuild and unchanged Code OSS MCP reopen smoke are now running against ba71aa1b.

  10. wieslawsoltes commented on Sep 20, 2026

    @wieslawsoltes
    CollaboratorAuthor

    Exact AppScene cd0a02e / WebScene ba71aa1b retest completed. #881 fixed the direct beforeunload timer/pagehide ordering case, but the unchanged VS Code IndexedDB compatibility transaction still loses mcpInputs: mcpStoredInputKeys=[], mcpStoredInputPresent=false, while the independent native storage round trip remains true. Opened and scheduled #882 with the exact nested transaction lineage and package acceptance requirements. Package executable SHA-256: 6b44ef80282a6f491ba974318ed84fb8c637b6a4d2245f241a4412e7f9b787a4; failure duration 28.803 s.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    vscode-oss/planned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions