From 4823af1d2379fcb759526dcff3cc75d0779e18ba Mon Sep 17 00:00:00 2001 From: "anthropic-code-agent[bot]" <242468646+Claude@users.noreply.github.com> Date: Sun, 22 Mar 2026 17:31:00 +0000 Subject: [PATCH] Fix data format detection logic for JSON vs Text - Correctly detect when output is JSON (has smartctl/output property) vs text - When smartctl/output property exists, output is JSON format - When no property exists, output is text format (loaded virtual drive) - Ensures filters are shown appropriately for available formats Co-authored-by: ashaduri <2302268+ashaduri@users.noreply.github.com> Agent-Logs-Url: https://github.com/ashaduri/gsmartcontrol/sessions/a0167009-9a8b-4835-9c5d-83a6f7ff903d --- src/gui/gsc_text_window.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/gui/gsc_text_window.h b/src/gui/gsc_text_window.h index 8803ec5..774df51 100644 --- a/src/gui/gsc_text_window.h +++ b/src/gui/gsc_text_window.h @@ -178,16 +178,22 @@ class GscTextWindow : public AppBuilderWidget, Ins has_text = true; } } - // If we have full_output or basic_output, we have JSON + // Get the output - it could be JSON or text format std::string output = storage_device_->get_full_output(); if (output.empty()) { output = storage_device_->get_basic_output(); } if (!output.empty()) { - has_json = true; + // If we have text in property repo, the output is JSON; otherwise it's text + if (has_text) { + has_json = true; + } else { + // No text in property means the output itself is text format + has_text = true; + } } } else { - // If no storage device is set, assume we have JSON (contents_) + // If no storage device is set, we only have the contents (assume JSON for backward compatibility) has_json = true; } @@ -296,13 +302,13 @@ class GscTextWindow : public AppBuilderWidget, Ins } else if (json_selected) { file += ".json"; } else { - // "JSON and Text Files" or "All Files" selected - use extension from file.extension() or default + // "JSON and Text Files" or "All Files" selected - use user-provided extension or default if (has_json && !has_text) { file += ".json"; } else if (has_text && !has_json) { file += ".txt"; } else { - // Both available, default to JSON + // Both available, default to JSON (per requirements) file += ".json"; } }