fix(ai): 本会话运行为整会话托管,去掉插入不执行
Always 不再按命令指纹记忆,点一次后本话题内非 critical 命令不再弹确认;移除「插入不执行」按钮与相关 prop。
This commit is contained in:
1 parent
2ca32f3199
commit
b18214e96a
11 files changed
+66
-111
No files matched your search
@@ -129,26 +129,27 @@ describe('terminal Agent CLI panel', () => {
|
||||
const dialog = await screen.findByRole('dialog')
|
||||
expect(within(dialog).getByText(/宽松/)).toBeVisible()
|
||||
expect(within(dialog).getByText(/systemctl restart nginx/)).toBeVisible()
|
||||
expect(within(dialog).queryByRole('button', { name: '插入不执行' })).not.toBeInTheDocument()
|
||||
expect(mockDesktopApi.sshExec).not.toHaveBeenCalled()
|
||||
fireEvent.click(within(dialog).getByRole('button', { name: '执行一次' }))
|
||||
await waitFor(() => expect(mockDesktopApi.sshExec).toHaveBeenCalledTimes(1))
|
||||
})
|
||||
|
||||
it('Always skips confirmation for the same command shape in the current panel session', async () => {
|
||||
it('Always auto-runs remaining confirmable commands in the current panel session', async () => {
|
||||
vi.mocked(mockDesktopApi.aiComplete)
|
||||
.mockResolvedValueOnce({
|
||||
success: true,
|
||||
text: '```bash\nrm /tmp/tmp.AAA111\n```',
|
||||
text: '```bash\nsudo rmdir /var/ftp\n```',
|
||||
model: 'test',
|
||||
redactedCount: 0,
|
||||
})
|
||||
.mockResolvedValueOnce({
|
||||
success: true,
|
||||
text: '```bash\nrm /tmp/tmp.BBB222\n```',
|
||||
text: '```bash\nsystemctl restart nginx\n```',
|
||||
model: 'test',
|
||||
redactedCount: 0,
|
||||
})
|
||||
.mockResolvedValueOnce({ success: true, text: 'FINAL: 清理完成。', model: 'test', redactedCount: 0 })
|
||||
.mockResolvedValueOnce({ success: true, text: 'FINAL: 清理并重启完成。', model: 'test', redactedCount: 0 })
|
||||
vi.mocked(mockDesktopApi.sshExec)
|
||||
.mockResolvedValueOnce({ success: true, result: 'ok', exitCode: 0 })
|
||||
.mockResolvedValueOnce({ success: true, result: 'ok', exitCode: 0 })
|
||||
@@ -162,20 +163,23 @@ describe('terminal Agent CLI panel', () => {
|
||||
/>
|
||||
)
|
||||
fireEvent.change(screen.getByPlaceholderText(PLACEHOLDER), {
|
||||
target: { value: '清理临时文件' },
|
||||
target: { value: '清理并重启' },
|
||||
})
|
||||
fireEvent.click(screen.getByRole('button', { name: '发送' }))
|
||||
|
||||
const dialog = await screen.findByRole('dialog')
|
||||
fireEvent.click(within(dialog).getByRole('button', { name: '本会话允许' }))
|
||||
expect(within(dialog).queryByRole('button', { name: '插入不执行' })).not.toBeInTheDocument()
|
||||
fireEvent.click(within(dialog).getByRole('button', { name: '本会话运行' }))
|
||||
await waitFor(() =>
|
||||
expect(mockDesktopApi.sshExec).toHaveBeenCalledWith('ssh-active-1', 'rm /tmp/tmp.AAA111', { fromAgent: true })
|
||||
expect(mockDesktopApi.sshExec).toHaveBeenCalledWith('ssh-active-1', 'sudo rmdir /var/ftp', { fromAgent: true })
|
||||
)
|
||||
await waitFor(() =>
|
||||
expect(mockDesktopApi.sshExec).toHaveBeenCalledWith('ssh-active-1', 'rm /tmp/tmp.BBB222', { fromAgent: true })
|
||||
expect(mockDesktopApi.sshExec).toHaveBeenCalledWith('ssh-active-1', 'systemctl restart nginx', {
|
||||
fromAgent: true,
|
||||
})
|
||||
)
|
||||
expect(screen.queryByRole('dialog')).not.toBeInTheDocument()
|
||||
expect(await screen.findByText('清理完成。')).toBeVisible()
|
||||
expect(await screen.findByText('清理并重启完成。')).toBeVisible()
|
||||
})
|
||||
|
||||
it('lets strict mode require confirmation from medium risk upward', async () => {
|
||||
|
||||
Reference in new issue
Block a user