genbox 1.0.166 → 1.0.168

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.
@@ -207,12 +207,64 @@ function uploadFileSync(localPath, ipAddress, keyPath) {
207
207
  return { success: false, remotePath: '', error: error.message };
208
208
  }
209
209
  }
210
- // Show message in tmux status bar
211
- function showTmuxMessage(ipAddress, keyPath, sessionName, message) {
210
+ // Check if our terminal window is currently in foreground
211
+ function isTerminalInForeground(genboxName) {
212
+ if (os.platform() !== 'darwin') {
213
+ return true; // Can't detect on other platforms, assume yes
214
+ }
215
+ try {
216
+ // Get frontmost app and window title
217
+ const script = `
218
+ tell application "System Events"
219
+ set frontApp to first application process whose frontmost is true
220
+ set frontAppName to name of frontApp
221
+ try
222
+ tell frontApp
223
+ set windowTitle to name of window 1
224
+ end tell
225
+ on error
226
+ set windowTitle to ""
227
+ end try
228
+ return frontAppName & "|" & windowTitle
229
+ end tell
230
+ `;
231
+ const result = (0, child_process_1.execSync)(`osascript -e '${script}'`, { encoding: 'utf-8', timeout: 1000 }).trim();
232
+ const [appName, windowTitle] = result.split('|');
233
+ // Check if it's a terminal app
234
+ const terminalApps = ['iTerm2', 'Terminal', 'Hyper', 'Alacritty', 'kitty', 'Warp'];
235
+ if (!terminalApps.some(t => appName.includes(t))) {
236
+ return false; // Not a terminal in foreground
237
+ }
238
+ // Check if window title contains our genbox name
239
+ if (windowTitle && windowTitle.toLowerCase().includes(genboxName.toLowerCase())) {
240
+ return true;
241
+ }
242
+ // Also check for common patterns like "dev@genbox-name" or "genbox-name"
243
+ if (windowTitle && (windowTitle.includes(`@${genboxName}`) || windowTitle.includes(`dev@`))) {
244
+ return true;
245
+ }
246
+ return false;
247
+ }
248
+ catch {
249
+ return true; // On error, assume yes to not break functionality
250
+ }
251
+ }
252
+ // Show message in tmux status bar with styling
253
+ function showTmuxMessage(ipAddress, keyPath, sessionName, message, style = 'success') {
212
254
  const controlPath = getControlPath(ipAddress);
255
+ // Style configurations
256
+ const styles = {
257
+ uploading: 'bg=colour214,fg=black,bold', // Orange/yellow for uploading
258
+ success: 'bg=colour34,fg=white,bold', // Nice green for success
259
+ error: 'bg=colour196,fg=white,bold', // Red for error
260
+ warning: 'bg=colour208,fg=black,bold', // Orange for warning
261
+ };
262
+ const duration = style === 'uploading' ? 30000 : 4000; // Long duration for uploading (will be replaced)
263
+ const msgStyle = styles[style];
213
264
  try {
214
- // Send message to tmux session's status bar
215
- (0, child_process_1.execSync)(`ssh -i "${keyPath}" -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ControlPath=${controlPath} dev@${ipAddress} "tmux display-message -t ${sessionName} -d 3000 '${message.replace(/'/g, "\\'")}'" 2>/dev/null`, { encoding: 'utf-8', timeout: 5000 });
265
+ // Set message style and display message
266
+ const cmd = `tmux set-option -t ${sessionName} message-style '${msgStyle}' \\; display-message -t ${sessionName} -d ${duration} ' ${message.replace(/'/g, "\\'")} '`;
267
+ (0, child_process_1.execSync)(`ssh -i "${keyPath}" -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ControlPath=${controlPath} dev@${ipAddress} "${cmd}" 2>/dev/null`, { encoding: 'utf-8', timeout: 5000 });
216
268
  }
217
269
  catch {
218
270
  // Fallback to macOS notification if tmux message fails
@@ -508,6 +560,10 @@ async function attachToSession(ipAddress, keyPath, sessionName, genboxName) {
508
560
  const uploadedPaths = new Set();
509
561
  const clipboardInterval = setInterval(() => {
510
562
  try {
563
+ // Only process if THIS terminal window is in foreground
564
+ if (!isTerminalInForeground(genboxName)) {
565
+ return;
566
+ }
511
567
  const currentClipboard = getClipboard();
512
568
  // Check if clipboard changed
513
569
  if (currentClipboard === lastClipboard) {
@@ -523,7 +579,7 @@ async function attachToSession(ipAddress, keyPath, sessionName, genboxName) {
523
579
  // If file path was detected but file doesn't exist (e.g., macOS temp file was cleaned up)
524
580
  if (extractResult.notFound) {
525
581
  const fileName = path.basename(extractResult.notFound);
526
- showTmuxMessage(ipAddress, keyPath, sessionName, '⚠ File not found: ' + fileName.substring(0, 30));
582
+ showTmuxMessage(ipAddress, keyPath, sessionName, '⚠ File not found: ' + fileName.substring(0, 30), 'warning');
527
583
  return;
528
584
  }
529
585
  if (!extractResult.path) {
@@ -534,8 +590,8 @@ async function attachToSession(ipAddress, keyPath, sessionName, genboxName) {
534
590
  if (uploadedPaths.has(localPath)) {
535
591
  return;
536
592
  }
537
- // Show uploading message in tmux
538
- showTmuxMessage(ipAddress, keyPath, sessionName, '📤 Uploading image... please wait');
593
+ // Show uploading message in tmux (orange background, stays until replaced)
594
+ showTmuxMessage(ipAddress, keyPath, sessionName, '📤 Uploading image...', 'uploading');
539
595
  // Upload the file (this happens in background, might cause brief pause)
540
596
  const result = uploadFileSync(localPath, ipAddress, keyPath);
541
597
  if (result.success) {
@@ -543,12 +599,12 @@ async function attachToSession(ipAddress, keyPath, sessionName, genboxName) {
543
599
  uploadedPaths.add(result.remotePath); // Also track remote path to avoid re-detection
544
600
  // Replace clipboard with remote path
545
601
  setClipboard(result.remotePath);
546
- // Show success in tmux
547
- showTmuxMessage(ipAddress, keyPath, sessionName, '✓ Image ready! Press Cmd+V to paste');
602
+ // Show success in tmux (green background, replaces uploading message immediately)
603
+ showTmuxMessage(ipAddress, keyPath, sessionName, '✓ Image ready! Cmd+V to paste', 'success');
548
604
  }
549
605
  else {
550
- // Show failure in tmux
551
- showTmuxMessage(ipAddress, keyPath, sessionName, '✗ Upload failed: ' + (result.error || 'unknown'));
606
+ // Show failure in tmux (red background)
607
+ showTmuxMessage(ipAddress, keyPath, sessionName, '✗ Upload failed: ' + (result.error || 'unknown'), 'error');
552
608
  }
553
609
  }
554
610
  catch {
package/dist/index.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "genbox",
3
- "version": "1.0.166",
3
+ "version": "1.0.168",
4
4
  "description": "Genbox CLI - AI-Powered Development Environments",
5
5
  "main": "dist/index.js",
6
6
  "bin": {