-
Notifications
You must be signed in to change notification settings - Fork 480
chore: release new version for VSCode && IDEA #482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5a3abcf
b8240a7
6e61eb5
65bafab
2365210
c1855b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -22,7 +22,7 @@ | |||||||||||
| package cc.unitmesh.devti.llms.custom | ||||||||||||
|
|
||||||||||||
| import com.intellij.openapi.diagnostic.logger | ||||||||||||
| import io.reactivex.rxjava3.core.FlowableEmitter | ||||||||||||
| import kotlinx.coroutines.channels.ProducerScope | ||||||||||||
| import okhttp3.Call | ||||||||||||
| import okhttp3.Callback | ||||||||||||
| import okhttp3.Response | ||||||||||||
|
|
@@ -39,10 +39,9 @@ class AutoDevHttpException(error: String, private val statusCode: Int) : Runtime | |||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Callback to parse Server Sent Events (SSE) from raw InputStream and | ||||||||||||
| * emit the events with io.reactivex.FlowableEmitter to allow streaming of | ||||||||||||
| * SSE. | ||||||||||||
| * emit the events with ProducerScope to allow streaming of SSE. | ||||||||||||
| */ | ||||||||||||
| class ResponseBodyCallback(private val emitter: FlowableEmitter<SSE>, private val emitDone: Boolean) : Callback { | ||||||||||||
| class ResponseBodyCallback(private val emitter: ProducerScope<SSE>, private val emitDone: Boolean) : Callback { | ||||||||||||
| val logger = logger<ResponseBodyCallback>() | ||||||||||||
|
|
||||||||||||
| override fun onResponse(call: Call, response: Response) { | ||||||||||||
|
|
@@ -59,7 +58,7 @@ class ResponseBodyCallback(private val emitter: FlowableEmitter<SSE>, private va | |||||||||||
| reader = BufferedReader(InputStreamReader(inputStream, StandardCharsets.UTF_8)) | ||||||||||||
| var line: String? = null | ||||||||||||
| var sse: SSE? = null | ||||||||||||
| while (!emitter.isCancelled && reader.readLine().also { line = it } != null) { | ||||||||||||
| while (!emitter.isClosedForSend && reader.readLine().also { line = it } != null) { | ||||||||||||
| sse = when { | ||||||||||||
| line!!.startsWith("data:") -> { | ||||||||||||
| val data = line!!.substring(5).trim { it <= ' ' } | ||||||||||||
|
|
@@ -69,11 +68,11 @@ class ResponseBodyCallback(private val emitter: FlowableEmitter<SSE>, private va | |||||||||||
| line == "" && sse != null -> { | ||||||||||||
| if (sse.isDone) { | ||||||||||||
| if (emitDone) { | ||||||||||||
| emitter.onNext(sse) | ||||||||||||
| emitter.trySend(sse) | ||||||||||||
| } | ||||||||||||
| break | ||||||||||||
| } | ||||||||||||
| emitter.onNext(sse) | ||||||||||||
| emitter.trySend(sse) | ||||||||||||
|
||||||||||||
| emitter.trySend(sse) | |
| val result = emitter.trySend(sse) | |
| if (!result.isSuccess) { | |
| logger.warn("SSE message dropped: $sse (reason: ${result.exceptionOrNull()?.message})") | |
| } |
Copilot
AI
Dec 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using trySend() without checking the result can silently drop messages if the channel buffer is full. Unlike RxJava's onNext() which would handle backpressure, trySend() returns a ChannelResult that should be checked. Consider using send() (which suspends) or handling the trySend() result to detect message loss.
Copilot
AI
Dec 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using trySend() without checking the result can silently drop messages if the channel buffer is full. Unlike RxJava's onNext() which would handle backpressure, trySend() returns a ChannelResult that should be checked. Consider using send() (which suspends) or handling the trySend() result to detect message loss.
| emitter.trySend(SSE(line)) | |
| val sendResult = emitter.trySend(SSE(line)) | |
| if (!sendResult.isSuccess) { | |
| logger.error("Failed to send SSE event: $line. Reason: ${sendResult.exceptionOrNull()}") | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent capitalization: "Intellij" should be "IntelliJ" (with capital J) to match JetBrains' official product naming.