@@ -94,6 +94,9 @@ const MAX_HISTORY_CHUNK_LENGTH = 16 * 1024;
9494const DEFAULT_PERSIST_DEBOUNCE_MS = 250 ;
9595const DEFAULT_SUBPROCESS_POLL_INTERVAL_MS = 1_000 ;
9696const MAX_SUBPROCESS_POLL_INTERVAL_MS = 60_000 ;
97+ // Quiet sessions are still snapshotted on every 30th poll tick, so a child started
98+ // with no terminal input or output is found within that bound.
99+ const QUIET_SUBPROCESS_SNAPSHOT_EVERY_TICKS = 30 ;
97100const DEFAULT_PROCESS_KILL_GRACE_MS = 1_000 ;
98101const DEFAULT_MAX_RETAINED_INACTIVE_SESSIONS = 128 ;
99102const DEFAULT_OPEN_COLS = 120 ;
@@ -2391,9 +2394,10 @@ export const makeWithOptions = Effect.fn("TerminalManager.makeWithOptions")(func
23912394 // Running sessions the last snapshots found without a child process, with the
23922395 // activity mark they had. A shell at its prompt starts a child only after input
23932396 // or output, so while every running session is quiet the poll skips the
2394- // process-table snapshot. Requiring two idle snapshots covers a child forked
2395- // just after the snapshot that followed the input.
2397+ // process-table snapshot on all but every 30th tick. Requiring two idle
2398+ // snapshots covers a child forked just after the snapshot that followed the input.
23962399 let quietSessions = new Map < string , QuietTerminalSession > ( ) ;
2400+ let skippedQuietTicks = 0 ;
23972401 const isQuiet = ( session : TerminalSessionState & { pid : number } ) => {
23982402 const quiet = quietSessions . get ( toSessionKey ( session . threadId , session . terminalId ) ) ;
23992403 return (
@@ -2412,9 +2416,17 @@ export const makeWithOptions = Effect.fn("TerminalManager.makeWithOptions")(func
24122416 session . status === "running" && Number . isInteger ( session . pid ) ,
24132417 ) ;
24142418
2415- if ( runningSessions . every ( isQuiet ) ) {
2419+ if ( runningSessions . length === 0 ) {
24162420 return true ;
24172421 }
2422+ if (
2423+ runningSessions . every ( isQuiet ) &&
2424+ skippedQuietTicks < QUIET_SUBPROCESS_SNAPSHOT_EVERY_TICKS - 1
2425+ ) {
2426+ skippedQuietTicks += 1 ;
2427+ return true ;
2428+ }
2429+ skippedQuietTicks = 0 ;
24182430
24192431 const inspectorOption = yield * acquireSubprocessInspector . pipe (
24202432 Effect . asSome ,
0 commit comments