refactor(frontend): remove quota UI and preserve queue lifecycle
This commit is contained in:
@@ -3,7 +3,6 @@ import { z } from "zod";
|
||||
import { createAudioContext } from "../audio/engine";
|
||||
import {
|
||||
errorMessage,
|
||||
getAccount,
|
||||
getConfig,
|
||||
getProfile,
|
||||
getReports,
|
||||
@@ -15,7 +14,6 @@ import {
|
||||
import { buildInstructions, profileContext, ragContext, speechInstructions, WEB_SEARCH } from "../lib/context";
|
||||
import {
|
||||
defaultConfig,
|
||||
type AccountInfo,
|
||||
type ConnectionStatus,
|
||||
type DynamicTool,
|
||||
type Profile,
|
||||
@@ -44,7 +42,6 @@ export interface AppState {
|
||||
settings: Settings;
|
||||
profile: Profile | null;
|
||||
reports: Reports | null;
|
||||
account: AccountInfo | null;
|
||||
tools: DynamicTool[];
|
||||
toolsLoading: boolean;
|
||||
toolsError: string;
|
||||
@@ -57,8 +54,6 @@ export interface AppState {
|
||||
rag: string;
|
||||
queuePosition: number;
|
||||
joinDeadline: number;
|
||||
remainingSec: number | null;
|
||||
limitReached: boolean;
|
||||
unlock: boolean;
|
||||
}
|
||||
|
||||
@@ -76,7 +71,6 @@ export class VoiceController {
|
||||
private sessionNumber = 0;
|
||||
private reasoned = new Set<string>();
|
||||
private autoStarted = false;
|
||||
private pageSignal: AbortSignal | undefined;
|
||||
|
||||
constructor(caller = callerFromLocation()) {
|
||||
this.caller = caller;
|
||||
@@ -86,7 +80,6 @@ export class VoiceController {
|
||||
settings: loadSettings(),
|
||||
profile: null,
|
||||
reports: null,
|
||||
account: null,
|
||||
tools: [],
|
||||
toolsLoading: false,
|
||||
toolsError: "",
|
||||
@@ -99,8 +92,6 @@ export class VoiceController {
|
||||
rag: "",
|
||||
queuePosition: 0,
|
||||
joinDeadline: 0,
|
||||
remainingSec: null,
|
||||
limitReached: false,
|
||||
unlock: false,
|
||||
};
|
||||
}
|
||||
@@ -119,18 +110,16 @@ export class VoiceController {
|
||||
}
|
||||
|
||||
async initialize(signal: AbortSignal) {
|
||||
this.pageSignal = signal;
|
||||
try {
|
||||
const [config, profile, reports, account] = await Promise.all([
|
||||
const [config, profile, reports] = await Promise.all([
|
||||
getConfig(signal),
|
||||
getProfile(this.caller.phoneNumber, signal),
|
||||
getReports(this.caller.phoneNumber, signal),
|
||||
getAccount(signal),
|
||||
]);
|
||||
if (signal.aborted) {
|
||||
return;
|
||||
}
|
||||
this.update({ config, profile, reports, account, loading: false, error: "" });
|
||||
this.update({ config, profile, reports, loading: false, error: "" });
|
||||
if (config.apipilot) {
|
||||
await this.refreshTools(signal, !!profile);
|
||||
}
|
||||
@@ -189,9 +178,6 @@ export class VoiceController {
|
||||
this.update({ rag: rag.trim() });
|
||||
this.pushSettings();
|
||||
}
|
||||
dismissLimit() {
|
||||
this.update({ limitReached: false });
|
||||
}
|
||||
dismissError() {
|
||||
this.update({ error: "" });
|
||||
}
|
||||
@@ -220,7 +206,6 @@ export class VoiceController {
|
||||
notice: "",
|
||||
status: "connecting",
|
||||
muted: false,
|
||||
limitReached: false,
|
||||
joinDeadline: 0,
|
||||
});
|
||||
let context: AudioContext | undefined;
|
||||
@@ -307,8 +292,8 @@ export class VoiceController {
|
||||
client.on("readyToJoin", ({ expiresSec }) => {
|
||||
this.update({ joinDeadline: Date.now() + expiresSec * 1000 });
|
||||
}),
|
||||
client.on("grant", ({ remainingSec }) => {
|
||||
this.update({ remainingSec: remainingSec ?? null, joinDeadline: 0 });
|
||||
client.on("grant", () => {
|
||||
this.update({ joinDeadline: 0 });
|
||||
}),
|
||||
client.on("error", (error) => {
|
||||
this.reportError(error);
|
||||
@@ -352,7 +337,6 @@ export class VoiceController {
|
||||
this.update({
|
||||
error: errorMessage(error),
|
||||
status: "error",
|
||||
limitReached: error instanceof SessionError && error.code === "limit",
|
||||
});
|
||||
}
|
||||
private transcript(transcript: Transcript, interrupted = false) {
|
||||
@@ -513,19 +497,11 @@ export class VoiceController {
|
||||
muted: false,
|
||||
level: 0,
|
||||
joinDeadline: 0,
|
||||
remainingSec: null,
|
||||
unlock: false,
|
||||
messages: this.state.messages.map((message) =>
|
||||
message.partial ? { ...message, partial: false, interrupted: message.role === "assistant" } : message,
|
||||
),
|
||||
});
|
||||
await client?.close();
|
||||
if (client && this.state.account?.enabled && this.pageSignal && !this.pageSignal.aborted) {
|
||||
const signal = this.pageSignal;
|
||||
const account = await getAccount(signal).catch(() => null);
|
||||
if (!signal.aborted && account) {
|
||||
this.update({ account });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user