@@ -30,7 +30,6 @@ import {
3030 type TerminalToolArgs ,
3131 type TerminalToolResponse ,
3232} from '@sim/terminal-protocol'
33- import { getErrorMessage } from '@sim/utils/errors'
3433import { sleep } from '@sim/utils/helpers'
3534import type { BrowserWindow , WebContents } from 'electron'
3635import {
@@ -219,7 +218,6 @@ const STOP_ESCALATION_MS = 2_000
219218export class TerminalService {
220219 /** Insertion-ordered, which is also the tab order the user sees. */
221220 private readonly sessions = new Map < string , TerminalSession > ( )
222- private foregroundReadFailureLogged = false
223221 private activeId : string | null = null
224222 private readonly pendingCloseConfirmations = new Set < string > ( )
225223 private agentActiveId : string | null = null
@@ -308,26 +306,16 @@ export class TerminalService {
308306 /**
309307 * The command line holding each busy terminal's foreground, `''` when unannounced. A shell
310308 * without integration (fish, sh) announces nothing, so the OS's foreground process group
311- * answers for it; a failed read counts as idle so a restart is never held by a stale guess .
309+ * answers for it; an unreadable group (null) counts as idle.
312310 */
313311 async runningCommands ( ) : Promise < string [ ] > {
314312 const groups = this . options . processGroups ?? OS_PROCESS_GROUPS
315313 const commands = await Promise . all (
316314 [ ...this . sessions . values ( ) ] . map ( async ( session ) => {
317315 if ( session . isBusy ) return [ session . foreground ?? '' ]
318316 if ( session . hasShellIntegration ) return [ ]
319- try {
320- const pgid = await groups . foreground ( session . pid )
321- return pgid !== null && pgid !== session . pid ? [ '' ] : [ ]
322- } catch ( error ) {
323- if ( ! this . foregroundReadFailureLogged ) {
324- this . foregroundReadFailureLogged = true
325- logger . warn ( 'Could not read a terminal foreground process group' , {
326- error : getErrorMessage ( error ) ,
327- } )
328- }
329- return [ ]
330- }
317+ const pgid = await groups . foreground ( session . pid )
318+ return pgid !== null && pgid !== session . pid ? [ '' ] : [ ]
331319 } )
332320 )
333321 return commands . flat ( )
0 commit comments