完善客户端模块与工作区能力
Some checks failed
Electron E2E / Electron E2E (macos-latest) (push) Has been cancelled
Electron E2E / Electron E2E (ubuntu-latest) (push) Has been cancelled
Electron E2E / Electron E2E (windows-latest) (push) Has been cancelled

This commit is contained in:
inman
2026-08-13 19:45:30 +08:00
parent 0148b91a15
commit 22add3f01f
97 changed files with 4756 additions and 3226 deletions

View File

@@ -8,6 +8,12 @@ import type { ProjectAgentConfig } from '../../shared/project-config';
import type { ProjectSessionMetadata } from '../../shared/project-conversations';
import type { OpencodeSession } from '@/types/opencode';
const hostApiFetchMock = vi.hoisted(() => vi.fn());
vi.mock('@/lib/host-api', () => ({
hostApiFetch: (...args: unknown[]) => hostApiFetchMock(...args),
}));
const modelOption: ConfiguredModelOption = {
modelRef: 'openai/gpt-4o-mini',
label: 'gpt-4o-mini',
@@ -92,6 +98,8 @@ function renderSidebar(
describe('AgentConversationSidebar', () => {
beforeEach(() => {
useSettingsStore.setState({ sidebarCollapsed: false });
hostApiFetchMock.mockReset();
hostApiFetchMock.mockResolvedValue({ skills: [] });
});
afterEach(() => {
@@ -129,13 +137,13 @@ describe('AgentConversationSidebar', () => {
expect(screen.queryByRole('button', { name: '真机预览' })).not.toBeInTheDocument();
expect(screen.getByRole('button', { name: '项目设置' })).toHaveClass('no-drag');
const createButton = screen.getByRole('button', { name: '创建伙伴' });
expect(createButton).toHaveClass('no-drag', 'text-brand');
expect(createButton.querySelector('svg')).toHaveClass('text-brand');
expect(createButton).toHaveClass('no-drag', 'text-brand', 'hover:text-white');
expect(createButton.querySelector('svg')).toHaveClass('text-brand', 'group-hover:text-white');
expect(createButton).toHaveAttribute('aria-expanded', 'false');
fireEvent.click(createButton);
expect(createButton).toHaveClass('bg-brand', 'text-primary-foreground');
expect(createButton.querySelector('svg')).toHaveClass('text-primary-foreground');
expect(createButton).toHaveClass('bg-brand', 'text-white');
expect(createButton.querySelector('svg')).toHaveClass('text-white');
expect(createButton).toHaveAttribute('aria-expanded', 'true');
});
@@ -316,6 +324,26 @@ describe('AgentConversationSidebar', () => {
expect(callbacks.onArchiveAgent).not.toHaveBeenCalled();
});
it('loads installed skills for the contact creation dialog', async () => {
hostApiFetchMock.mockResolvedValue({
skills: [{ name: 'agent-browser' }],
});
const callbacks = renderSidebar();
fireEvent.click(screen.getByRole('button', { name: '创建伙伴' }));
expect(await screen.findByLabelText('绑定技能:开发浏览器')).toBeInTheDocument();
expect(hostApiFetchMock).toHaveBeenCalledWith('/api/opencode/skills');
fireEvent.click(screen.getByLabelText('绑定技能:开发浏览器'));
fireEvent.change(screen.getByLabelText(/伙伴名称/), { target: { value: '小李' } });
fireEvent.change(screen.getByLabelText(/职责简述/), { target: { value: '负责整理资料。' } });
fireEvent.click(screen.getByRole('button', { name: '创建并开始对话' }));
await waitFor(() => expect(callbacks.onCreateAgent).toHaveBeenCalledWith(expect.objectContaining({
skillIds: ['agent-browser'],
})));
});
it('shows advanced creation settings directly below the basics', () => {
renderSidebar();
fireEvent.click(screen.getByRole('button', { name: '创建伙伴' }));