Skip to content
Open
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
5 changes: 5 additions & 0 deletions website/src/pages/AppPopoutFrame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { Btn } from '../components/ui'
import BuiltinAppRoute from '../apps/BuiltinAppRoute'
import AppPage from './AppPage'
import { i18nT } from '../i18n/t'
import { useLanguageGeneration } from '../i18n/useLanguageGeneration'

/**
* The session an app in this window activated and no exit has carried yet.
Expand Down Expand Up @@ -257,6 +258,10 @@ export default function AppPopoutFrame({ route }: {

// Reflect the app in the window/taskbar title so multiple pop-outs are
// distinguishable at the OS level. A core page has no app record to name it.
// The language switch is subscribed to: a store-driven re-render that lands
// before the repaint would otherwise bail out, keeping the new label but
// dropping the effect that titles the window.
useLanguageGeneration()
const corePage = corePopoutPage(route)
const shownLabel = (corePage ? i18nT(corePage.labelKey) : label) || i18nT('pages.appPopoutFrame.app')
useEffect(() => {
Expand Down
5 changes: 5 additions & 0 deletions website/src/shell/appShell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ import { shortcutEntry } from '../lib/shortcutRegistry'
import { ariaKeyshortcutsFor, useKeyboardLayout, useShortcutsEnabled } from '../hooks/useNavShortcutHint'
import type { MobileRosterBarState } from '../components/MobileNavRailContext'
import { i18nT } from '../i18n/t'
import { useLanguageGeneration } from '../i18n/useLanguageGeneration'
import { useGuideRevealScope } from '../guide/GuideRevealScope'
import { useGuideGate, useGuidePredicate } from '../guide/guidePredicates'
import { appNavTarget } from '../appNav'
Expand Down Expand Up @@ -158,6 +159,10 @@ const APP_LIST_RETURN_FLOOR_MS = 2000
function ShellTabTitle({ isChat, isPopout, panelLabel, instanceName, tabProduct, totalAttention, locationKey }: {
isChat: boolean; isPopout: boolean; panelLabel: string; instanceName: string; tabProduct: string; totalAttention: number; locationKey: string
}) {
// The language switch is subscribed to: a store-driven re-render that lands
// before the repaint would otherwise bail out, keeping the new labels but
// dropping the effects that hand them on.
useLanguageGeneration()
// A slot whose title is its key or the backend placeholder has no real title
// yet (same rule as the chat popout).
const activeSessionTitle = useAppSelector(s => {
Expand Down
26 changes: 26 additions & 0 deletions website/src/test/App.tabTitle.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,20 @@ import { ThemeProvider } from '../hooks/useTheme'
import { BrandingProvider } from '../hooks/useBranding'
import type { ChatSlot } from '../types'
import { namedCeiling } from './namedCeiling'
import { i18next } from '../i18n/all'
import { labelCurrentRouteEntry } from '../lib/routeHistoryLabels'

// Counts shell renders: `useAppShell` runs once per render of the whole shell.
const shellRenders = vi.hoisted(() => ({ count: 0 }))
vi.mock('../shell/appShell', async (importOriginal) => {
const actual = await importOriginal<typeof import('../shell/appShell')>()
return { ...actual, useAppShell: () => { shellRenders.count++; return actual.useAppShell() } }
})
// The real writer, watched: what the shell names the history entry on screen.
vi.mock('../lib/routeHistoryLabels', async (importOriginal) => {
const actual = await importOriginal<typeof import('../lib/routeHistoryLabels')>()
return { ...actual, labelCurrentRouteEntry: vi.fn(actual.labelCurrentRouteEntry) }
})
vi.mock('../pages/ChatPage', () => ({ default: () => <div data-testid="chat-page">ChatPage</div> }))
vi.mock('../pages/SchedulePage', () => ({ default: () => <div data-testid="schedule-page">SchedulePage</div> }))
vi.mock('../hooks/useWebSocket', () => ({ useWebSocket: () => ({ subscribeLogs: () => {}, subscribeSubagents: () => {}, forceReconnect: () => {} }) }))
Expand Down Expand Up @@ -188,6 +195,25 @@ describe('main window tab title', () => {
await waitFor(() => expect(document.title).toBe('Chat — Kiro Crew'))
})

it('names the tab and the history entry in the new language on the switch itself, with no repaint from above', async () => {
// A store-driven re-render that lands between the switch and the
// provider's repaint bails out, keeping the new label but dropping the
// effects that hand it on; following the switch itself closes that.
renderAt('/chat')
await waitFor(() => expect(document.title).toBe('Chat — Kiro Crew'))
await shellSettled()
expect(labelCurrentRouteEntry).toHaveBeenLastCalledWith('Chat')
try {
await act(async () => { await i18next.changeLanguage('ja') })
const chat = i18next.t('app.tab_title_chat')
expect(chat).not.toBe('Chat')
expect(document.title).toBe(`${chat} — Kiro Crew`)
expect(labelCurrentRouteEntry).toHaveBeenLastCalledWith(chat)
} finally {
await act(async () => { await i18next.changeLanguage('en') })
}
})

it('names the panel on any other page', async () => {
renderAt('/schedule')
await waitFor(() => expect(document.title).toBe('Schedule — Kiro Crew'))
Expand Down
19 changes: 19 additions & 0 deletions website/src/test/AppPopoutFrame.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { ThemeProvider } from '../hooks/useTheme'
import { useAppDispatch } from '../store'
import { setActiveSlot, setPendingInput, switchSlot } from '../store/chatSlice'
import { ERROR_HANDOFF_KEY, consumeChatHandoff, handoffToChat, hardNavigate } from '../utils/errorReport'
import { i18next } from '../i18n/all'

const popout = vi.hoisted(() => {
const unregister = vi.fn()
Expand Down Expand Up @@ -156,6 +157,7 @@ vi.mock('../apps/BuiltinAppRoute', async importOriginal => {
}
})
vi.mock('../pages/AppPage', () => ({ default: () => <div data-testid="app-page" /> }))
vi.mock('../pages/ChannelPage', () => ({ default: () => <div data-testid="channel-page" /> }))

import AppPopoutFrame, { AppPopoutHardExit, __resetForTests } from '../pages/AppPopoutFrame'

Expand Down Expand Up @@ -295,6 +297,23 @@ describe('AppPopoutFrame', () => {
expect(document.title).toBe('Dev Fleet — Kiro Crew')
})

it('re-titles a core page’s window on the language switch itself, with no repaint from above', async () => {
// A store-driven re-render that lands between the switch and the
// provider's repaint bails out, keeping the new label but dropping the
// effect that titles the window; following the switch itself closes that.
renderFrame('/channels', '/channels')
expect(document.title).toBe('Channels — Kiro Crew')
try {
await act(async () => { await i18next.changeLanguage('ja') })
const label = i18next.t('nav.channels')
expect(label).not.toBe('Channels')
expect(document.title).toBe(`${label} — Kiro Crew`)
expect(screen.getByTestId('app-popout-title-bar')).toHaveTextContent(label)
} finally {
await act(async () => { await i18next.changeLanguage('en') })
}
})

it('lets the app navigate its own sub-paths in place', () => {
renderFrame('/dev-fleet', '/dev-fleet')
fireEvent.click(screen.getByRole('button', { name: 'deeper' }))
Expand Down
Loading