mirror of
https://github.com/toeverything/AFFiNE.git
synced 2025-01-08 09:36:26 +03: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:
parent
bf0cba31d3
commit
92be6b2ff7
@ -401,6 +401,7 @@ const OthersAIGroup: AIItemGroupConfig = {
|
|||||||
icon: CommentIcon,
|
icon: CommentIcon,
|
||||||
handler: host => {
|
handler: host => {
|
||||||
const panel = getAIPanel(host);
|
const panel = getAIPanel(host);
|
||||||
|
AIProvider.slots.requestOpenWithChat.emit();
|
||||||
AIProvider.slots.requestContinueWithAIInChat.emit({ host });
|
AIProvider.slots.requestContinueWithAIInChat.emit({ host });
|
||||||
panel.hide();
|
panel.hide();
|
||||||
},
|
},
|
||||||
@ -410,6 +411,7 @@ const OthersAIGroup: AIItemGroupConfig = {
|
|||||||
icon: ChatWithAIIcon,
|
icon: ChatWithAIIcon,
|
||||||
handler: host => {
|
handler: host => {
|
||||||
const panel = getAIPanel(host);
|
const panel = getAIPanel(host);
|
||||||
|
AIProvider.slots.requestOpenWithChat.emit();
|
||||||
AIProvider.slots.requestContinueInChat.emit({
|
AIProvider.slots.requestContinueInChat.emit({
|
||||||
host: host,
|
host: host,
|
||||||
show: true,
|
show: true,
|
||||||
|
@ -463,6 +463,7 @@ export function actionToResponse<T extends keyof BlockSuitePresets.AIActions>(
|
|||||||
handler: () => {
|
handler: () => {
|
||||||
reportResponse('result:continue-in-chat');
|
reportResponse('result:continue-in-chat');
|
||||||
const panel = getAIPanel(host);
|
const panel = getAIPanel(host);
|
||||||
|
AIProvider.slots.requestOpenWithChat.emit();
|
||||||
AIProvider.slots.requestContinueInChat.emit({
|
AIProvider.slots.requestContinueInChat.emit({
|
||||||
host: host,
|
host: host,
|
||||||
show: true,
|
show: true,
|
||||||
|
@ -233,6 +233,7 @@ export function buildTextResponseConfig<
|
|||||||
icon: ChatWithAIIcon,
|
icon: ChatWithAIIcon,
|
||||||
handler: () => {
|
handler: () => {
|
||||||
reportResponse('result:continue-in-chat');
|
reportResponse('result:continue-in-chat');
|
||||||
|
AIProvider.slots.requestOpenWithChat.emit();
|
||||||
AIProvider.slots.requestContinueInChat.emit({
|
AIProvider.slots.requestContinueInChat.emit({
|
||||||
host: panel.host,
|
host: panel.host,
|
||||||
show: true,
|
show: true,
|
||||||
|
@ -105,6 +105,7 @@ const othersGroup: AIItemGroupConfig = {
|
|||||||
showWhen: () => true,
|
showWhen: () => true,
|
||||||
handler: host => {
|
handler: host => {
|
||||||
const panel = getAIPanel(host);
|
const panel = getAIPanel(host);
|
||||||
|
AIProvider.slots.requestOpenWithChat.emit();
|
||||||
AIProvider.slots.requestContinueWithAIInChat.emit({
|
AIProvider.slots.requestContinueWithAIInChat.emit({
|
||||||
host,
|
host,
|
||||||
mode: 'edgeless',
|
mode: 'edgeless',
|
||||||
@ -118,6 +119,7 @@ const othersGroup: AIItemGroupConfig = {
|
|||||||
showWhen: () => true,
|
showWhen: () => true,
|
||||||
handler: host => {
|
handler: host => {
|
||||||
const panel = getAIPanel(host);
|
const panel = getAIPanel(host);
|
||||||
|
AIProvider.slots.requestOpenWithChat.emit();
|
||||||
AIProvider.slots.requestContinueInChat.emit({
|
AIProvider.slots.requestContinueInChat.emit({
|
||||||
host: host,
|
host: host,
|
||||||
show: true,
|
show: true,
|
||||||
|
@ -80,6 +80,7 @@ export class AIProvider {
|
|||||||
private readonly slots = {
|
private readonly slots = {
|
||||||
// use case: when user selects "continue in chat" in an ask ai result panel
|
// 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?
|
// do we need to pass the context to the chat panel?
|
||||||
|
requestOpenWithChat: new Slot(),
|
||||||
requestContinueInChat: new Slot<{ host: EditorHost; show: boolean }>(),
|
requestContinueInChat: new Slot<{ host: EditorHost; show: boolean }>(),
|
||||||
requestContinueWithAIInChat: new Slot<{
|
requestContinueWithAIInChat: new Slot<{
|
||||||
host: EditorHost;
|
host: EditorHost;
|
||||||
|
@ -73,7 +73,7 @@ const DocPreview = forwardRef<
|
|||||||
}, [docId, docs.list, resolvedMode, mode]);
|
}, [docId, docs.list, resolvedMode, mode]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const disposable = AIProvider.slots.requestContinueInChat.on(() => {
|
const disposable = AIProvider.slots.requestOpenWithChat.on(() => {
|
||||||
if (doc) {
|
if (doc) {
|
||||||
workbench.openPage(doc.id);
|
workbench.openPage(doc.id);
|
||||||
peekView.close();
|
peekView.close();
|
||||||
|
@ -106,7 +106,7 @@ const DetailPageImpl = memo(function DetailPageImpl() {
|
|||||||
}, [editor, isActiveView, setActiveBlockSuiteEditor]);
|
}, [editor, isActiveView, setActiveBlockSuiteEditor]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
AIProvider.slots.requestContinueInChat.on(() => {
|
AIProvider.slots.requestOpenWithChat.on(() => {
|
||||||
rightSidebar.open();
|
rightSidebar.open();
|
||||||
if (activeTabName !== 'chat') {
|
if (activeTabName !== 'chat') {
|
||||||
setActiveTabName('chat');
|
setActiveTabName('chat');
|
||||||
|
Loading…
Reference in New Issue
Block a user