feat(ai): open Ask AI side panel with a preprompt in two modes (#22582)

Add the ability to open the Ask AI side panel pre-filled with a prompt
from any frontend component, with a mode to control whether the message
is sent automatically or left for the user to review.

- agentChatPrepromptState: holds the pending preprompt and its mode
(PREFILL = fill only, SEND = fill and auto-submit)
- useOpenAskAiPageWithPreprompt: seeds the new-thread draft, opens a
fresh Ask AI thread and stores the preprompt intent
- AgentChatPrepromptEffect: applies the intent once the chat editor and
send listener are mounted, either restoring the editor content or
dispatching the send event and clearing the editor

<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/twentyhq/twenty/pull/22582?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
This commit is contained in:
Weiko
2026-07-06 17:38:28 +02:00
committed by GitHub
parent 62c7e8f6b4
commit 8580cd6f27
6 changed files with 122 additions and 0 deletions
@@ -45,6 +45,16 @@ export type OpenSidePanelPageParams =
pageIcon?: string;
resetNavigationStack?: boolean;
}
| {
page: SidePanelPages.AskAI;
pageTitle: string;
pageIcon?: string;
shouldResetSearchState?: boolean;
preprompt?: {
text: string;
mode?: 'PREFILL' | 'SEND';
};
}
| {
page: Exclude<
SidePanelPages,
@@ -52,6 +62,7 @@ export type OpenSidePanelPageParams =
| SidePanelPages.EditRichText
| SidePanelPages.ComposeEmail
| SidePanelPages.ViewFrontComponent
| SidePanelPages.AskAI
>;
pageTitle: string;
pageIcon?: string;