Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/services/app-state.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ export class AppStateService {
* run to hundreds of KB and every state change broadcasts the whole object.
*/
getRendererState(): RendererAppState {
const { interviewConfig, ...rest } = this.state;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { interviewConfig, providedLLMModel, ...rest } = this.state;
return {
...rest,
interviewConfig: {
Expand Down
4 changes: 3 additions & 1 deletion src/main/types/app-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ export interface AppState {
}

/** The app state as sent to the renderer, with the interview config reduced to a summary. */
export type RendererAppState = Omit<AppState, 'interviewConfig'> & {
// `providedLLMModel` stays in main: the app shows a generic "free model" / "SOTA model" label, and
// the exact backend model name is not something to put on screen.
export type RendererAppState = Omit<AppState, 'interviewConfig' | 'providedLLMModel'> & {
interviewConfig: InterviewConfigSummary;
};
17 changes: 8 additions & 9 deletions src/renderer/components/custom/credits-display.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ interface CreditsDisplayProps {
/** The free-tier balance, in credits. */
credits: number;
subscription: SubscriptionSummary;
llmModel?: string;
/** From the backend ping; falls back to the compiled-in mirror while that has not arrived. */
creditsPerMinute?: number;
className?: string;
Expand All @@ -27,16 +26,17 @@ interface CreditsDisplayProps {
export default function CreditsDisplay({
credits,
subscription,
llmModel,
creditsPerMinute,
className,
style,
}: CreditsDisplayProps) {
const t = useT();
const now = useNow();
const subscribed = isSubscriptionActive(subscription, now);

return (
<div className={cn('flex text-xs font-bold gap-2', className)} style={style}>
{isSubscriptionActive(subscription, now) && subscription.expiresAt !== null ? (
{subscribed && subscription.expiresAt !== null ? (
<SubscribedSummary
subscription={subscription}
expiresAt={subscription.expiresAt}
Expand All @@ -45,12 +45,11 @@ export default function CreditsDisplay({
) : (
<FreeSummary credits={credits} creditsPerMinute={creditsPerMinute} />
)}
{llmModel && (
<>
<hr className="h-4 border border-border" />
<span className="text-muted-foreground">{llmModel}</span>
</>
)}
{/* The tier, never the backend's exact model name. */}
<hr className="h-4 border border-border" />
<span className="text-muted-foreground">
{subscribed ? t.creditsDisplay.sotaModel : t.creditsDisplay.freeModel}
</span>
</div>
);
}
Expand Down
3 changes: 0 additions & 3 deletions src/renderer/components/custom/status-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ interface StatusPanelProps {
runningState: RunningState;
credits: number;
subscription: SubscriptionSummary;
llmModel: string;
creditsPerMinute?: number;
}

Expand All @@ -34,7 +33,6 @@ const badgeClass = (active: boolean) =>

export default function StatusPanel({
runningState,
llmModel,
credits,
subscription,
creditsPerMinute,
Expand All @@ -51,7 +49,6 @@ export default function StatusPanel({
<CreditsDisplay
credits={credits}
subscription={subscription}
llmModel={llmModel}
creditsPerMinute={creditsPerMinute}
className="ml-2"
/>
Expand Down
1 change: 0 additions & 1 deletion src/renderer/components/custom/titlebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ export default function Titlebar() {
<CreditsDisplay
credits={appState.credits ?? 0}
subscription={subscriptionOf(appState)}
llmModel={appState.providedLLMModel ?? ''}
creditsPerMinute={appState.creditsPerMinute}
style={DRAG}
/>
Expand Down
1 change: 0 additions & 1 deletion src/renderer/hooks/use-app-state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class AppStateManager {
subscriptionExpiresAt: raw.subscriptionExpiresAt,
subscriptionPlan: raw.subscriptionPlan,
userRole: raw.userRole,
providedLLMModel: raw.providedLLMModel,
creditsPerMinute: raw.creditsPerMinute,
interviewConfig: raw.interviewConfig ?? { fullName: '', hasProfileData: false, hasContextData: false },
interviewConfigLoaded: raw.interviewConfigLoaded ?? false,
Expand Down
3 changes: 3 additions & 0 deletions src/renderer/i18n/locales/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,9 @@ export const de: Translation = {

creditsDisplay: {
freePlan: 'Gratis',
/** The model tier, shown instead of the backend's exact model name. */
freeModel: 'Gratis-Modell',
sotaModel: 'SOTA-Modell',
planNames: {
monthly: 'Monatlich',
quarterly: 'Vierteljährlich',
Expand Down
3 changes: 3 additions & 0 deletions src/renderer/i18n/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,9 @@ export const en = {

creditsDisplay: {
freePlan: 'Free',
/** The model tier, shown instead of the backend's exact model name. */
freeModel: 'Free model',
sotaModel: 'SOTA model',
/** The plan an active subscription was bought as; `other` when the backend did not say. */
planNames: {
monthly: 'Monthly',
Expand Down
3 changes: 3 additions & 0 deletions src/renderer/i18n/locales/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,9 @@ export const es: Translation = {

creditsDisplay: {
freePlan: 'Gratis',
/** The model tier, shown instead of the backend's exact model name. */
freeModel: 'Modelo gratuito',
sotaModel: 'Modelo SOTA',
planNames: {
monthly: 'Mensual',
quarterly: 'Trimestral',
Expand Down
3 changes: 3 additions & 0 deletions src/renderer/i18n/locales/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,9 @@ export const fr: Translation = {

creditsDisplay: {
freePlan: 'Gratuit',
/** The model tier, shown instead of the backend's exact model name. */
freeModel: 'Modèle gratuit',
sotaModel: 'Modèle SOTA',
planNames: {
monthly: 'Mensuel',
quarterly: 'Trimestriel',
Expand Down
3 changes: 3 additions & 0 deletions src/renderer/i18n/locales/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,9 @@ export const ja: Translation = {

creditsDisplay: {
freePlan: '無料',
/** The model tier, shown instead of the backend's exact model name. */
freeModel: '無料モデル',
sotaModel: '最先端モデル',
planNames: {
monthly: '月額',
quarterly: '3 か月',
Expand Down
3 changes: 3 additions & 0 deletions src/renderer/i18n/locales/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,9 @@ export const ko: Translation = {

creditsDisplay: {
freePlan: '무료',
/** The model tier, shown instead of the backend's exact model name. */
freeModel: '무료 모델',
sotaModel: '최신 모델',
planNames: {
monthly: '월간',
quarterly: '3개월',
Expand Down
3 changes: 3 additions & 0 deletions src/renderer/i18n/locales/pt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,9 @@ export const pt: Translation = {

creditsDisplay: {
freePlan: 'Grátis',
/** The model tier, shown instead of the backend's exact model name. */
freeModel: 'Modelo grátis',
sotaModel: 'Modelo SOTA',
planNames: {
monthly: 'Mensal',
quarterly: 'Trimestral',
Expand Down
3 changes: 3 additions & 0 deletions src/renderer/i18n/locales/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,9 @@ export const ru: Translation = {

creditsDisplay: {
freePlan: 'Бесплатно',
/** The model tier, shown instead of the backend's exact model name. */
freeModel: 'Базовая модель',
sotaModel: 'Передовая модель',
planNames: {
monthly: 'Месячная',
quarterly: 'Квартальная',
Expand Down
3 changes: 3 additions & 0 deletions src/renderer/i18n/locales/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,9 @@ export const zh: Translation = {

creditsDisplay: {
freePlan: '免费',
/** The model tier, shown instead of the backend's exact model name. */
freeModel: '免费模型',
sotaModel: '最先进模型',
planNames: {
monthly: '月度',
quarterly: '季度',
Expand Down
1 change: 0 additions & 1 deletion src/renderer/pages/main/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,6 @@ export default function MainPage() {
runningState={appState?.runningState ?? RunningState.Idle}
credits={appState?.credits ?? 0}
subscription={subscriptionOf(appState)}
llmModel={appState?.providedLLMModel ?? ''}
creditsPerMinute={appState?.creditsPerMinute}
/>
)}
Expand Down
1 change: 0 additions & 1 deletion src/renderer/types/app-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export interface AppState {
/** The last pass applied (`monthly` / `quarterly` / `yearly`), for display; null when unknown. */
subscriptionPlan?: string | null;
userRole?: UserRole;
providedLLMModel?: string;
interviewConfig: InterviewConfigSummary;
interviewConfigLoaded: boolean;
/**
Expand Down
4 changes: 4 additions & 0 deletions test/app-state.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ export async function run() {
// No-op updates must not even schedule a broadcast, so flushing produces nothing.
appStateService.flushRenderer();
check('identical updates do not broadcast', sent.length === baseline);
check(
'the exact model name is never broadcast',
sent.every(({ payload }) => typeof payload !== 'object' || !('providedLLMModel' in payload))
);

appStateService.updateState({ isBackendLive: false });
appStateService.flushRenderer();
Expand Down