mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
fix(core): chat input will be sent repeatedly in two documents with split view (#9289)
Fix issue [AF-2011](https://linear.app/affine-design/issue/AF-2011). Add `host` strict equality check before ai request send.
This commit is contained in:
@@ -74,7 +74,11 @@ export class AskAIToolbarButton extends WithDisposable(LitElement) {
|
||||
AIProvider.slots.requestOpenWithChat.emit({ host: this.host });
|
||||
extractContext(this.host)
|
||||
.then(context => {
|
||||
AIProvider.slots.requestSendWithChat.emit({ input, context });
|
||||
AIProvider.slots.requestSendWithChat.emit({
|
||||
input,
|
||||
context,
|
||||
host: this.host,
|
||||
});
|
||||
})
|
||||
.catch(console.error);
|
||||
};
|
||||
|
||||
@@ -300,11 +300,15 @@ export class ChatPanelInput extends WithDisposable(LitElement) {
|
||||
super.connectedCallback();
|
||||
|
||||
this._disposables.add(
|
||||
AIProvider.slots.requestSendWithChat.on(async ({ input, context }) => {
|
||||
context && this.updateContext(context);
|
||||
await this.updateComplete;
|
||||
await this.send(input);
|
||||
})
|
||||
AIProvider.slots.requestSendWithChat.on(
|
||||
async ({ input, context, host }) => {
|
||||
if (this.host === host) {
|
||||
context && this.updateContext(context);
|
||||
await this.updateComplete;
|
||||
await this.send(input);
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,11 @@ export function setupEdgelessElementToolbarAIEntry(
|
||||
AIProvider.slots.requestOpenWithChat.emit({ host: edgeless.host });
|
||||
extractContext(edgeless.host)
|
||||
.then(context => {
|
||||
AIProvider.slots.requestSendWithChat.emit({ input, context });
|
||||
AIProvider.slots.requestSendWithChat.emit({
|
||||
input,
|
||||
context,
|
||||
host: edgeless.host,
|
||||
});
|
||||
})
|
||||
.catch(console.error);
|
||||
};
|
||||
|
||||
@@ -24,6 +24,7 @@ export interface AIChatParams {
|
||||
}
|
||||
|
||||
export interface AISendParams {
|
||||
host: EditorHost;
|
||||
input?: string;
|
||||
context?: Partial<ChatContextValue | null>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user