Skip to content

Commit 763ac98

Browse files
committed
Fix shouldSynchronize CI test and kittyKeyboard enabled mode
- Branch shouldSynchronize test assertion on isInCi so it expects the correct value in both CI and non-CI environments - Restructure initKittyKeyboard so mode 'enabled' bypasses the interactive guard while still requiring TTY streams, matching the documented behavior
1 parent 5e731a7 commit 763ac98

2 files changed

Lines changed: 23 additions & 9 deletions

File tree

src/ink.tsx

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,19 +1012,28 @@ export default class Ink {
10121012
const opts = this.options.kittyKeyboard;
10131013
const mode = opts.mode ?? 'auto';
10141014

1015-
if (
1016-
mode === 'disabled' ||
1017-
!this.interactive ||
1018-
!this.options.stdin.isTTY ||
1019-
!this.options.stdout.isTTY
1020-
) {
1015+
if (mode === 'disabled') {
10211016
return;
10221017
}
10231018

10241019
const flags: KittyFlagName[] = opts.flags ?? ['disambiguateEscapeCodes'];
10251020

1021+
// 'enabled' force-enables the protocol as long as both streams are TTYs,
1022+
// regardless of the interactive setting (e.g. even in CI).
10261023
if (mode === 'enabled') {
1027-
this.enableKittyProtocol(flags);
1024+
if (this.options.stdin.isTTY && this.options.stdout.isTTY) {
1025+
this.enableKittyProtocol(flags);
1026+
}
1027+
1028+
return;
1029+
}
1030+
1031+
// Auto mode: require interactive + TTY
1032+
if (
1033+
!this.interactive ||
1034+
!this.options.stdin.isTTY ||
1035+
!this.options.stdout.isTTY
1036+
) {
10281037
return;
10291038
}
10301039

test/write-synchronized.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import EventEmitter from 'node:events';
22
import test from 'ava';
3+
import isInCi from 'is-in-ci';
34
import {bsu, esu, shouldSynchronize} from '../src/write-synchronized.js';
45

56
const createStream = ({tty = false} = {}) => {
@@ -38,8 +39,12 @@ test('shouldSynchronize returns false for non-TTY stream', t => {
3839
test('shouldSynchronize uses CI detection when interactive is not specified', t => {
3940
const ttyStream = createStream({tty: true});
4041
// When interactive is omitted, shouldSynchronize falls back to is-in-ci.
41-
// In a non-CI environment with a TTY stream, this should return true.
42-
t.true(shouldSynchronize(ttyStream));
42+
// In CI the result is false (non-interactive by design); outside CI it's true.
43+
if (isInCi) {
44+
t.false(shouldSynchronize(ttyStream));
45+
} else {
46+
t.true(shouldSynchronize(ttyStream));
47+
}
4348
});
4449

4550
test('shouldSynchronize returns false for non-TTY stream when interactive is not specified', t => {

0 commit comments

Comments
 (0)