fleetbo-cockpit-cli 1.0.119 → 1.0.120

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 +55 -29
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -639,48 +639,74 @@ if (command === 'alex') {
639
639
  process.stdout.write('\n\x1b[F');
640
640
  rl.prompt();
641
641
 
642
- let inputBuffer = "";
643
- let isProcessing = false;
642
+ let inputBuffer = "";
643
+ let isProcessing = false;
644
+ let hintTimer = null; // affiche le hint seulement après silence de 300ms
645
+ let submitTimer = null; // soumet après ligne vide si buffer non vide
646
+
647
+ const showHint = () => {
648
+ if (hintTimer) { clearTimeout(hintTimer); hintTimer = null; }
649
+ hintTimer = setTimeout(() => {
650
+ if (inputBuffer.trim() !== "" && !isProcessing) {
651
+ rl.setPrompt("\x1b[90m ↵ again to send\x1b[0m");
652
+ rl.prompt();
653
+ }
654
+ }, 300);
655
+ };
656
+
657
+ const doSubmit = async () => {
658
+ if (hintTimer) { clearTimeout(hintTimer); hintTimer = null; }
659
+ if (submitTimer) { clearTimeout(submitTimer); submitTimer = null; }
660
+ if (isProcessing || inputBuffer.trim() === "") return;
661
+
662
+ const finalPrompt = inputBuffer.trim();
663
+ inputBuffer = "";
664
+
665
+ if (finalPrompt.length > 1000) {
666
+ console.log(`\n\x1b[31m⛔ [Alex Safety] Mission rejected: Excessive size (${finalPrompt.length}/1000 characters).\x1b[0m`);
667
+ rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
668
+ rl.prompt();
669
+ return;
670
+ }
671
+
672
+ isProcessing = true;
673
+ rl.setPrompt("");
674
+ await processAlexRequest(finalPrompt);
675
+ isProcessing = false;
676
+
677
+ console.log('');
678
+ rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
679
+ rl.prompt();
680
+ };
644
681
 
645
682
  rl.on('line', async (line) => {
646
- if (isProcessing) return;
683
+ if (isProcessing) return;
647
684
 
648
685
  const trimmedLine = line.trim();
649
686
 
650
- if (['exit', 'quit'].includes(trimmedLine.toLowerCase())) {
687
+ if (['exit', 'quit'].includes(trimmedLine.toLowerCase())) {
651
688
  console.log('\n\x1b[90m Alex session closed.\x1b[0m');
652
- rl.close();
653
- return;
689
+ rl.close();
690
+ return;
654
691
  }
655
692
 
656
693
  if (trimmedLine !== "") {
694
+ // Annule tout timer en attente
695
+ if (submitTimer) { clearTimeout(submitTimer); submitTimer = null; }
657
696
  inputBuffer += (inputBuffer ? "\n" : "") + line;
658
- rl.setPrompt("\x1b[90m ↵ again to send\x1b[0m");
659
- rl.prompt();
660
- }
661
- else {
697
+ // Hint affiché seulement après 300ms de silence (frappe normale)
698
+ // Si d'autres lignes arrivent avant (paste), le timer se remet à zéro
699
+ showHint();
700
+ } else {
701
+ // Ligne vide : soumet si buffer non vide, sinon prompt
662
702
  if (inputBuffer.trim() !== "") {
663
- const finalPrompt = inputBuffer.trim();
664
- inputBuffer = "";
665
-
666
- if (finalPrompt.length > 1000) {
667
- console.log(`\n\x1b[31m⛔ [Alex Safety] Mission rejected: Excessive size (${finalPrompt.length}/1000 characters).\x1b[0m`);
668
- rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
669
- rl.prompt();
670
- return;
671
- }
672
-
673
- isProcessing = true;
674
- rl.setPrompt("");
675
- await processAlexRequest(finalPrompt);
676
- isProcessing = false;
677
-
678
- console.log('');
679
- rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
680
- rl.prompt();
703
+ // Attend 100ms : si d'autres lignes non-vides arrivent (paste en cours),
704
+ // le submitTimer sera annulé par le bloc trimmedLine !== "" ci-dessus
705
+ submitTimer = setTimeout(() => doSubmit(), 100);
681
706
  } else {
707
+ if (hintTimer) { clearTimeout(hintTimer); hintTimer = null; }
682
708
  rl.setPrompt(`\x1b[34m${dynamicUsername} ❯ \x1b[0m`);
683
- rl.prompt();
709
+ rl.prompt();
684
710
  }
685
711
  }
686
712
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetbo-cockpit-cli",
3
- "version": "1.0.119",
3
+ "version": "1.0.120",
4
4
  "description": "Fleetbo CLI - Build native mobile apps with React",
5
5
  "author": "Fleetbo",
6
6
  "license": "MIT",