Refine agent list attention handling
This commit is contained in:
@@ -57,4 +57,52 @@ describe("shouldClearAgentAttention", () => {
|
||||
})
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("returns false for focus entry when clear was deferred while already focused", () => {
|
||||
expect(
|
||||
shouldClearAgentAttention({
|
||||
agentId: "agent-1",
|
||||
isConnected: true,
|
||||
requiresAttention: true,
|
||||
attentionReason: "finished",
|
||||
trigger: "focus-entry",
|
||||
hasDeferredFocusEntryClear: true,
|
||||
})
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("returns true for explicit follow-up entrypoints after deferred focus clear", () => {
|
||||
expect(
|
||||
shouldClearAgentAttention({
|
||||
agentId: "agent-1",
|
||||
isConnected: true,
|
||||
requiresAttention: true,
|
||||
attentionReason: "finished",
|
||||
trigger: "input-focus",
|
||||
hasDeferredFocusEntryClear: true,
|
||||
})
|
||||
).toBe(true);
|
||||
|
||||
expect(
|
||||
shouldClearAgentAttention({
|
||||
agentId: "agent-1",
|
||||
isConnected: true,
|
||||
requiresAttention: true,
|
||||
attentionReason: "finished",
|
||||
trigger: "prompt-send",
|
||||
hasDeferredFocusEntryClear: true,
|
||||
})
|
||||
).toBe(true);
|
||||
|
||||
expect(
|
||||
shouldClearAgentAttention({
|
||||
agentId: "agent-1",
|
||||
isConnected: true,
|
||||
requiresAttention: true,
|
||||
attentionReason: "finished",
|
||||
trigger: "agent-blur",
|
||||
hasDeferredFocusEntryClear: true,
|
||||
})
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,8 +3,16 @@ interface ShouldClearAgentAttentionInput {
|
||||
isConnected: boolean;
|
||||
requiresAttention: boolean | null | undefined;
|
||||
attentionReason?: "finished" | "error" | "permission" | null | undefined;
|
||||
trigger?: AgentAttentionClearTrigger;
|
||||
hasDeferredFocusEntryClear?: boolean;
|
||||
}
|
||||
|
||||
export type AgentAttentionClearTrigger =
|
||||
| "focus-entry"
|
||||
| "input-focus"
|
||||
| "prompt-send"
|
||||
| "agent-blur";
|
||||
|
||||
export function shouldClearAgentAttention(
|
||||
input: ShouldClearAgentAttentionInput
|
||||
): boolean {
|
||||
@@ -21,5 +29,11 @@ export function shouldClearAgentAttention(
|
||||
if (input.attentionReason === "permission") {
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
input.trigger === "focus-entry" &&
|
||||
input.hasDeferredFocusEntryClear === true
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user