mirror of
https://github.com/logancyang/obsidian-copilot.git
synced 2026-07-22 07:50:24 +00:00
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:
parent
0c9ce57dd5
commit
19dd1aab40
1 changed files with 14 additions and 11 deletions
|
|
@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue