@gxp-dev/tools 2.0.14 → 2.0.15

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