@f5xc-salesdemos/pi-tui 19.27.1 → 19.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/terminal.ts +29 -25
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@f5xc-salesdemos/pi-tui",
4
- "version": "19.27.1",
4
+ "version": "19.28.0",
5
5
  "description": "Terminal User Interface library with differential rendering for efficient text-based applications",
6
6
  "homepage": "https://github.com/f5xc-salesdemos/xcsh",
7
7
  "author": "Can Boluk",
@@ -37,8 +37,8 @@
37
37
  "fmt": "biome format --write ."
38
38
  },
39
39
  "dependencies": {
40
- "@f5xc-salesdemos/pi-natives": "19.27.1",
41
- "@f5xc-salesdemos/pi-utils": "19.27.1",
40
+ "@f5xc-salesdemos/pi-natives": "19.28.0",
41
+ "@f5xc-salesdemos/pi-utils": "19.28.0",
42
42
  "marked": "^17.0"
43
43
  },
44
44
  "devDependencies": {
package/src/terminal.ts CHANGED
@@ -264,41 +264,33 @@ export class ProcessTerminal implements Terminal {
264
264
 
265
265
  // Forward individual sequences to the input handler
266
266
  this.#stdinBuffer.on("data", (sequence: string) => {
267
- // Check for Kitty protocol response (only if not already enabled)
268
- if (!this.#kittyProtocolActive) {
269
- const match = sequence.match(kittyResponsePattern);
270
- if (match) {
267
+ // Kitty protocol response always swallow, enable protocol on first match
268
+ const kittyMatch = sequence.match(kittyResponsePattern);
269
+ if (kittyMatch) {
270
+ if (!this.#kittyProtocolActive) {
271
271
  if (this.#modifyOtherKeysTimeout) {
272
272
  clearTimeout(this.#modifyOtherKeysTimeout);
273
273
  this.#modifyOtherKeysTimeout = undefined;
274
274
  }
275
275
  this.#kittyProtocolActive = true;
276
276
  setKittyProtocolActive(true);
277
-
278
- // Enable Kitty keyboard protocol (push flags)
279
- // Flag 1 = disambiguate escape codes
280
- // Flag 2 = report event types (press/repeat/release)
281
- // Flag 4 = report alternate keys
282
277
  this.#safeWrite("\x1b[>7u");
283
- return; // Don't forward protocol response to TUI
284
278
  }
279
+ return;
285
280
  }
286
281
 
287
- // DA1 response: swallow our sentinel reply regardless of whether OSC 11
288
- // already succeeded. Other terminal probes should never see these replies.
289
- if (da1ResponsePattern.test(sequence) && this.#pendingDa1Sentinels > 0) {
290
- this.#pendingDa1Sentinels--;
291
- if (this.#osc11Pending) {
292
- // DA1 arrived before OSC 11 response: terminal does not support
293
- // OSC 11. Clear the pending state without starting a queued query
294
- // (queued query is started below, after sentinel is consumed).
295
- this.#osc11Pending = false;
296
- this.#osc11ResponseBuffer = "";
297
- }
298
- // Now that this DA1 cycle is complete, start any queued query.
299
- if (this.#osc11QueryQueued && !this.#dead) {
300
- this.#osc11QueryQueued = false;
301
- this.#startOsc11Query();
282
+ // DA1 response — always swallow; manage sentinel count if pending
283
+ if (da1ResponsePattern.test(sequence)) {
284
+ if (this.#pendingDa1Sentinels > 0) {
285
+ this.#pendingDa1Sentinels--;
286
+ if (this.#osc11Pending) {
287
+ this.#osc11Pending = false;
288
+ this.#osc11ResponseBuffer = "";
289
+ }
290
+ if (this.#osc11QueryQueued && !this.#dead) {
291
+ this.#osc11QueryQueued = false;
292
+ this.#startOsc11Query();
293
+ }
302
294
  }
303
295
  return;
304
296
  }
@@ -339,6 +331,18 @@ export class ProcessTerminal implements Terminal {
339
331
  }, 100);
340
332
  return;
341
333
  }
334
+ // Drop stale terminal responses that leaked through the stdin buffer
335
+ // timeout flush. These are incomplete DA1/DA2 replies, OSC 11
336
+ // fragments, or Kitty protocol responses that arrived split across
337
+ // data events and were flushed before their terminator arrived.
338
+ if (
339
+ /^\x1b\[\?[\d;]*[a-z]?$/i.test(sequence) || // DA1/Kitty responses: ESC[?...
340
+ /^\x1b\](?:11|10|4);/.test(sequence) || // OSC color responses without terminator
341
+ /^\x1b\[>[\d;]*[a-z]?$/i.test(sequence) // DA2 responses: ESC[>...
342
+ ) {
343
+ return;
344
+ }
345
+
342
346
  if (this.#inputHandler) {
343
347
  this.#inputHandler(sequence);
344
348
  }