From 893dfc75c8f349eff1c58d9f66330aa6616d747e Mon Sep 17 00:00:00 2001 From: "anthropic-code-agent[bot]" <242468646+Claude@users.noreply.github.com> Date: Sun, 22 Mar 2026 17:32:06 +0000 Subject: [PATCH] Improve format detection: check output content for JSON vs text - When smartctl/output property exists: both JSON and text available - When no property and output starts with '{': JSON only (loaded JSON virtual drive) - When no property and output doesn't start with '{': text only (loaded text virtual drive) - Ensures correct filters shown for each scenario per requirements 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 | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/gui/gsc_text_window.h b/src/gui/gsc_text_window.h index 774df51..39ef83e 100644 --- a/src/gui/gsc_text_window.h +++ b/src/gui/gsc_text_window.h @@ -172,10 +172,11 @@ class GscTextWindow : public AppBuilderWidget, Ins if (storage_device_) { // Check if we have text output in the property repository + bool has_text_property = false; if (auto p = storage_device_->get_property_repository().lookup_property("smartctl/output"); !p.empty()) { const std::string text_output = p.get_value(); if (!text_output.empty()) { - has_text = true; + has_text_property = true; } } // Get the output - it could be JSON or text format @@ -184,12 +185,20 @@ class GscTextWindow : public AppBuilderWidget, Ins output = storage_device_->get_basic_output(); } if (!output.empty()) { - // If we have text in property repo, the output is JSON; otherwise it's text - if (has_text) { + // If we have text in property repo, the output is JSON with embedded text + if (has_text_property) { has_json = true; - } else { - // No text in property means the output itself is text format has_text = true; + } else { + // No text in property means either: + // 1. Output is JSON without embedded text, or + // 2. Output is text format (loaded text virtual drive) + // We check if output starts with '{' to detect JSON + if (!output.empty() && output[0] == '{') { + has_json = true; + } else { + has_text = true; + } } } } else {