fix: ensure extracted thought is not empty before displaying in report

This commit is contained in:
lilong.129
2025-06-24 22:22:34 +08:00
parent 084c28834c
commit 43d990f863
2 changed files with 11 additions and 4 deletions

View File

@@ -541,7 +541,7 @@ func (g *HTMLReportGenerator) GenerateReport(outputFile string) error {
// Try to parse as JSON to extract thought field
var data map[string]interface{}
if err := json.Unmarshal([]byte(content), &data); err == nil {
if thought, ok := data["thought"].(string); ok {
if thought, ok := data["thought"].(string); ok && thought != "" {
return thought
}
}
@@ -2325,8 +2325,15 @@ const htmlTemplate = `<!DOCTYPE html>
{{if $planning.Error}}<span class="error">Error: {{$planning.Error}}</span>{{end}}
</div>
{{if $planning.Thought}}
<div class="thought">{{$planning.Thought}}</div>
{{$extractedThought := extractThought $planning.Content}}
{{if or $planning.Thought $extractedThought}}
<div class="thought">
{{if $planning.Thought}}
{{$planning.Thought}}
{{else}}
{{$extractedThought}}
{{end}}
</div>
{{end}}
<!-- Three-column layout: screenshot left, model output and actions right -->