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(ui): dismiss the session-memory panel on an outside click
enes4c71bfcc84a2
diff --git a/src/renderer/components/SessionMemoryPanel.test.tsx b/src/renderer/components/SessionMemoryPanel.test.tsxindex 78888e0b1..74fb18ec2 100644--- a/src/renderer/components/SessionMemoryPanel.test.tsx+++ b/src/renderer/components/SessionMemoryPanel.test.tsx@@ -211,12 +211,20 @@ describe('SessionMemoryPanel', () => {})it('says it could not measure — never an empty list, never a zero', () => {- mount({ ok: false, rows: [], loadedScope: null })+ // `loadedScope: ''` on purpose, and it is the realistic shape: the store's failure path sets+ // `ok:false, rows:[]` and leaves `loadedScope` where the last SUCCESSFUL sweep put it. So a+ // panel that decided "have we measured?" from the scope stamp alone would find a match here and+ // render a confident `0 MB` / `0 sessions` over a sweep that failed — with a `loadedScope: null`+ // fixture it would have fallen into "Measuring…" and passed.+ mount({ ok: false, rows: [], loadedScope: '' })expect(text()).toContain('Could not measure')expect(rowsOf()).toHaveLength(0)expect(host.querySelector('.sessmem-panel__total')).toBeNull()- expect(text()).not.toContain('0 MB')expect(text()).not.toContain('0 sessions')+ // Not `not.toContain('0 MB')`: `formatBytes(0)` is "0 B", so spelling one unit would have let+ // the zero through. Without a reading there is no number we are entitled to print at all —+ // the same rule the pill holds itself to.+ expect(text()).not.toMatch(/\d/)// "We could not look" is the one state where the retry matters most.expect(host.querySelector<HTMLButtonElement>('.sessmem-panel__refresh')?.disabled).toBe(false)})@@ -245,6 +253,7 @@ describe('SessionMemoryPanel', () => {})mount({ ok: false, rows: [], loadedScope: null })expect(text()).not.toContain('Could not measure')+ expect(text()).not.toContain('Measuring')expect(text()).toContain('relay')expect(host.querySelector('.sessmem-panel__refresh')).toBeNull()// No point sweeping a machine whose answer is a stub.diff --git a/src/renderer/components/SystemResourcePill.test.tsx b/src/renderer/components/SystemResourcePill.test.tsxindex e7fd369f5..04226571d 100644--- a/src/renderer/components/SystemResourcePill.test.tsx+++ b/src/renderer/components/SystemResourcePill.test.tsx@@ -175,6 +175,26 @@ describe('SystemResourcePill', () => {expect(host.querySelector('.sysres-pill')?.getAttribute('aria-expanded')).toBe('false')})+ it('closes on an outside click, but not on the kill confirm', () => {+ mount(MEM)+ document.body.appendChild(host)+ act(() => host.querySelector<HTMLButtonElement>('.sysres-pill')!.click())+ expect(host.querySelector('.sessmem-panel')).not.toBeNull()++ // The `×` raises a ConfirmDialog through a portal OUTSIDE this container. Answering it must not+ // dismiss the list the user is working through.+ const confirm = document.createElement('div')+ confirm.className = 'confirm-overlay'+ document.body.appendChild(confirm)+ act(() => confirm.dispatchEvent(new MouseEvent('mousedown', { bubbles: true })))+ expect(host.querySelector('.sessmem-panel')).not.toBeNull()++ act(() => document.body.dispatchEvent(new MouseEvent('mousedown', { bubbles: true })))+ expect(host.querySelector('.sessmem-panel')).toBeNull()+ confirm.remove()+ host.remove()+ })+it('announces a region that actually exists', () => {// `aria-expanded` on its own told assistive tech about an expandable region and expanded// nothing. It may only ship pointing at the real panel.diff --git a/src/renderer/components/SystemResourcePill.tsx b/src/renderer/components/SystemResourcePill.tsxindex 1805c5b01..f71354e09 100644--- a/src/renderer/components/SystemResourcePill.tsx+++ b/src/renderer/components/SystemResourcePill.tsx@@ -1,4 +1,4 @@-import { useEffect, useState } from 'react'+import { useEffect, useRef, useState } from 'react'import { formatBytes } from '@shared/fsLimits'import { useProjects } from '../state/projects'import { useSshConn } from '../state/sshConn'@@ -37,6 +37,7 @@ export function SystemResourcePill({onKillSession}: SystemResourcePillProps): JSX.Element | null {const [open, setOpen] = useState(false)+ const wrapRef = useRef<HTMLDivElement>(null)const mem = useSessionMemory((s) => s.mem)const startHostPoll = useSessionMemory((s) => s.startHostPoll)@@ -72,6 +73,22 @@ export function SystemResourcePill({return () => stopHostPoll()}, [scopeKey, activeProjectId, sshUp, startHostPoll, stopHostPoll])+ // Close on an outside click, like the usage popover beside it — otherwise the panel sits over the+ // canvas until the pill is clicked again. The ConfirmDialog the `×` raises is a PORTAL outside+ // this container, so it is excluded explicitly: answering "yes, end it" must not also dismiss the+ // list the user is working through.+ useEffect(() => {+ if (!open) return+ const onDown = (e: MouseEvent): void => {+ const target = e.target as HTMLElement | null+ if (wrapRef.current?.contains(target)) return+ if (target?.closest('.confirm-overlay')) return+ setOpen(false)+ }+ window.addEventListener('mousedown', onDown)+ return () => window.removeEventListener('mousedown', onDown)+ }, [open])+if (!activeProjectId) return nulllet body: JSX.Element@@ -111,7 +128,7 @@ export function SystemResourcePill({}return (- <div className={`sysres-indicator${overBoard ? ' sysres-indicator--board' : ''}`}>+ <div ref={wrapRef} className={`sysres-indicator${overBoard ? ' sysres-indicator--board' : ''}`}>{open && (<SessionMemoryPanelonGoToNode={onGoToNode}