Fix dictation lifecycle and add real STT e2e

This commit is contained in:
Mohamed Boudra
2026-01-20 13:09:22 +07:00
parent 687ea706b1
commit facd99ab13
9 changed files with 306 additions and 112 deletions
+36
View File
@@ -0,0 +1,36 @@
export class AttemptCancelledError extends Error {
constructor(message = "Attempt cancelled") {
super(message);
this.name = "AttemptCancelledError";
}
}
/**
* Tiny helper for async lifecycles:
* - Call `next()` to start a new attempt and invalidate previous ones
* - Call `cancel()` to invalidate any in-flight attempt
* - Call `assertCurrent(id)` after awaits to enforce a single active attempt
*/
export class AttemptGuard {
private attemptId = 0;
public next(): number {
this.attemptId += 1;
return this.attemptId;
}
public cancel(): void {
this.attemptId += 1;
}
public isCurrent(id: number): boolean {
return id === this.attemptId;
}
public assertCurrent(id: number): void {
if (!this.isCurrent(id)) {
throw new AttemptCancelledError();
}
}
}