From 9b6fe73af2b758746e3cc1676921d95eebec464a Mon Sep 17 00:00:00 2001 From: omigamedev Date: Mon, 15 Jun 2026 20:54:21 +0200 Subject: [PATCH] Extract cloud browser thumbnail helper --- docs/modernization/debt.md | 7 ++++ docs/modernization/roadmap.md | 5 +++ docs/modernization/tasks.md | 36 ++++++++++++++++++++ src/node_dialog_cloud.cpp | 63 ++++++++++++++++++++--------------- 4 files changed, 85 insertions(+), 26 deletions(-) diff --git a/docs/modernization/debt.md b/docs/modernization/debt.md index 9952aab2..554f8a19 100644 --- a/docs/modernization/debt.md +++ b/docs/modernization/debt.md @@ -18,6 +18,13 @@ agent or engineer to remove them without reconstructing context from chat. ## Recent Reductions +- 2026-06-15: `DEBT-0038` was narrowed again. The retained cloud-browser + thumbnail fetch, decode, and texture-apply path in + `NodeDialogCloud::load_thumbs_thread()` now routes through a focused helper + in `src/node_dialog_cloud.cpp` instead of living inline in the retained + loader body; the remaining cloud bridge debt stays concentrated in retained + prompt/progress lifetime, OpenGL context guarding, and transfer-thread + execution. - 2026-06-15: `DEBT-0038` was narrowed again. The cloud-browser slot creation and selection wiring in `NodeDialogCloud::load_thumbs_thread()` now route through a focused helper in `src/node_dialog_cloud.*` instead of diff --git a/docs/modernization/roadmap.md b/docs/modernization/roadmap.md index 60ff0722..fa5c9941 100644 --- a/docs/modernization/roadmap.md +++ b/docs/modernization/roadmap.md @@ -124,6 +124,11 @@ The cloud-browser slot creation and selection wiring in helper in `src/node_dialog_cloud.*`, so the remaining cloud bridge debt is further concentrated on prompt/progress lifetime, OpenGL context guarding, `NodeDialogCloud` thumbnail execution, and transfer-thread execution. +The retained cloud-browser thumbnail fetch, decode, and texture-apply path in +`NodeDialogCloud::load_thumbs_thread()` now also routes through a focused +helper in `src/node_dialog_cloud.cpp`, so the remaining cloud bridge debt is +further concentrated on prompt/progress lifetime, OpenGL context guarding, +and transfer-thread execution. Recent 2026-06-13 retained preview reductions continue to narrow DEBT-0036: `NodeStrokePreview::draw_stroke_immediate()` now also routes diff --git a/docs/modernization/tasks.md b/docs/modernization/tasks.md index 0029fa9c..61ed2921 100644 --- a/docs/modernization/tasks.md +++ b/docs/modernization/tasks.md @@ -660,6 +660,42 @@ Completed Task Log: | --- | --- | ---: | --- | --- | | 2026-06-15 | ADP-016 | no score movement | `MSBuild.exe out\build\windows-msvc-default\panopainter_app.vcxproj /p:Configuration=Debug /p:Platform=x64`; `ctest --preset desktop-fast --build-config Debug -R "pp_app_core_document_cloud" --output-on-failure` | `45f08ee8` | +### ADP-017 - Extract Cloud Browser Thumbnail Helper + +Status: Done +Score: no score movement +Debt: `DEBT-0038` +Scope: `src/node_dialog_cloud.cpp` only + +Goal: + +Reduce the inline retained cloud-browser loader surface in +`NodeDialogCloud::load_thumbs_thread()` by extracting the per-item thumbnail +fetch, decode, and texture-apply path into a focused helper while preserving +current behavior. + +Done Checks: + +- The per-item thumbnail fetch/decode/apply path no longer lives inline in + `NodeDialogCloud::load_thumbs_thread()`. +- The retained cloud-browser thumbnail path now routes through a focused + helper in `src/node_dialog_cloud.cpp`. +- `DEBT-0038` and the roadmap note the reduced remaining cloud bridge + surface. + +Validation: + +```powershell +& 'C:\Program Files\Microsoft Visual Studio\18\Community\MSBuild\Current\Bin\MSBuild.exe' out\build\windows-msvc-default\panopainter_app.vcxproj /p:Configuration=Debug /p:Platform=x64 +ctest --preset desktop-fast --build-config Debug -R "pp_app_core_document_cloud" --output-on-failure +``` + +Completed Task Log: + +| Date | Task | Score | Validation | Commit | +| --- | --- | ---: | --- | --- | +| 2026-06-15 | ADP-017 | no score movement | `MSBuild.exe out\build\windows-msvc-default\panopainter_app.vcxproj /p:Configuration=Debug /p:Platform=x64`; `ctest --preset desktop-fast --build-config Debug -R "pp_app_core_document_cloud" --output-on-failure` | `(pending)` | + Completed Task Log: | Date | Task | Score | Validation | Commit | diff --git a/src/node_dialog_cloud.cpp b/src/node_dialog_cloud.cpp index 7da46193..f24c4440 100644 --- a/src/node_dialog_cloud.cpp +++ b/src/node_dialog_cloud.cpp @@ -10,6 +10,41 @@ #include "legacy_ui_overlay_services.h" #include "platform_api/network_tls_policy.h" +namespace +{ +bool load_cloud_thumb(CURL* curl, const std::string& name, NodeDialogCloudItem* node, std::string& response) +{ + response.clear(); + char* url_escaped = curl_easy_escape(curl, name.c_str(), (int)name.size()); + std::string url = std::string("https://panopainter.com/cloud/cloud-info.php?file=") + url_escaped; + delete url_escaped; + curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); + LOG("%s", url.c_str()); + auto err = curl_easy_perform(curl); + if (err != CURLE_OK) + return false; // TODO: handle this error with a message or something + + auto info = split(response, ',', 3); + int width = atoi(info[0].c_str()); + int height = atoi(info[1].c_str()); + int comp = atoi(info[2].c_str()); + assert(comp == 4); + std::string rgb; + rgb.resize(Base64::DecodedLength(info[3])); + Base64::Decode(info[3], &rgb); + Image thumb; + thumb.create(width, height); + thumb.copy_from((uint8_t*)rgb.data()); + + auto image_tex = node->find("thumb-tex"); + image_tex->tex = std::make_shared(); + image_tex->tex->create(thumb); + + node->app_redraw(); + return true; +} +} // namespace + Node* NodeDialogCloud::clone_instantiate() const { return new NodeDialogCloud(); @@ -138,33 +173,9 @@ void NodeDialogCloud::load_thumbs_thread() auto* node = nodes[i]; if (closed) break; - - res.clear(); - char* url_escaped = curl_easy_escape(curl, n.c_str(), (int)n.size()); - std::string url = std::string("https://panopainter.com/cloud/cloud-info.php?file=") + url_escaped; - delete url_escaped; - curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); - LOG("%s", url.c_str()); - auto err = curl_easy_perform(curl); - if (err != CURLE_OK) - break; // TODO: handle this error with a message or something - auto info = split(res, ',', 3); - int width = atoi(info[0].c_str()); - int height = atoi(info[1].c_str()); - int comp = atoi(info[2].c_str()); - assert(comp == 4); - std::string rgb; - rgb.resize(Base64::DecodedLength(info[3])); - Base64::Decode(info[3], &rgb); - Image thumb; - thumb.create(width, height); - thumb.copy_from((uint8_t*)rgb.data()); - auto image_tex = node->find("thumb-tex"); - image_tex->tex = std::make_shared(); - image_tex->tex->create(thumb); - - app_redraw(); + if (!load_cloud_thumb(curl, n, node, res)) + break; } curl_easy_cleanup(curl); }