- Added functionality to track member spawn statuses during team provisioning, including marking members as online when their first inbox message arrives. - Introduced new IPC channels and handlers for fetching member spawn statuses. - Enhanced TeamProvisioningService to manage spawn status updates and emit events for changes. - Updated UI components to reflect member spawn statuses, improving visibility of member activity during provisioning. - Added CSS animations for member spawn effects to enhance user experience.
27 lines
891 B
TypeScript
27 lines
891 B
TypeScript
import type { ContextInjection } from '@renderer/types/contextInjection';
|
|
|
|
export function sumContextInjectionTokens(injections: readonly ContextInjection[]): number {
|
|
let sum = 0;
|
|
for (const inj of injections) {
|
|
sum += inj.estimatedTokens ?? 0;
|
|
}
|
|
return sum;
|
|
}
|
|
|
|
export function computePercentOfTotal(
|
|
visibleTokens: number,
|
|
totalSessionTokens: number | undefined
|
|
): number | null {
|
|
if (totalSessionTokens === undefined || totalSessionTokens <= 0) return null;
|
|
if (!Number.isFinite(visibleTokens) || visibleTokens <= 0) return 0;
|
|
return Math.min((visibleTokens / totalSessionTokens) * 100, 100);
|
|
}
|
|
|
|
export function formatPercentOfTotal(
|
|
visibleTokens: number,
|
|
totalSessionTokens: number | undefined
|
|
): string | null {
|
|
const pct = computePercentOfTotal(visibleTokens, totalSessionTokens);
|
|
if (pct === null) return null;
|
|
return `${pct.toFixed(1)}% of input`;
|
|
}
|