From 93846763674abc33ca8e28c6561a2d8769b7cab2 Mon Sep 17 00:00:00 2001 From: omigamedev Date: Mon, 15 Jun 2026 22:02:39 +0200 Subject: [PATCH] Extract document-session overwrite prompt helper --- docs/modernization/debt.md | 6 +++++ docs/modernization/roadmap.md | 5 ++++ docs/modernization/tasks.md | 34 ++++++++++++++++++++++++ src/legacy_document_session_services.cpp | 31 ++++++++++++--------- 4 files changed, 64 insertions(+), 12 deletions(-) diff --git a/docs/modernization/debt.md b/docs/modernization/debt.md index ca8b8987..99291d11 100644 --- a/docs/modernization/debt.md +++ b/docs/modernization/debt.md @@ -18,6 +18,12 @@ agent or engineer to remove them without reconstructing context from chat. ## Recent Reductions +- 2026-06-15: `DEBT-0040`/`DEBT-0041`/`DEBT-0042` were narrowed again. The + retained overwrite-prompt wiring in `src/legacy_document_session_services.cpp` + now routes through a focused helper instead of living inline in the new + document and save-file prompt methods; the remaining document-session bridge + debt stays concentrated in close prompts, native close requests, save-version + routing, app document field mutation, and keyboard/dialog cleanup. - 2026-06-15: `DEBT-0039` was narrowed again. The retained ABR/PPBR import prompt wiring in `src/legacy_document_open_services.cpp` now routes through a focused helper instead of living inline in each document-open import diff --git a/docs/modernization/roadmap.md b/docs/modernization/roadmap.md index 2d8ff458..f6056e28 100644 --- a/docs/modernization/roadmap.md +++ b/docs/modernization/roadmap.md @@ -1405,6 +1405,11 @@ Close-unsaved, save-before-workflow, new-document overwrite, and Save As overwrite prompt creation now also goes through `src/legacy_app_dialog_services.*` before the document-session bridge attaches its legacy callbacks. +The retained new-document and Save As overwrite prompt wiring in +`src/legacy_document_session_services.*` now also routes through a focused +helper, so the remaining document-session bridge debt is further concentrated +on close prompts, native close requests, save-version routing, app document +field mutation, and keyboard/dialog cleanup. `App::dialog_newdoc` now routes accepted new-document plans through the app-core new-document executor and `src/legacy_document_session_services.*`, preserving target overwrite prompts, legacy canvas resize/layer setup, history diff --git a/docs/modernization/tasks.md b/docs/modernization/tasks.md index bdf75c7e..d7cf4796 100644 --- a/docs/modernization/tasks.md +++ b/docs/modernization/tasks.md @@ -1418,6 +1418,40 @@ Completed Task Log: | --- | --- | ---: | --- | --- | | 2026-06-15 | ADP-037 | no score movement | `powershell -ExecutionPolicy Bypass -File scripts\\automation\\quiet-validate.ps1 -BuildTargets pano_cli -TestRegex "pp_app_core_document_route|pp_app_core_document_session"` | `16111e09` | +### ADP-038 - Extract Document-Session Overwrite Prompt Helper + +Status: Done +Score: no score movement +Debt: `DEBT-0040`, `DEBT-0041`, `DEBT-0042` +Scope: `src/legacy_document_session_services.cpp` only + +Goal: + +Reduce the inline retained document-session overwrite-prompt surface by +extracting the shared OK wiring from the new-document and save-file overwrite +prompts into a focused helper while preserving current behavior. + +Done Checks: + +- The retained document-session overwrite-prompt OK wiring no longer lives + inline in the new-document and save-file prompt methods. +- The retained document-session overwrite-prompt path now routes through a + focused helper in `src/legacy_document_session_services.cpp`. +- `DEBT-0040`, `DEBT-0041`, `DEBT-0042`, and the roadmap note the reduced + remaining document-session bridge surface. + +Validation: + +```powershell +powershell -ExecutionPolicy Bypass -File scripts\\automation\\quiet-validate.ps1 -BuildTargets pano_cli,pp_app_core_document_session_tests -TestRegex "pp_app_core_document_session|pano_cli_plan_document_session_prompt" +``` + +Completed Task Log: + +| Date | Task | Score | Validation | Commit | +| --- | --- | ---: | --- | --- | +| 2026-06-15 | ADP-038 | no score movement | `powershell -ExecutionPolicy Bypass -File scripts\\automation\\quiet-validate.ps1 -BuildTargets pano_cli,pp_app_core_document_session_tests -TestRegex "pp_app_core_document_session|pano_cli_plan_document_session_prompt"` | `16111e09` | + ### RND-001 - Make Pure Equirectangular Export The Primary Success Path Status: Done diff --git a/src/legacy_document_session_services.cpp b/src/legacy_document_session_services.cpp index 507c45e9..40b0b84f 100644 --- a/src/legacy_document_session_services.cpp +++ b/src/legacy_document_session_services.cpp @@ -148,6 +148,23 @@ void create_legacy_new_document( pp::panopainter::close_legacy_dialog_and_hide_keyboard(app, *dialog); } +template +void wire_legacy_overwrite_prompt_ok( + App& app, + const std::shared_ptr& msgbox, + const std::shared_ptr& dialog, + const Plan& plan, + AcceptAction&& accept_action) +{ + auto* app_ptr = &app; + auto msgbox_ptr = msgbox; + auto dialog_ptr = dialog; + msgbox->btn_ok->on_click = [app_ptr, msgbox_ptr, dialog_ptr, plan, accept_action = std::forward(accept_action)](Node*) { + accept_action(*app_ptr, plan, dialog_ptr); + pp::panopainter::close_legacy_dialog_node(*msgbox_ptr); + }; +} + class LegacyNewDocumentServices final : public pp::app::NewDocumentServices { public: LegacyNewDocumentServices(App& app, std::shared_ptr dialog) noexcept @@ -167,12 +184,7 @@ public: app_, pp::app::plan_document_session_prompt( pp::app::DocumentSessionPromptKind::new_document_overwrite)); - auto* app = &app_; - auto dialog = dialog_; - msgbox->btn_ok->on_click = [app, msgbox, dialog, plan](Node*) { - create_legacy_new_document(*app, plan, dialog); - pp::panopainter::close_legacy_dialog_node(*msgbox); - }; + wire_legacy_overwrite_prompt_ok(app_, msgbox, dialog_, plan, create_legacy_new_document); } private: @@ -217,12 +229,7 @@ public: pp::app::plan_document_session_prompt( pp::app::DocumentSessionPromptKind::document_file_overwrite, plan.target.name)); - auto* app = &app_; - auto dialog = dialog_; - msgbox->btn_ok->on_click = [app, msgbox, dialog, plan](Node*) { - save_legacy_document_file(*app, plan, dialog); - pp::panopainter::close_legacy_dialog_node(*msgbox); - }; + wire_legacy_overwrite_prompt_ok(app_, msgbox, dialog_, plan, save_legacy_document_file); } private: