From c8d08e1b2151350bab67f32993820bcd39e4d73c Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Wed, 12 Aug 2026 20:57:54 -0700 Subject: [PATCH] test(pty): pin incarnation write fence --- .../ipc/pty-superseded-operation-fence.test.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/ipc/pty-superseded-operation-fence.test.ts b/src/main/ipc/pty-superseded-operation-fence.test.ts index c7c74bc0f72..f357954bc26 100644 --- a/src/main/ipc/pty-superseded-operation-fence.test.ts +++ b/src/main/ipc/pty-superseded-operation-fence.test.ts @@ -78,6 +78,16 @@ describe('superseded PTY operation fence', () => { }) describe('the fence is wired into every mutating handler', () => { + it('combines supersession and incarnation in the write fence', async () => { + const { readFileSync } = await import('node:fs') + const source = readFileSync('src/main/ipc/pty.ts', 'utf-8') + const start = source.indexOf('const isCurrentPtyWrite') + + expect(start).toBeGreaterThan(0) + expect(source.slice(start, start + 300)).toContain('isSupersededPtyId') + expect(source.slice(start, start + 300)).toContain('ptyIncarnationById') + }) + // The capability existed for months and was never called from these handlers. // Pin the call site, not the capability — that is the failure this program hit. it.each(['pty:write', 'pty:writeAccepted', 'pty:resize', 'pty:signal'])( @@ -90,7 +100,9 @@ describe('the fence is wired into every mutating handler', () => { new RegExp(`ipcMain\\.(?:on|handle)\\(\\s*'${channel.replace(':', ':')}'`) ) expect(start, `${channel} handler not found`).toBeGreaterThan(0) - expect(source.slice(start, start + 700)).toContain('isSupersededPtyId') + expect(source.slice(start, start + 700)).toContain( + channel.startsWith('pty:write') ? 'isCurrentPtyWrite' : 'isSupersededPtyId' + ) } )