feat: 升级至 v0.3.16 — 工单修复 51 项 + 审查修复 30 项(安全加固/适配器/工具系统/数据层/前端)
This commit is contained in:
@@ -62,6 +62,8 @@ export function ConfirmationDialog(): React.JSX.Element | null {
|
||||
const [remainingMs, setRemainingMs] = useState<number>(0);
|
||||
// 记录首次接收时的剩余时间,作为进度条总量(固定不变)
|
||||
const [initialMs, setInitialMs] = useState<number>(0);
|
||||
// #40 修复: autoExecute 永久自动执行风险高,勾选时弹出二次确认避免误点击
|
||||
const [confirmAutoExecute, setConfirmAutoExecute] = useState(false);
|
||||
|
||||
// ===== 弹框打开时主动拉取已积压的 pending 请求 =====
|
||||
// 解决:并行工具触发的多个 IPC 事件可能在本组件 mount 前已到达,
|
||||
@@ -291,12 +293,16 @@ export function ConfirmationDialog(): React.JSX.Element | null {
|
||||
: requests[0]?.reason ?? 'Agent 正在请求执行工具';
|
||||
|
||||
return (
|
||||
<>
|
||||
<Dialog
|
||||
open={requests.length > 0}
|
||||
onClose={(_, reason) => {
|
||||
// 超时时禁止通过外部点击/ESC 关闭(与"拒绝全部"按钮 disabled 一致)
|
||||
// 防止超时后用户误触关闭,导致后端 pending 状态不一致
|
||||
if (isExpired) return;
|
||||
// 审查修复: 内层二次确认 Dialog 打开时,外层禁用 ESC/backdrop 关闭
|
||||
// 防止 ESC 穿透到外层导致意外拒绝所有工具执行
|
||||
if (confirmAutoExecute) return;
|
||||
// 只允许"拒绝全部"语义的关闭方式(点击外部 / ESC)
|
||||
// reason: 'backdropClick' | 'escapeKeyDown' | 'closeButtonClick'
|
||||
if (reason === 'backdropClick' || reason === 'escapeKeyDown') {
|
||||
@@ -305,6 +311,7 @@ export function ConfirmationDialog(): React.JSX.Element | null {
|
||||
}}
|
||||
maxWidth="md"
|
||||
fullWidth
|
||||
disableEscapeKeyDown={confirmAutoExecute}
|
||||
slotProps={{
|
||||
paper: {
|
||||
sx: { bgcolor: 'background.paper' },
|
||||
@@ -520,9 +527,12 @@ export function ConfirmationDialog(): React.JSX.Element | null {
|
||||
<Checkbox
|
||||
checked={autoExecute}
|
||||
onChange={(e) => {
|
||||
setAutoExecute(e.target.checked);
|
||||
// 勾选永久自动执行时,自动勾选会话内记忆(保持一致)
|
||||
if (e.target.checked) setRemember(true);
|
||||
// #40 修复: autoExecute 永久自动执行风险高,勾选时弹出二次确认避免误点击
|
||||
if (e.target.checked) {
|
||||
setConfirmAutoExecute(true);
|
||||
} else {
|
||||
setAutoExecute(false);
|
||||
}
|
||||
}}
|
||||
size="small"
|
||||
/>
|
||||
@@ -576,5 +586,42 @@ export function ConfirmationDialog(): React.JSX.Element | null {
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
|
||||
{/* #40 修复: autoExecute 二次确认 Dialog — 避免误点击导致永久自动执行 */}
|
||||
{/* 审查修复: disableEscapeKeyDown + onKeyDown stopPropagation 防止 ESC 事件穿透到外层 Dialog */}
|
||||
<Dialog
|
||||
open={confirmAutoExecute}
|
||||
onClose={() => setConfirmAutoExecute(false)}
|
||||
maxWidth="xs"
|
||||
fullWidth
|
||||
disableEscapeKeyDown
|
||||
onKeyDown={(e) => e.stopPropagation()}
|
||||
>
|
||||
<DialogTitle sx={{ fontSize: 14 }}>确认永久自动执行?</DialogTitle>
|
||||
<DialogContent>
|
||||
<Typography variant="body2" sx={{ color: 'text.secondary' }}>
|
||||
勾选后,选中的工具将永久自动执行(跨会话不再询问),包括未来的潜在危险操作。此设置可在「设置 → 工具管理」中关闭。
|
||||
</Typography>
|
||||
<Typography variant="body2" sx={{ mt: 1, color: 'warning.main', fontWeight: 600 }}>
|
||||
确定要启用吗?
|
||||
</Typography>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={() => setConfirmAutoExecute(false)} color="inherit">取消</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
setAutoExecute(true);
|
||||
// 勾选永久自动执行时,自动勾选会话内记忆(保持一致)
|
||||
setRemember(true);
|
||||
setConfirmAutoExecute(false);
|
||||
}}
|
||||
color="warning"
|
||||
variant="contained"
|
||||
>
|
||||
确认自动执行
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user