loop/server: use pre tags for json schemas in debug page
Co-Authored-By: sketch <hello@sketch.dev>
Change-ID: s3ef91294c48fdad4k
diff --git a/loop/server/debug_tools_test.go b/loop/server/debug_tools_test.go
index 87ad354..f42804c 100644
--- a/loop/server/debug_tools_test.go
+++ b/loop/server/debug_tools_test.go
@@ -37,6 +37,19 @@
t.Error("Expected HTML to NOT use <div class=\"tool-description\"> tag")
}
+ // Verify HTML uses <pre> tag for tool schema
+ if !strings.Contains(html, `<pre class="tool-schema">`) {
+ t.Error("Expected HTML to use <pre class=\"tool-schema\"> tag")
+ }
+ if strings.Contains(html, `<div class="tool-schema">`) {
+ t.Error("Expected HTML to NOT use <div class=\"tool-schema\"> tag")
+ }
+
+ // Verify CSS includes white-space: pre for schemas
+ if !strings.Contains(html, "white-space: pre") {
+ t.Error("Expected CSS to contain 'white-space: pre' for schemas")
+ }
+
// Verify the description content is preserved
if !strings.Contains(html, "This is a test tool") {
t.Error("Expected tool description to be included")
diff --git a/loop/server/loophttp.go b/loop/server/loophttp.go
index 5abe750..4738a70 100644
--- a/loop/server/loophttp.go
+++ b/loop/server/loophttp.go
@@ -1258,7 +1258,7 @@
.tool { background: #f8f9fa; border: 1px solid #e9ecef; border-radius: 6px; padding: 20px; margin: 20px 0; }
.tool-name { font-size: 1.2em; font-weight: bold; color: #0366d6; margin-bottom: 8px; }
.tool-description { color: #586069; margin-bottom: 12px; white-space: pre-wrap; font-family: 'SF Mono', Monaco, monospace; }
- .tool-schema { background: #f6f8fa; border: 1px solid #d0d7de; border-radius: 4px; padding: 12px; font-family: 'SF Mono', Monaco, monospace; font-size: 12px; overflow-x: auto; }
+ .tool-schema { background: #f6f8fa; border: 1px solid #d0d7de; border-radius: 4px; padding: 12px; font-family: 'SF Mono', Monaco, monospace; font-size: 12px; overflow-x: auto; white-space: pre; }
.tool-meta { font-size: 0.9em; color: #656d76; margin-top: 8px; }
.summary { background: #e6f3ff; border-left: 4px solid #0366d6; padding: 16px; margin-bottom: 30px; }
</style>
@@ -1289,7 +1289,7 @@
} else {
schemaFormatted = string(tool.InputSchema)
}
- fmt.Fprintf(w, ` <div class="tool-schema">%s</div>
+ fmt.Fprintf(w, ` <pre class="tool-schema">%s</pre>
`, html.EscapeString(schemaFormatted))
}