fix(quick-ask): provide AppContext to overlay panel (#2466)

The Quick Ask overlay creates its own React root, so descendants that
call useApp() (AtMentionCommandPlugin → useAtMentionSearch →
useOpenWebTabs) crashed with "useApp() called outside of an
<AppContext.Provider>" when opening the panel.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Zero Liu 2026-05-15 10:58:01 -07:00 committed by GitHub
parent 0c9ce57dd5
commit 19dd1aab40
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -12,6 +12,7 @@ import React from "react";
import { createRoot, Root } from "react-dom/client";
import { updateDynamicStyleClass, clearDynamicStyleClass } from "@/utils/dom/dynamicStyleManager";
import { QuickAskPanel } from "./QuickAskPanel";
import { AppContext } from "@/context";
import type CopilotPlugin from "@/main";
import type { ReplaceGuard } from "@/editor/replaceGuard";
import type { ResizeDirection } from "@/hooks/use-resizable";
@ -239,17 +240,19 @@ export class QuickAskOverlay {
}
this.root.render(
<QuickAskPanel
plugin={this.options.plugin}
editor={this.options.editor}
view={this.options.view}
selectedText={this.options.selectedText}
replaceGuard={this.options.replaceGuard}
onClose={this.closeWithAnimation}
onDragOffset={this.handleDragOffset}
onResizeStart={this.handleResizeStart}
hasCustomHeight={this.hasUserResizedHeight}
/>
<AppContext.Provider value={this.options.plugin.app}>
<QuickAskPanel
plugin={this.options.plugin}
editor={this.options.editor}
view={this.options.view}
selectedText={this.options.selectedText}
replaceGuard={this.options.replaceGuard}
onClose={this.closeWithAnimation}
onDragOffset={this.handleDragOffset}
onResizeStart={this.handleResizeStart}
hasCustomHeight={this.hasUserResizedHeight}
/>
</AppContext.Provider>
);
}