feat: prepare Zhinian desktop client for pilot release

This commit is contained in:
inman
2026-04-29 10:23:20 +08:00
parent f9361e686a
commit 47b83b79fc
149 changed files with 15341 additions and 3590 deletions

View File

@@ -69,14 +69,14 @@ vi.mock('react-i18next', () => ({
}),
}));
describe('ChatInput agent targeting', () => {
describe('ChatInput context controls', () => {
beforeEach(() => {
agentsState.agents = [];
chatState.currentAgentId = 'main';
gatewayState.status = { state: 'running', port: 18789 };
});
it('hides the @agent picker when only one agent is configured', () => {
it('does not expose the old @agent picker', () => {
agentsState.agents = [
{
id: 'main',
@@ -96,43 +96,40 @@ describe('ChatInput agent targeting', () => {
expect(screen.queryByTitle('Choose agent')).not.toBeInTheDocument();
});
it('lets the user select an agent target and sends it with the message', () => {
it('passes selected knowledge documents as context option', () => {
const onSend = vi.fn();
agentsState.agents = [
{
id: 'main',
name: 'Main',
isDefault: true,
modelDisplay: 'MiniMax',
inheritedModel: true,
workspace: '~/.openclaw/workspace',
agentDir: '~/.openclaw/agents/main/agent',
mainSessionKey: 'agent:main:main',
channelTypes: [],
},
{
id: 'research',
name: 'Research',
isDefault: false,
modelDisplay: 'Claude',
inheritedModel: false,
workspace: '~/.openclaw/workspace-research',
agentDir: '~/.openclaw/agents/research/agent',
mainSessionKey: 'agent:research:desk',
channelTypes: [],
},
];
render(
<ChatInput
onSend={onSend}
knowledgeDocuments={[
{
id: 'doc-1',
name: 'handbook.docx',
mimeType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
storedPath: '/kb/files/handbook.docx',
textPath: '/kb/texts/handbook.txt',
},
{
id: 'doc-2',
name: 'faq.md',
mimeType: 'text/markdown',
storedPath: '/kb/files/faq.md',
},
]}
workspaceId="workspace-1"
/>,
);
render(<ChatInput onSend={onSend} />);
fireEvent.click(screen.getByTitle('Choose agent'));
fireEvent.click(screen.getByText('Research'));
expect(screen.getByText('@Research')).toBeInTheDocument();
fireEvent.change(screen.getByRole('textbox'), { target: { value: 'Hello direct agent' } });
fireEvent.click(screen.getByTestId('chat-composer-knowledge-button'));
fireEvent.click(screen.getByText('handbook.docx'));
fireEvent.click(screen.getByText('faq.md'));
fireEvent.change(screen.getByRole('textbox'), { target: { value: 'Use company docs' } });
fireEvent.click(screen.getByTitle('Send'));
expect(onSend).toHaveBeenCalledWith('Hello direct agent', undefined, 'research');
expect(onSend).toHaveBeenCalledWith('Use company docs', undefined, null, {
useKnowledgeBase: true,
workspaceId: 'workspace-1',
selectedKnowledgeDocumentIds: ['doc-1', 'doc-2'],
});
});
});