Extract cloud browser thumbnail helper

This commit is contained in:
2026-06-15 20:54:21 +02:00
parent abd72a790d
commit 9b6fe73af2
4 changed files with 85 additions and 26 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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 |

View File

@@ -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<NodeImageTexture>("thumb-tex");
image_tex->tex = std::make_shared<Texture2D>();
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<NodeImageTexture>("thumb-tex");
image_tex->tex = std::make_shared<Texture2D>();
image_tex->tex->create(thumb);
app_redraw();
if (!load_cloud_thumb(curl, n, node, res))
break;
}
curl_easy_cleanup(curl);
}