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(session-memory): never book a non-nt- session's shell as session-host overhead

review8adc06e138ab
diff --git a/docs/windows-session-host.md b/docs/windows-session-host.md
index 7893d13f0..01c769607 100644
--- a/docs/windows-session-host.md
+++ b/docs/windows-session-host.md
@@ -735,7 +735,9 @@ older host never answers, and the client reports `sessions: null` — named but
from the state file (`SessionHostListing.hostPid`; every host version writes it, so no protocol
change), and the panel shows one non-killable line, `nodeterm session host (N consoles)`, added to
the total only under the `measured` gate. Both figures are MEASURED working sets, labelled as
- such; nothing is estimated. Unknown host pid, a pid missing from the table, or an undescribed
+ such; nothing is estimated. Every non-shell child is included, so while the host's pane-probe
+ PowerShell worker (below) is warm — up to 60 s after a probe — its working set is part of the line
+ too; it is genuinely the host's cost, but expect the line to drop when it idles out. Unknown host pid, a pid missing from the table, or an undescribed
session (whose shell would be booked as host overhead) ⇒ no line, never `0 B`. An idle host with no
session is still measured.
- **Dev-server ports**: one PowerShell call per scan — `Win32_Process` plus
diff --git a/src/core/session-memory-session-host.test.ts b/src/core/session-memory-session-host.test.ts
index 54dd7c8a6..72a7c0338 100644
--- a/src/core/session-memory-session-host.test.ts
+++ b/src/core/session-memory-session-host.test.ts
@@ -290,6 +290,29 @@ describe('collectSessionHostMemory: the host\'s own cost', () => {
expect(r.host).toBeUndefined()
})
+ it('a described session outside nt- is not a row, and its shell is not booked as host overhead', async () => {
+ const extra = [...table, N(200, 900, 1024, 'cmd.exe'), N(201, 200, 500 * 1024, 'node.exe')]
+ const r = await collectSessionHostMemory({
+ list: async () => listing({ names: ['nt-a', 'other'], sessions: [row('nt-a', 100), row('other', 200)] }),
+ readTable: async () => extra,
+ readMem: () => MEM
+ })
+ expect(r.rows.map((x) => x.session)).toEqual(['nt-a'])
+ expect(r.host).toEqual({ pid: 900, selfMb: 60, consoleMb: 8, consoleCount: 1, totalMb: 68 })
+ })
+
+ it('an UNDESCRIBED session outside nt- withholds the host line (its shell could not be excluded)', async () => {
+ const extra = [...table, N(200, 900, 500 * 1024, 'cmd.exe')]
+ const r = await collectSessionHostMemory({
+ list: async () => listing({ names: ['nt-a', 'other'] }),
+ readTable: async () => extra,
+ readMem: () => MEM
+ })
+ expect(r.unmeasured).toBeUndefined()
+ expect(r.rows).toHaveLength(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.ts
index e9b998934..70de95ab0 100644
--- a/src/core/session-memory.ts
+++ b/src/core/session-memory.ts
@@ -637,7 +637,14 @@ export async function collectSessionHostMemory(deps: SessionHostMemoryDeps): Pro
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
+ // The same holds for a session outside the `nt-` namespace (the host accepts any name, and the
+ // rows only cover ours): every session the host NAMED must be described, and every described
+ // shell — whatever its name — is excluded from the overhead walk.
+ const allDescribed = listing.names.every((n) => described.has(n))
+ const host =
+ unmeasured === 0 && allDescribed
+ ? hostOverhead(table, hostPid, (listing.sessions ?? []).map((row) => row.pid))
+ : undefined
return host ? { ...report, host } : report
}
diff --git a/src/shared/types.ts b/src/shared/types.ts
index d499cfd2e..48de20241 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -3116,7 +3116,8 @@ export interface SessionHostOverhead {
pid: number
/** The session-host process itself. */
selfMb: number
- /** Its non-shell children (conhost / OpenConsole, plus anything under them). */
+ /** Its non-shell children (conhost / OpenConsole, plus anything under them — including the
+ * pane-probe PowerShell worker while it is warm, which is the host's child and its cost). */
consoleMb: number
/** Direct children recognised as a console host — "N consoles" in the panel. */
consoleCount: number