Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions chatbot/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,10 @@ function AssistantTurn({ message, steps, assets, projectId, sessionId, local, re
</>
);
}
function LiveMessage({ live, generation, finished = false, local = false, readOnly = false }) {
function LiveMessage({ live, generation, finished = false, local = false, readOnly = false, diagnosticMessage }) {
const steps = live.activity || [];
const stopReason = generation?.status === "failed" && generation.error
? generation.error : "已停止,以上是停止前的内容。";
const textual = hasTextSegments(steps);
// A streamed paragraph followed by tool calls stays in the process above;
// only the paragraph still being written shows as the answer.
Expand Down Expand Up @@ -286,13 +288,7 @@ function LiveMessage({ live, generation, finished = false, local = false, readOn
)}
{answer ? <RichContent message={answer} /> : null}
{!finished && !local && !readOnly && generation?.id ? <GenerationDiagnostics sessionId={generation.sessionId} generationId={generation.id} compact /> : null}
{finished ? (
<p className="reply-stopped">
{generation?.status === "failed" && generation?.error
? generation.error
: "已停止,以上是停止前的内容。"}
</p>
) : null}
{finished && stopReason !== diagnosticMessage ? <p className="reply-stopped">{stopReason}</p> : null}
</div>
);
}
Expand Down Expand Up @@ -952,6 +948,9 @@ export default function App() {
}));
}, [chat.activeId, chat.projectId]);
const messages = chat.session?.messages || [];
const currentFailure = !chat.local && !chat.busy && chat.session?.id && chat.generation?.id &&
chat.generation.failure && !messages.some(m => m.generationId === chat.generation.id && m.failure)
? chat.generation.failure : null;
const conversationStarted = Boolean(
chat.activeId && chat.session?.id === chat.activeId &&
(messages.length || chat.busy || sidebarArtifacts.length || conversationRuns.length),
Expand Down Expand Up @@ -1741,6 +1740,7 @@ export default function App() {
live={chat.live}
generation={chat.generation}
finished
diagnosticMessage={currentFailure?.message}
local={chat.local}
readOnly={chat.readOnly}
/>
Expand All @@ -1749,7 +1749,7 @@ export default function App() {
if (follow.current && scroll.current)
scroll.current.scrollTop = scroll.current.scrollHeight;
}} />
{!chat.local && !chat.busy && chat.generation?.failure && !messages.some((m) => m.generationId === chat.generation.id && m.failure) ? <GenerationDiagnostics sessionId={chat.session?.id} generationId={chat.generation.id} failure={chat.generation.failure} onCLIInstall={chat.adoptCLIInstall} readOnly={chat.readOnly} /> : null}
{currentFailure ? <GenerationDiagnostics sessionId={chat.session.id} generationId={chat.generation.id} failure={currentFailure} onCLIInstall={chat.adoptCLIInstall} readOnly={chat.readOnly} /> : null}
{!chat.local && !chat.readOnly && !chat.busy && chat.generation?.id && chat.generation.status === "cancelled" && !chat.generation.failure && !messages.some((m) => m.generationId === chat.generation.id) ? <GenerationDiagnostics sessionId={chat.session?.id} generationId={chat.generation.id} compact /> : null}
<RunAlerts
runs={conversationRuns}
Expand Down
9 changes: 9 additions & 0 deletions chatbot/tests/app-render.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,15 @@ describe("App", () => {
});
view.rerender(<App />);
expect(screen.getByText("中断原因")).toBeInTheDocument();
chat.generation = { ...chat.generation, failure: { code: "TEST_ERROR", message: "中断原因" } };
view.rerender(<App />);
const diagnostics = screen.getByRole("region", { name: "本轮失败诊断" });
expect(within(diagnostics).getByText("中断原因")).toBeInTheDocument();
expect(screen.getAllByText("中断原因")).toHaveLength(1);
expect(screen.getByText("部分内容")).toBeInTheDocument();
chat.generation = { ...chat.generation, error: "执行器已断开" };
view.rerender(<App />);
expect(screen.getByText("执行器已断开")).toBeInTheDocument();
Object.assign(chat, previous);
});

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/qa/assistant-replies/reply-after.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions e2e/ui/02-interactions.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ test('chat: asking AI about a failed run keeps the reply above the run alert', a
track(`assistant session ${sid}`, () => del(`/api/assistant/sessions/${sid}`));
await put(`/api/assistant/sessions/${sid}`, {
id: sid, title: `E2E 运行提醒 ${cfg.runTag}`, projectId: cfg.projectId,
executor: cfg.executor, model: cfg.modelID,
messages: [
{ role: 'user', content: '帮我跑一下这个 SOP' },
{ role: 'assistant', content: JSON.stringify({ drafts: [], message: `已启动运行 ${run.id}` }) },
Expand All @@ -281,9 +282,21 @@ test('chat: asking AI about a failed run keeps the reply above the run alert', a
: el.classList.contains('assistant') ? 'assistant' : '')
.filter(Boolean).slice(-3).join(' > '));
await alert.getByRole('button', { name: '让 AI 分析' }).click();
const submitted = page.waitForRequest(request =>
request.method() === 'POST' && new URL(request.url()).pathname === '/api/assistant/generations');
await page.getByRole('button', { name: '发送消息' }).click();
const payload = (await submitted).postDataJSON();
expect(payload.executor).toBe(cfg.executor);
if (cfg.modelID) expect(payload.model).toBe(cfg.modelID);
await expect.poll(tail).toBe('user > live > alert');
await expect.poll(tail, { timeout: 300_000 }).toBe('user > assistant > alert');
// A provider error also renders an assistant message in this position.
const generation = await get(`/api/assistant/sessions/${sid}/generation?after=0`);
expect(generation.status, generation.failure?.code).toBe('completed');
const saved = await get(`/api/assistant/sessions/${sid}`);
const reply = saved.messages.at(-1);
expect(reply.role).toBe('assistant');
expect(reply.content.trim()).not.toBe('');
expect(errors).toEqual([]);
});

Expand Down
Loading