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

@ -38,4 +38,10 @@ export class TauriInputGateway implements InputGateway {
request: { agentId, attached },
});
}
async cancelResume(agentId: string): Promise<boolean> {
// `cancel_resume` takes a bare `agent_id` (camelCase `agentId`), not a
// `request` envelope, and returns whether a pending resume was disarmed.
return invoke<boolean>("cancel_resume", { agentId });
}
}

View File

@ -1559,6 +1559,14 @@ export class MockInputGateway implements InputGateway {
readonly delivered: MockInputCall[] = [];
/** All recorded front-attached reports, in order. */
readonly frontAttached: { agentId: string; attached: boolean }[] = [];
/** All recorded cancel-resume calls, in order. */
readonly cancelledResumes: string[] = [];
/**
* What {@link cancelResume} resolves to (mirrors the backend `bool`: whether a
* pending resume was disarmed). Tests can flip it to exercise the "already
* fired / none armed" path.
*/
cancelResumeResult = true;
async interrupt(projectId: string, agentId: string): Promise<void> {
this.interrupts.push({ projectId, agentId });
@ -1575,6 +1583,11 @@ export class MockInputGateway implements InputGateway {
async setFrontAttached(agentId: string, attached: boolean): Promise<void> {
this.frontAttached.push({ agentId, attached });
}
async cancelResume(agentId: string): Promise<boolean> {
this.cancelledResumes.push(agentId);
return this.cancelResumeResult;
}
}
/** In-memory permissions gateway. */