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:
fundon 2024-06-21 01:52:29 +00:00 committed by Fangdun Tsai
parent bf0cba31d3
commit 92be6b2ff7
No known key found for this signature in database
GPG Key ID: C4E964E8E5E3A7BF
7 changed files with 9 additions and 2 deletions

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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;

View File

@ -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();

View File

@ -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');