feat: support chatting in center peek (#7601)

This commit is contained in:
donteatfriedrice
2024-07-26 09:36:26 +00:00
parent 6bc5337307
commit 1575472a3f
26 changed files with 2058 additions and 645 deletions
@@ -24,6 +24,7 @@ export type TextToTextOptions = {
signal?: AbortSignal;
retry?: boolean;
workflow?: boolean;
isRootSession?: boolean;
postfix?: (text: string) => string;
};
@@ -151,6 +152,7 @@ export function textToText({
timeout = TIMEOUT,
retry = false,
workflow = false,
isRootSession = false,
postfix,
}: TextToTextOptions) {
let _sessionId: string;
@@ -188,6 +190,9 @@ export function textToText({
workflow ? 'workflow' : undefined
);
AIProvider.LAST_ACTION_SESSIONID = _sessionId;
if (isRootSession) {
AIProvider.LAST_ROOT_SESSION_ID = _sessionId;
}
if (signal) {
if (signal.aborted) {
@@ -250,6 +255,10 @@ export function textToText({
}
AIProvider.LAST_ACTION_SESSIONID = _sessionId;
if (isRootSession) {
AIProvider.LAST_ROOT_SESSION_ID = _sessionId;
}
return client.chatText({
sessionId: _sessionId,
messageId: _messageId,
@@ -77,7 +77,8 @@ function setupAIProvider() {
//#region actions
AIProvider.provide('chat', options => {
const sessionId = getChatSessionId(options.workspaceId, options.docId);
const sessionId =
options.sessionId ?? getChatSessionId(options.workspaceId, options.docId);
return textToText({
...options,
content: options.input,
@@ -18,13 +18,15 @@ type AIActionEventProperties = {
| 'AI action panel'
| 'right side bar'
| 'inline chat panel'
| 'AI result panel';
| 'AI result panel'
| 'AI chat block';
module:
| 'exit confirmation'
| 'AI action panel'
| 'AI chat panel'
| 'inline chat panel'
| 'AI result panel';
| 'AI result panel'
| 'AI chat block';
control:
| 'stop button'
| 'format toolbar'
@@ -139,6 +141,8 @@ function inferSegment(
return 'AI result panel';
} else if (event.options.where === 'chat-panel') {
return 'right side bar';
} else if (event.options.where === 'ai-chat-block') {
return 'AI chat block';
} else {
return 'AI action panel';
}
@@ -155,6 +159,8 @@ function inferModule(
return 'AI result panel';
} else if (event.options.where === 'inline-chat-panel') {
return 'inline chat panel';
} else if (event.options.where === 'ai-chat-block') {
return 'AI chat block';
} else {
return 'AI action panel';
}