Simplify Agent chat with inline attachments and separate thinking

This commit is contained in:
鲨鱼辣椒 committed 2026-10-12 21:57:09 +08:00
1 parent 7af43acebb
commit faebfe9e84
18 files changed
+1558 -195

No files matched your search

+22 -3
View File
@@ -71,7 +71,11 @@ it('starts once from the saved configuration and opens conversation only after a
fireEvent.click(screen.getByRole('button', { name: '继续编辑' }));
await act(async () => finish({ version: 1, draft_revision: 3 }));
expect(await screen.findByRole('region', { name: '智能体对话' })).toBeVisible();
expect(screen.getByRole('button', { name: '调整智能体', exact: true })).toBeVisible();
expect(screen.getByRole('heading', { name: '写作搭档', exact: true })).toBeVisible();
expect(screen.queryByLabelText('名称')).not.toBeInTheDocument();
for (const name of ['调整智能体', '已保存', '已应用', '应用最新修改']) {
expect(screen.queryByRole('button', { name, exact: true })).not.toBeInTheDocument();
}
expect(api.save).not.toHaveBeenCalled();
expect(messageOperations()).toHaveLength(0);
});
@@ -166,6 +170,10 @@ it('keeps a newer saved revision unapplied when retry resolves the original unce
const base = api.call.getMockImplementation()!;
let attempts = 0;
let activated = false;
let current = { ...draft, published_version: null as number | null };
api.list.mockImplementation(async () => ({ agents: [current], next_cursor: null }));
api.get.mockImplementation(async () => current);
api.save.mockImplementation(async (_slug, input) => (current = { ...current, ...input, draft_revision: 4 }));
api.call.mockImplementation(async (operation, input) => {
if (operation === 'access') return {
published_version: activated ? 1 : null, enabled: true, grants: [], applications: [],
@@ -174,6 +182,7 @@ it('keeps a newer saved revision unapplied when retry resolves the original unce
if (operation === 'publish') {
if (++attempts === 1) throw new Error('连接中断');
activated = true;
current = { ...current, published_version: 1 };
return { version: 1, draft_revision: input.expected_revision };
}
return base(operation, input);
@@ -186,6 +195,9 @@ it('keeps a newer saved revision unapplied when retry resolves the original unce
await waitFor(() => expect(screen.getByRole('button', { name: '已保存', exact: true })).toBeDisabled());
fireEvent.click(screen.getByRole('button', { name: '重试开始使用', exact: true }));
expect(await screen.findByRole('region', { name: '智能体对话' })).toBeVisible();
expect(screen.queryByRole('button', { name: '应用最新修改', exact: true })).not.toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: '返回智能体列表', exact: true }));
fireEvent.click(await screen.findByRole('button', { name: '调整', exact: true }));
await screen.findByText('修改已保存,尚未应用');
expect(screen.getByText('这次修改还没有应用到正在使用的助手')).toBeVisible();
expect(screen.getByRole('button', { name: '应用最新修改', exact: true })).toBeEnabled();
@@ -200,6 +212,8 @@ it('keeps a newer saved revision unapplied when retry resolves the original unce
it('keeps successful activation and conversation when the following status read fails', async () => {
const base = api.call.getMockImplementation()!;
let activated = false;
api.list.mockImplementation(async () => ({ agents: [{ ...draft, published_version: activated ? 1 : null }], next_cursor: null }));
api.get.mockImplementation(async () => ({ ...draft, published_version: activated ? 1 : null }));
api.call.mockImplementation(async (operation, input) => {
if (operation === 'access' && activated) throw new Error('状态刷新失败');
const result = await base(operation, input);
@@ -209,10 +223,15 @@ it('keeps successful activation and conversation when the following status read
await openConfiguration();
fireEvent.click(screen.getByRole('button', { name: '开始使用', exact: true }));
expect(await screen.findByRole('region', { name: '智能体对话' })).toBeVisible();
await waitFor(() => expect(api.call.mock.calls.filter(([operation]) => operation === 'access')).toHaveLength(2));
expect(screen.queryByRole('button', { name: '已应用', exact: true })).not.toBeInTheDocument();
expect(screen.queryByRole('button', { name: '重试开始使用', exact: true })).not.toBeInTheDocument();
expect(screen.queryByText(/状态刷新失败/)).not.toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: '返回智能体列表', exact: true }));
fireEvent.click(await screen.findByRole('button', { name: '调整', exact: true }));
await screen.findByText(/状态刷新失败/);
expect(screen.getByRole('button', { name: '已应用', exact: true })).toBeDisabled();
fireEvent.click(screen.getByRole('button', { name: '刷新应用状态', exact: true }));
await waitFor(() => expect(api.call.mock.calls.filter(([operation]) => operation === 'access')).toHaveLength(3));
await waitFor(() => expect(api.call.mock.calls.filter(([operation]) => operation === 'access')).toHaveLength(4));
expect(publications()).toHaveLength(1);
expect(messageOperations()).toHaveLength(0);
});