Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

fix(settings): stop the Team seats section crashing on render (#1243)

eneskirca5f0a561d379d
diff --git a/src/renderer/components/settings/sections/TeamAccessSection.render.test.tsx b/src/renderer/components/settings/sections/TeamAccessSection.render.test.tsx
new file mode 100644
index 000000000..d589ec4ce
--- /dev/null
+++ b/src/renderer/components/settings/sections/TeamAccessSection.render.test.tsx
@@ -0,0 +1,52 @@
+// @vitest-environment jsdom
+//
+// Settings → Team seats rendered "This section could not be displayed" with React error #185
+// (maximum update depth) from zustand 5 on: a selector that derives a NEW array on every call
+// never settles under v5's Object.is snapshot check. Rendering the section is the whole test —
+// the loop throws during the first commit, for a premium user and a free one alike.
+import { act } from 'react'
+import { createRoot, type Root } from 'react-dom/client'
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+
+;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true
+
+let root: Root
+let host: HTMLElement
+
+beforeEach(() => {
+ vi.resetModules()
+ // The entitlement store subscribes to license changes the moment it is created.
+ ;(window as unknown as { nodeTerminal: unknown }).nodeTerminal = {
+ license: { onChange: () => () => {} }
+ }
+ host = document.createElement('div')
+ document.body.appendChild(host)
+ root = createRoot(host)
+})
+
+afterEach(() => {
+ act(() => root.unmount())
+ host.remove()
+})
+
+async function renderSection(premium: boolean): Promise<string> {
+ const { useEntitlement } = await import('../../../state/entitlement')
+ const { useTeamAccess } = await import('../../../state/teamAccess')
+ useEntitlement.setState({ isPremium: premium, seats: premium ? 3 : 0 })
+ useTeamAccess.getState().addPending('seat-1', '[email protected]')
+ const { TeamAccessSection } = await import('./TeamAccessSection')
+ act(() => root.render(<TeamAccessSection isActive />))
+ return host.textContent ?? ''
+}
+
+describe('Team seats section', () => {
+ it('renders for a Pro user, listing the seat table', async () => {
+ const text = await renderSection(true)
+ expect(text).toContain('Connected devices')
+ expect(text).toContain('[email protected]')
+ })
+
+ it('renders the upgrade pitch for a free user', async () => {
+ expect(await renderSection(false)).toContain('Upgrade to Pro')
+ })
+})
diff --git a/src/renderer/components/settings/sections/TeamAccessSection.tsx b/src/renderer/components/settings/sections/TeamAccessSection.tsx
index 518466646..bfd1c4ff5 100644
--- a/src/renderer/components/settings/sections/TeamAccessSection.tsx
+++ b/src/renderer/components/settings/sections/TeamAccessSection.tsx
@@ -1,4 +1,4 @@
-import { useState } from 'react'
+import { useMemo, useState } from 'react'
import { useEntitlement } from '../../../state/entitlement'
import { useTeamAccess } from '../../../state/teamAccess'
import { listSeats, usedCount, type SeatEntry } from '../../../state/teamAccessCore'
@@ -43,8 +43,12 @@ export function TeamAccessSection({
}): React.JSX.Element {
const ent = useEntitlement()
const seats = useEntitlement((s) => s.seats)
- const used = useTeamAccess((s) => usedCount(s.seats))
- const seatList = useTeamAccess((s) => listSeats(s.seats))
+ // Select the table itself and derive from it. `listSeats` builds a NEW array on every call, and
+ // zustand 5 compares selector results with Object.is, so selecting it directly never settled:
+ // React error #185 (maximum update depth) took the whole section down.
+ const seatTable = useTeamAccess((s) => s.seats)
+ const used = usedCount(seatTable)
+ const seatList = useMemo(() => listSeats(seatTable), [seatTable])
const view = teamAccessView({ premium: ent.isPremium, seats, used })
const [email, setEmail] = useState('')