akborana4 commited on
Commit
a635cff
·
verified ·
1 Parent(s): 9fa171f

Update static/js/terminal.js

Browse files
Files changed (1) hide show
  1. static/js/terminal.js +13 -4
static/js/terminal.js CHANGED
@@ -37,7 +37,7 @@ function initTerminal() {
37
  out.appendChild(div);
38
  out.scrollTop = out.scrollHeight;
39
 
40
- // If it's an AI message, also show it in the shiny side panel!
41
  if (data.type === 'ai' && aiChat) {
42
  const aiDiv = document.createElement('div');
43
  aiDiv.style.marginBottom = '10px';
@@ -63,15 +63,24 @@ function initTerminal() {
63
  }
64
  };
65
 
66
- // Handle Input
67
  const input = document.getElementById('terminal-input');
68
  if (input) {
69
- // Remove old event listeners by cloning
70
  const newInput = input.cloneNode(true);
71
  input.parentNode.replaceChild(newInput, input);
72
 
 
73
  newInput.addEventListener('keydown', (e) => {
74
- if (e.key === 'Enter') {
 
 
 
 
 
 
 
 
 
75
  const cmd = newInput.value.trim();
76
  if (cmd && ws.readyState === WebSocket.OPEN) {
77
  // Echo user command to screen
 
37
  out.appendChild(div);
38
  out.scrollTop = out.scrollHeight;
39
 
40
+ // If it's an AI message, also show it in the shiny side panel
41
  if (data.type === 'ai' && aiChat) {
42
  const aiDiv = document.createElement('div');
43
  aiDiv.style.marginBottom = '10px';
 
63
  }
64
  };
65
 
66
+ // Handle Input - MOBILE OPTIMIZED
67
  const input = document.getElementById('terminal-input');
68
  if (input) {
 
69
  const newInput = input.cloneNode(true);
70
  input.parentNode.replaceChild(newInput, input);
71
 
72
+ // 1. Block the physical 'Enter' key from creating new lines on mobile
73
  newInput.addEventListener('keydown', (e) => {
74
+ if (e.key === 'Enter' || e.keyCode === 13) {
75
+ e.preventDefault();
76
+ }
77
+ });
78
+
79
+ // 2. Actually execute the command on keyup (much more reliable on Android)
80
+ newInput.addEventListener('keyup', (e) => {
81
+ if (e.key === 'Enter' || e.keyCode === 13) {
82
+ e.preventDefault();
83
+
84
  const cmd = newInput.value.trim();
85
  if (cmd && ws.readyState === WebSocket.OPEN) {
86
  // Echo user command to screen