Skip to content

Commit b67ce2a

Browse files
committed
fix(webview): tolerate missing view state id helper
1 parent ee7c08e commit b67ce2a

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

webview-ui/src/App.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,14 @@ const App = () => {
191191
}, [telemetrySetting, telemetryKey, machineId, didHydrateState])
192192

193193
// Tell the extension that we are ready to receive messages.
194-
useEffect(() => vscode.postMessage({ type: "webviewDidLaunch", viewStateId: vscode.getViewStateId() }), [])
194+
useEffect(
195+
() =>
196+
vscode.postMessage({
197+
type: "webviewDidLaunch",
198+
viewStateId: typeof vscode.getViewStateId === "function" ? vscode.getViewStateId() : undefined,
199+
}),
200+
[],
201+
)
195202

196203
// Initialize source map support for better error reporting
197204
useEffect(() => {

webview-ui/src/context/ExtensionStateContext.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,10 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode
489489
}, [handleMessage])
490490

491491
useEffect(() => {
492-
vscode.postMessage({ type: "webviewDidLaunch", viewStateId: vscode.getViewStateId() })
492+
vscode.postMessage({
493+
type: "webviewDidLaunch",
494+
viewStateId: typeof vscode.getViewStateId === "function" ? vscode.getViewStateId() : undefined,
495+
})
493496
}, [])
494497

495498
// Apply the configurable chat font size as a CSS variable. When unset, the

0 commit comments

Comments
 (0)