Skip to content

Commit

Permalink
Merge pull request #3134 from 0xBigBoss/allen/fix-intellij-freezing
Browse files Browse the repository at this point in the history
fix: intellij sidebar chat freezing
  • Loading branch information
Patrick-Erichsen authored Dec 4, 2024
2 parents 1d7919f + 1f602e5 commit 80985b2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion core/protocol/ideWebview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & {
insertAtCursor: [{ text: string }, void];
copyText: [{ text: string }, void];
"jetbrains/editorInsetHeight": [{ height: number }, void];
"jetbrains/isOSREnabled": [undefined, void];
"jetbrains/isOSREnabled": [undefined, boolean];
"vscode/openMoveRightMarkdown": [undefined, void];
setGitHubAuthToken: [{ token: string }, void];
acceptDiff: [{ filepath: string; streamId?: string }, void];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class ContinueBrowser(val project: Project, url: String) {
}

"jetbrains/isOSREnabled" -> {
sendToWebview( "jetbrains/isOSREnabled", isOSREnabled)
respond(isOSREnabled)
}

"onLoad" -> {
Expand Down Expand Up @@ -268,7 +268,9 @@ class ContinueBrowser(val project: Project, url: String) {
val jsCode = buildJavaScript(jsonData)

try {
this.browser.executeJavaScriptAsync(jsCode)
this.browser.executeJavaScriptAsync(jsCode).onError {
println("Failed to execute jsCode error: ${it.message}")
}
} catch (error: IllegalStateException) {
println("Webview not initialized yet $error")
}
Expand Down
16 changes: 10 additions & 6 deletions gui/src/hooks/useIsOSREnabled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@ export default function useIsOSREnabled() {
const [isOSREnabled, setIsOSREnabled] = useState(false);
const ideMessenger = useContext(IdeMessengerContext);

useWebviewListener("jetbrains/isOSREnabled", async (isOSREnabled) => {
setIsOSREnabled(isOSREnabled);
});

useEffect(() => {
if (isJetBrains()) {
ideMessenger.post("jetbrains/isOSREnabled", undefined);
(async () => {
await ideMessenger
.request("jetbrains/isOSREnabled", undefined)
.then((result) => {
if (result.status === "success") {
setIsOSREnabled(result.content);
}
});
})();
}
}, []);
}, [ideMessenger]);

return isOSREnabled;
}

0 comments on commit 80985b2

Please sign in to comment.