fix(vscode,ui): stop postMessage crash when opening chat in Cursor (#2335)
VS Code webviews delete window.parent, so ChatContainer's settings-sync effect threw TypeError on chat open. Also harden the webview bridge when acquireVsCodeApi() returns undefined and SSE panel disposal races. Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
co-authored by
Cursor Agent
Serhii Dziupin
parent
200c02cd00
commit
485efc7117
@@ -437,7 +437,8 @@ export class SessionEditorPanelProvider {
|
||||
headers: this._buildSseHeaders(headers),
|
||||
signal: controller.signal,
|
||||
onChunk: (chunk) => {
|
||||
entry.panel.webview.postMessage({ type: 'api:sse:chunk', streamId, chunk });
|
||||
// Panel may be disposed before SSE callbacks fire.
|
||||
entry.panel?.webview?.postMessage({ type: 'api:sse:chunk', streamId, chunk });
|
||||
},
|
||||
});
|
||||
|
||||
@@ -445,12 +446,12 @@ export class SessionEditorPanelProvider {
|
||||
|
||||
start.run
|
||||
.then(() => {
|
||||
entry.panel.webview.postMessage({ type: 'api:sse:end', streamId });
|
||||
entry.panel?.webview?.postMessage({ type: 'api:sse:end', streamId });
|
||||
})
|
||||
.catch((error) => {
|
||||
if (!controller.signal.aborted) {
|
||||
const messageText = error instanceof Error ? error.message : String(error);
|
||||
entry.panel.webview.postMessage({ type: 'api:sse:end', streamId, error: messageText });
|
||||
entry.panel?.webview?.postMessage({ type: 'api:sse:end', streamId, error: messageText });
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
|
||||
Reference in New Issue
Block a user