From 6effec951e5b91cbe45ae252ec49528be4350614 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 27 Oct 2026 18:14:01 +0000 Subject: [PATCH 1/4] Fix suggestions handling in diagnostics renderer Include suggestions field in RichDiagnostic JSON output and add unit tests for suggestion rendering across plain, colored, and JSON formats. Co-authored-by: Tcode-Motion <188012755+Tcode-Motion@users.noreply.github.com> --- cli/src/diagnostics.rs | 54 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/cli/src/diagnostics.rs b/cli/src/diagnostics.rs index b8b7609f..3761214a 100644 --- a/cli/src/diagnostics.rs +++ b/cli/src/diagnostics.rs @@ -387,12 +387,28 @@ impl<'a> DiagnosticRenderer<'a> { .map(|r| serde_json::json!({ "severity": r.severity.label(), "message": r.message })) .collect(); + let suggestions_json: Vec<_> = diag + .suggestions + .iter() + .map(|s| { + serde_json::json!({ + "message": s.message, + "replacement": s.replacement, + "span": { + "start": s.span.start, + "end": s.span.end, + } + }) + }) + .collect(); + let obj = serde_json::json!({ "severity": diag.severity.label(), "code": diag.code.map(|c| format!("{:?}", c)), "message": diag.message, "span": span_json, "related": related_json, + "suggestions": suggestions_json, }); obj.to_string() @@ -480,3 +496,41 @@ impl DiagnosticStats { .to_string() } } + +#[cfg(test)] +mod tests { + use super::*; + use techscript_common::Span; + + #[test] + fn test_fix_suggestion_rendering() { + let sm = SourceManager::new(); + let diag = + RichDiagnostic::error("undefined variable `foo`").with_suggestion(FixSuggestion { + message: "change to `bar`".into(), + span: Span::new(0, 3), + replacement: "bar".into(), + }); + + // Plain output rendering + let renderer_plain = DiagnosticRenderer::new(DiagnosticOutput::Plain, &sm); + let rendered_plain = renderer_plain.render(&diag); + assert!(rendered_plain.contains("suggestion: change to `bar` → `bar`")); + + // Colored output rendering + let renderer_colored = DiagnosticRenderer::new(DiagnosticOutput::Colored, &sm); + let rendered_colored = renderer_colored.render(&diag); + assert!(rendered_colored.contains("suggestion")); + assert!(rendered_colored.contains("change to `bar`")); + assert!(rendered_colored.contains("bar")); + + // JSON output rendering + let renderer_json = DiagnosticRenderer::new(DiagnosticOutput::Json, &sm); + let json_str = renderer_json.render(&diag); + let parsed: serde_json::Value = serde_json::from_str(&json_str).unwrap(); + assert_eq!(parsed["suggestions"][0]["message"], "change to `bar`"); + assert_eq!(parsed["suggestions"][0]["replacement"], "bar"); + assert_eq!(parsed["suggestions"][0]["span"]["start"], 0); + assert_eq!(parsed["suggestions"][0]["span"]["end"], 3); + } +} From 607d4331228eb9cb0353f5fb707161ff9c0474d1 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 27 Oct 2026 19:35:36 +0000 Subject: [PATCH 2/4] Fix suggestions handling in diagnostics renderer Include suggestions field in RichDiagnostic JSON output and add unit tests for suggestion rendering across plain, colored, and JSON formats. Co-authored-by: Tcode-Motion <188012755+Tcode-Motion@users.noreply.github.com> From 46432db4a7da09cda6aaff9290d89719f64b6cde Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 27 Oct 2026 19:54:22 +0000 Subject: [PATCH 3/4] Fix suggestions handling in diagnostics renderer Include suggestions field in RichDiagnostic JSON output, add unit tests for suggestion rendering across plain, colored, and JSON formats, and fix flaky Windows TCP socket shutdown in stdlib HTTP tests. Co-authored-by: Tcode-Motion <188012755+Tcode-Motion@users.noreply.github.com> --- stdlib/tests/stdlib_tests.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/stdlib/tests/stdlib_tests.rs b/stdlib/tests/stdlib_tests.rs index 05c13a8c..51fdb1dc 100644 --- a/stdlib/tests/stdlib_tests.rs +++ b/stdlib/tests/stdlib_tests.rs @@ -519,6 +519,7 @@ fn test_http_module() { let response = "HTTP/1.1 200 OK\r\nContent-Length: 13\r\nContent-Type: text/plain\r\nConnection: close\r\n\r\nHello Server!"; let _ = stream.write_all(response.as_bytes()); let _ = stream.flush(); + let _ = stream.shutdown(std::net::Shutdown::Both); } }); From a77d5064d9681e03aeea05958c0b081a05bae628 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 27 Oct 2026 23:17:51 +0000 Subject: [PATCH 4/4] Fix suggestions handling in diagnostics renderer Include suggestions field in RichDiagnostic JSON output, add unit tests for suggestion rendering across plain, colored, and JSON formats, fix flaky Windows TCP socket shutdown in stdlib HTTP tests, and widen sleep gap in threads example to prevent output ordering race conditions in CI. Co-authored-by: Tcode-Motion <188012755+Tcode-Motion@users.noreply.github.com> --- examples/threads/threads.txs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/threads/threads.txs b/examples/threads/threads.txs index 7396bb40..34286a5d 100644 --- a/examples/threads/threads.txs +++ b/examples/threads/threads.txs @@ -6,12 +6,12 @@ spawn_fn = thread["spawn"] join_fn = thread["join"] do task_a() - time.sleep(100) + time.sleep(200) say "Task A completed on worker thread." end do task_b() - time.sleep(50) + time.sleep(10) say "Task B completed on worker thread." end