Files
tabby/tabby-ssh/test/shellChannel.test.ts
T
a8abcc0be6 Allow per-profile custom SSH TERM (#11480)
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Co-authored-by: x06579 <x06579@ai-dashboard>
Co-authored-by: Eugene <inbox@null.page>
2026-09-11 22:03:05 +02:00

49 lines
1.9 KiB
TypeScript

import assert from 'node:assert/strict'
import { describe, it } from 'node:test'
import { DEFAULT_SSH_TERMINAL_TYPE, openShellChannelForProfile, requestShellPTY } from '../src/session/shellChannel.ts'
import type { SSHShellChannelOptions } from '../src/session/shellChannel.ts'
class SharedSSHSessionAdapter {
readonly channelOptions: SSHShellChannelOptions[] = []
readonly requestedTerms: string[] = []
async openShellChannel (options: SSHShellChannelOptions): Promise<void> {
this.channelOptions.push(options)
await requestShellPTY({
requestPTY: async term => {
this.requestedTerms.push(term)
},
}, options)
}
}
describe('shared SSH session shell channels', () => {
it('uses each shell profile TERM and applies the blank fallback', async () => {
const sharedSession = new SharedSSHSessionAdapter()
await openShellChannelForProfile(sharedSession, { options: { x11: false, term: ' vt100 ' } })
await openShellChannelForProfile(sharedSession, { options: { x11: true, term: 'xterm' } })
await openShellChannelForProfile(sharedSession, { options: { x11: false, term: ' ' } })
assert.deepEqual(sharedSession.channelOptions, [
{ x11: false, term: ' vt100 ' },
{ x11: true, term: 'xterm' },
{ x11: false, term: ' ' },
])
assert.deepEqual(sharedSession.requestedTerms, [
'vt100',
'xterm',
'xterm-256color',
])
})
it('falls back for a malformed persisted TERM value', async () => {
const sharedSession = new SharedSSHSessionAdapter()
const profile = { options: { x11: false, term: 256 } } as unknown as Parameters<typeof openShellChannelForProfile>[1]
await openShellChannelForProfile(sharedSession, profile)
assert.deepEqual(sharedSession.requestedTerms, [DEFAULT_SSH_TERMINAL_TYPE])
})
})