@gxp-dev/tools 2.0.14 → 2.0.16

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.
@@ -451,30 +451,33 @@ export default function App({ autoStart, args }: AppProps) {
451
451
  };
452
452
 
453
453
  const addSystemLog = (message: string) => {
454
- // Find or create system service for general messages
455
- let systemService = services.find(s => s.id === 'system');
456
- if (!systemService) {
457
- const newService: Service = {
458
- id: 'system',
459
- name: 'System',
460
- status: 'running',
461
- logs: [message],
462
- };
463
- setServices(prev => {
464
- const updated = [...prev, newService];
465
- return updated;
466
- });
467
- if (services.length === 0) setActiveTab(0);
468
- } else {
469
- setServices(prev => prev.map(s =>
470
- s.id === 'system' ? { ...s, logs: [...s.logs, message] } : s
471
- ));
472
- }
454
+ // Use functional update to properly handle rapid successive calls
455
+ setServices(prev => {
456
+ const existingSystem = prev.find(s => s.id === 'system');
457
+ if (existingSystem) {
458
+ // Add message to existing system service
459
+ return prev.map(s =>
460
+ s.id === 'system' ? { ...s, logs: [...s.logs, message] } : s
461
+ );
462
+ } else {
463
+ // Create new system service with the message
464
+ const newService: Service = {
465
+ id: 'system',
466
+ name: 'System',
467
+ status: 'running',
468
+ logs: [message],
469
+ };
470
+ return [...prev, newService];
471
+ }
472
+ });
473
473
 
474
474
  // Switch to system tab
475
475
  setTimeout(() => {
476
- const sysIdx = services.findIndex(s => s.id === 'system');
477
- if (sysIdx >= 0) setActiveTab(sysIdx);
476
+ setServices(current => {
477
+ const sysIdx = current.findIndex(s => s.id === 'system');
478
+ if (sysIdx >= 0) setActiveTab(sysIdx);
479
+ return current; // Don't modify, just read
480
+ });
478
481
  }, 50);
479
482
  };
480
483
 
@@ -124,14 +124,22 @@ export default function CommandInput({ onSubmit, activeService, onSuggestionsCha
124
124
  return;
125
125
  }
126
126
 
127
- // Up/Down to navigate suggestions when showing
127
+ // Up/Down to navigate suggestions when showing (circular navigation)
128
128
  if (showSuggestions) {
129
129
  if (key.upArrow) {
130
- setSelectedSuggestion(prev => Math.max(0, prev - 1));
130
+ setSelectedSuggestion(prev => {
131
+ // Wrap to bottom when at top
132
+ if (prev <= 0) return suggestions.length - 1;
133
+ return prev - 1;
134
+ });
131
135
  return;
132
136
  }
133
137
  if (key.downArrow) {
134
- setSelectedSuggestion(prev => Math.min(suggestions.length - 1, prev + 1));
138
+ setSelectedSuggestion(prev => {
139
+ // Wrap to top when at bottom
140
+ if (prev >= suggestions.length - 1) return 0;
141
+ return prev + 1;
142
+ });
135
143
  return;
136
144
  }
137
145
  } else {