Skip to content

Commit 1f2202f

Browse files
Merge branch 'release/v3.7.0' into feature/event-registration
2 parents daee738 + 5f1018b commit 1f2202f

8 files changed

Lines changed: 128 additions & 273 deletions

File tree

ai-agent/chat/components/chat-container/ChatContainer.module.scss

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
@use "../../../../styles/mixins";
3838

3939
:global(.dark) {
40-
.chatContainer {
40+
.chatContainer,
41+
.chatTokens {
4142
--accent-main: var(--chat-accent-color, var(--color-scheme-main-accent, #{$light-blue-main}));
4243
--background-color: var(--chat-background, #{$black});
4344
--text-color: var(--chat-text-color, #{$white});
@@ -86,7 +87,8 @@
8687
}
8788

8889
:global(.rtl) {
89-
.chatContainer {
90+
.chatContainer,
91+
.chatTokens {
9092
--input-text-align: right;
9193
}
9294
}
@@ -114,7 +116,8 @@
114116
padding: 0 var(--chat-content-padding) !important;
115117
}
116118

117-
.chatContainer {
119+
.chatContainer,
120+
.chatTokens {
118121
// ─── Public API ───────────────────────────────────────────────────────
119122
// Set any --chat-* variable on a parent element to override the default.
120123
// If not set, the fallback (second argument) is used.

ai-agent/chat/components/chat-message-body/sub-components/message/ToolCallMessage/index.tsx

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -41,49 +41,20 @@ import { MessageToolCallProps } from "../../../../../Chat.types";
4141
import styles from "../../../ChatMessageBody.module.scss";
4242

4343
import { ToolCallConfirmDialog } from "./tool-call-confirm-dialog";
44-
import { OpenFileConfirmDialog } from "./open-file-confirm-dialog";
4544
import { ToolCall } from "./tool-call";
4645
import { ToolCallPlacement, ToolCallStatus } from "./tool-call/ToolCall.enum";
47-
import { useMessageStore } from "../../../../../store/messageStore";
4846

4947
const ToolCallMessage = observer(({
5048
content,
5149
openLink,
5250
openFile,
5351
}: MessageToolCallProps) => {
54-
const {
55-
openFileConfirmQueue,
56-
removeFromOpenFileConfirmQueue,
57-
generateDocxToolName,
58-
generateFormToolName,
59-
generatePresentationToolName,
60-
} = useMessageStore();
61-
6252
const [needConfirmation, setNeedConfirmation] = React.useState(
6353
() => !!content.managed,
6454
);
6555

6656
const hideConfirmDialog = () => setNeedConfirmation(false);
6757

68-
const isGenerateTool =
69-
content.name === generateDocxToolName ||
70-
content.name === generateFormToolName ||
71-
content.name === generatePresentationToolName;
72-
73-
const fileData = (
74-
content.result as
75-
| { data?: { id?: number; title?: string } }
76-
| undefined
77-
)?.data;
78-
79-
const needOpenFileConfirm =
80-
isGenerateTool &&
81-
typeof fileData?.id === "number" &&
82-
typeof fileData?.title === "string" &&
83-
openFileConfirmQueue.some(
84-
(e) => e.fileId === fileData.id,
85-
);
86-
8758
const hasError = !!content.result?.error;
8859

8960
const toolCallStatus: ToolCallStatus = needConfirmation
@@ -114,16 +85,6 @@ const ToolCallMessage = observer(({
11485
{needConfirmation ? (
11586
<ToolCallConfirmDialog content={content} onClose={hideConfirmDialog} />
11687
) : null}
117-
118-
{needOpenFileConfirm && fileData?.id ? (
119-
<OpenFileConfirmDialog
120-
content={content}
121-
fileId={fileData.id}
122-
onClose={() =>
123-
removeFromOpenFileConfirmQueue(fileData.id!)
124-
}
125-
/>
126-
) : null}
12788
</div>
12889
);
12990
});

ai-agent/chat/components/chat-message-body/sub-components/message/ToolCallMessage/open-file-confirm-dialog/index.tsx

Lines changed: 0 additions & 136 deletions
This file was deleted.

ai-agent/chat/components/chat-message-body/sub-components/message/ToolCallMessage/tool-call-confirm-dialog/index.tsx

Lines changed: 65 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
*/
3535

3636
import React from "react";
37+
import classNames from "classnames";
3738
import { observer } from "mobx-react";
3839

3940
import { ToolsPermission } from "../../../../../../../../enums";
@@ -48,6 +49,7 @@ import {
4849
} from "../../../../../../../../components/modal-dialog";
4950

5051
import styles from "../../../../ChatMessageBody.module.scss";
52+
import chatStyles from "../../../../../chat-container/ChatContainer.module.scss";
5153
import { ToolCall } from "../tool-call";
5254
import { isMobile } from "../../../../../../../../utils";
5355
import { useCommonTranslation } from "../../../../../../../../utils/i18n";
@@ -67,26 +69,57 @@ export const ToolCallConfirmDialog = observer(
6769
toolsConfirmQueue,
6870
addToToolsConfirmQueue,
6971
removeFromToolsConfirmQueue,
72+
generateDocxToolName,
73+
generateFormToolName,
74+
generatePresentationToolName,
7075
} = useMessageStore();
7176
const { aiApi } = useApi();
7277
const t = useCommonTranslation();
7378

74-
const onClickAction = (decision: ToolsPermission) => {
79+
const isGenerateTool =
80+
content.name === generateDocxToolName ||
81+
content.name === generateFormToolName ||
82+
content.name === generatePresentationToolName;
83+
84+
const onClickAction = async (decision: ToolsPermission) => {
7585
if (content.callId) {
76-
aiApi.updateToolsPermission(
77-
content.callId,
78-
alwaysAllow && decision === ToolsPermission.Allow
79-
? ToolsPermission.AlwaysAllow
80-
: decision,
81-
);
86+
if (isGenerateTool) {
87+
const allow = decision === ToolsPermission.Allow;
88+
const result = await aiApi.updateToolFileDecision(
89+
content.callId,
90+
allow,
91+
);
92+
93+
if (allow && typeof result?.id === "number") {
94+
const searchParams = new URLSearchParams();
95+
searchParams.append("fileId", String(result.id));
96+
searchParams.append("withTool", "true");
97+
98+
window.open(
99+
`${window.location.origin}/doceditor?${searchParams.toString()}`,
100+
"_blank",
101+
);
102+
}
103+
} else {
104+
aiApi.updateToolsPermission(
105+
content.callId,
106+
alwaysAllow && decision === ToolsPermission.Allow
107+
? ToolsPermission.AlwaysAllow
108+
: decision,
109+
);
110+
}
82111
}
83112

84113
onClose();
85114
};
86115

87116
const onCloseAction = () => {
88117
if (content.callId) {
89-
aiApi.updateToolsPermission(content.callId, ToolsPermission.Deny);
118+
if (isGenerateTool) {
119+
aiApi.updateToolFileDecision(content.callId, false);
120+
} else {
121+
aiApi.updateToolsPermission(content.callId, ToolsPermission.Deny);
122+
}
90123
}
91124

92125
onClose();
@@ -114,40 +147,52 @@ export const ToolCallConfirmDialog = observer(
114147
</ModalDialog.Header>
115148

116149
<ModalDialog.Body>
117-
<div className={styles.toolCallManage}>
150+
<div
151+
className={classNames(styles.toolCallManage, chatStyles.chatTokens)}
152+
>
118153
<Text>{t("AIWouldLikeToUseThisTool")}</Text>
119154
<ToolCall
120155
content={content}
121156
status={ToolCallStatus.Confirmation}
122157
placement={ToolCallPlacement.ConfirmDialog}
123158
/>
124159
<div>
125-
<Text>{t("ReviewAction")}</Text>
126-
<Text>{t("CannotGuaranteeSecurity")}</Text>
160+
{isGenerateTool ? (
161+
<Text>{t("AIGenerateDocumentDescription")}</Text>
162+
) : (
163+
<>
164+
<Text>{t("ReviewAction")}</Text>
165+
<Text>{t("CannotGuaranteeSecurity")}</Text>
166+
</>
167+
)}
127168
</div>
128169
</div>
129170
</ModalDialog.Body>
130171

131172
<ModalDialog.Footer>
132-
<div className={styles.toolCallFooter}>
133-
<Checkbox
134-
isChecked={alwaysAllow}
135-
onChange={(e) => setAlwaysAllow(e.target.checked)}
136-
label={t("AlwaysAllowToolCall")}
137-
data-testid="always-allow-checkbox"
138-
/>
173+
<div
174+
className={classNames(styles.toolCallFooter, chatStyles.chatTokens)}
175+
>
176+
{!isGenerateTool ? (
177+
<Checkbox
178+
isChecked={alwaysAllow}
179+
onChange={(e) => setAlwaysAllow(e.target.checked)}
180+
label={t("AlwaysAllowToolCall")}
181+
data-testid="always-allow-checkbox"
182+
/>
183+
) : null}
139184
<div className={styles.buttonsBlockContainer}>
140185
<Button
141186
primary
142-
label={t("Allow")}
187+
label={isGenerateTool ? t("Create") : t("Allow")}
143188
onClick={() => onClickAction(ToolsPermission.Allow)}
144189
scale={isMobile()}
145190
size={ButtonSize.normal}
146191
data-testid="allow-button"
147192
/>
148193
<Button
149194
className={styles.denyButton}
150-
label={t("Deny")}
195+
label={isGenerateTool ? t("CancelButton") : t("Deny")}
151196
onClick={() => onClickAction(ToolsPermission.Deny)}
152197
size={ButtonSize.normal}
153198
scale={isMobile()}

0 commit comments

Comments
 (0)