fix: use JSON.parse for bracket-prefixed lines instead of blanket suppression
This commit is contained in:
1 parent
4bf659e433
commit
2ca65abefa
2 files changed
+5
-1
No files matched your search
+2
-1
@@ -12908,7 +12908,8 @@ function _toolResultOneLiner(preview){
|
|||||||
const first=preview.split('\n').find(l=>l.trim())||'';
|
const first=preview.split('\n').find(l=>l.trim())||'';
|
||||||
const trimmed=first.trim();
|
const trimmed=first.trim();
|
||||||
if(!trimmed) return '';
|
if(!trimmed) return '';
|
||||||
if(trimmed[0]==='{'||trimmed[0]==='[') return '';
|
if(trimmed[0]==='{') return '';
|
||||||
|
if(trimmed[0]==='['){try{JSON.parse(trimmed);return '';}catch(e){/* not JSON */}}
|
||||||
return trimmed.length>180?trimmed.slice(0,177)+'…':trimmed;
|
return trimmed.length>180?trimmed.slice(0,177)+'…':trimmed;
|
||||||
}
|
}
|
||||||
function _toolCardPreviewText(tc, displaySnippet){
|
function _toolCardPreviewText(tc, displaySnippet){
|
||||||
|
|||||||
@@ -99,6 +99,9 @@ class TestToolResultOneLiner:
|
|||||||
def test_json_array_suppressed(self):
|
def test_json_array_suppressed(self):
|
||||||
assert _result_one_liner('[1,2,3]') == ""
|
assert _result_one_liner('[1,2,3]') == ""
|
||||||
|
|
||||||
|
def test_bracket_prefixed_non_json_shown(self):
|
||||||
|
assert _result_one_liner('[INFO] 3 files created') == "[INFO] 3 files created"
|
||||||
|
|
||||||
def test_multiline_collapses_to_first_nonempty_line(self):
|
def test_multiline_collapses_to_first_nonempty_line(self):
|
||||||
assert _result_one_liner("Line 1\nLine 2\nLine 3") == "Line 1"
|
assert _result_one_liner("Line 1\nLine 2\nLine 3") == "Line 1"
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user