Skip to content

Commit 5577db2

Browse files
committed
fix(hub): preserve killed PTY status
1 parent 90b89f4 commit 5577db2

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

packages/hub/src/node/__tests__/host-terminals.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,11 @@ describe('devframeTerminalHost interactive PTY sessions', () => {
476476
})
477477

478478
itPty('getResult() marks a terminated PTY run as killed', async () => {
479-
expect.assertions(4)
479+
expect.assertions(6)
480480

481481
const { host } = createTerminalHost()
482+
const updates: string[] = []
483+
host.events.on('terminals:session:updated', session => updates.push(session.status))
482484

483485
const session = await host.startPtySession({
484486
command: NODE,
@@ -502,6 +504,8 @@ describe('devframeTerminalHost interactive PTY sessions', () => {
502504
await expect(result).resolves.toHaveProperty('signal', undefined)
503505
else
504506
await expect(result).resolves.toHaveProperty('signal', expect.any(Number))
507+
expect(session.status).toBe('stopped')
508+
expect(updates).not.toContain('error')
505509
})
506510

507511
itPty('getResult() isolates the previous PTY run after restart()', async () => {

packages/hub/src/node/host-terminals.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,10 +468,10 @@ export class DevframeTerminalsHost implements DevframeTerminalsHostType {
468468
return
469469
closeStream()
470470
/**
471-
* A signal kill (terminate()/restart()) and a clean exit are deliberate stops.
472-
* Only an unsignalled non-zero exit code is a crash, matching the child-process path.
471+
* Killed runs and clean exits are stopped. Only a non-killed non-zero exit
472+
* code is a crash, matching the child-process path.
473473
*/
474-
markStatus(signal === 0 && exitCode !== 0 ? 'error' : 'stopped')
474+
markStatus(!killed && exitCode !== 0 ? 'error' : 'stopped')
475475
})
476476
currentResult = {
477477
get pid() {

0 commit comments

Comments
 (0)