feat(session-limits): LS7-front — UI limites de session (badge + compte à rebours + filet humain)

Expose la surface produit des limites de session côté React/TS,
au-dessus du câblage backend (9df5923).

- domain/index.ts : 5 variantes ajoutées au union DomainEvent
  (agentRateLimited / ResumeScheduled / ResumeCancelled / Resumed /
  RateLimitSuspected).
- ports/index.ts : cancelResume(agentId) ajouté à InputGateway.
- adapters/input.ts : TauriInputGateway.cancelResume → invoke("cancel_resume").
- adapters/mock/index.ts : MockInputGateway.cancelResume
  (cancelledResumes / cancelResumeResult).
- features/agents/useAgents.ts : état limitByAgent + action cancelResume.
- features/agents/AgentLimitBadge.tsx (nouveau) : badge + compte à rebours
  + bouton Annuler + helpers purs.
- features/agents/AgentsPanel.tsx : câblage du badge.

Tests : useAgentsLimits.test.tsx (13) + AgentLimitBadge.test.tsx (11),
suite agents 63 tests verts, tsc --noEmit propre.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-17 08:06:56 +02:00
parent 9df592389c
commit 4fad0423e7
9 changed files with 702 additions and 1 deletions

View File

@ -36,6 +36,55 @@ export type DomainEvent =
submitSequence?: string;
submitDelayMs?: number;
}
| {
/**
* An agent entered a session/rate limit (ARCHITECTURE §21). Low-frequency,
* model-agnostic. `resetsAtMs` is the reset instant in epoch-milliseconds;
* absent ⇒ unknown (no reliable time → no auto-resume). The frontend badges
* "limité jusqu'à HH:MM" when known, "limité" otherwise.
*/
type: "agentRateLimited";
agentId: string;
resetsAtMs?: number;
}
| {
/**
* An auto-resume was armed for a rate-limited agent (ARCHITECTURE §21).
* `fireAtMs` is the wake-up deadline in epoch-milliseconds. The frontend
* shows the countdown + the "Annuler la reprise" button (cancellable window).
*/
type: "agentResumeScheduled";
agentId: string;
fireAtMs: number;
}
| {
/**
* An agent's auto-resume was cancelled (ARCHITECTURE §21): the user clicked
* "Annuler la reprise". The frontend removes the countdown but keeps the
* "limité" state (no auto-resume will fire).
*/
type: "agentResumeCancelled";
agentId: string;
}
| {
/**
* An agent was effectively resumed after a limit (ARCHITECTURE §21): the
* wake-up fired (or an immediate resume). The frontend clears all limit state.
*/
type: "agentResumed";
agentId: string;
}
| {
/**
* Human net (level 3): a session limit is suspected without any reliable
* reset time (ARCHITECTURE §21.1). IdeA never resumes blind: this asks the
* frontend to surface an "heure inconnue" state and prompt the user.
* `resetsAtMs` carries an estimate when one exists, else absent.
*/
type: "agentRateLimitSuspected";
agentId: string;
resetsAtMs?: number;
}
| { type: "templateUpdated"; templateId: string; version: number }
| { type: "agentDriftDetected"; agentId: string; from: number; to: number }
| { type: "agentSynced"; agentId: string; to: number }