chore: 保存工作副本——客户端授权新契约(双端点/验签/令牌/周检)与桌面会话可靠性改进
This commit is contained in:
1 parent
f71eef0eba
commit
ae6093c9b3
163 files changed
+4911
-2494
No files matched your search
@@ -130,7 +130,7 @@ describe('terminal Agent CLI panel', () => {
|
||||
expect(within(dialog).getByText(/宽松/)).toBeVisible()
|
||||
expect(within(dialog).getByText(/systemctl restart nginx/)).toBeVisible()
|
||||
expect(mockDesktopApi.sshExec).not.toHaveBeenCalled()
|
||||
fireEvent.click(within(dialog).getByRole('button', { name: 'Once' }))
|
||||
fireEvent.click(within(dialog).getByRole('button', { name: '执行一次' }))
|
||||
await waitFor(() => expect(mockDesktopApi.sshExec).toHaveBeenCalledTimes(1))
|
||||
})
|
||||
|
||||
@@ -167,7 +167,7 @@ describe('terminal Agent CLI panel', () => {
|
||||
fireEvent.click(screen.getByRole('button', { name: '发送' }))
|
||||
|
||||
const dialog = await screen.findByRole('dialog')
|
||||
fireEvent.click(within(dialog).getByRole('button', { name: 'Always' }))
|
||||
fireEvent.click(within(dialog).getByRole('button', { name: '本会话允许' }))
|
||||
await waitFor(() =>
|
||||
expect(mockDesktopApi.sshExec).toHaveBeenCalledWith('ssh-active-1', 'rm /tmp/tmp.AAA111', { fromAgent: true })
|
||||
)
|
||||
@@ -388,4 +388,65 @@ describe('terminal Agent CLI panel', () => {
|
||||
await waitFor(() => expect(screen.getByRole('button', { name: '发送' })).toBeVisible())
|
||||
expect(mockDesktopApi.aiComplete).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('splits model and SSH target in the header and hides extra chrome until needed', () => {
|
||||
useAiProviderStore.setState({
|
||||
providers: [
|
||||
{
|
||||
id: 'deepseek',
|
||||
name: 'DeepSeek',
|
||||
protocol: 'openai-chat',
|
||||
authStyle: 'bearer',
|
||||
baseUrl: 'https://api.deepseek.com',
|
||||
models: [
|
||||
{ id: 'v4', model: 'deepseek-v4-pro', label: 'DeepSeek V4 Pro', capability: 'chat', billing: 'payg' },
|
||||
],
|
||||
defaultModelId: 'v4',
|
||||
enabled: true,
|
||||
hasApiKey: true,
|
||||
allowInsecureHttp: false,
|
||||
},
|
||||
],
|
||||
activeProviderId: 'deepseek',
|
||||
isLoaded: true,
|
||||
catalogProviders: [],
|
||||
catalogUpdatedAt: null,
|
||||
})
|
||||
render(
|
||||
<AiTerminalPanel
|
||||
capture={() => ({ selection: '', viewport: '' })}
|
||||
onClose={vi.fn()}
|
||||
connectionId="ssh-active-1"
|
||||
targetLabel="pre-jenkins"
|
||||
/>
|
||||
)
|
||||
expect(screen.getByText('DeepSeek V4 Pro')).toBeVisible()
|
||||
expect(screen.getByText('SSH · pre-jenkins')).toBeVisible()
|
||||
expect(screen.queryByRole('button', { name: '所有命令都需确认(只读白名单除外)' })).not.toBeInTheDocument()
|
||||
expect(screen.queryByRole('button', { name: '新话题' })).not.toBeInTheDocument()
|
||||
expect(screen.getByRole('button', { name: '关闭' })).toBeVisible()
|
||||
})
|
||||
|
||||
it('compacts oversized terminal dumps before summarizing', async () => {
|
||||
vi.mocked(mockDesktopApi.aiComplete).mockResolvedValueOnce({
|
||||
success: true,
|
||||
text: 'FINAL: 日志过长,已按摘要阅读。',
|
||||
model: 'test',
|
||||
redactedCount: 0,
|
||||
})
|
||||
const viewport = Array.from({ length: 200 }, (_, index) => `line-${index} ${'x'.repeat(48)}`).join('\n')
|
||||
render(
|
||||
<AiTerminalPanel
|
||||
capture={() => ({ selection: '', viewport })}
|
||||
onClose={vi.fn()}
|
||||
connectionId="ssh-active-1"
|
||||
targetLabel="root@opsbase.cn"
|
||||
/>
|
||||
)
|
||||
fireEvent.click(screen.getByRole('button', { name: '总结输出' }))
|
||||
await waitFor(() => expect(mockDesktopApi.aiComplete).toHaveBeenCalledTimes(1))
|
||||
const context = String(vi.mocked(mockDesktopApi.aiComplete).mock.calls[0][0].context)
|
||||
expect(context.length).toBeLessThan(viewport.length)
|
||||
expect(context).toMatch(/总行数|已省略/)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user