feat(documents): reload saves and preserve the reading position #6

Open
opened 2026-10-11 00:50:13 +00:00 by KofTwentyTwo · 5 comments
KofTwentyTwo commented 2026-10-11 00:50:13 +00:00 (Migrated from github.com)

The reference app watches document saves, including write-then-rename replacement, and preserves the relative reading position. The Windows implementation now watches the containing directory with a 350ms debounce, retries brief save windows and reports watcher failures. Earlier hosted acceptance covers replacement/deletion/lock/scroll; verify the current implementation against the owner's explicit live-refresh requirement below.

Implement:

  • Watch the containing directory and debounce changes to the selected path.
  • Handle replacement, rename-away, deletion and recreation without losing the subscription.
  • Retain the last readable snapshot and report missing/unreadable files.
  • Retry brief sharing/missing-file windows during editor saves.
  • Preserve relative scroll when the document's height changes.
  • Dispose subscriptions and ignore stale/closed-window continuations.

Verify native directory events and core viewport validation, then actual browser replacement/deletion/lock/scroll acceptance. Keep authored JavaScript disabled: only fixed application-origin native queries and validated numeric restore arguments are permitted.

This is part of the full application goal #1; it does not complete themes, source/find/navigation, printing or release signing.

Owner requirement - 2026-10-11

An open document must show externally saved changes automatically without a manual reload. If automatic refresh cannot complete, visibly indicate that the displayed snapshot may be stale and offer File → Reload; do not silently leave old content looking current.

Confirm ordinary editor saves, atomic replacement, rapid consecutive saves, brief sharing locks, deletion/recreation and watcher errors. Retain the last readable snapshot on failure and restore scroll/source/find/collapse state when refresh succeeds. The original file must remain untouched. Independent open readers must update the correct document, and closed/replaced readers must ignore stale callbacks.

This request extends the existing #6 rather than creating a duplicate ticket. Current-head live behavior still needs evidence; no new desktop test ran while the owner uses the app.

The reference app watches document saves, including write-then-rename replacement, and preserves the relative reading position. The Windows implementation now watches the containing directory with a 350ms debounce, retries brief save windows and reports watcher failures. Earlier hosted acceptance covers replacement/deletion/lock/scroll; verify the current implementation against the owner's explicit live-refresh requirement below. Implement: - Watch the containing directory and debounce changes to the selected path. - Handle replacement, rename-away, deletion and recreation without losing the subscription. - Retain the last readable snapshot and report missing/unreadable files. - Retry brief sharing/missing-file windows during editor saves. - Preserve relative scroll when the document's height changes. - Dispose subscriptions and ignore stale/closed-window continuations. Verify native directory events and core viewport validation, then actual browser replacement/deletion/lock/scroll acceptance. Keep authored JavaScript disabled: only fixed application-origin native queries and validated numeric restore arguments are permitted. This is part of the full application goal #1; it does not complete themes, source/find/navigation, printing or release signing. ## Owner requirement - 2026-10-11 An open document must show externally saved changes automatically without a manual reload. If automatic refresh cannot complete, visibly indicate that the displayed snapshot may be stale and offer File → Reload; do not silently leave old content looking current. Confirm ordinary editor saves, atomic replacement, rapid consecutive saves, brief sharing locks, deletion/recreation and watcher errors. Retain the last readable snapshot on failure and restore scroll/source/find/collapse state when refresh succeeds. The original file must remain untouched. Independent open readers must update the correct document, and closed/replaced readers must ignore stale callbacks. This request extends the existing #6 rather than creating a duplicate ticket. Current-head live behavior still needs evidence; no new desktop test ran while the owner uses the app.
KofTwentyTwo commented 2026-10-11 01:01:10 +00:00 (Migrated from github.com)

Signed/DCO commit 09d14e6b78 is pushed in draft PR #3.

Automatic reload now uses a debounced containing-directory subscription, handles replacement/rename/deletion/recreation, retains the last readable snapshot, and retries brief editor locks. Relative scroll preservation matches the reference's behavior when document height changes. Core scheduling keeps picker selections and coalesces save notifications.

Local proof: zero-warning build; 82 core tests at 100% measured line coverage; 12 real native file/watcher tests; formatting/docs/hooks pass. New browser save/recovery/lock/scroll/network tests await exact-head hosted results. No local GUI input run or screenshot is claimed.

Previous reader f1756d2 fully passed hosted CI including 13 native/UI tests and both installed update channels; CodeQL/security also passed. PSScriptAnalyzer engine crash remains open in #5. Keep #4/#6 open pending their new browser scenarios; full scope in #1 remains unfinished. No failed run restarted, no merge or release published.

Signed/DCO commit 09d14e6b78ee9abff3f44a035f8fd7bded15a578 is pushed in draft PR #3. Automatic reload now uses a debounced containing-directory subscription, handles replacement/rename/deletion/recreation, retains the last readable snapshot, and retries brief editor locks. Relative scroll preservation matches the reference's behavior when document height changes. Core scheduling keeps picker selections and coalesces save notifications. Local proof: zero-warning build; 82 core tests at 100% measured line coverage; 12 real native file/watcher tests; formatting/docs/hooks pass. New browser save/recovery/lock/scroll/network tests await exact-head hosted results. No local GUI input run or screenshot is claimed. Previous reader f1756d2 fully passed hosted CI including 13 native/UI tests and both installed update channels; CodeQL/security also passed. PSScriptAnalyzer engine crash remains open in #5. Keep #4/#6 open pending their new browser scenarios; full scope in #1 remains unfinished. No failed run restarted, no merge or release published.
KofTwentyTwo commented 2026-10-11 01:30:27 +00:00 (Migrated from github.com)

