Skip to content

Commit 66fe76a

Browse files
resolve: code review comments
1 parent f725ce7 commit 66fe76a

File tree

3 files changed

+38
-25
lines changed

3 files changed

+38
-25
lines changed

frontend/src/App.jsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@ const App = () => {
100100

101101
const updatedRows = prevState.rows.map((row) =>
102102
row.map((component) => {
103-
if (!component || !component.id) return component;
103+
if (!component || !component.id) {
104+
console.warn('[App] Invalid component found during bulk state update:', component);
105+
return component;
106+
}
104107

105108
// Check if this component has a state update
106109
if (stateUpdates.hasOwnProperty(component.id)) {
@@ -174,7 +177,10 @@ const App = () => {
174177
// Process components with bulk-retrieved states using optimized approach
175178
const updatedRows = components.rows.map((row) =>
176179
row.map((component) => {
177-
if (!component || !component.id) return component;
180+
if (!component || !component.id) {
181+
console.warn('[App] Invalid component found during component refresh:', component);
182+
return component;
183+
}
178184

179185
const currentState = stateMap.get(component.id);
180186
return {
@@ -196,8 +202,7 @@ const App = () => {
196202
timestamp: new Date().toISOString()
197203
};
198204

199-
console.log(`[App] Enhanced bulk component processing completed: ${componentIds.length} components in ${processingTime.toFixed(2)}ms`);
200-
console.log('[App] Processing metrics:', metrics);
205+
console.debug(`[App] Enhanced bulk component processing completed: ${componentIds.length} components in ${processingTime.toFixed(2)}ms`, { metrics });
201206

202207
setAreComponentsLoading(false);
203208
setComponents({ rows: updatedRows });
@@ -260,7 +265,7 @@ const App = () => {
260265
}
261266
};
262267

263-
const handleBulkComponentUpdate = async (updates) => {
268+
const processBulkComponentUpdates = async (updates) => {
264269
const startTime = performance.now();
265270

266271
try {
@@ -289,7 +294,10 @@ const App = () => {
289294

290295
const updatedRows = prevState.rows.map((row) =>
291296
row.map((component) => {
292-
if (!component || !component.id) return component;
297+
if (!component || !component.id) {
298+
console.warn('[App] Invalid component found during bulk component update:', component);
299+
return component;
300+
}
293301

294302
// Check if this component was updated
295303
if (updates.hasOwnProperty(component.id)) {

frontend/src/utils/websocket.js

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,6 +1317,7 @@ class BaseCommunicationClient extends IPreswaldCommunicator {
13171317
type: 'error',
13181318
content: {
13191319
message: error.message,
1320+
fullError: error.toString(),
13201321
context,
13211322
timestamp: performance.now(),
13221323
transport: this.constructor.name
@@ -1349,7 +1350,7 @@ class BaseCommunicationClient extends IPreswaldCommunicator {
13491350
}
13501351

13511352
class WebSocketClient extends BaseCommunicationClient {
1352-
constructor() {
1353+
constructor(config = {}) {
13531354
super();
13541355
this.socket = null;
13551356
this.clientId = Math.random().toString(36).substring(7);
@@ -1358,13 +1359,12 @@ class WebSocketClient extends BaseCommunicationClient {
13581359
this.maxReconnectAttempts = 5;
13591360
this.reconnectDelay = 1000;
13601361

1361-
// Enhanced transport optimization features
13621362
this.messageQueue = [];
1363-
this.maxQueueSize = 1000;
1364-
this.batchingEnabled = true;
1363+
this.maxQueueSize = config.maxQueueSize || 1000;
1364+
this.batchingEnabled = config.batchingEnabled !== false;
13651365
this.batchTimeout = null;
1366-
this.batchSize = 10;
1367-
this.batchDelay = 16; // ~60fps for UI responsiveness
1366+
this.batchSize = config.batchSize || 10;
1367+
this.batchDelay = config.batchDelay || 16;
13681368

13691369
// Compression statistics for monitoring
13701370
this.compressionStats = {
@@ -1806,16 +1806,16 @@ class WebSocketClient extends BaseCommunicationClient {
18061806
}
18071807

18081808
class PostMessageClient extends BaseCommunicationClient {
1809-
constructor() {
1809+
constructor(config = {}) {
18101810
super();
18111811

1812-
// Enhanced transport optimization features for PostMessage
18131812
this.messageQueue = [];
1814-
this.maxQueueSize = 500; // Smaller queue for PostMessage due to potential parent window limitations
1815-
this.batchingEnabled = true;
1813+
this.maxQueueSize = config.maxQueueSize || 500;
1814+
this.batchingEnabled = config.batchingEnabled !== false;
18161815
this.batchTimeout = null;
1817-
this.batchSize = 8; // Smaller batch size for PostMessage
1818-
this.batchDelay = 20; // Slightly higher delay for PostMessage
1816+
this.batchSize = config.batchSize || 8;
1817+
this.batchDelay = config.batchDelay || 20;
1818+
this.messageSequence = 0;
18191819

18201820
// Serialization optimization statistics
18211821
this.serializationStats = {
@@ -2193,10 +2193,18 @@ class PostMessageClient extends BaseCommunicationClient {
21932193
}
21942194

21952195
class ComlinkClient extends BaseCommunicationClient {
2196-
constructor() {
2196+
constructor(config = {}) {
21972197
super();
21982198
console.log('[Client] Initializing ComlinkClient');
21992199
this.worker = null;
2200+
2201+
this.messageQueue = [];
2202+
this.maxQueueSize = config.maxQueueSize || 100;
2203+
this.batchingEnabled = config.batchingEnabled !== false;
2204+
this.batchTimeout = null;
2205+
this.batchSize = config.batchSize || 5;
2206+
this.batchDelay = config.batchDelay || 50;
2207+
22002208
// Note: callbacks, componentStates, isConnected, pendingUpdates
22012209
// are now inherited from BaseCommunicationClient
22022210
}
@@ -3163,11 +3171,11 @@ export const createCommunicationLayer = (config = {}) => {
31633171
function createTransportClient(transportType, config) {
31643172
switch (transportType) {
31653173
case TransportType.WEBSOCKET:
3166-
return new WebSocketClient();
3174+
return new WebSocketClient(config);
31673175
case TransportType.POST_MESSAGE:
3168-
return new PostMessageClient();
3176+
return new PostMessageClient(config);
31693177
case TransportType.COMLINK:
3170-
return new ComlinkClient();
3178+
return new ComlinkClient(config);
31713179
default:
31723180
throw new Error(`Unsupported transport type: ${transportType}`);
31733181
}

preswald/engine/base_service.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,6 @@ async def _broadcast_bulk_state_updates(
418418
self, states: dict[str, Any], exclude_client: str | None = None
419419
):
420420
"""Broadcast bulk state updates to all clients except the sender (optimized for bulk operations)"""
421-
422-
if not states:
423-
return
424421

425422
# Prepare bulk update message with compression
426423
processed_states = {}

0 commit comments

Comments
 (0)