Merge branch 'master' of github.com:cexll/myclaude

This commit is contained in:
cexll
2026-01-09 11:56:40 +08:00
2 changed files with 11 additions and 1 deletions

View File

@@ -2096,6 +2096,16 @@ func TestBackendParseJSONStream_GeminiEvents(t *testing.T) {
}
}
func TestBackendParseJSONStream_GeminiInitEventSessionID(t *testing.T) {
input := `{"type":"init","session_id":"gemini-abc123"}`
_, threadID := parseJSONStream(strings.NewReader(input))
if threadID != "gemini-abc123" {
t.Fatalf("threadID=%q, want %q", threadID, "gemini-abc123")
}
}
func TestBackendParseJSONStream_GeminiEvents_DeltaFalseStillDetected(t *testing.T) {
input := `{"type":"init","session_id":"xyz789"}
{"type":"message","content":"Hi","delta":false,"session_id":"xyz789"}

View File

@@ -171,7 +171,7 @@ func parseJSONStreamInternal(r io.Reader, warnFn func(string), infoFn func(strin
if !isClaude && event.Type == "result" && event.SessionID != "" && event.Status == "" {
isClaude = true
}
isGemini := event.Role != "" || event.Delta != nil || event.Status != ""
isGemini := (event.Type == "init" && event.SessionID != "") || event.Role != "" || event.Delta != nil || event.Status != ""
// Handle Codex events
if isCodex {