The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): open the Nous sign-in dialog from Billing's logged-out notice
brooklyn!72b8502f425f
diff --git a/apps/desktop/src/AGENTS.md b/apps/desktop/src/AGENTS.mdindex 536e3b24f44..c42f4c1bfb2 100644--- a/apps/desktop/src/AGENTS.md+++ b/apps/desktop/src/AGENTS.md@@ -102,7 +102,8 @@ reads/writes a stored pointer), `canonical-chat-creation.test.ts`, `canonical-ch`$freeTierStatus` mirrors `free_tier.status` (pull; refreshed with the status snapshot and after asign-in). `deriveBillingView` branches on `billing.free_tier` BEFORE `logged_in` (status-`free_tier`: notice + one Sign in, Plan/Model/Connectors summary, no payment or usage rows). The-sign-in dialog is a single claimed owner (first mount wins, like the real-profile consent prompt);-its states map 1:1 to the poll route's `status` + `reason`. Copy is the ruled free-tier copy: never+`free_tier`: notice + one Sign in, Plan/Model/Connectors summary, no payment or usage rows); the+`logged_out` notice's Sign in opens the same dialog, never a portal link (a link writes no+credential). The sign-in dialog is a single claimed owner (first mount wins, like the+real-profile consent prompt); its states map 1:1 to the poll route's `status` + `reason`. Copy is the ruled free-tier copy: never"guest", "anonymous", "claim" or "Nous Portal" in user-facing text.diff --git a/apps/desktop/src/app/settings/billing/index.test.tsx b/apps/desktop/src/app/settings/billing/index.test.tsxindex 027d01bc248..c890544d4e0 100644--- a/apps/desktop/src/app/settings/billing/index.test.tsx+++ b/apps/desktop/src/app/settings/billing/index.test.tsx@@ -5,6 +5,7 @@ import { MemoryRouter } from 'react-router'import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'import { type I18nContextValue, I18nProvider, useI18n } from '@/i18n'+import { $freeTierSignIn } from '@/store/free-tier-sign-in'import { formatMoney } from './billing-amounts'import {@@ -595,13 +596,18 @@ describe('BillingSettings', () => {)})- it('renders logged-out as a connect card without normal account rows', async () => {+ it('renders logged-out as a connect card whose sign-in opens the shared dialog', async () => {apiMocks.fetchBillingState.mockResolvedValue(okBilling(loggedOutBillingState))apiMocks.fetchSubscriptionState.mockResolvedValue(okSubscription(loggedOutSubscriptionState))+ $freeTierSignIn.set({ status: 'closed' })renderBilling()expect(await screen.findByText('Connect your Nous account')).toBeTruthy()+ fireEvent.click(screen.getByRole('button', { name: 'Sign in' }))+ expect($freeTierSignIn.get()).toEqual({ status: 'requested' })+ expect(apiMocks.openExternal).not.toHaveBeenCalled()+ $freeTierSignIn.set({ status: 'closed' })expect(screen.queryByText('Payment method')).toBeNull()expect(screen.queryByText('Usage')).toBeNull()})diff --git a/apps/desktop/src/app/settings/billing/use-billing-state.test.ts b/apps/desktop/src/app/settings/billing/use-billing-state.test.tsindex ba45703ee86..10785b38537 100644--- a/apps/desktop/src/app/settings/billing/use-billing-state.test.ts+++ b/apps/desktop/src/app/settings/billing/use-billing-state.test.ts@@ -1,6 +1,7 @@import { describe, expect, it } from 'vitest'import { TRANSLATIONS } from '@/i18n'+import { $freeTierSignIn } from '@/store/free-tier-sign-in'import type { BillingRefusal } from './api'import { resolveRefusal } from './errors'@@ -248,6 +249,18 @@ describe('deriveBillingView', () => {expect(view.usageRows).toEqual([])})+ it('signs in from the logged-out notice through the shared sign-in dialog, not a portal link', () => {+ // A plain portal link never writes a credential, so the page would stay logged out forever+ // (#87792). The action must open the one Nous sign-in dialog (device-code + poll).+ $freeTierSignIn.set({ status: 'closed' })+ const view = deriveBillingView(okBilling(loggedOutBillingState), okSubscription(loggedOutSubscriptionState))++ expect(view.notice?.action?.url).toBeUndefined()+ view.notice?.action?.onSelect?.()+ expect($freeTierSignIn.get()).toEqual({ status: 'requested' })+ $freeTierSignIn.set({ status: 'closed' })+ })+it('derives the free-tier view before the logged-out one, with nothing to pay', () => {// A free-tier install is logged_in:false, so this branch must win — otherwise// the generic "connect your account" notice sends the user to the portal.diff --git a/apps/desktop/src/app/settings/billing/use-billing-state.ts b/apps/desktop/src/app/settings/billing/use-billing-state.tsindex bbd5aa037d9..b7ab342d15b 100644--- a/apps/desktop/src/app/settings/billing/use-billing-state.ts+++ b/apps/desktop/src/app/settings/billing/use-billing-state.ts@@ -222,13 +222,12 @@ export function deriveBillingView(return freeTierView(billing, b)}+ // Signing in is the only thing that writes a credential; a portal link never would, so the+ // page would stay logged out after the user logged in on the web (#87792).if (!billing.logged_in || subscription?.logged_in === false) {return {notice: {- action: {- label: b.state.notice.loggedOut.action,- url: billing.portal_url ?? subscription?.portal_url ?? FALLBACK_PORTAL_URL- },+ action: { label: b.state.notice.loggedOut.action, onSelect: openFreeTierSignIn },message: b.state.notice.loggedOut.message,title: b.state.notice.loggedOut.title},@@ -365,7 +364,7 @@ function refusalNotice(refusal: BillingRefusal, b: Translations['settings']['bilconst portalUrl = resolved.action.type === 'portal' ? resolved.action.url : undefinedreturn {- action: portalUrl ? { label: b.state.notice.loggedOut.action, url: portalUrl } : undefined,+ action: portalUrl ? { label: b.state.notice.openPortal, url: portalUrl } : undefined,message: resolved.message,title: resolved.title,tone: 'warn'diff --git a/apps/desktop/src/i18n/de.ts b/apps/desktop/src/i18n/de.tsindex 972ab600a7b..ac2f952bac8 100644--- a/apps/desktop/src/i18n/de.ts+++ b/apps/desktop/src/i18n/de.ts@@ -2385,9 +2385,10 @@ export const de = defineLocale({notice: {loggedOut: {title: 'Nous-Konto verbinden',- message: 'Führen Sie /portal in der TUI aus oder öffnen Sie das Nous-Portal, um Ihr Konto zu verbinden.',- action: 'Portal öffnen ↗'+ message: 'Melden Sie sich mit Ihrem Nous-Konto an, um hier Guthaben, Tarif und Nutzung zu sehen.',+ action: 'Anmelden'},+ openPortal: 'Portal öffnen ↗',noCard: {title: 'Keine Zahlungsmethode hinterlegt',message:diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.tsindex 8ffa7c2eeb7..f7d6d0786be 100644--- a/apps/desktop/src/i18n/en.ts+++ b/apps/desktop/src/i18n/en.ts@@ -2006,9 +2006,10 @@ export const en: Translations = {notice: {loggedOut: {title: 'Connect your Nous account',- message: 'Run /portal in the TUI or open the Nous portal to connect your account.',- action: 'Open portal ↗'+ message: 'Sign in with your Nous account to see your balance, plan and usage here.',+ action: 'Sign in'},+ openPortal: 'Open portal ↗',noCard: {title: 'No payment method on file',message:diff --git a/apps/desktop/src/i18n/es.ts b/apps/desktop/src/i18n/es.tsindex 161425680aa..5669057ee18 100644--- a/apps/desktop/src/i18n/es.ts+++ b/apps/desktop/src/i18n/es.ts@@ -2376,9 +2376,10 @@ export const es = defineLocale({notice: {loggedOut: {title: 'Conecta tu cuenta de Nous',- message: 'Ejecuta /portal en la TUI o abre el portal de Nous para conectar tu cuenta.',- action: 'Abrir el portal ↗'+ message: 'Inicia sesión con tu cuenta de Nous para ver aquí tu saldo, plan y uso.',+ action: 'Iniciar sesión'},+ openPortal: 'Abrir el portal ↗',noCard: {title: 'No hay ningún método de pago registrado',message:diff --git a/apps/desktop/src/i18n/fr.ts b/apps/desktop/src/i18n/fr.tsindex ac2d417b233..5cd11ccd7d4 100644--- a/apps/desktop/src/i18n/fr.ts+++ b/apps/desktop/src/i18n/fr.ts@@ -2390,9 +2390,11 @@ export const fr = defineLocale({notice: {loggedOut: {title: 'Connectez votre compte Nous',- message: 'Exécutez /portal dans la TUI ou ouvrez le portail Nous pour connecter votre compte.',- action: 'Ouvrir le portail ↗'+ message:+ 'Connectez-vous avec votre compte Nous pour voir ici votre solde, votre offre et votre utilisation.',+ action: 'Se connecter'},+ openPortal: 'Ouvrir le portail ↗',noCard: {title: 'Aucun moyen de paiement enregistré',message:diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.tsindex 9f6d6ec402a..640a7d80fde 100644--- a/apps/desktop/src/i18n/types.ts+++ b/apps/desktop/src/i18n/types.ts@@ -1710,6 +1710,7 @@ export interface Translations {state: {notice: {loggedOut: { title: string; message: string; action: string }+ openPortal: stringnoCard: { title: string; message: string; action: string }}paymentMethod: {diff --git a/apps/desktop/src/i18n/zh-hant.ts b/apps/desktop/src/i18n/zh-hant.tsindex 415bfc20d92..9ae37d8a6f8 100644--- a/apps/desktop/src/i18n/zh-hant.ts+++ b/apps/desktop/src/i18n/zh-hant.ts@@ -1575,9 +1575,10 @@ export const zhHant = defineLocale({notice: {loggedOut: {title: '連接你的 Nous 帳戶',- message: '在 TUI 中執行 /portal,或開啟 Nous 入口網站連接帳戶。',- action: '開啟入口網站 ↗'+ message: '登入你的 Nous 帳戶,即可在此查看餘額、方案和用量。',+ action: '登入'},+ openPortal: '開啟入口網站 ↗',noCard: {title: '尚未新增付款方式',message: '新增銀行卡後才能購買額度和使用自動儲值。請在入口網站中新增。',diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.tsindex ad76677dd13..d736468185e 100644--- a/apps/desktop/src/i18n/zh.ts+++ b/apps/desktop/src/i18n/zh.ts@@ -1932,9 +1932,10 @@ export const zh = defineLocale({notice: {loggedOut: {title: '连接你的 Nous 账户',- message: '在 TUI 中运行 /portal,或打开 Nous 门户连接账户。',- action: '打开门户 ↗'+ message: '登录你的 Nous 账户,即可在此查看余额、套餐和用量。',+ action: '登录'},+ openPortal: '打开门户 ↗',noCard: {title: '尚未添加支付方式',message: '添加银行卡后才能购买额度和使用自动充值。请在门户中添加。',