Skip to content

Commit 2720423

Browse files
committed
chore(desktop): drop the unreachable foreground-read catch
1 parent da77a69 commit 2720423

2 files changed

Lines changed: 3 additions & 20 deletions

File tree

‎apps/desktop/src/main/terminal/index.ts‎

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import {
3030
type TerminalToolArgs,
3131
type TerminalToolResponse,
3232
} from '@sim/terminal-protocol'
33-
import { getErrorMessage } from '@sim/utils/errors'
3433
import { sleep } from '@sim/utils/helpers'
3534
import type { BrowserWindow, WebContents } from 'electron'
3635
import {
@@ -219,7 +218,6 @@ const STOP_ESCALATION_MS = 2_000
219218
export 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()

‎apps/desktop/src/main/terminal/service.test.ts‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -515,11 +515,6 @@ describe('running work before a restart', () => {
515515

516516
read = async () => session.pid
517517
await expect(terminal.runningCommands()).resolves.toEqual([])
518-
519-
read = async () => {
520-
throw new Error('ps is unavailable')
521-
}
522-
await expect(terminal.runningCommands()).resolves.toEqual([])
523518
})
524519
})
525520

0 commit comments

Comments
 (0)