Skip to content

Commit e00df98

Browse files
committed
⚡️ CI 支持 feature/* 分支构建、Agent 错误持久化及 UI 优化
- build.yaml/test.yaml 增加 feature/* 分支触发构建和测试 - Agent 错误消息持久化到 OPFS,刷新后仍可见 - 修复主布局全屏溢出问题 - 优化错误消息展示样式,支持暗色主题
1 parent cf63761 commit e00df98

File tree

7 files changed

+70
-10
lines changed

7 files changed

+70
-10
lines changed

.github/workflows/build.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches:
66
- main
77
- release/*
8+
- feature/*
89
- dev
910
paths-ignore:
1011
- ".github/**"

.github/workflows/test.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches:
66
- main
77
- release/*
8+
- feature/*
89
- dev
910
- develop/*
1011
pull_request:

src/app/service/service_worker/agent.ts

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,9 +1232,20 @@ export class AgentService {
12321232
}
12331233

12341234
// 超过最大迭代次数
1235+
const maxIterMsg = `Tool calling loop exceeded maximum iterations (${maxIterations})`;
1236+
if (conversationId) {
1237+
await this.repo.appendMessage({
1238+
id: uuidv4(),
1239+
conversationId,
1240+
role: "assistant",
1241+
content: "",
1242+
error: maxIterMsg,
1243+
createtime: Date.now(),
1244+
});
1245+
}
12351246
sendEvent({
12361247
type: "error",
1237-
message: `Tool calling loop exceeded maximum iterations (${maxIterations})`,
1248+
message: maxIterMsg,
12381249
errorCode: "max_iterations",
12391250
});
12401251
}
@@ -1497,7 +1508,23 @@ export class AgentService {
14971508
}
14981509
} catch (e: any) {
14991510
if (abortController.signal.aborted) return;
1500-
sendEvent({ type: "error", message: e.message || "Unknown error", errorCode: classifyErrorCode(e) });
1511+
const errorMsg = e.message || "Unknown error";
1512+
// 持久化错误消息到 OPFS,确保刷新后仍可见
1513+
if (params.conversationId && !params.ephemeral) {
1514+
try {
1515+
await this.repo.appendMessage({
1516+
id: uuidv4(),
1517+
conversationId: params.conversationId,
1518+
role: "assistant",
1519+
content: "",
1520+
error: errorMsg,
1521+
createtime: Date.now(),
1522+
});
1523+
} catch {
1524+
// 持久化失败不阻塞错误事件发送
1525+
}
1526+
}
1527+
sendEvent({ type: "error", message: errorMsg, errorCode: classifyErrorCode(e) });
15011528
}
15021529
}
15031530

src/pages/components/layout/MainLayout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ const MainLayout: React.FC<{
339339
}}
340340
>
341341
{contextHolder}
342-
<Layout className={"tw-min-h-screen"}>
342+
<Layout className={"tw-h-screen tw-overflow-hidden"}>
343343
<Layout.Header
344344
style={{
345345
height: "50px",
@@ -520,7 +520,7 @@ const MainLayout: React.FC<{
520520
</Space>
521521
</Layout.Header>
522522
<Layout
523-
className={`tw-bottom-0 tw-w-full ${className}`}
523+
className={`tw-bottom-0 tw-w-full tw-flex-1 tw-overflow-hidden ${className}`}
524524
style={{ background: "var(--color-fill-2)" }}
525525
{...getRootProps({})}
526526
>

src/pages/components/layout/Sider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ const Sider: React.FC = () => {
218218
borderLeft: "1px solid var(--color-bg-5)",
219219
overflow: "hidden",
220220
padding: 0,
221-
height: "auto",
221+
height: "100%",
222222
boxSizing: "border-box",
223223
position: "relative",
224224
}}

src/pages/options/routes/AgentChat/MessageItem.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import ThinkingBlock from "./ThinkingBlock";
55
import ToolCallBlock from "./ToolCallBlock";
66
import MessageToolbar from "./MessageToolbar";
77
import { Message as ArcoMessage, Tooltip } from "@arco-design/web-react";
8-
import { IconRobot, IconUser, IconEdit, IconCopy, IconRefresh } from "@arco-design/web-react/icon";
8+
import { IconRobot, IconUser, IconEdit, IconCopy, IconRefresh, IconExclamationCircleFill } from "@arco-design/web-react/icon";
99
import { useTranslation } from "react-i18next";
1010
import { getTextContent } from "@App/app/service/agent/content_utils";
1111

@@ -39,10 +39,9 @@ function AssistantMessageContent({ message, isStreaming }: { message: ChatMessag
3939

4040
{/* 错误 */}
4141
{message.error && (
42-
<div className="tw-mt-2 tw-px-3 tw-py-2 tw-rounded-lg tw-bg-[rgb(var(--red-1))] tw-text-[rgb(var(--red-6))] tw-text-xs tw-border tw-border-solid tw-border-[rgb(var(--red-2))]">
43-
{t("agent_chat_error")}
44-
{": "}
45-
{message.error}
42+
<div className="agent-error-block">
43+
<IconExclamationCircleFill className="agent-error-icon" />
44+
<span style={{ minWidth: 0, wordBreak: "break-word" }}>{message.error}</span>
4645
</div>
4746
)}
4847
</div>

src/pages/options/routes/AgentChat/styles.css

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,38 @@ body[arco-theme="dark"] .ai-markdown-body .hljs-deletion {
298298
background-color: #67060c;
299299
}
300300

301+
/* 错误消息 */
302+
.agent-error-block {
303+
margin-top: 8px;
304+
display: flex;
305+
align-items: flex-start;
306+
gap: 10px;
307+
padding: 10px 14px;
308+
border-radius: 8px;
309+
border-left: 3px solid #e5484d;
310+
background: #fff0f0;
311+
color: #ce2c31;
312+
font-size: 13px;
313+
line-height: 1.5;
314+
}
315+
316+
.agent-error-block .agent-error-icon {
317+
flex-shrink: 0;
318+
font-size: 16px;
319+
margin-top: 1px;
320+
color: #e5484d;
321+
}
322+
323+
body[arco-theme="dark"] .agent-error-block {
324+
background: rgba(229, 72, 77, 0.1);
325+
color: #ff6369;
326+
border-left-color: #e5484d;
327+
}
328+
329+
body[arco-theme="dark"] .agent-error-block .agent-error-icon {
330+
color: #ff6369;
331+
}
332+
301333
/* 侧边栏会话列表 */
302334
.agent-conversation-item {
303335
position: relative;

0 commit comments

Comments
 (0)