mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 05:14:54 +00:00
fix: copilot ci (#9066)
This commit is contained in:
@@ -412,7 +412,10 @@ const OthersAIGroup: AIItemGroupConfig = {
|
||||
icon: ChatWithAIIcon,
|
||||
handler: host => {
|
||||
const panel = getAIPanel(host);
|
||||
AIProvider.slots.requestOpenWithChat.emit({ host });
|
||||
AIProvider.slots.requestOpenWithChat.emit({
|
||||
host,
|
||||
appendCard: true,
|
||||
});
|
||||
panel.hide();
|
||||
},
|
||||
},
|
||||
|
||||
@@ -585,7 +585,10 @@ export function actionToResponse<T extends keyof BlockSuitePresets.AIActions>(
|
||||
handler: () => {
|
||||
reportResponse('result:continue-in-chat');
|
||||
const panel = getAIPanel(host);
|
||||
AIProvider.slots.requestOpenWithChat.emit({ host });
|
||||
AIProvider.slots.requestOpenWithChat.emit({
|
||||
host,
|
||||
appendCard: true,
|
||||
});
|
||||
panel.hide();
|
||||
},
|
||||
},
|
||||
|
||||
@@ -231,7 +231,10 @@ export function buildTextResponseConfig<
|
||||
icon: ChatWithAIIcon,
|
||||
handler: () => {
|
||||
reportResponse('result:continue-in-chat');
|
||||
AIProvider.slots.requestOpenWithChat.emit({ host });
|
||||
AIProvider.slots.requestOpenWithChat.emit({
|
||||
host,
|
||||
appendCard: true,
|
||||
});
|
||||
panel.hide();
|
||||
},
|
||||
},
|
||||
|
||||
@@ -12,6 +12,7 @@ import { css, html, nothing, type PropertyValues } from 'lit';
|
||||
import { property, query, state } from 'lit/decorators.js';
|
||||
import { repeat } from 'lit/directives/repeat.js';
|
||||
import { styleMap } from 'lit/directives/style-map.js';
|
||||
import { debounce } from 'lodash-es';
|
||||
|
||||
import {
|
||||
EdgelessEditorActions,
|
||||
@@ -133,7 +134,7 @@ export class ChatPanelMessages extends WithDisposable(ShadowlessElement) {
|
||||
accessor updateContext!: (context: Partial<ChatContextValue>) => void;
|
||||
|
||||
@query('.chat-panel-messages')
|
||||
accessor messagesContainer!: HTMLDivElement;
|
||||
accessor messagesContainer: HTMLDivElement | null = null;
|
||||
|
||||
@state()
|
||||
accessor showChatCards = true;
|
||||
@@ -203,6 +204,17 @@ export class ChatPanelMessages extends WithDisposable(ShadowlessElement) {
|
||||
</div>`;
|
||||
}
|
||||
|
||||
private readonly _onScroll = () => {
|
||||
if (!this.messagesContainer) return;
|
||||
const { clientHeight, scrollTop, scrollHeight } = this.messagesContainer;
|
||||
this.showDownIndicator = scrollHeight - scrollTop - clientHeight > 200;
|
||||
};
|
||||
|
||||
private readonly _debouncedOnScroll = debounce(
|
||||
this._onScroll.bind(this),
|
||||
100
|
||||
);
|
||||
|
||||
protected override render() {
|
||||
const { items } = this.chatContextValue;
|
||||
const { isLoading } = this;
|
||||
@@ -227,12 +239,7 @@ export class ChatPanelMessages extends WithDisposable(ShadowlessElement) {
|
||||
|
||||
<div
|
||||
class="chat-panel-messages"
|
||||
@scroll=${(evt: Event) => {
|
||||
const element = evt.target as HTMLDivElement;
|
||||
this.showDownIndicator =
|
||||
element.scrollHeight - element.scrollTop - element.clientHeight >
|
||||
200;
|
||||
}}
|
||||
@scroll=${() => this._debouncedOnScroll()}
|
||||
>
|
||||
${items.length === 0
|
||||
? html`<div class="chat-panel-messages-placeholder">
|
||||
@@ -390,6 +397,7 @@ export class ChatPanelMessages extends WithDisposable(ShadowlessElement) {
|
||||
scrollToEnd() {
|
||||
this.updateComplete
|
||||
.then(() => {
|
||||
if (!this.messagesContainer) return;
|
||||
this.messagesContainer.scrollTo({
|
||||
top: this.messagesContainer.scrollHeight,
|
||||
behavior: 'smooth',
|
||||
|
||||
@@ -195,17 +195,12 @@ export class ChatPanel extends WithDisposable(ShadowlessElement) {
|
||||
this._resetItems();
|
||||
}
|
||||
|
||||
if (!this.isLoading && _changedProperties.has('chatContextValue')) {
|
||||
if (this.chatContextValue.status !== 'idle') {
|
||||
this._scrollToEnd();
|
||||
}
|
||||
if (
|
||||
this.chatContextValue.status === 'loading' ||
|
||||
this.chatContextValue.status === 'error' ||
|
||||
this.chatContextValue.status === 'success'
|
||||
) {
|
||||
setTimeout(this._scrollToEnd, 500);
|
||||
}
|
||||
if (
|
||||
!this.isLoading &&
|
||||
_changedProperties.has('chatContextValue') &&
|
||||
this.chatContextValue.status !== 'idle'
|
||||
) {
|
||||
setTimeout(this._scrollToEnd, 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,11 @@ const othersGroup: AIItemGroupConfig = {
|
||||
showWhen: () => true,
|
||||
handler: host => {
|
||||
const panel = getAIPanel(host);
|
||||
AIProvider.slots.requestOpenWithChat.emit({ host, mode: 'edgeless' });
|
||||
AIProvider.slots.requestOpenWithChat.emit({
|
||||
host,
|
||||
mode: 'edgeless',
|
||||
appendCard: true,
|
||||
});
|
||||
panel.hide();
|
||||
},
|
||||
},
|
||||
|
||||
@@ -3,9 +3,8 @@ import {
|
||||
DocModeProvider,
|
||||
RefNodeSlotsProvider,
|
||||
} from '@blocksuite/affine/blocks';
|
||||
import { assertExists } from '@blocksuite/affine/global/utils';
|
||||
import type { AffineEditorContainer } from '@blocksuite/affine/presets';
|
||||
import { forwardRef, useCallback, useEffect, useRef } from 'react';
|
||||
import { forwardRef, useEffect, useRef } from 'react';
|
||||
|
||||
import * as styles from './chat.css';
|
||||
|
||||
@@ -20,13 +19,7 @@ export const EditorChatPanel = forwardRef(function EditorChatPanel(
|
||||
ref: React.ForwardedRef<ChatPanel>
|
||||
) {
|
||||
const chatPanelRef = useRef<ChatPanel | null>(null);
|
||||
|
||||
const onRefChange = useCallback((container: HTMLDivElement | null) => {
|
||||
if (container) {
|
||||
assertExists(chatPanelRef.current, 'chat panel should be initialized');
|
||||
container.append(chatPanelRef.current);
|
||||
}
|
||||
}, []);
|
||||
const containerRef = useRef<HTMLDivElement | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (onLoad && chatPanelRef.current) {
|
||||
@@ -45,40 +38,32 @@ export const EditorChatPanel = forwardRef(function EditorChatPanel(
|
||||
}, [onLoad, ref]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!editor) return;
|
||||
const pageService = editor.host?.std.getService('affine:page');
|
||||
if (!pageService) return;
|
||||
const docModeService = editor.host?.std.get(DocModeProvider);
|
||||
const refNodeService = editor.host?.std.getOptional(RefNodeSlotsProvider);
|
||||
if (!editor || !editor.host) return;
|
||||
|
||||
if (!chatPanelRef.current) {
|
||||
chatPanelRef.current = new ChatPanel();
|
||||
chatPanelRef.current.host = editor.host;
|
||||
chatPanelRef.current.doc = editor.doc;
|
||||
containerRef.current?.append(chatPanelRef.current);
|
||||
} else {
|
||||
chatPanelRef.current.host = editor.host;
|
||||
chatPanelRef.current.doc = editor.doc;
|
||||
}
|
||||
|
||||
const docModeService = editor.host.std.get(DocModeProvider);
|
||||
const refNodeService = editor.host.std.getOptional(RefNodeSlotsProvider);
|
||||
const disposable = [
|
||||
refNodeService &&
|
||||
refNodeService.docLinkClicked.on(() => {
|
||||
(chatPanelRef.current as ChatPanel).doc = editor.doc;
|
||||
}),
|
||||
docModeService &&
|
||||
docModeService.onPrimaryModeChange(() => {
|
||||
if (!editor.host) return;
|
||||
(chatPanelRef.current as ChatPanel).host = editor.host;
|
||||
}, editor.doc.id),
|
||||
refNodeService?.docLinkClicked.on(() => {
|
||||
(chatPanelRef.current as ChatPanel).doc = editor.doc;
|
||||
}),
|
||||
docModeService?.onPrimaryModeChange(() => {
|
||||
if (!editor.host) return;
|
||||
(chatPanelRef.current as ChatPanel).host = editor.host;
|
||||
}, editor.doc.id),
|
||||
];
|
||||
|
||||
return () => disposable.forEach(d => d?.dispose());
|
||||
}, [editor]);
|
||||
|
||||
if (!editor) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!chatPanelRef.current) {
|
||||
chatPanelRef.current = new ChatPanel();
|
||||
}
|
||||
|
||||
if (editor.host) {
|
||||
(chatPanelRef.current as ChatPanel).host = editor.host;
|
||||
}
|
||||
(chatPanelRef.current as ChatPanel).doc = editor.doc;
|
||||
// (copilotPanelRef.current as CopilotPanel).fitPadding = [20, 20, 20, 20];
|
||||
|
||||
return <div className={styles.root} ref={onRefChange} />;
|
||||
return <div className={styles.root} ref={containerRef} />;
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"ar": 74,
|
||||
"ca": 5,
|
||||
"da": 6,
|
||||
"de": 28,
|
||||
"de": 27,
|
||||
"el-GR": 0,
|
||||
"en": 100,
|
||||
"es-AR": 13,
|
||||
@@ -15,10 +15,10 @@
|
||||
"ja": 98,
|
||||
"ko": 78,
|
||||
"pl": 0,
|
||||
"pt-BR": 85,
|
||||
"pt-BR": 84,
|
||||
"ru": 72,
|
||||
"sv-SE": 4,
|
||||
"ur": 3,
|
||||
"zh-Hans": 99,
|
||||
"zh-Hans": 98,
|
||||
"zh-Hant": 98
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user