Deletion diagnostics proved the expected FileNotFoundException (0x80070002) on the UI thread, while the status lookup failed. Explicit automation properties alone did not resolve it. Terminal diagnostic CI 38101512710 retained a screenshot showing the fixed-size window extending beyond the hosted desktop and clipping the status line. The assertions were preserved throughout.

Signed/pushed fa0df78 now clamps initial size/position and minimum dimensions to the actual DPI-scaled monitor work area. Exact-head CI 38101906688 is running. Replacement-save, editor-lock, relative-scroll and remote-image tests previously passed; deletion/recovery remains pending the corrected hosted window test. Evidence is preserved locally under artifacts/status-layout-38101512710 and in that run's installed-update-results artifact.

Deletion diagnostics proved the expected FileNotFoundException (0x80070002) on the UI thread, while the status lookup failed. Explicit automation properties alone did not resolve it. Terminal diagnostic CI 38101512710 retained a screenshot showing the fixed-size window extending beyond the hosted desktop and clipping the status line. The assertions were preserved throughout. Signed/pushed fa0df78 now clamps initial size/position and minimum dimensions to the actual DPI-scaled monitor work area. Exact-head CI 38101906688 is running. Replacement-save, editor-lock, relative-scroll and remote-image tests previously passed; deletion/recovery remains pending the corrected hosted window test. Evidence is preserved locally under artifacts/status-layout-38101512710 and in that run's installed-update-results artifact.
KofTwentyTwo commented 2026-10-11 01:34:45 +00:00 (Migrated from github.com)

Fitted head fa0df78 completed with 25/26 UI tests passed; its document-theme choice passed. The retained screenshot now clearly shows the status line inside the window, so clipping was corrected but did not resolve the automation lookup. A diagnostic property read also threw on the browser peer's unsupported IsOffscreen property; it now uses ValueOrDefault.

Signed/pushed 77dd04d declares the native status peer before the embedded browser, without changing Grid.Row or the visual layout. Original initial/missing-status/recovery assertions remain intact. Theme acceptance now also waits for actual painted Catppuccin-dark and GitHub-Light backgrounds and retains a fixture screenshot. Exact current CI 38102249889 is running; CodeQL 38102249846, security 38102249838 and scripts 38102249407 are also the handles to follow. No failed run was restarted.

Fitted head fa0df78 completed with 25/26 UI tests passed; its document-theme choice passed. The retained screenshot now clearly shows the status line inside the window, so clipping was corrected but did not resolve the automation lookup. A diagnostic property read also threw on the browser peer's unsupported IsOffscreen property; it now uses ValueOrDefault. Signed/pushed 77dd04d declares the native status peer before the embedded browser, without changing Grid.Row or the visual layout. Original initial/missing-status/recovery assertions remain intact. Theme acceptance now also waits for actual painted Catppuccin-dark and GitHub-Light backgrounds and retains a fixture screenshot. Exact current CI 38102249889 is running; CodeQL 38102249846, security 38102249838 and scripts 38102249407 are also the handles to follow. No failed run was restarted.
KofTwentyTwo commented 2026-10-11 02:15:14 +00:00 (Migrated from github.com)

Scoped live-reload acceptance passed on signed 77dd04d: CI 38102249889 SUCCESS, including actual replacement saves, temporary editor locks, deletion/last-readable-snapshot/recreation and relative scrolling. Exact missing/recovery assertions were preserved; declaring the native status before the embedded browser peer resolved UIA traversal. Published 26/26 and installed stable/dev 25/25 each passed without skips.

AppKit fixture updates applied/restarted within both channels, with exact payload-byte gates. Retained evidence: artifacts/verified-reader-38102249889. This issue's acceptance is complete for reviewed merge; the complete port and signed production release remain open in #1.

Scoped live-reload acceptance passed on signed 77dd04d: [CI 38102249889](https://github.com/KofTwentyTwo/MarkdownViewr.Windows/actions/runs/38102249889) SUCCESS, including actual replacement saves, temporary editor locks, deletion/last-readable-snapshot/recreation and relative scrolling. Exact missing/recovery assertions were preserved; declaring the native status before the embedded browser peer resolved UIA traversal. Published 26/26 and installed stable/dev 25/25 each passed without skips. AppKit fixture updates applied/restarted within both channels, with exact payload-byte gates. Retained evidence: artifacts/verified-reader-38102249889. This issue's acceptance is complete for reviewed merge; the complete port and signed production release remain open in #1.
KofTwentyTwo commented 2026-10-11 12:59:18 +00:00 (Migrated from github.com)

Fresh current-worktree native filesystem verification passes6/6 (ordinary save, atomic replacement, deletion/recreation, rename-away/back, unrelated-file filtering, disposal). These tests launch no app and use no desktop input. Failed reload now explicitly identifies the retained previous view and offers File → Reload; existing missing-file recovery text remains. A new actual prolonged editor-lock/stale-status/automatic-recovery acceptance case compiles; it has not run. Total prepared suite is now70 native/published,69 per installed channel. Earlier hosted scroll/replace/PDF proof remains historical; current-head user-visible behavior still needs acceptance.

Fresh current-worktree native filesystem verification passes6/6 (ordinary save, atomic replacement, deletion/recreation, rename-away/back, unrelated-file filtering, disposal). These tests launch no app and use no desktop input. Failed reload now explicitly identifies the retained previous view and offers File → Reload; existing missing-file recovery text remains. A new actual prolonged editor-lock/stale-status/automatic-recovery acceptance case compiles; it has not run. Total prepared suite is now70 native/published,69 per installed channel. Earlier hosted scroll/replace/PDF proof remains historical; current-head user-visible behavior still needs acceptance.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: KofTwentyTwo/MarkdownViewr.Windows#6