Skip to content

Commit 48a7f80

Browse files
AnnatarHeclaude
andcommitted
fix(ai): handle SSE data prefix without space and add query logging
The SSE spec treats the space after "data:" as optional. Update the prefix check to match "data:" instead of "data: " so responses parse correctly regardless of spacing. Also add info-level logging for query command results. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6655bd9 commit 48a7f80

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

commands/query.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ func commandQuery(c *cli.Context) error {
101101

102102
// Print newline after streaming
103103
fmt.Println()
104+
slog.InfoContext(ctx, "query command", "command", result.String())
104105

105106
newCommand := strings.TrimSpace(result.String())
106107

model/ai_service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ func (s *sseAIService) QueryCommandStream(
6969
continue
7070
}
7171

72-
if strings.HasPrefix(line, "data: ") {
73-
data := line[len("data: "):]
72+
if strings.HasPrefix(line, "data:") {
73+
data := line[len("data:"):]
7474

7575
if isError {
7676
return fmt.Errorf("server error: %s", data)

0 commit comments

Comments
 (0)