✨ streaming response in jetbrains

This commit is contained in:
Nate Sesti 2023-12-20 21:04:53 -05:00
parent c7d2b8a16a
commit e166dc2c48
4 changed files with 9 additions and 40 deletions

View file

@ -4,7 +4,7 @@ pluginGroup = com.github.continuedev.continueintellijextension
pluginName = continue-intellij-extension
pluginRepositoryUrl = https://github.com/continuedev/continue
# SemVer format -> https://semver.org
pluginVersion = 0.0.21
pluginVersion = 0.0.22
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 223

View file

@ -96,7 +96,6 @@ fun Application.proxyServer() {
}
}
// Read the response
call.respondOutputStream(ContentType.parse(response.header("Content-Type") ?: "text/plain"), HttpStatusCode(response.code, response.message)) {
response.body?.byteStream()?.use { inputStream ->
if (inputStream == null) {
@ -109,43 +108,9 @@ fun Application.proxyServer() {
break
}
write(buffer, 0, bytesRead)
flush()
}
}
}
}
}
// Trying to use ktor client, but dependency problems
// val client = HttpClient()
// val response = client.request(continueUrl) {
// method = HttpMethod.parse(originalRequest.httpMethod.value)
// headers {
// originalRequest.headers.forEach { key, values ->
// if (key != HttpHeaders.Host && key != HttpHeaders.Origin) {
// appendAll(key, values)
// }
// }
// append(HttpHeaders.Host, parsedUrl.host)
// }
// }
// call.respond(object : OutgoingContent.WriteChannelContent() {
// override val headers: Headers = ktorHeaders;
// override val status: HttpStatusCode = HttpStatusCode(response.code, response.message)
// override suspend fun writeTo(channel: ByteWriteChannel) {
// response.body?.byteStream().use { inputStream ->
// if (inputStream == null) {
// return;
// }
// val buffer = byteArray(4096) // size of the buffer can be adjusted as needed
// while (true) {
// val bytesRead = inputStream.read(buffer)
// if (bytesRead == -1) {
// break
// }
// channel.writeFully(buffer, 0, bytesRead)
// }
// }
// }
// })
}

View file

@ -58,7 +58,7 @@ import {
getMetaKeyLabel,
getPlatform,
} from "../../util";
import { postToIde } from "../../util/ide";
import { isJetBrains, postToIde } from "../../util/ide";
import {
handleKeyDownJetBrains,
handleKeyDownJetBrainsMac,
@ -1642,7 +1642,7 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => {
}}
className="mr-auto"
>
New Session ({getMetaKeyLabel()} M)
New Session ({getMetaKeyLabel()} {isJetBrains() ? "J" : "M"})
</NewSessionButton>
) : null)}
</div>

View file

@ -87,3 +87,7 @@ export function appendText(text: string) {
div.innerText = text;
document.body.appendChild(div);
}
export function isJetBrains() {
return localStorage.getItem("ide") === "jetbrains";
}