fix(core): ai apply ui opt (#13238)

> CLOSE AI-377 AI-372 AI-373 AI-381 AI-378 AI-374 AI-382 AI-375

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Style**
* Improved button styling for tool controls, including hover effects and
consistent padding.
* Updated background colors and border placements for result cards and
headers.

* **New Features**
  * Added tooltips to control buttons for enhanced user guidance.

* **Bug Fixes**
* Improved accessibility by replacing clickable spans with button
elements.
* Updated loading indicators to use a spinner icon for clearer feedback
during actions.

* **Refactor**
* Simplified layout and reduced unnecessary wrapper elements for cleaner
rendering.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
德布劳外 · 贾贵
2025-07-17 09:16:26 +00:00
committed by GitHub
parent 07f2f7b5a8
commit dc68c2385d
@@ -2,7 +2,7 @@ import track from '@affine/track';
import { WithDisposable } from '@blocksuite/affine/global/lit'; import { WithDisposable } from '@blocksuite/affine/global/lit';
import { unsafeCSSVar, unsafeCSSVarV2 } from '@blocksuite/affine/shared/theme'; import { unsafeCSSVar, unsafeCSSVarV2 } from '@blocksuite/affine/shared/theme';
import { type EditorHost, ShadowlessElement } from '@blocksuite/affine/std'; import { type EditorHost, ShadowlessElement } from '@blocksuite/affine/std';
import { AIStarIconWithAnimation } from '@blocksuite/affine-components/icons'; import { LoadingIcon } from '@blocksuite/affine-components/icons';
import type { NotificationService } from '@blocksuite/affine-shared/services'; import type { NotificationService } from '@blocksuite/affine-shared/services';
import { import {
CloseIcon, CloseIcon,
@@ -83,7 +83,7 @@ export class DocEditTool extends WithDisposable(ShadowlessElement) {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: flex-start; align-items: flex-start;
background: ${unsafeCSSVarV2('layer/background/overlayPanel')}; background: ${unsafeCSSVar('--affine-overlay-panel-shadow')};
box-shadow: ${unsafeCSSVar('shadow1')}; box-shadow: ${unsafeCSSVar('shadow1')};
border-radius: 8px; border-radius: 8px;
width: 100%; width: 100%;
@@ -96,7 +96,6 @@ export class DocEditTool extends WithDisposable(ShadowlessElement) {
width: 100%; width: 100%;
justify-content: space-between; justify-content: space-between;
border-bottom: 1px solid ${unsafeCSSVarV2('layer/insideBorder/border')};
.doc-edit-tool-result-card-header-title { .doc-edit-tool-result-card-header-title {
display: flex; display: flex;
@@ -118,9 +117,17 @@ export class DocEditTool extends WithDisposable(ShadowlessElement) {
padding-right: 8px; padding-right: 8px;
color: ${unsafeCSSVarV2('text/secondary')}; color: ${unsafeCSSVarV2('text/secondary')};
span { button {
width: 20px; cursor: pointer;
height: 20px; padding: 2px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 4px;
}
button:hover {
background: ${unsafeCSSVar('hoverColor')};
} }
} }
} }
@@ -128,23 +135,27 @@ export class DocEditTool extends WithDisposable(ShadowlessElement) {
.doc-edit-tool-result-card-content { .doc-edit-tool-result-card-content {
padding: 8px; padding: 8px;
width: 100%; width: 100%;
border-top: 1px solid ${unsafeCSSVarV2('layer/insideBorder/border')};
} }
.doc-edit-tool-result-card-footer { .doc-edit-tool-result-card-footer {
display: flex; display: flex;
justify-content: flex-end; justify-content: flex-end;
align-items: center; align-items: center;
padding: 8px;
gap: 4px; gap: 4px;
width: 100%; width: 100%;
cursor: pointer; cursor: pointer;
.doc-edit-tool-result-reject, button {
.doc-edit-tool-result-accept {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 4px; gap: 4px;
padding: 8px; padding: 4px;
border-radius: 4px;
}
button:hover {
background: ${unsafeCSSVar('hoverColor')};
} }
} }
@@ -421,55 +432,55 @@ export class DocEditTool extends WithDisposable(ShadowlessElement) {
${docId} ${docId}
</div> </div>
<div class="doc-edit-tool-result-card-header-operations"> <div class="doc-edit-tool-result-card-header-operations">
<span @click=${() => this._toggleCollapse()} <button @click=${() => this._toggleCollapse()}>
>${this.isCollapsed ${this.isCollapsed ? ExpandFullIcon() : ExpandCloseIcon()}
? ExpandFullIcon() <affine-tooltip>
: ExpandCloseIcon()}</span ${this.isCollapsed ? 'Expand' : 'Collapse'}
> </affine-tooltip>
<span @click=${() => this._handleCopy(changedContent)}> </button>
<button @click=${() => this._handleCopy(changedContent)}>
${CopyIcon()} ${CopyIcon()}
</span> <affine-tooltip>Copy</affine-tooltip>
</button>
<button <button
@click=${() => this._handleApply(op, updates)} @click=${() => this._handleApply(op, updates)}
?disabled=${this.isBusyForOp(op)} ?disabled=${this.isBusyForOp(op)}
> >
${this.applyingMap[op] ${this.applyingMap[op]
? AIStarIconWithAnimation ? html`${LoadingIcon()} Applying`
: html`Apply`} : 'Apply'}
</button> </button>
</div> </div>
</div> </div>
<div class="doc-edit-tool-result-card-content"> <div class="doc-edit-tool-result-card-content">
<div class="doc-edit-tool-result-card-content-title"> ${this.renderBlockDiffs(diffs)}
${this.renderBlockDiffs(diffs)} <div class="doc-edit-tool-result-card-footer">
<button
class="doc-edit-tool-result-reject"
@click=${() => this._handleReject(op)}
>
${CloseIcon({
style: `color: ${unsafeCSSVarV2('icon/secondary')}`,
})}
Reject
</button>
<button
class="doc-edit-tool-result-accept"
@click=${() => this._handleAccept(op, updates)}
?disabled=${this.isBusyForOp(op)}
style="${this.isBusyForOp(op)
? 'pointer-events: none; opacity: 0.6;'
: ''}"
>
${this.acceptingMap[op]
? html`${LoadingIcon()}`
: DoneIcon({
style: `color: ${unsafeCSSVarV2('icon/activated')}`,
})}
${this.acceptingMap[op] ? 'Accepting...' : 'Accept'}
</button>
</div> </div>
</div> </div>
<div class="doc-edit-tool-result-card-footer">
<div
class="doc-edit-tool-result-reject"
@click=${() => this._handleReject(op)}
>
${CloseIcon({
style: `color: ${unsafeCSSVarV2('icon/secondary')}`,
})}
Reject
</div>
<button
class="doc-edit-tool-result-accept"
@click=${() => this._handleAccept(op, updates)}
?disabled=${this.isBusyForOp(op)}
style="${this.isBusyForOp(op)
? 'pointer-events: none; opacity: 0.6;'
: ''}"
>
${this.acceptingMap[op]
? AIStarIconWithAnimation
: DoneIcon({
style: `color: ${unsafeCSSVarV2('icon/activated')}`,
})}
${this.acceptingMap[op] ? 'Accepting...' : 'Accept'}
</button>
</div>
</div> </div>
</div> </div>
`; `;