Skip to content

Commit 0b0d3b0

Browse files
authored
Merge pull request #186 from githubnext/copilot/review-markdown-style
2 parents b5c9ec1 + f5c1966 commit 0b0d3b0

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

internal/logger/rpc_logger.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ func isEffectivelyEmpty(data map[string]interface{}) bool {
184184

185185
// formatRPCMessageMarkdown formats an RPC message for markdown logging
186186
func formatRPCMessageMarkdown(info *RPCMessageInfo) string {
187-
// Concise format: **server**→method \n~~~ \n{formatted json} \n~~~
187+
// Concise format: **server**→method \n```json \n{formatted json} \n```
188188
var dir string
189189
if info.Direction == RPCDirectionOutbound {
190190
dir = "→"
@@ -199,7 +199,7 @@ func formatRPCMessageMarkdown(info *RPCMessageInfo) string {
199199
if info.Method != "" {
200200
message = fmt.Sprintf("**%s**%s`%s`", info.ServerID, dir, info.Method)
201201
} else {
202-
message = fmt.Sprintf("**%s**%sresp", info.ServerID, dir)
202+
message = fmt.Sprintf("**%s**%s`resp`", info.ServerID, dir)
203203
}
204204
}
205205

@@ -210,9 +210,9 @@ func formatRPCMessageMarkdown(info *RPCMessageInfo) string {
210210
if isValidJSON {
211211
// Don't show JSON block if it's effectively empty (only params: null)
212212
if !isEmpty {
213-
// Valid JSON: use code block for better readability (pretty printed)
214-
// Empty line before ~~~ per markdown convention
215-
message += fmt.Sprintf(" \n\n~~~\n%s\n~~~", formatted)
213+
// Valid JSON: use json code block for syntax highlighting (pretty printed)
214+
// Empty line before code block per markdown convention
215+
message += fmt.Sprintf("\n\n```json\n%s\n```", formatted)
216216
}
217217
} else {
218218
// Invalid JSON: use inline backticks to avoid malformed markdown

internal/logger/rpc_logger_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func TestFormatRPCMessageMarkdown(t *testing.T) {
194194
PayloadSize: 50,
195195
Payload: `{"jsonrpc":"2.0","method":"tools/list","params":{}}`,
196196
},
197-
want: []string{"**github**→`tools/list`", "~~~", `"params"`, "{}"},
197+
want: []string{"**github**→`tools/list`", "```json", `"params"`, "{}"},
198198
notWant: []string{`"jsonrpc"`, `"method"`},
199199
},
200200
{
@@ -206,7 +206,7 @@ func TestFormatRPCMessageMarkdown(t *testing.T) {
206206
PayloadSize: 100,
207207
Payload: `{"result":{}}`,
208208
},
209-
want: []string{"**github**←resp", "~~~", `"result"`},
209+
want: []string{"**github**←`resp`", "```json", `"result"`},
210210
notWant: []string{`"jsonrpc"`, `"method"`},
211211
},
212212
{
@@ -218,7 +218,7 @@ func TestFormatRPCMessageMarkdown(t *testing.T) {
218218
PayloadSize: 100,
219219
Error: "Connection timeout",
220220
},
221-
want: []string{"**github**←resp", "⚠️`Connection timeout`"},
221+
want: []string{"**github**←`resp`", "⚠️`Connection timeout`"},
222222
notWant: []string{},
223223
},
224224
{
@@ -232,7 +232,7 @@ func TestFormatRPCMessageMarkdown(t *testing.T) {
232232
Payload: `{invalid json syntax}`,
233233
},
234234
want: []string{"**github**→`tools/call`", "`{invalid json syntax}`"},
235-
notWant: []string{"~~~"}, // Should NOT use code blocks for invalid JSON
235+
notWant: []string{"```json"}, // Should NOT use code blocks for invalid JSON
236236
},
237237
{
238238
name: "request with only params null after field removal",
@@ -245,7 +245,7 @@ func TestFormatRPCMessageMarkdown(t *testing.T) {
245245
Payload: `{"jsonrpc":"2.0","method":"tools/list","params":null}`,
246246
},
247247
want: []string{"**github**→`tools/list`"},
248-
notWant: []string{"~~~", `"params"`}, // Should NOT show JSON block when only params: null
248+
notWant: []string{"```json", `"params"`}, // Should NOT show JSON block when only params: null
249249
},
250250
{
251251
name: "request with empty object after field removal",
@@ -258,7 +258,7 @@ func TestFormatRPCMessageMarkdown(t *testing.T) {
258258
Payload: `{"jsonrpc":"2.0","method":"tools/list"}`,
259259
},
260260
want: []string{"**github**→`tools/list`"},
261-
notWant: []string{"~~~"}, // Should NOT show JSON block when empty
261+
notWant: []string{"```json"}, // Should NOT show JSON block when empty
262262
},
263263
}
264264

@@ -475,7 +475,7 @@ func TestLogRPCResponse(t *testing.T) {
475475
}
476476

477477
mdStr := string(mdContent)
478-
expectedInMd := []string{"**github**←resp", "⚠️`backend connection failed`"}
478+
expectedInMd := []string{"**github**←`resp`", "⚠️`backend connection failed`"}
479479
for _, expected := range expectedInMd {
480480
if !strings.Contains(mdStr, expected) {
481481
t.Errorf("Markdown log does not contain %q", expected)

0 commit comments

Comments
 (0)