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
feat(session-memory): show the Windows session host's own cost in the memory panel
reviewa9ea674234de
diff --git a/src/core/session-host-client-details.test.ts b/src/core/session-host-client-details.test.tsindex 287ccd532..927f54e4a 100644--- a/src/core/session-host-client-details.test.ts+++ b/src/core/session-host-client-details.test.ts@@ -125,6 +125,8 @@ describe('SessionHostClient.listSessionsDetailed', () => {expect(listing).toEqual({running: true,names: ['nt-a', 'nt-b'],+ // The pid the state file published: the memory panel's handle on the host's own cost.+ hostPid: expect.any(Number),sessions: [{ name: 'nt-a', pid: 11, subscribers: 0, lastOutputMs: 1000, createdMs: 900, generation: GEN_A },{ name: 'nt-b', pid: 12, subscribers: 2, lastOutputMs: 2000, createdMs: 900, generation: GEN_B }@@ -141,6 +143,7 @@ describe('SessionHostClient.listSessionsDetailed', () => {await expect(client.listSessionsDetailed()).resolves.toEqual({running: true,names: ['nt-a', 'nt-b'],+ hostPid: expect.any(Number),sessions: null})})diff --git a/src/core/session-host-client.ts b/src/core/session-host-client.tsindex ba9025c06..f24f44b51 100644--- a/src/core/session-host-client.ts+++ b/src/core/session-host-client.ts@@ -96,6 +96,12 @@ export interface SessionHostListing {running: booleannames: string[]sessions: SessionHostSessionDetail[] | null+ /**+ * The host process's pid, from the state file the connection was verified against (every host+ * version writes it, so this needs no protocol change). Absent when unknown or not a safe+ * positive integer. Only the memory panel reads it, to report the host's own cost.+ */+ hostPid?: number}const GENERATION_RE = /^[A-Za-z0-9_-]{8,128}$/@@ -2322,7 +2328,10 @@ export class SessionHostClient {const sessions = this.hostFeatures.has('sessionDetails') && Array.isArray(result.sessions)? validSessionDetails(result.sessions).filter((row) => result.names.includes(row.name)): null- return { running: true, names: result.names, sessions }+ const hostPid = this.hostPid+ return Number.isSafeInteger(hostPid) && (hostPid as number) > 0+ ? { running: true, names: result.names, sessions, hostPid: hostPid as number }+ : { running: true, names: result.names, sessions }} catch {return null}diff --git a/src/core/session-memory-service.test.ts b/src/core/session-memory-service.test.tsindex 733cf322a..f543ea6bd 100644--- a/src/core/session-memory-service.test.ts+++ b/src/core/session-memory-service.test.ts@@ -383,4 +383,10 @@ describe('mergeLocalLegs', () => {expect(mergeLocalLegs(r(true, [], { unmeasured: null }), r(true, [], { unmeasured: 1 })).unmeasured).toBeNull()expect(mergeLocalLegs(r(true, []), r(true, []))).not.toHaveProperty('unmeasured')})+ it("the session host's own cost survives the merge, but never from a leg that failed", () => {+ const host = { pid: 9, selfMb: 60, consoleMb: 8, consoleCount: 1, totalMb: 68 }+ expect(mergeLocalLegs(r(true, [1]), r(true, [], { host })).host).toEqual(host)+ expect(mergeLocalLegs(r(true, [1]), r(false, [], { host }))).not.toHaveProperty('host')+ expect(mergeLocalLegs(r(true, []), r(true, []))).not.toHaveProperty('host')+ })})diff --git a/src/core/session-memory-service.ts b/src/core/session-memory-service.tsindex abec30038..eeace1a12 100644--- a/src/core/session-memory-service.ts+++ b/src/core/session-memory-service.ts@@ -92,6 +92,9 @@ export function mergeLocalLegs(a: SessionMemoryReport, b: SessionMemoryReport):if (unmeasured !== 0) out.unmeasured = unmeasuredconst backend = answered.find((r) => r.unmeasuredBackend)?.unmeasuredBackendif (backend && unmeasured !== 0) out.unmeasuredBackend = backend+ // Only the session-host leg ever carries it; a failed leg's is never adopted.+ const host = answered.find((r) => r.host)?.host+ if (host) out.host = hostreturn out}diff --git a/src/core/session-memory-session-host.test.ts b/src/core/session-memory-session-host.test.tsindex 85faa444e..54dd7c8a6 100644--- a/src/core/session-memory-session-host.test.ts+++ b/src/core/session-memory-session-host.test.ts@@ -3,6 +3,7 @@import { describe, it, expect } from 'vitest'import {collectSessionHostMemory,+ hostOverhead,parseWin32ProcessTable,win32ProcessTable,WIN32_PROCESS_TABLE_SCRIPT,@@ -48,6 +49,11 @@ describe('parseWin32ProcessTable', () => {])expect(parseWin32ProcessTable(json)).toEqual([P(4000, 900, 10 * 1024), P(4100, 4000, 2)])})+ it('keeps the image name when CIM gives one (the host-overhead console count reads it)', () => {+ expect(+ parseWin32ProcessTable('{"ProcessId":7,"ParentProcessId":1,"WorkingSetSize":1024,"Name":"conhost.exe"}')+ ).toEqual([{ pid: 7, ppid: 1, rssKb: 1, name: 'conhost.exe' }])+ })it('accepts a single object; a missing working set is 0, not a dropped process', () => {expect(parseWin32ProcessTable('{"ProcessId":7,"ParentProcessId":1,"WorkingSetSize":null}')).toEqual([P(7, 1, 0)])})@@ -174,3 +180,118 @@ describe('collectSessionHostMemory', () => {expect(sessionName(r.rows[0].nodeId)).toBe('nt-node-1')})})++const N = (pid: number, ppid: number, rssKb: number, name: string): ProcEntry => ({ pid, ppid, rssKb, name })++describe('hostOverhead', () => {+ // host 900 → shells 4000/4001 (rows) and consoles 901/902; a claude under 4000; a child under 901.+ const table = [+ N(900, 1, 60 * 1024, 'node.exe'),+ N(4000, 900, 50 * 1024, 'pwsh.exe'),+ N(4100, 4000, 300 * 1024, 'node.exe'),+ N(4001, 900, 40 * 1024, 'cmd.exe'),+ N(901, 900, 8 * 1024, 'conhost.exe'),+ N(902, 900, 6 * 1024, 'OpenConsole.exe'),+ N(950, 901, 2 * 1024, 'conhost.exe'),+ N(7000, 1, 999 * 1024, 'unrelated.exe')+ ]++ it('is the host plus its non-shell children, never a shell subtree', () => {+ expect(hostOverhead(table, 900, [4000, 4001])).toEqual({+ pid: 900,+ selfMb: 60,+ consoleMb: 16,+ consoleCount: 2,+ totalMb: 76+ })+ })++ it('an unknown or absent host pid is undefined, never 0 MB', () => {+ expect(hostOverhead(table, undefined, [4000])).toBeUndefined()+ expect(hostOverhead(table, 123, [4000])).toBeUndefined()+ expect(hostOverhead(table, 0, [])).toBeUndefined()+ expect(hostOverhead(table, -5, [])).toBeUndefined()+ })++ it('a pane pid equal to the host pid is not counted twice, and a ppid cycle cannot hang the walk', () => {+ expect(hostOverhead([N(900, 1, 1024, 'node.exe')], 900, [900])).toMatchObject({ selfMb: 1, consoleMb: 0 })+ const cyclic = [N(900, 901, 1024, 'node.exe'), N(901, 900, 1024, 'conhost.exe')]+ expect(hostOverhead(cyclic, 900, [])).toMatchObject({ selfMb: 1, consoleMb: 1, consoleCount: 1 })+ })++ it('without image names the memory is still counted, the console count is 0', () => {+ expect(hostOverhead([P(900, 1, 1024), P(901, 900, 2048)], 900, [])).toEqual({+ pid: 900,+ selfMb: 1,+ consoleMb: 2,+ consoleCount: 0,+ totalMb: 3+ })+ })+})++describe('collectSessionHostMemory: the host\'s own cost', () => {+ const table = [+ N(900, 1, 60 * 1024, 'node.exe'),+ N(100, 900, 1024, 'pwsh.exe'),+ N(101, 100, 300 * 1024, 'node.exe'),+ N(901, 900, 8 * 1024, 'conhost.exe')+ ]+ const listing = (over: Partial<SessionHostListing> = {}): SessionHostListing => ({+ running: true,+ names: ['nt-a'],+ sessions: [row('nt-a', 100)],+ hostPid: 900,+ ...over+ })++ it('rows are unchanged and the host is reported beside them', async () => {+ const r = await collectSessionHostMemory({ list: async () => listing(), readTable: async () => table, readMem: () => MEM })+ expect(r.rows.map((x) => [x.session, x.totalMb])).toEqual([['nt-a', 301]])+ expect(r.host).toEqual({ pid: 900, selfMb: 60, consoleMb: 8, consoleCount: 1, totalMb: 68 })+ })++ it('an idle host (no sessions) is still measured', async () => {+ const r = await collectSessionHostMemory({+ list: async () => listing({ names: [], sessions: [] }),+ readTable: async () => table.filter((e) => e.pid === 900 || e.pid === 901),+ readMem: () => MEM+ })+ expect(r).toEqual({ ok: true, rows: [], mem: MEM, host: { pid: 900, selfMb: 60, consoleMb: 8, consoleCount: 1, totalMb: 68 } })+ })++ it('with no session to describe, an unreadable table is still the "no sessions" answer', async () => {+ const r = await collectSessionHostMemory({+ list: async () => listing({ names: [], sessions: [] }),+ readTable: async () => null,+ readMem: () => MEM+ })+ expect(r).toEqual({ ok: true, rows: [], mem: MEM })+ })++ it('a host pid missing from the table leaves host undefined and the rows ok', async () => {+ const r = await collectSessionHostMemory({+ list: async () => listing({ hostPid: 4242 }),+ readTable: async () => table,+ readMem: () => MEM+ })+ expect(r.ok).toBe(true)+ expect(r.rows).toHaveLength(1)+ expect(r.host).toBeUndefined()+ })++ it('an undescribed session would be booked as overhead, so the host is not reported', async () => {+ const r = await collectSessionHostMemory({+ list: async () => listing({ names: ['nt-a', 'nt-b'] }),+ readTable: async () => table,+ readMem: () => MEM+ })+ expect(r.unmeasured).toBe(1)+ expect(r.host).toBeUndefined()+ })++ it('ok:false carries no host', async () => {+ const r = await collectSessionHostMemory({ list: async () => listing(), readTable: async () => null, readMem: () => MEM })+ expect(r).toEqual({ ok: false, rows: [], mem: MEM })+ })+})diff --git a/src/core/session-memory.ts b/src/core/session-memory.tsindex f1faff46e..e9b998934 100644--- a/src/core/session-memory.ts+++ b/src/core/session-memory.ts@@ -12,7 +12,7 @@ import fs from 'fs'import os from 'os'import { execFile, execFileSync } from 'child_process'import { promisify } from 'util'-import type { MemInfo, SessionMemoryRow, SessionMemoryReport } from '../shared/types'+import type { MemInfo, SessionHostOverhead, SessionMemoryRow, SessionMemoryReport } from '../shared/types'import { TMUX_SOCKET } from './tmux-naming'import { RMT_TMUX_SOCKET } from './remote-ssh/control-master'import type { SessionHostListing } from './session-host-client'@@ -28,6 +28,8 @@ export interface ProcEntry {pid: numberppid: numberrssKb: number+ /** Image name, when the reader has one (the Windows CIM table). Only `hostOverhead` reads it. */+ name?: string}/** Reads the whole process table at once; null when it could not run. */@@ -467,7 +469,7 @@ async function psProcessTable(/** The PowerShell the Windows table comes from: one CIM query, compressed JSON on one line. */export const WIN32_PROCESS_TABLE_SCRIPT =- 'Get-CimInstance Win32_Process | Select-Object ProcessId,ParentProcessId,WorkingSetSize | ConvertTo-Json -Compress'+ 'Get-CimInstance Win32_Process | Select-Object ProcessId,ParentProcessId,WorkingSetSize,Name | ConvertTo-Json -Compress'/*** Parse `WIN32_PROCESS_TABLE_SCRIPT`'s output. `ConvertTo-Json` prints a bare OBJECT for a@@ -486,7 +488,9 @@ export function parseWin32ProcessTable(json: string): ProcEntry[] | null {const ppid = Number(r.ParentProcessId)if (!Number.isSafeInteger(pid) || !Number.isSafeInteger(ppid)) continueconst bytes = Number(r.WorkingSetSize)- out.push({ pid, ppid, rssKb: Number.isFinite(bytes) && bytes > 0 ? bytes / 1024 : 0 })+ const entry: ProcEntry = { pid, ppid, rssKb: Number.isFinite(bytes) && bytes > 0 ? bytes / 1024 : 0 }+ if (typeof r.Name === 'string' && r.Name) entry.name = r.Name+ out.push(entry)}return out.length > 0 ? out : null}@@ -502,6 +506,57 @@ export async function win32ProcessTable(}}+/** The ConPTY console hosts: inbox `conhost.exe`, or node-pty's bundled `OpenConsole.exe`. */+const CONSOLE_HOST_IMAGE = /^(conhost|openconsole)(\.exe)?$/i++/**+ * The session host's own cost (`SessionMemoryReport.host`): the host process, plus every child of+ * it that is NOT a session's shell, with their subtrees. ConPTY's conhost/OpenConsole is created by+ * the host's `CreatePseudoConsole`, so it is the host's child and the shell's SIBLING — no row's+ * rollup reaches it, and without this it is counted nowhere.+ *+ * The shells' subtrees are excluded by pid (they are the rows), so nothing is counted twice; a pane+ * pid equal to the host pid (it never should be) is still only the host's own working set.+ * `consoleCount` counts direct children named as a console host — the table carries image names on+ * Windows; without names the count is 0 while the memory is still included. Undefined when the host+ * pid is unknown or not in the table: a host we did not find is "could not measure", never 0 MB.+ */+export function hostOverhead(+ entries: readonly ProcEntry[],+ hostPid: number | undefined,+ panePids: readonly number[]+): SessionHostOverhead | undefined {+ if (hostPid === undefined || !Number.isSafeInteger(hostPid) || hostPid <= 0) return undefined+ const { table, kids } = indexProcesses(entries)+ const self = table.get(hostPid)+ if (!self) return undefined+ const panes = new Set(panePids)+ // Pre-seed the walk with the host and every pane so neither a shell subtree nor a cyclic ppid+ // chain back to the host is ever entered.+ const seen = new Set<number>([hostPid, ...panes])+ let childKb = 0+ let consoleCount = 0+ const stack: number[] = []+ for (const k of kids.get(hostPid) ?? []) {+ if (panes.has(k)) continue+ const e = table.get(k)+ if (e?.name && CONSOLE_HOST_IMAGE.test(e.name)) consoleCount+++ stack.push(k)+ }+ while (stack.length > 0) {+ const pid = stack.pop() as number+ if (seen.has(pid)) continue+ seen.add(pid)+ const e = table.get(pid)+ if (!e) continue+ childKb += e.rssKb+ for (const k of kids.get(pid) ?? []) stack.push(k)+ }+ const selfMb = kbToMb(self.rssKb)+ const consoleMb = kbToMb(childKb)+ return { pid: hostPid, selfMb, consoleMb, consoleCount, totalMb: selfMb + consoleMb }+}+export interface SessionHostMemoryDeps {/** The host's listing (`PtyManager.sessionHostListing()`); null = the read failed. */list: () => Promise<SessionHostListing | null>@@ -532,6 +587,7 @@ export async function collectSessionHostMemory(deps: SessionHostMemoryDeps): Prolisting = null}if (!listing) return { ok: false, rows: [], mem }+ if (!listing.running) return { ok: true, rows: [], mem }const ours = listing.names.filter((n) => n.startsWith('nt-'))const described = new Map((listing.sessions ?? []).map((row) => [row.name, row]))const panes: PaneRef[] = []@@ -543,7 +599,11 @@ export async function collectSessionHostMemory(deps: SessionHostMemoryDeps): Pro}const withUnmeasured = (report: SessionMemoryReport): SessionMemoryReport =>unmeasured === 0 ? report : { ...report, unmeasured, unmeasuredBackend: 'session-host' }- if (panes.length === 0) return withUnmeasured({ ok: true, rows: [], mem })+ // An idle host still costs memory, so a running host with no described session still reads the+ // table — but only when there is a host pid to measure. Without one there is nothing to look up,+ // and "no sessions" stays the no-table answer it always was.+ const hostPid = listing.hostPid+ if (panes.length === 0 && hostPid === undefined) return withUnmeasured({ ok: true, rows: [], mem })const platformName = deps.platformName ?? process.platformconst exec =@@ -568,8 +628,17 @@ export async function collectSessionHostMemory(deps: SessionHostMemoryDeps): Pro} catch {table = null}- if (table === null) return { ok: false, rows: [], mem }- return withUnmeasured(buildReport(panes, table, mem))+ if (table === null) {+ // No pane to describe: the table was read only for the host's own cost, and failing to read it+ // says nothing about sessions — the answer stays "none", with the host simply unmeasured.+ if (panes.length === 0) return withUnmeasured({ ok: true, rows: [], mem })+ return { ok: false, rows: [], mem }+ }+ const report = withUnmeasured(buildReport(panes, table, mem))+ // A session the host named but did not describe has a shell among the host's children that no+ // row excludes, so its memory would be booked as host overhead. Report nothing rather than that.+ const host = unmeasured === 0 ? hostOverhead(table, hostPid, panes.map((p) => p.panePid)) : undefined+ return host ? { ...report, host } : report}/**diff --git a/src/renderer/components/SessionMemoryPanel.test.tsx b/src/renderer/components/SessionMemoryPanel.test.tsxindex 55f8d93fe..8370064f0 100644--- a/src/renderer/components/SessionMemoryPanel.test.tsx+++ b/src/renderer/components/SessionMemoryPanel.test.tsx@@ -77,6 +77,7 @@ function mount(over: Partial<ReturnType<typeof useSessionMemory.getState>> = {})rows: ROWS,loadedScope: '',loading: false,+ host: undefined,refreshFull,startHostPoll,stopHostPoll,@@ -158,6 +159,38 @@ describe('SessionMemoryPanel', () => {expect(host.querySelector('.sessmem-panel__total')?.textContent).toBe('1.5 GB')})+ describe("the Windows session host's own cost", () => {+ const HOST = { pid: 900, selfMb: 300, consoleMb: 40, consoleCount: 4, totalMb: 340 }+ const line = (): Element | null => host.querySelector('.sessmem-host')++ it('renders a non-killable line, adds to the total, and is not a session', () => {+ mount({ host: HOST })+ expect(line()?.textContent).toContain('nodeterm session host (4 consoles)')+ expect(line()?.querySelector('button')).toBeNull()+ // 1560 + 340 = 1900 MB.+ expect(host.querySelector('.sessmem-panel__total')?.textContent).toBe('1.9 GB')+ expect(host.querySelector('.sessmem-panel__count')?.textContent).toBe('4 sessions')+ expect(rowsOf()).toHaveLength(4)+ })++ it('shows beside "no sessions" too — an idle host still costs memory', () => {+ mount({ rows: [], host: { ...HOST, consoleCount: 1 } })+ expect(text()).toContain('No sessions are running here.')+ expect(line()?.textContent).toContain('(1 console)')+ })++ it('never renders unmeasured: absent, failed, or not yet measured', () => {+ mount()+ expect(line()).toBeNull()+ act(() => root.unmount())+ mount({ ok: false, host: HOST })+ expect(line()).toBeNull()+ act(() => root.unmount())+ mount({ loadedScope: null, host: HOST })+ expect(line()).toBeNull()+ })+ })+it("resolves a CLOSED project's session to its real title", () => {// closeProject keeps the project and its nodes on disk. Passing only the open tabs would turn// every parked session into an orphan — silently, in this file, with the suite green.diff --git a/src/renderer/components/SessionMemoryPanel.tsx b/src/renderer/components/SessionMemoryPanel.tsxindex 9e1f5523e..fe53e1043 100644--- a/src/renderer/components/SessionMemoryPanel.tsx+++ b/src/renderer/components/SessionMemoryPanel.tsx@@ -16,7 +16,7 @@ import { formatBytes } from '@shared/fsLimits'import { useAgentStatus } from '../state/agentStatus'import { useProjects } from '../state/projects'import { useSessionMemory } from '../state/sessionMemory'-import { resolveSessionRows, totalMb } from '../lib/sessionMemoryRows'+import { hostOverheadLabel, resolveSessionRows, totalMb } from '../lib/sessionMemoryRows'import { usageScopeKey } from '../lib/usageScope'import type { SessionPauseOffer } from '../lib/sessionPause'import { unmeasuredNote } from '../lib/sessionMemoryNote'@@ -80,6 +80,7 @@ export function SessionMemoryPanel({const rows = useSessionMemory((s) => s.rows)const unmeasured = useSessionMemory((s) => s.unmeasured)const unmeasuredBackend = useSessionMemory((s) => s.unmeasuredBackend)+ const hostCost = useSessionMemory((s) => s.host)const loading = useSessionMemory((s) => s.loading)const loadedScope = useSessionMemory((s) => s.loadedScope)const refreshFull = useSessionMemory((s) => s.refreshFull)@@ -253,11 +254,25 @@ export function SessionMemoryPanel({<span className="sessmem-panel__scope">{scopeKey || 'This machine'}</span>{/* No total unless we measured one: a grand total of `0 MB` beside a failure is the exactconflation this panel exists to end. */}- {measured && <span className="sessmem-panel__total">{formatMb(totalMb(views))}</span>}+ {measured && <span className="sessmem-panel__total">{formatMb(totalMb(views, hostCost))}</span>}</div>{body}+ {/* The Windows session host's own cost — the one process whose size grows with session count+ and that no row's tree reaches (its conhost/OpenConsole children are the shells'+ siblings). Not a session: not travelable, not killable, not in the session count. Only+ under the `measured` gate, like the total it is part of. */}+ {measured && !relay && hostCost && (+ <div+ className="sessmem-host"+ title="Measured working set of nodeterm's session host and the console hosts it runs for each terminal. It is shared, so it belongs to no session above."+ >+ <span className="sessmem-host__label">{hostOverheadLabel(hostCost)}</span>+ <span className="sessmem-host__mb">{formatMb(hostCost.totalMb)}</span>+ </div>+ )}+{/* Whose memory this is. The feature exists because a user reported "Claude terminals arekilling my memory" — their NUMBER was right and their attribution was wrong: it is theagent CLI's own V8 heap, and nodeterm allocates none of it. Showing those numbers insidediff --git a/src/renderer/lib/sessionMemoryRows.test.ts b/src/renderer/lib/sessionMemoryRows.test.tsindex 2f2edaef7..891c4d57a 100644--- a/src/renderer/lib/sessionMemoryRows.test.ts+++ b/src/renderer/lib/sessionMemoryRows.test.ts@@ -1,5 +1,5 @@import { describe, it, expect } from 'vitest'-import { resolveSessionRows, totalMb } from './sessionMemoryRows'+import { hostOverheadLabel, resolveSessionRows, totalMb } from './sessionMemoryRows'import type { SessionMemoryRow } from '@shared/types'const row = (nodeId: string, mb: number): SessionMemoryRow => ({@@ -76,4 +76,13 @@ describe('totalMb', () => {}expect(totalMb(resolveSessionRows([withChildren], [], {}))).toBe(500)})++ it("adds the session host's measured cost; an unmeasured host adds nothing", () => {+ const views = resolveSessionRows([row('a', 100)], [], {})+ const host = { pid: 9, selfMb: 60, consoleMb: 8, consoleCount: 2, totalMb: 68 }+ expect(totalMb(views, host)).toBe(168)+ expect(totalMb(views, undefined)).toBe(100)+ expect(hostOverheadLabel(host)).toBe('nodeterm session host (2 consoles)')+ expect(hostOverheadLabel({ ...host, consoleCount: 1 })).toBe('nodeterm session host (1 console)')+ })})diff --git a/src/renderer/lib/sessionMemoryRows.ts b/src/renderer/lib/sessionMemoryRows.tsindex b5a6a815c..481ae4b5b 100644--- a/src/renderer/lib/sessionMemoryRows.ts+++ b/src/renderer/lib/sessionMemoryRows.ts@@ -5,7 +5,7 @@// orphan/closed-project policy is unit-testable without mounting anything.import type { AgentState } from '@shared/agents/normalize'-import type { Project, SessionMemoryRow } from '@shared/types'+import type { Project, SessionHostOverhead, SessionMemoryRow } from '@shared/types'export interface SessionMemoryView {row: SessionMemoryRow@@ -70,7 +70,17 @@ export function resolveSessionRows(})}-/** Grand total across the resolved rows — the panel header's number. */-export function totalMb(views: readonly SessionMemoryView[]): number {- return views.reduce((sum, v) => sum + v.row.totalMb, 0)+/**+ * Grand total — the panel header's number: every resolved row, plus the Windows session host's own+ * cost when it was measured (it belongs to no row, so leaving it out understates what nodeterm's+ * sessions hold; absent = not measured, which adds nothing rather than a guess).+ */+export function totalMb(views: readonly SessionMemoryView[], host?: SessionHostOverhead): number {+ return views.reduce((sum, v) => sum + v.row.totalMb, 0) + (host?.totalMb ?? 0)+}++/** The host line's label: `nodeterm session host (3 consoles)`. */+export function hostOverheadLabel(host: SessionHostOverhead): string {+ const n = host.consoleCount+ return `nodeterm session host (${n} console${n === 1 ? '' : 's'})`}diff --git a/src/renderer/state/sessionMemory.ts b/src/renderer/state/sessionMemory.tsindex c7c75cdaf..3a2fdc506 100644--- a/src/renderer/state/sessionMemory.ts+++ b/src/renderer/state/sessionMemory.ts@@ -10,7 +10,13 @@// for different scopes without any intervening bump, which is exactly the switch this must catch.import { create } from 'zustand'-import type { MemInfo, SessionMemoryApi, SessionMemoryQuery, SessionMemoryRow } from '@shared/types'+import type {+ MemInfo,+ SessionHostOverhead,+ SessionMemoryApi,+ SessionMemoryQuery,+ SessionMemoryRow+} from '@shared/types'import { activeSessionApi, sessionForProject } from '../session/session'/** How often the pill re-reads the LOCAL machine's RAM. Local only — see `startHostPoll`. */@@ -23,6 +29,8 @@ interface SessionMemoryState {unmeasured: number | null/** Whose sessions `unmeasured` counts — absent = Zellij (see SessionMemoryReport). */unmeasuredBackend?: 'session-host'+ /** The Windows session host's own cost (SessionMemoryReport.host); absent = none / unmeasured. */+ host?: SessionHostOverheadmem: MemInfo | nullloading: boolean/** Scope key the current rows belong to; null before the first successful load. */@@ -88,12 +96,20 @@ export const useSessionMemory = create<SessionMemoryState>((set, get) => ({if (scopeKey !== activeScope) return// `ok:false` is carried through untouched: the panel renders "could not measure", never an// empty session list.- set({ ok: r.ok, rows: r.rows, mem: r.mem, unmeasured: r.unmeasured ?? 0, unmeasuredBackend: r.unmeasuredBackend, loadedScope: scopeKey })+ set({+ ok: r.ok,+ rows: r.rows,+ mem: r.mem,+ unmeasured: r.unmeasured ?? 0,+ unmeasuredBackend: r.unmeasuredBackend,+ host: r.ok ? r.host : undefined,+ loadedScope: scopeKey+ })} catch {// A rejected call (dead WS bridge, no session yet) is the same fact as `ok:false` — the sweep// could not run. It is emphatically not "there are no sessions".if (scopeKey !== activeScope) return- set({ ok: false, rows: [], unmeasured: 0, unmeasuredBackend: undefined })+ set({ ok: false, rows: [], unmeasured: 0, unmeasuredBackend: undefined, host: undefined })} finally {// A response for a scope we have left owns nothing here — `enterScope` already cleared the// spinner when it switched.@@ -135,5 +151,14 @@ function enterScope(scopeKey: string, set: SetState): void {activeScope = scopeKey// `loading:false` too: whatever was in flight now belongs to a scope we have left, so its// `finally` will (correctly) not clear the spinner it set.- set({ ok: true, rows: [], unmeasured: 0, unmeasuredBackend: undefined, mem: null, loading: false, loadedScope: null })+ set({+ ok: true,+ rows: [],+ unmeasured: 0,+ unmeasuredBackend: undefined,+ host: undefined,+ mem: null,+ loading: false,+ loadedScope: null+ })}diff --git a/src/renderer/styles.css b/src/renderer/styles.cssindex 4caaf30b8..c451e93af 100644--- a/src/renderer/styles.css+++ b/src/renderer/styles.css@@ -8987,6 +8987,27 @@ button.group-node__setup:disabled {}/* The attribution line: quieter than a row, above the foot rule, and rendered in EVERY state — afailed sweep is exactly when a user is most likely to be blaming the wrong process. */+/* The session host's own cost: a quiet, non-interactive line under the rows (Windows only). */+.sessmem-host {+ display: flex;+ align-items: center;+ gap: 8px;+ margin-top: 6px;+ padding: 6px 2px 0;+ border-top: 1px solid rgba(var(--tint-rgb), 0.08);+ font-size: 12px;+ color: rgba(var(--tint-rgb), 0.6);+}+.sessmem-host__label {+ flex: 1;+ min-width: 0;+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+}+.sessmem-host__mb {+ font-variant-numeric: tabular-nums;+}.sessmem-panel__attrib {margin-top: 10px;font-size: 11px;@@ -16994,7 +17015,7 @@ body.focus-mode .dock:hover {}/* RAM panel secondary text (N5-L2): hard-coded 0.45–0.6 ink measured 3.95–4.22:1 on glass; it takesthe glass secondary label. */-:root[data-nt-glass='on'] :is(.sessmem-panel__scope, .sessmem-panel__note, .sessmem-row__project, .sessmem-row__orphan, .sessmem-row__cmd, .sessmem-row__kids, .sessmem-panel__attrib, .sessmem-panel__foot) {+:root[data-nt-glass='on'] :is(.sessmem-panel__scope, .sessmem-panel__note, .sessmem-row__project, .sessmem-row__orphan, .sessmem-row__cmd, .sessmem-row__kids, .sessmem-panel__attrib, .sessmem-panel__foot, .sessmem-host) {color: var(--muted);}/* The Members picker's hover was a solid accent row with white text (3.65:1) while every other listdiff --git a/src/shared/types.ts b/src/shared/types.tsindex 771ee3cd3..d499cfd2e 100644--- a/src/shared/types.ts+++ b/src/shared/types.ts@@ -3101,6 +3101,26 @@ export interface SessionMemoryReport {* (the original and, off Windows, only case); `'session-host'` = a running session host older* than this app, which names its sessions but cannot describe their processes. */unmeasuredBackend?: 'session-host'+ /**+ * The Windows session host's OWN cost, which belongs to no session row (CLAUDE.md, Session+ * memory): its process (every session's headless emulator, node-pty's per-session conout worker+ * thread) and its non-shell children (one conhost/OpenConsole per ConPTY — they are the host's+ * children, siblings of the shell, so no row's tree reaches them). Absent = no session host, or it+ * could not be measured: never a fake zero. The tmux leg never sets it.+ */+ host?: SessionHostOverhead+}++/** See `SessionMemoryReport.host`. All MB figures are MEASURED working sets, not estimates. */+export interface SessionHostOverhead {+ pid: number+ /** The session-host process itself. */+ selfMb: number+ /** Its non-shell children (conhost / OpenConsole, plus anything under them). */+ consoleMb: number+ /** Direct children recognised as a console host — "N consoles" in the panel. */+ consoleCount: number+ totalMb: number}/**