From be8dee8de5229ede44522190e4d9465c5694d1c4 Mon Sep 17 00:00:00 2001 From: omigamedev Date: Mon, 15 Jun 2026 22:09:49 +0200 Subject: [PATCH] Extract document-session close prompt helper --- docs/modernization/debt.md | 6 ++++ docs/modernization/roadmap.md | 5 ++++ docs/modernization/tasks.md | 36 ++++++++++++++++++++++++ src/legacy_document_session_services.cpp | 26 ++++++++++------- 4 files changed, 63 insertions(+), 10 deletions(-) diff --git a/docs/modernization/debt.md b/docs/modernization/debt.md index 9170aee6..5dac2948 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` was narrowed again. The retained close-unsaved + prompt wiring in `src/legacy_document_session_services.cpp` now routes + through a focused helper instead of living inline in + `show_unsaved_close_prompt()`; the remaining document-session bridge debt + stays concentrated in save-before-workflow prompts, save-version routing, + app document field mutation, and keyboard/dialog cleanup. - 2026-06-15: `DEBT-0040` was narrowed again. The retained save-before- continue workflow prompt wiring in `src/legacy_document_session_services.cpp` now routes through a focused helper instead of living inline in diff --git a/docs/modernization/roadmap.md b/docs/modernization/roadmap.md index 777e1806..52b5d3a3 100644 --- a/docs/modernization/roadmap.md +++ b/docs/modernization/roadmap.md @@ -1415,6 +1415,11 @@ The retained save-before-continue workflow prompt wiring in 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. +The retained close-unsaved 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 save-before-workflow prompts, 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 37898b85..2bb4f406 100644 --- a/docs/modernization/tasks.md +++ b/docs/modernization/tasks.md @@ -1488,6 +1488,42 @@ Completed Task Log: | --- | --- | ---: | --- | --- | | 2026-06-15 | ADP-039 | 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"` | `c37451e9` | +### ADP-040 - Extract Document-Session Close Prompt Helper + +Status: Done +Score: no score movement +Debt: `DEBT-0040` +Scope: `src/legacy_document_session_services.cpp` only + +Closeout: `c37451e9` + +Goal: + +Reduce the inline retained close-unsaved prompt surface by extracting the +button wiring from `show_unsaved_close_prompt()` into a focused helper while +preserving current behavior. + +Done Checks: + +- The retained close-unsaved prompt wiring no longer lives inline in + `show_unsaved_close_prompt()`. +- The retained close prompt path now routes through a focused helper in + `src/legacy_document_session_services.cpp`. +- `DEBT-0040` 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-040 | 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"` | `c37451e9` | + ### 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 4fe7bcf7..912f140d 100644 --- a/src/legacy_document_session_services.cpp +++ b/src/legacy_document_session_services.cpp @@ -118,6 +118,21 @@ void project_save_after_snapshot(App& app, std::function on_complete app.canvas->m_canvas->project_save(std::move(on_complete)); } +void wire_unsaved_close_prompt_buttons( + App& app, + bool& dialog_already_opened, + const std::shared_ptr& dialog) +{ + dialog->btn_ok->on_click = [&app](Node*) { + app.request_app_close(); + Canvas::I->m_unsaved = false; + }; + dialog->btn_cancel->on_click = [&dialog_already_opened, dialog](Node*) { + pp::panopainter::close_legacy_dialog_node(*dialog); + dialog_already_opened = false; + }; +} + void create_legacy_new_document( App& app, const pp::app::NewDocumentPlan& plan, @@ -285,20 +300,11 @@ public: if (!history_status.ok()) { LOG("Close prompt history effect failed: %s", history_status.message); } - auto* app = &app_; - auto* dialog_already_opened = &dialog_already_opened_; auto m = pp::panopainter::create_legacy_app_message_dialog( app_, pp::app::plan_document_session_prompt( pp::app::DocumentSessionPromptKind::close_unsaved_document)); - m->btn_ok->on_click = [app](Node*) { - app->request_app_close(); - Canvas::I->m_unsaved = false; - }; - m->btn_cancel->on_click = [dialog_already_opened, m](Node*) { - pp::panopainter::close_legacy_dialog_node(*m); - *dialog_already_opened = false; - }; + wire_unsaved_close_prompt_buttons(app_, dialog_already_opened_, m); dialog_already_opened_ = true; }