task(A2): tool dispatcher behind flag

This commit is contained in:
Agent Zero
2026-08-26 21:14:46 +02:00
parent 5d7fa23825
commit 4a7a8f912f
5 changed files with 396 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
/**
* session.ts Minimaler Werkzeug-Sitzungszustand (Task A2).
*
* phase 'idle' : kein Ziehen aktiv, Tool wartet auf down
* phase 'active' : down ist erfolgt; Tool zieht/zeichnet bis up/cancel
*
* Der Dispatcher nutzt das, um move-Events nur während aktiver Sitzung an
* Handler durchzureichen (und als Guard gegen verlorene up-Events).
*/
export type ToolPhase = 'idle' | 'active';
export class ToolSession {
private current: ToolPhase = 'idle';
/** Ist eine Zeichensitzung aktiv (zwischen down und up)? */
get isActive(): boolean {
return this.current === 'active';
}
/** Aktuelle Phase. */
get phase(): ToolPhase {
return this.current;
}
/** Startet eine Sitzung (nach einem gültigen down). */
begin(): void {
this.current = 'active';
}
/** Beendet die Sitzung regulär (up) oder abgebrochen (cancel/ESC). */
end(): void {
this.current = 'idle';
}
}