From e152616d7f5194e92130f42d8e537b92039d09bb Mon Sep 17 00:00:00 2001 From: omigamedev Date: Wed, 3 Jun 2026 05:08:00 +0200 Subject: [PATCH] Route live reload policy through platform services --- docs/modernization/build-inventory.md | 3 ++- docs/modernization/debt.md | 2 +- docs/modernization/roadmap.md | 12 ++++++--- src/app.cpp | 25 ++++++++++--------- src/app.h | 1 + src/app_events.cpp | 5 ++++ src/platform_api/platform_services.h | 1 + .../legacy_platform_services.cpp | 9 +++++++ .../windows_platform_services.cpp | 5 ++++ .../platform_api/platform_services_tests.cpp | 21 ++++++++++++++++ 10 files changed, 66 insertions(+), 18 deletions(-) diff --git a/docs/modernization/build-inventory.md b/docs/modernization/build-inventory.md index b4166a5..d666483 100644 --- a/docs/modernization/build-inventory.md +++ b/docs/modernization/build-inventory.md @@ -449,7 +449,8 @@ Known local toolchain state: virtual-keyboard visibility, external file display, file sharing, native app/window close, UI-thread lifecycle hooks, render-context lifecycle hooks, render-capture frame hooks, per-frame platform hooks, picker callbacks, and - recording cleanup, prepared-file save/download handoff; + recording cleanup, live asset/layout reload policy, prepared-file + save/download handoff; Windows live app execution now uses injected `WindowsPlatformServices` from diff --git a/docs/modernization/debt.md b/docs/modernization/debt.md index 92b58a7..98aa8d1 100644 --- a/docs/modernization/debt.md +++ b/docs/modernization/debt.md @@ -35,7 +35,7 @@ agent or engineer to remove them without reconstructing context from chat. | DEBT-0014 | Open | Modernization | `windows-clangcl-asan` now configures as a headless Ninja/clang-cl preset and uses the release MSVC runtime required by ASan, but local builds still fail because installed clang-cl 18.1.8 is paired with VS 2026-preview STL headers that require Clang 20 or newer | Sanitizer validation should be local and repeatable, but this machine's compiler/header pairing is incompatible | `cmake --fresh --preset windows-clangcl-asan`; `cmake --build --preset windows-clangcl-asan --target pp_foundation` | Install/use Clang 20+ with the VS 2026 STL, or point the preset at a compatible VS 2022 toolchain, then make `platform-build.ps1 -Presets windows-clangcl-asan` pass for the headless matrix | | DEBT-0015 | Open | Modernization | Cursor visibility requests now consume pure `pp_app_core` planning through `pano_cli plan-cursor-visibility`, `App::show_cursor`/`App::hide_cursor` dispatch through `PlatformServices` without platform guards, and Windows live execution uses injected `WindowsPlatformServices`, but macOS cursor execution still reaches the retained fallback adapter | Keep canvas cursor behavior stable while platform shells are extracted incrementally | `pp_app_core_document_platform_io_tests`; `pano_cli plan-cursor-visibility --visible`; `ctest --preset desktop-fast --build-config Debug` | Cursor visibility execution is owned by injected `pp_platform_*` services for every supported platform | | DEBT-0016 | Open | Modernization | Clipboard get/set requests now consume pure `pp_app_core` planning through `pano_cli plan-clipboard-read` and `pano_cli plan-clipboard-write`, and Windows live execution uses injected `WindowsPlatformServices`, but Apple/Android clipboard execution still reaches retained fallback adapter branches from `App::clipboard_get_text` and `App::clipboard_set_text` | Keep picker/color text clipboard behavior stable while platform shells are extracted incrementally | `pp_app_core_document_platform_io_tests`; `pano_cli plan-clipboard-write --text #ff00aa`; `ctest --preset desktop-fast --build-config Debug` | Clipboard execution is owned by injected `pp_platform_*` services for every supported platform | -| DEBT-0017 | Open | Modernization | Startup storage path preparation, `App::clipboard_get_text`, `App::clipboard_set_text`, `App::show_cursor`, `App::hide_cursor`, `App::showKeyboard`, `App::hideKeyboard`, `App::display_file`, `App::share_file`, native app/window close, UI-thread lifecycle hooks, render-context acquire/release/present hooks, render-capture frame hooks, recording cleanup, per-frame platform hooks, `App::pick_image`, `App::pick_file`, the non-writer `App::pick_file_save`, `App::pick_dir`, and prepared-file save/download handoff now call the SDK-free `pp::platform::PlatformServices` interface, and Windows injects `WindowsPlatformServices` from `src/platform_windows/windows_platform_services.*`; non-Windows live implementations still use `src/platform_legacy/legacy_platform_services.*`, a named fallback adapter that forwards to retained Apple/Android/Linux/Web bridge functions and retained no-op branches | Preserve behavior while moving platform execution behind a testable service boundary before platform shell implementations are injected | `pp_platform_api_tests`; `pp_app_core_document_platform_io_tests`; `ctest --preset desktop-fast --build-config Debug`; `powershell -ExecutionPolicy Bypass -File scripts\automation\package-smoke.ps1 -Preset windows-msvc-default -Configuration Debug` | Replace `src/platform_legacy/legacy_platform_services.*` with injected `pp_platform_*` service implementations owned by each non-Windows platform shell | +| DEBT-0017 | Open | Modernization | Startup storage path preparation, `App::clipboard_get_text`, `App::clipboard_set_text`, `App::show_cursor`, `App::hide_cursor`, `App::showKeyboard`, `App::hideKeyboard`, `App::display_file`, `App::share_file`, native app/window close, UI-thread lifecycle hooks, render-context acquire/release/present hooks, render-capture frame hooks, recording cleanup, live asset/layout reload policy, per-frame platform hooks, `App::pick_image`, `App::pick_file`, the non-writer `App::pick_file_save`, `App::pick_dir`, and prepared-file save/download handoff now call the SDK-free `pp::platform::PlatformServices` interface, and Windows injects `WindowsPlatformServices` from `src/platform_windows/windows_platform_services.*`; non-Windows live implementations still use `src/platform_legacy/legacy_platform_services.*`, a named fallback adapter that forwards to retained Apple/Android/Linux/Web bridge functions and retained no-op branches | Preserve behavior while moving platform execution behind a testable service boundary before platform shell implementations are injected | `pp_platform_api_tests`; `pp_app_core_document_platform_io_tests`; `ctest --preset desktop-fast --build-config Debug`; `powershell -ExecutionPolicy Bypass -File scripts\automation\package-smoke.ps1 -Preset windows-msvc-default -Configuration Debug` | Replace `src/platform_legacy/legacy_platform_services.*` with injected `pp_platform_*` service implementations owned by each non-Windows platform shell | ## Closed Debt diff --git a/docs/modernization/roadmap.md b/docs/modernization/roadmap.md index 2d8ce36..26eb236 100644 --- a/docs/modernization/roadmap.md +++ b/docs/modernization/roadmap.md @@ -472,8 +472,8 @@ before retained platform clipboard bridges continue. startup storage path preparation, clipboard text, cursor visibility, virtual-keyboard visibility, UI-thread lifecycle hooks, render-context acquire/release/present hooks, render-capture frame hooks, external file -display, file sharing, recording file cleanup, image/file/save-file pickers, -and directory pickers. +display, file sharing, recording file cleanup, live asset/layout reload policy, +image/file/save-file pickers, and directory pickers. Windows installs an injected `WindowsPlatformServices` implementation from `src/platform_windows/windows_platform_services.*` in `pp_platform_windows`; other platforms still route through the debt-tracked legacy fallback adapter @@ -513,6 +513,9 @@ Recording clear now asks `PlatformServices` whether the platform owns recorded file deletion and dispatches the cleanup through the service, preserving the current Apple recorded-frame cleanup while removing Apple-specific file cleanup guards from `App::rec_clear`. +The UI loop now asks `PlatformServices` whether live shader/layout reloading +should run, preserving the previous Windows/macOS reload behavior while removing +the direct `(_WIN32 || __OSX__)` guard from `App::ui_thread_main`. `pano_cli plan-cloud-upload` exposes the app-core cloud upload decision used by the live cloud upload command for missing-canvas, new-document warning, publish prompt, and dirty-document save-before-upload states before legacy UI, canvas, @@ -1029,8 +1032,9 @@ Results: dispatch, external file display dispatch, file sharing dispatch, native app/window close dispatch, UI-thread lifecycle dispatch, render-context lifecycle dispatch, render-capture frame hook dispatch, recording cleanup - dispatch, per-frame platform hook dispatch, picker callback dispatch, and - prepared-file save/download callback dispatch. The live Windows app now + dispatch, live asset/layout reload policy dispatch, per-frame platform hook + dispatch, picker callback dispatch, and prepared-file save/download callback + dispatch. The live Windows app now consumes this interface through an injected `WindowsPlatformServices` instance isolated in `src/platform_windows/windows_platform_services.*`; other platforms still diff --git a/src/app.cpp b/src/app.cpp index d187f6b..fed8f94 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -1014,22 +1014,23 @@ void App::ui_thread_main() rendered_frames = 0; } -#if /*_DEBUG &&*/ (_WIN32 || __OSX__) - t_reloader += dt; - if (t_reloader > 1.0) + if (platform_enables_live_asset_reloading()) { - t_reloader = 0; - if (ShaderManager::reload()) + t_reloader += dt; + if (t_reloader > 1.0) { - stroke->update_controls(); - redraw = true; + t_reloader = 0; + if (ShaderManager::reload()) + { + stroke->update_controls(); + redraw = true; + } + if (layout.reload()) + redraw = true; + if (layout_designer.reload()) + redraw = true; } - if (layout.reload()) - redraw = true; - if (layout_designer.reload()) - redraw = true; } -#endif tick(dt); diff --git a/src/app.h b/src/app.h index 62b5855..753a823 100644 --- a/src/app.h +++ b/src/app.h @@ -200,6 +200,7 @@ public: void end_render_capture_frame(); [[nodiscard]] bool platform_deletes_recorded_files_on_clear(); void clear_platform_recorded_files(std::string path); + [[nodiscard]] bool platform_enables_live_asset_reloading(); void update_platform_frame(float delta_time_seconds); void report_rendered_frames(int frames); void save_prepared_file( diff --git a/src/app_events.cpp b/src/app_events.cpp index 92a19f0..f2828d8 100644 --- a/src/app_events.cpp +++ b/src/app_events.cpp @@ -269,6 +269,11 @@ void App::clear_platform_recorded_files(std::string path) active_platform_services().clear_recorded_files(path); } +bool App::platform_enables_live_asset_reloading() +{ + return active_platform_services().enables_live_asset_reloading(); +} + void App::update_platform_frame(float delta_time_seconds) { active_platform_services().update_platform_frame(delta_time_seconds); diff --git a/src/platform_api/platform_services.h b/src/platform_api/platform_services.h index 7d5986b..19040a0 100644 --- a/src/platform_api/platform_services.h +++ b/src/platform_api/platform_services.h @@ -35,6 +35,7 @@ public: virtual void end_render_capture_frame() = 0; [[nodiscard]] virtual bool deletes_recorded_files_on_clear() = 0; virtual void clear_recorded_files(std::string_view recording_path) = 0; + [[nodiscard]] virtual bool enables_live_asset_reloading() = 0; virtual void update_platform_frame(float delta_time_seconds) = 0; virtual void report_rendered_frames(int frames) = 0; virtual void display_file(std::string_view path) = 0; diff --git a/src/platform_legacy/legacy_platform_services.cpp b/src/platform_legacy/legacy_platform_services.cpp index 82b4e8f..1dfe1df 100644 --- a/src/platform_legacy/legacy_platform_services.cpp +++ b/src/platform_legacy/legacy_platform_services.cpp @@ -230,6 +230,15 @@ public: #endif } + [[nodiscard]] bool enables_live_asset_reloading() override + { +#if defined(__OSX__) + return true; +#else + return false; +#endif + } + void update_platform_frame(float delta_time_seconds) override { (void)delta_time_seconds; diff --git a/src/platform_windows/windows_platform_services.cpp b/src/platform_windows/windows_platform_services.cpp index 8bcb155..11a53de 100644 --- a/src/platform_windows/windows_platform_services.cpp +++ b/src/platform_windows/windows_platform_services.cpp @@ -261,6 +261,11 @@ public: (void)recording_path; } + [[nodiscard]] bool enables_live_asset_reloading() override + { + return true; + } + void update_platform_frame(float delta_time_seconds) override { win32_update_stylus(delta_time_seconds); diff --git a/tests/platform_api/platform_services_tests.cpp b/tests/platform_api/platform_services_tests.cpp index 9f72488..6e1ea38 100644 --- a/tests/platform_api/platform_services_tests.cpp +++ b/tests/platform_api/platform_services_tests.cpp @@ -93,6 +93,12 @@ public: cleared_recording_path.assign(recording_path); } + [[nodiscard]] bool enables_live_asset_reloading() override + { + ++live_asset_reload_policy_checks; + return live_asset_reloading; + } + void update_platform_frame(float delta_time_seconds) override { ++platform_frame_updates; @@ -173,6 +179,7 @@ public: int storage_prepares = 0; int recording_delete_policy_checks = 0; int recording_clears = 0; + int live_asset_reload_policy_checks = 0; int platform_frame_updates = 0; int frame_reports = 0; int display_file_requests = 0; @@ -187,6 +194,7 @@ public: bool keyboard_visible = false; bool prepared_file_saved = true; bool deletes_recorded_files = true; + bool live_asset_reloading = true; float last_platform_delta = 0.0f; int last_frame_report = 0; std::string displayed_path; @@ -313,6 +321,18 @@ void platform_services_dispatch_recording_cleanup(pp::tests::Harness& harness) PP_EXPECT(harness, fake.cleared_recording_path == "D:/Paint/frames"); } +void platform_services_dispatch_live_asset_reload_policy(pp::tests::Harness& harness) +{ + FakePlatformServices fake("unused"); + pp::platform::PlatformServices& services = fake; + + PP_EXPECT(harness, services.enables_live_asset_reloading()); + fake.live_asset_reloading = false; + PP_EXPECT(harness, !services.enables_live_asset_reloading()); + + PP_EXPECT(harness, fake.live_asset_reload_policy_checks == 2); +} + void platform_services_dispatch_frame_hooks(pp::tests::Harness& harness) { FakePlatformServices fake("unused"); @@ -404,6 +424,7 @@ int main() harness.run("platform services dispatch render context lifecycle", platform_services_dispatch_render_context_lifecycle); harness.run("platform services dispatch render capture hooks", platform_services_dispatch_render_capture_hooks); harness.run("platform services dispatch recording cleanup", platform_services_dispatch_recording_cleanup); + harness.run("platform services dispatch live asset reload policy", platform_services_dispatch_live_asset_reload_policy); harness.run("platform services dispatch frame hooks", platform_services_dispatch_frame_hooks); harness.run("platform services dispatch file actions", platform_services_dispatch_file_actions); harness.run("platform services dispatch picker callbacks", platform_services_dispatch_picker_callbacks);