fix(core): ai message resending (#13359)

Close [AI-395](https://linear.app/affine-design/issue/AI-395)

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

* **Bug Fixes**
* Improved chat stability by resetting chat action signals after
processing to prevent repeated triggers.

* **New Features**
* Added end-to-end tests for new chat session creation and chat pinning
functionality to enhance reliability.

* **Enhancements**
* Enhanced chat toolbar with test identifiers and pinned state
attributes for better accessibility and testing.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: fengmk2 <fengmk2@gmail.com>
This commit is contained in:
Wu Yue
2025-07-30 14:44:44 +08:00
committed by GitHub
parent b61807d005
commit 603f2a1e5a
4 changed files with 94 additions and 1 deletions

View File

@@ -391,6 +391,7 @@ export class AIChatContent extends SignalWatcher(
})
.catch(console.error);
}
AIProvider.slots.requestOpenWithChat.next(null);
}
)
);

View File

@@ -405,6 +405,7 @@ export class AIChatInput extends SignalWatcher(
this.send(input).catch(console.error);
}, 0);
}
AIProvider.slots.requestSendWithChat.next(null);
}
)
);

View File

@@ -92,14 +92,20 @@ export class AIChatToolbar extends WithDisposable(ShadowlessElement) {
const pinned = this.session?.pinned;
return html`
<div class="ai-chat-toolbar">
<div class="chat-toolbar-icon" @click=${this.onPlusClick}>
<div
class="chat-toolbar-icon"
@click=${this.onPlusClick}
data-testid="ai-panel-new-chat"
>
${PlusIcon()}
<affine-tooltip>New Chat</affine-tooltip>
</div>
<div
class="chat-toolbar-icon"
@click=${this.onPinClick}
data-pinned=${!!pinned}
data-disabled=${this.isGenerating}
data-testid="ai-panel-pin-chat"
>
${pinned ? PinedIcon() : PinIcon()}
<affine-tooltip>