fix: copilot ci (#9066)

This commit is contained in:
darkskygit
2024-12-09 11:11:04 +00:00
parent 814b4c9cb0
commit 31146e5213
10 changed files with 95 additions and 80 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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