fleetbo-cockpit-cli 1.0.113 → 1.0.115

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/cli.js +13 -57
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -636,15 +636,9 @@ if (command === 'alex') {
636
636
  prompt: `\x1b[34m${dynamicUsername} ❯ \x1b[0m`
637
637
  });
638
638
 
639
- // Active les events keypress sur stdin pour détecter le paste
640
- readline.emitKeypressEvents(process.stdin, rl);
641
- if (process.stdin.isTTY) process.stdin.setRawMode(true);
642
-
643
639
  let inputBuffer = "";
644
640
  let isProcessing = false;
645
- let currentLine = "";
646
- let isPasting = false;
647
- let pasteTimer = null;
641
+ let submitTimer = null; // fenêtre de 80ms : ignore les lignes vides d'un paste
648
642
 
649
643
  const resetPrompt = () => {
650
644
  rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
@@ -652,10 +646,9 @@ if (command === 'alex') {
652
646
  };
653
647
 
654
648
  const submit = async () => {
649
+ if (submitTimer) { clearTimeout(submitTimer); submitTimer = null; }
655
650
  const finalPrompt = inputBuffer.trim();
656
651
  inputBuffer = "";
657
- currentLine = "";
658
-
659
652
  if (!finalPrompt) { resetPrompt(); return; }
660
653
 
661
654
  if (finalPrompt.length > 1000) {
@@ -666,72 +659,35 @@ if (command === 'alex') {
666
659
 
667
660
  isProcessing = true;
668
661
  rl.setPrompt("");
669
- process.stdout.write('\n');
670
662
  await processAlexRequest(finalPrompt);
671
663
  isProcessing = false;
672
664
  console.log('');
673
665
  resetPrompt();
674
666
  };
675
667
 
676
- // Keypress : détecte si c'est un paste (chunk > 1 char) ou frappe normale
677
- process.stdin.on('keypress', (char, key) => {
678
- if (isProcessing) return;
679
-
680
- // Ctrl+C
681
- if (key && key.ctrl && key.name === 'c') {
682
- console.log('\n\x1b[90mAlex session closed.\x1b[0m');
683
- process.exit(0);
684
- }
685
-
686
- // Entrée : soumettre si buffer non vide
687
- if (key && (key.name === 'return' || key.name === 'enter')) {
688
- if (inputBuffer.trim() !== "") {
689
- submit();
690
- }
691
- return;
692
- }
693
-
694
- // Paste : char arrive avec plusieurs caractères d'un coup
695
- if (char && char.length > 1) {
696
- isPasting = true;
697
- if (pasteTimer) clearTimeout(pasteTimer);
698
- // Accumule dans inputBuffer via readline line event
699
- pasteTimer = setTimeout(() => {
700
- isPasting = false;
701
- // Affiche le hint après le paste
702
- process.stdout.write(`\n\x1b[90m↵ to send · keep typing to add more\x1b[0m`);
703
- rl.setPrompt(`\n\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
704
- rl.prompt(true);
705
- }, 50);
706
- }
707
- });
708
-
709
- // Line event : accumule les lignes dans le buffer
710
- rl.on('line', (line) => {
668
+ rl.on('line', async (line) => {
711
669
  if (isProcessing) return;
712
670
 
713
- if (isPasting) {
714
- // Pendant un paste : accumule sans soumettre
715
- inputBuffer += (inputBuffer ? "\n" : "") + line;
716
- return;
717
- }
718
-
719
671
  const trimmed = line.trim();
672
+
720
673
  if (['exit', 'quit'].includes(trimmed.toLowerCase())) {
721
674
  console.log('\n\x1b[90mAlex session closed.\x1b[0m');
675
+ rl.close();
722
676
  process.exit(0);
723
677
  }
724
678
 
725
679
  if (trimmed !== "") {
680
+ // Nouvelle ligne avec contenu : annule le timer de soumission en cours
681
+ // (cas paste : la ligne vide du paste n'aura pas eu le temps de soumettre)
682
+ if (submitTimer) { clearTimeout(submitTimer); submitTimer = null; }
726
683
  inputBuffer += (inputBuffer ? "\n" : "") + line;
727
- // Hint de confirmation après frappe normale
728
- process.stdout.write(`\x1b[90m ↵ to send · keep typing to add more\x1b[0m\n`);
729
- rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
684
+ rl.setPrompt(`\x1b[90m ↵ to send · keep typing\x1b[0m\n\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
730
685
  rl.prompt(true);
731
686
  } else {
732
- // Ligne vide = soumettre
733
- if (inputBuffer.trim()) {
734
- submit();
687
+ if (inputBuffer.trim() !== "") {
688
+ // Ligne vide reçue : attend 80ms avant de soumettre
689
+ // Si une autre ligne non-vide arrive dans ce délai (paste), on annule
690
+ submitTimer = setTimeout(() => submit(), 80);
735
691
  } else {
736
692
  resetPrompt();
737
693
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetbo-cockpit-cli",
3
- "version": "1.0.113",
3
+ "version": "1.0.115",
4
4
  "description": "Fleetbo CLI - Build native mobile apps with React",
5
5
  "author": "Fleetbo",
6
6
  "license": "MIT",