mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
fix(core): ask ai loses user selected context (#11767)
Close [AI-72](https://linear.app/affine-design/issue/AI-72)
This commit is contained in:
@@ -281,12 +281,9 @@ export class AIChatInput extends SignalWatcher(WithDisposable(LitElement)) {
|
||||
({ input, context, host }) => {
|
||||
if (this.host === host) {
|
||||
context && this.updateContext(context);
|
||||
const { updateComplete, send } = this;
|
||||
updateComplete
|
||||
.then(() => {
|
||||
return send(input);
|
||||
})
|
||||
.catch(console.error);
|
||||
setTimeout(() => {
|
||||
this.send(input).catch(console.error);
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@@ -84,11 +84,11 @@ export class AIPanelInput extends SignalWatcher(WithDisposable(LitElement)) {
|
||||
}
|
||||
}
|
||||
|
||||
.arrow[data-active] {
|
||||
.arrow[data-active='true'] {
|
||||
background: ${unsafeCSSVarV2('icon/activated')};
|
||||
}
|
||||
|
||||
.arrow[data-active]:hover {
|
||||
.arrow[data-active='true']:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ export class AIPanelInput extends SignalWatcher(WithDisposable(LitElement)) {
|
||||
)};
|
||||
}
|
||||
|
||||
.arrow[data-active] {
|
||||
.arrow[data-active='true'] {
|
||||
background: ${unsafeCSS(
|
||||
lightCssVariablesV2['--affine-v2-icon-activated']
|
||||
)};
|
||||
@@ -178,7 +178,7 @@ export class AIPanelInput extends SignalWatcher(WithDisposable(LitElement)) {
|
||||
)};
|
||||
}
|
||||
|
||||
.arrow[data-active] {
|
||||
.arrow[data-active='true'] {
|
||||
background: ${unsafeCSS(
|
||||
darkCssVariablesV2['--affine-v2-icon-activated']
|
||||
)};
|
||||
@@ -196,13 +196,8 @@ export class AIPanelInput extends SignalWatcher(WithDisposable(LitElement)) {
|
||||
|
||||
this.onInput?.(this.textarea.value);
|
||||
const value = this.textarea.value.trim();
|
||||
if (value.length > 0) {
|
||||
this._arrow.dataset.active = '';
|
||||
this._hasContent = true;
|
||||
} else {
|
||||
delete this._arrow.dataset.active;
|
||||
this._hasContent = false;
|
||||
}
|
||||
this._hasContent = value.length > 0;
|
||||
this._arrow.dataset.active = String(this._hasContent);
|
||||
};
|
||||
|
||||
private readonly _onKeyDown = (e: KeyboardEvent) => {
|
||||
@@ -264,6 +259,7 @@ export class AIPanelInput extends SignalWatcher(WithDisposable(LitElement)) {
|
||||
: nothing}
|
||||
<div
|
||||
class="arrow"
|
||||
data-testid="ai-panel-input-send"
|
||||
@click=${this._sendToAI}
|
||||
@pointerdown=${stopPropagation}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user