Skip to content

Commit ccbbbcc

Browse files
committed
Optimize hook settings interface
1 parent f6d4330 commit ccbbbcc

3 files changed

Lines changed: 10 additions & 33 deletions

File tree

packages/desktop/src/settings/AgentConfigPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export default function AgentConfigPanel() {
9999
<div>
100100
<div className="text-[14px] text-[var(--text-title)]">最大停止续行次数</div>
101101
<div className="text-[12px] text-[var(--text-placeholder)] mt-0.5">
102-
Agent 在自动停止后最多允许重新激活的次数
102+
stop 钩子判定"继续执行"的最大次数,超出则强制终止
103103
</div>
104104
</div>
105105
<input

packages/desktop/src/settings/HooksPanel.tsx

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,14 @@ const HOOK_GROUPS: HookGroup[] = [
5959
{
6060
label: 'Agent 轮次',
6161
points: [
62-
{ name: 'agent.turn.start', description: '一轮对话开始时触发', type: 'observer' },
62+
{ name: 'agent.turn.start', description: '每一轮对话开始时触发', type: 'observer' },
6363
{ name: 'agent.step.before', description: '每个推理步骤前触发', type: 'decision' },
64-
{ name: 'agent.turn.stop', description: '对话轮次停止时触发', type: 'observer' },
65-
{ name: 'agent.turn.end', description: '对话轮次结束时触发', type: 'observer' },
64+
{
65+
name: 'agent.turn.stop',
66+
description: 'Agent 本轮无工具调用、准备停止时裁决,可返回 continue 续行',
67+
type: 'decision',
68+
},
69+
{ name: 'agent.turn.end', description: '轮次最终结束时通知,不可干预', type: 'observer' },
6670
],
6771
},
6872
{
@@ -81,7 +85,6 @@ interface HookForm {
8185
name: string;
8286
description: string;
8387
point: string;
84-
type: 'observer' | 'decision';
8588
command: string;
8689
args: string;
8790
env: string;
@@ -93,7 +96,6 @@ const EMPTY_FORM: HookForm = {
9396
name: '',
9497
description: '',
9598
point: ALL_POINTS[0]?.name ?? '',
96-
type: 'observer',
9799
command: '',
98100
args: '',
99101
env: '',
@@ -139,7 +141,6 @@ export default function HooksPanel({ global: isGlobal }: { global?: boolean }) {
139141
name: h.name,
140142
description: h.description ?? '',
141143
point: h.point,
142-
type: h.type,
143144
command: h.command,
144145
args: (h.args ?? []).join(', '),
145146
env: h.env
@@ -164,7 +165,7 @@ export default function HooksPanel({ global: isGlobal }: { global?: boolean }) {
164165
const hook: Record<string, unknown> = {
165166
name: form.name,
166167
point: form.point,
167-
type: form.type,
168+
type: ALL_POINTS.find((p) => p.name === form.point)?.type ?? 'observer',
168169
command: form.command,
169170
enabled: form.enabled,
170171
};
@@ -493,31 +494,6 @@ function FormCard({
493494
))}
494495
</select>
495496
</div>
496-
<div>
497-
<div className={labelCls}>类型</div>
498-
<div className="flex gap-2 pt-1">
499-
<button
500-
onClick={() => setForm({ ...form, type: 'observer' })}
501-
className={`px-3 py-1.5 rounded text-[13px] font-mono transition-colors ${
502-
form.type === 'observer'
503-
? 'bg-[var(--btn-primary-bg)] text-[var(--accent-primary)]'
504-
: 'bg-[var(--border-card)] text-[var(--text-secondary)] border border-[var(--border-hover)]'
505-
}`}
506-
>
507-
observer
508-
</button>
509-
<button
510-
onClick={() => setForm({ ...form, type: 'decision' })}
511-
className={`px-3 py-1.5 rounded text-[13px] font-mono transition-colors ${
512-
form.type === 'decision'
513-
? 'bg-[var(--btn-primary-bg)] text-[var(--accent-primary)]'
514-
: 'bg-[var(--border-card)] text-[var(--text-secondary)] border border-[var(--border-hover)]'
515-
}`}
516-
>
517-
decision
518-
</button>
519-
</div>
520-
</div>
521497
</div>
522498
<div>
523499
<div className={labelCls}>命令</div>

packages/desktop/test/settings-panels.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ describe('HooksPanel - hook point coverage', () => {
137137
'tool.approval.pre',
138138
'llm.request.before',
139139
'agent.step.before',
140+
'agent.turn.stop',
140141
'agent.subagent.spawn.before',
141142
];
142143
for (const h of decisionHooks) {

0 commit comments

Comments
 (0)