fix(custom-cli): le bouton Stop annule le tour courant sans fermer la session et cascade l'annulation aux agents délégués — stop_agent suit l'arbre des dépendances actives (cancel_current_turn + préemption runtime + enfants d'exécution), TurnCancel tue le process du tour en cours, autorisation requester/sous-arbre sur idea_stop_agent, fixtures DTO runtime_state/node_id alignées — #257 (QA verte)
This commit is contained in:
@ -1070,7 +1070,7 @@ export function CustomAgentChatView({
|
||||
});
|
||||
const delegationActive = requesterDelegation.delegationTargetName !== null;
|
||||
const effectiveBusy =
|
||||
busy || requesterDelegation.currentAgentBusy || delegationActive;
|
||||
busy || stopping || requesterDelegation.currentAgentBusy || delegationActive;
|
||||
const delegationFallbackText = requesterDelegation.delegationTargetName
|
||||
? `${agentName} attend ${requesterDelegation.delegationTargetName}`
|
||||
: "Délégation en cours.";
|
||||
@ -1982,21 +1982,19 @@ export function CustomAgentChatView({
|
||||
}
|
||||
}
|
||||
|
||||
async function stopAgent() {
|
||||
async function stopCurrentRequest() {
|
||||
const sid = sessionRef.current;
|
||||
if (!sid || !agent.stopLiveAgent || stopping) return;
|
||||
if (!sid || !agent.cancelAgentChat || stopping) return;
|
||||
setStopping(true);
|
||||
setError(null);
|
||||
try {
|
||||
const stopped = await agent.stopLiveAgent(projectId, agentId);
|
||||
await agent.cancelAgentChat(sid);
|
||||
if (activeInteractionIdRef.current) {
|
||||
markProjectCliInteractionStopped(projectId, activeInteractionIdRef.current);
|
||||
activeInteractionIdRef.current = null;
|
||||
}
|
||||
setBusy(false);
|
||||
setOpening(false);
|
||||
setCurrentSession(null);
|
||||
publishSessionId(null);
|
||||
updateChatViewState((prev) => {
|
||||
const completed = completeChatViewProgress(prev);
|
||||
return {
|
||||
@ -2005,10 +2003,7 @@ export function CustomAgentChatView({
|
||||
...completed.turns,
|
||||
{
|
||||
role: "tool",
|
||||
label:
|
||||
stopped.kind === "structured"
|
||||
? "Agent arrêté. Cascade d'arrêt demandée pour les tâches et appels MCP liés."
|
||||
: "Agent arrêté.",
|
||||
label: "Request stopped.",
|
||||
receivedAtMs: Date.now(),
|
||||
},
|
||||
],
|
||||
@ -2022,15 +2017,13 @@ export function CustomAgentChatView({
|
||||
}
|
||||
setBusy(false);
|
||||
setOpening(false);
|
||||
setCurrentSession(null);
|
||||
publishSessionId(null);
|
||||
updateChatViewState((prev) => {
|
||||
const completed = completeChatViewProgress(prev);
|
||||
return {
|
||||
...completed,
|
||||
turns: [
|
||||
...completed.turns,
|
||||
{ role: "tool", label: "Session déjà arrêtée.", receivedAtMs: Date.now() },
|
||||
{ role: "tool", label: "Request already stopped.", receivedAtMs: Date.now() },
|
||||
],
|
||||
};
|
||||
});
|
||||
@ -2043,7 +2036,7 @@ export function CustomAgentChatView({
|
||||
...prev.turns,
|
||||
{
|
||||
role: "error",
|
||||
text: `Arrêt de l'agent échoué: ${describe(e)}`,
|
||||
text: `Arrêt de la demande échoué: ${describe(e)}`,
|
||||
receivedAtMs: Date.now(),
|
||||
},
|
||||
],
|
||||
@ -2417,13 +2410,15 @@ export function CustomAgentChatView({
|
||||
className="shrink-0 whitespace-nowrap"
|
||||
disabled={
|
||||
effectiveBusy
|
||||
? !supported || !currentSession || !agent.stopLiveAgent || stopping
|
||||
? !supported || !currentSession || !agent.cancelAgentChat || stopping
|
||||
: !canSend
|
||||
}
|
||||
loading={stopping}
|
||||
onClick={() => (effectiveBusy ? void stopAgent() : void send())}
|
||||
title={effectiveBusy ? "Arrêter la demande en cours" : undefined}
|
||||
aria-label={effectiveBusy ? "Stop" : undefined}
|
||||
onClick={() => (effectiveBusy ? void stopCurrentRequest() : void send())}
|
||||
>
|
||||
{stopping ? "Arrêt en cours..." : effectiveBusy ? "Stop" : "Envoyer"}
|
||||
{stopping ? "Stopping..." : effectiveBusy ? "Stop" : "Envoyer"}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user