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.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
fix(chat): one loading row and one spinner for the ⌘M panel
review38d3ba61b35a
diff --git a/src/renderer/nodes/ChatPanel.paging.test.tsx b/src/renderer/nodes/ChatPanel.paging.test.tsxindex 818229079..416164f06 100644--- a/src/renderer/nodes/ChatPanel.paging.test.tsx+++ b/src/renderer/nodes/ChatPanel.paging.test.tsx@@ -40,6 +40,7 @@ const { readTranscript, pending, session } = vi.hoisted(() => {vi.mock('../session/session', () => ({ useSession: () => session }))import { ChatPanel } from './ChatPanel'+import { ChatPanelFallback } from './ChatPanelFallback'const NODE = 'n-chat-paging'let host: HTMLDivElement@@ -134,11 +135,22 @@ afterEach(async () => {describe('ChatPanel progressive loading', () => {it('shows a loading row while the first read is in flight', async () => {await render()- const row = host.querySelector('.term-chat__loading')+ const row = host.querySelector('.term-chat__status')expect(row?.textContent).toContain('Loading conversation…')- expect(row?.querySelector('.term-chat__spinner')).not.toBeNull()+ expect(row?.getAttribute('role')).toBe('status')+ expect(row?.querySelector('.nt-spinner')).not.toBeNull()await settle(0, { messages: [say(100, 'hi')] })- expect(host.querySelector('.term-chat__loading')).toBeNull()+ expect(host.querySelector('.term-chat__status')).toBeNull()+ })++ it('the initial loading row is the lazy fallback\'s row, identical DOM (no ring swap, no re-announced status)', async () => {+ const other = document.createElement('div')+ const otherRoot = createRoot(other)+ await act(async () => otherRoot.render(<ChatPanelFallback />))+ const fallbackRow = other.querySelector('.term-chat__msgs')!.innerHTML+ await act(async () => otherRoot.unmount())+ await render()+ expect(msgs().innerHTML).toBe(fallbackRow)})it('reads only a small tail window first', async () => {@@ -157,6 +169,8 @@ describe('ChatPanel progressive loading', () => {expect(pending).toHaveLength(2)expect(pending[1].page).toEqual({ before: 1000, maxBytes: CHAT_OLDER_PAGE_BYTES })expect(host.querySelector('.term-chat__older')?.textContent).toContain('Loading earlier messages…')+ // The app's one spinner, inside the row that is the status region.+ expect(host.querySelector('.term-chat__older[role="status"] .nt-spinner')).not.toBeNull()// The loading row appeared ABOVE the viewport: shifted by its height, not jumped.expect(msgs().scrollTop).toBe(50 + ROW)diff --git a/src/renderer/nodes/ChatPanel.tsx b/src/renderer/nodes/ChatPanel.tsxindex 9b3bbe51b..d82f8ee9f 100644--- a/src/renderer/nodes/ChatPanel.tsx+++ b/src/renderer/nodes/ChatPanel.tsx@@ -18,6 +18,8 @@ import {type ChatThread} from '../lib/chatPaging'import { E_UNSUPPORTED } from '@shared/rpc'+import { Spinner } from '../components/Spinner'+import { ChatLoadingStatus } from './ChatPanelFallback'// Memoized bubble: marked+DOMPurify re-ran for EVERY message on each ChatPanel render (each// turn-finish reload, each keystroke re-render). Text is stable per message, so cache per text.@@ -412,14 +414,11 @@ export function ChatPanel({</div><div className="term-chat__msgs" ref={msgsRef} onScroll={onScroll}>{initialLoading && (- <div className="term-chat__loading" role="status">- <span className="term-chat__spinner" aria-hidden="true" />- <span>{EMPTY_TEXT.loading.title}</span>- </div>+ <ChatLoadingStatus text={EMPTY_TEXT.loading.title} />)}{messages.length > 0 && olderState === 'loading' && (<div className="term-chat__older" role="status">- <span className="term-chat__spinner" aria-hidden="true" />+ <Spinner /><span>Loading earlier messages…</span></div>)}diff --git a/src/renderer/nodes/ChatPanelFallback.test.tsx b/src/renderer/nodes/ChatPanelFallback.test.tsxindex 9cc26f865..6f0b86063 100644--- a/src/renderer/nodes/ChatPanelFallback.test.tsx+++ b/src/renderer/nodes/ChatPanelFallback.test.tsx@@ -4,7 +4,7 @@ import { readFileSync } from 'node:fs'import { join } from 'node:path'import { createRoot, type Root } from 'react-dom/client'import { act } from 'react'-import { ChatPanelFallback } from './ChatPanelFallback'+import { ChatLoadingStatus, ChatPanelFallback } from './ChatPanelFallback';(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = truelet host: HTMLDivElement@@ -48,6 +48,32 @@ describe('ChatPanelFallback', () => {})})+// The fallback hands over to ChatPanel's own initial "Loading conversation…" row. Two different+// rows there swapped one spinner ring for another mid-load and REMOUNTED the role=status region,+// which a screen reader announces twice. Both now render ChatLoadingStatus — identical DOM.+describe('ChatLoadingStatus', () => {+ it('is the fallback\'s status row, verbatim', () => {+ act(() => root.render(<ChatPanelFallback />))+ const fromFallback = host.querySelector('.term-chat__msgs')!.innerHTML+ act(() => root.render(<ChatLoadingStatus text="Loading conversation…" />))+ expect(host.innerHTML).toBe(fromFallback)+ expect(host.innerHTML).toBe(+ '<div class="term-chat__status" role="status" aria-live="polite"><span class="nt-spinner" aria-hidden="true"></span>Loading conversation…</div>'+ )+ })+})++// styles.css carries ONE ring spinner for the chat surfaces: `.nt-spinner` (frozen under reduced+// motion). Lane B's local `.term-chat__spinner` kept rotating under reduced motion.+describe('styles.css spinner', () => {+ const css = readFileSync(join(__dirname, '../styles.css'), 'utf8').replace(/\r\n/g, '\n')+ it('has exactly one spinner @keyframes, and no chat-local spinner', () => {+ expect(css.match(/@keyframes [\w-]*spinner[\w-]*/g)).toEqual(['@keyframes nt-spinner-rotate'])+ expect(css).not.toMatch(/term-chat-spin|\.term-chat__spinner|\.term-chat__loading|\.term-chat__fallback-status/)+ expect(css).toContain('.term-chat__status {')+ })+})+// Every mount site of the lazy ChatPanel (canvas node, kanban card modal, closed-transcript dialog)// must show the shell while the chunk loads; `fallback={null}` is what left the ⌘M face blank.describe.each([diff --git a/src/renderer/nodes/ChatPanelFallback.tsx b/src/renderer/nodes/ChatPanelFallback.tsxindex 75d33891c..d67857b37 100644--- a/src/renderer/nodes/ChatPanelFallback.tsx+++ b/src/renderer/nodes/ChatPanelFallback.tsx@@ -1,6 +1,23 @@import { Spinner } from '../components/Spinner'import { chipFor } from '../lib/keybindingOverrides'+/**+ * The ⌘M panel's "loading" status row — ONE component for both the lazy-chunk fallback below and+ * ChatPanel's own initial "Loading conversation…" row, so the handover from one to the other+ * renders identical DOM. Two rows there (lane-local spinners) swapped one ring for another+ * mid-load, one of them kept rotating under reduced motion, and the role=status region was+ * REMOUNTED — which a screen reader announces a second time. It lives here, in the startup chunk,+ * because the fallback must not import the lazy ChatPanel.+ */+export function ChatLoadingStatus({ text }: { text: string }) {+ return (+ <div className="term-chat__status" role="status" aria-live="polite">+ <Spinner />+ {text}+ </div>+ )+}+/*** What the ⌘M face shows while the lazy `ChatPanel` chunk (it carries the markdown renderer) is* still loading — the `<Suspense>` fallback at EVERY one of its mount sites: the canvas terminal@@ -29,10 +46,7 @@ export function ChatPanelFallback({ title, hint }: { title?: string; hint?: stri</span></div><div className="term-chat__msgs">- <div className="term-chat__fallback-status" role="status" aria-live="polite">- <Spinner />- Loading conversation…- </div>+ <ChatLoadingStatus text="Loading conversation…" /></div></div>)diff --git a/src/renderer/styles.css b/src/renderer/styles.cssindex 8a39e0e00..34bec6b49 100644--- a/src/renderer/styles.css+++ b/src/renderer/styles.css@@ -3154,16 +3154,8 @@ body,.term-chat__retry:hover {background: rgba(var(--tint-rgb), 0.12);}-/* Progressive loading (lane B, chat paging). A LOCAL spinner on purpose: the shared one lives on- another branch and is unified at integration. */-.term-chat__loading {- margin: auto;- display: flex;- align-items: center;- gap: 8px;- font-size: 12px;- color: rgba(var(--tint-rgb), 0.4);-}+/* Progressive loading (chat paging): the top-of-thread rows. Their spinner is the shared+ `.nt-spinner` (`components/Spinner.tsx`) — never a local one. */.term-chat__older {flex: 0 0 auto;display: flex;@@ -3180,25 +3172,6 @@ body,.term-chat__older--start {color: rgba(var(--tint-rgb), 0.22);}-.term-chat__spinner {- width: 12px;- height: 12px;- border-radius: 50%;- border: 1.5px solid rgba(var(--tint-rgb), 0.15);- border-top-color: rgba(var(--tint-rgb), 0.55);- animation: term-chat-spin 0.8s linear infinite;- animation-play-state: var(--nt-anim-state);-}-@keyframes term-chat-spin {- to {- transform: rotate(360deg);- }-}-@media (prefers-reduced-motion: reduce) {- .term-chat__spinner {- animation-duration: 2.4s;- }-}.term-chat__msg {max-width: 92%;padding: 8px 10px;@@ -3306,8 +3279,9 @@ body,}}-/* ⌘M chat panel shell shown while the lazy ChatPanel chunk loads (`nodes/ChatPanelFallback.tsx`). */-.term-chat__fallback-status {+/* ⌘M chat panel "Loading conversation…" row (`ChatLoadingStatus`, `nodes/ChatPanelFallback.tsx`):+ the lazy-chunk fallback AND ChatPanel's own initial load render it, so the handover is seamless. */+.term-chat__status {margin: auto;display: flex;align-items: center;