mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
fix(core): open ai chat for first time (#7291)
There are two issues here: 1. open right sidebar with chat 2. notify chat-panel of selected content The second issue will be fixed in a subsequent PR.
This commit is contained in:
@@ -401,6 +401,7 @@ const OthersAIGroup: AIItemGroupConfig = {
|
||||
icon: CommentIcon,
|
||||
handler: host => {
|
||||
const panel = getAIPanel(host);
|
||||
AIProvider.slots.requestOpenWithChat.emit();
|
||||
AIProvider.slots.requestContinueWithAIInChat.emit({ host });
|
||||
panel.hide();
|
||||
},
|
||||
@@ -410,6 +411,7 @@ const OthersAIGroup: AIItemGroupConfig = {
|
||||
icon: ChatWithAIIcon,
|
||||
handler: host => {
|
||||
const panel = getAIPanel(host);
|
||||
AIProvider.slots.requestOpenWithChat.emit();
|
||||
AIProvider.slots.requestContinueInChat.emit({
|
||||
host: host,
|
||||
show: true,
|
||||
|
||||
@@ -463,6 +463,7 @@ export function actionToResponse<T extends keyof BlockSuitePresets.AIActions>(
|
||||
handler: () => {
|
||||
reportResponse('result:continue-in-chat');
|
||||
const panel = getAIPanel(host);
|
||||
AIProvider.slots.requestOpenWithChat.emit();
|
||||
AIProvider.slots.requestContinueInChat.emit({
|
||||
host: host,
|
||||
show: true,
|
||||
|
||||
@@ -233,6 +233,7 @@ export function buildTextResponseConfig<
|
||||
icon: ChatWithAIIcon,
|
||||
handler: () => {
|
||||
reportResponse('result:continue-in-chat');
|
||||
AIProvider.slots.requestOpenWithChat.emit();
|
||||
AIProvider.slots.requestContinueInChat.emit({
|
||||
host: panel.host,
|
||||
show: true,
|
||||
|
||||
@@ -105,6 +105,7 @@ const othersGroup: AIItemGroupConfig = {
|
||||
showWhen: () => true,
|
||||
handler: host => {
|
||||
const panel = getAIPanel(host);
|
||||
AIProvider.slots.requestOpenWithChat.emit();
|
||||
AIProvider.slots.requestContinueWithAIInChat.emit({
|
||||
host,
|
||||
mode: 'edgeless',
|
||||
@@ -118,6 +119,7 @@ const othersGroup: AIItemGroupConfig = {
|
||||
showWhen: () => true,
|
||||
handler: host => {
|
||||
const panel = getAIPanel(host);
|
||||
AIProvider.slots.requestOpenWithChat.emit();
|
||||
AIProvider.slots.requestContinueInChat.emit({
|
||||
host: host,
|
||||
show: true,
|
||||
|
||||
@@ -80,6 +80,7 @@ export class AIProvider {
|
||||
private readonly slots = {
|
||||
// use case: when user selects "continue in chat" in an ask ai result panel
|
||||
// do we need to pass the context to the chat panel?
|
||||
requestOpenWithChat: new Slot(),
|
||||
requestContinueInChat: new Slot<{ host: EditorHost; show: boolean }>(),
|
||||
requestContinueWithAIInChat: new Slot<{
|
||||
host: EditorHost;
|
||||
|
||||
@@ -73,7 +73,7 @@ const DocPreview = forwardRef<
|
||||
}, [docId, docs.list, resolvedMode, mode]);
|
||||
|
||||
useEffect(() => {
|
||||
const disposable = AIProvider.slots.requestContinueInChat.on(() => {
|
||||
const disposable = AIProvider.slots.requestOpenWithChat.on(() => {
|
||||
if (doc) {
|
||||
workbench.openPage(doc.id);
|
||||
peekView.close();
|
||||
|
||||
@@ -106,7 +106,7 @@ const DetailPageImpl = memo(function DetailPageImpl() {
|
||||
}, [editor, isActiveView, setActiveBlockSuiteEditor]);
|
||||
|
||||
useEffect(() => {
|
||||
AIProvider.slots.requestContinueInChat.on(() => {
|
||||
AIProvider.slots.requestOpenWithChat.on(() => {
|
||||
rightSidebar.open();
|
||||
if (activeTabName !== 'chat') {
|
||||
setActiveTabName('chat');
|
||||
|
||||
Reference in New Issue
Block a user