Skip to content

Commit f6627fb

Browse files
committed
Update rush-serve-plugin
1 parent b23911b commit f6627fb

File tree

3 files changed

+42
-41
lines changed

3 files changed

+42
-41
lines changed

rush-plugins/rush-serve-plugin/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ const socket = new WebSocket(`wss://${self.location.host}${buildStatusWebSocketP
3535

3636
// Static graph metadata (does not include dynamic status fields)
3737
const operationsByName: Map<string, IOperationInfo> = new Map();
38-
// Current execution state for this pass
38+
// Current execution state for this iteration
3939
const executionStates: Map<string, IOperationExecutionState> = new Map();
40-
// Queued states for the next pass (if a pass has been queued but not yet started)
40+
// Queued states for the next iteration (if an iteration has been scheduled but not yet started)
4141
const queuedStates: Map<string, IOperationExecutionState> = new Map();
4242

4343
let buildStatus: ReadableOperationStatus = 'Ready';
@@ -85,12 +85,12 @@ socket.addEventListener('message', (ev) => {
8585
// Manager state only – no operation arrays here
8686
break;
8787
}
88-
case 'pass-queued': {
88+
case 'iteration-scheduled': {
8989
applyQueuedStates(msg.queuedStates);
9090
break;
9191
}
9292
case 'before-execute': {
93-
// Start of a pass: queuedStates become irrelevant until a new pass is queued
93+
// Start of an iteration: queuedStates become irrelevant until a new iteration is scheduled
9494
applyQueuedStates(undefined);
9595
upsertExecutionStates(msg.executionStates);
9696
buildStatus = 'Executing';

rush-plugins/rush-serve-plugin/src/api.types.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ export interface IOperationExecutionState {
8080
name: string;
8181

8282
/**
83-
* Indicates whether this operation is scheduled to actually run in the current execution pass.
83+
* Indicates whether this operation is scheduled to actually run in the current execution iteration.
8484
* This is derived from the scheduler's decision (the execution record's `enabled` boolean), which
8585
* takes into account the configured enabled state plus change detection and dependency invalidation.
8686
*/
87-
runInThisPass: boolean;
87+
runInThisIteration: boolean;
8888

8989
/**
9090
* If true, this operation currently owns some kind of active resource (e.g. a service or a watch process).
@@ -128,18 +128,18 @@ export interface IRushSessionInfo {
128128
}
129129

130130
/**
131-
* Message sent to a WebSocket client at the start of an execution pass.
131+
* Message sent to a WebSocket client at the start of an execution iteration.
132132
*/
133133
// Event (server->client) message interfaces (alphabetically by interface name)
134134
/**
135-
* Message sent to a WebSocket client at the end of an execution pass.
135+
* Message sent to a WebSocket client at the end of an execution iteration.
136136
*/
137137
export interface IWebSocketAfterExecuteEventMessage {
138138
event: 'after-execute';
139139
executionStates: IOperationExecutionState[];
140140
status: ReadableOperationStatus;
141141
/**
142-
* The results of the previous execution pass for all operations, if available.
142+
* The results of the previous execution iteration for all operations, if available.
143143
* This mirrors the values() of OperationExecutionManager.lastExecutionResults at the time of emission.
144144
*/
145145
lastExecutionResults?: IOperationExecutionState[];
@@ -189,9 +189,9 @@ export interface IWebSocketSyncEventMessage {
189189
parallelism: number;
190190
debugMode: boolean;
191191
verbose: boolean;
192-
runNextPassBehavior: 'automatic' | 'manual';
192+
pauseNextIteration: boolean;
193193
status: ReadableOperationStatus;
194-
hasQueuedPass: boolean;
194+
hasScheduledIteration: boolean;
195195
};
196196
/**
197197
* The results of the previous execution pass for all operations, if available.
@@ -209,10 +209,10 @@ export interface IWebSocketSyncOperationsEventMessage {
209209
}
210210

211211
/**
212-
* Message sent when a pass is queued with its initial set of queued operations.
212+
* Message sent when an iteration is queued with its initial set of queued operations.
213213
*/
214214
export interface IWebSocketPassQueuedEventMessage {
215-
event: 'pass-queued';
215+
event: 'iteration-scheduled';
216216
queuedStates: IOperationExecutionState[];
217217
}
218218

@@ -321,12 +321,12 @@ export interface IWebSocketSetParallelismCommandMessage {
321321
}
322322

323323
/**
324-
* Message received from a WebSocket client to set how new execution passes are triggered after invalidations.
325-
* 'automatic' runs new passes automatically; 'manual' requires an explicit execute command.
324+
* Message received from a WebSocket client to set whether new execution iterations are paused when scheduled.
325+
* A value of true means iterations are paused (manual mode); false means iterations run automatically.
326326
*/
327-
export interface IWebSocketSetRunNextPassBehaviorCommandMessage {
328-
command: 'set-run-next-pass-behavior';
329-
value: 'automatic' | 'manual';
327+
export interface IWebSocketSetPauseNextIterationCommandMessage {
328+
command: 'set-pause-next-iteration';
329+
value: boolean;
330330
}
331331

332332
/**
@@ -361,6 +361,6 @@ export type IWebSocketCommandMessage =
361361
| IWebSocketSetDebugCommandMessage
362362
| IWebSocketSetEnabledStatesCommandMessage
363363
| IWebSocketSetParallelismCommandMessage
364-
| IWebSocketSetRunNextPassBehaviorCommandMessage
364+
| IWebSocketSetPauseNextIterationCommandMessage
365365
| IWebSocketSetVerboseCommandMessage
366366
| IWebSocketSyncCommandMessage;

rush-plugins/rush-serve-plugin/src/tryEnableBuildStatusWebSocketServer.ts

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import {
1414
OperationStatus,
1515
type ILogFilePaths,
1616
type RushConfiguration,
17-
type IOperationExecutionManager
17+
type IOperationExecutionManager,
18+
type IOperationExecutionIterationOptions
1819
} from '@rushstack/rush-sdk';
1920
import { type ITerminalChunk, TerminalChunkKind, TerminalWritable } from '@rushstack/terminal';
2021

@@ -183,7 +184,7 @@ export function tryEnableBuildStatusWebSocketServer(
183184
const { packageName } = associatedProject;
184185
return {
185186
name,
186-
runInThisPass: record.enabled,
187+
runInThisIteration: record.enabled,
187188
isActive: !!runner.isActive,
188189
status: readableStatusFromStatus[record.status],
189190
startTime: record.stopwatch.startTime,
@@ -242,9 +243,9 @@ export function tryEnableBuildStatusWebSocketServer(
242243
parallelism: executionManager.parallelism,
243244
debugMode: executionManager.debugMode,
244245
verbose: !executionManager.quietMode,
245-
runNextPassBehavior: executionManager.runNextPassBehavior,
246+
pauseNextIteration: executionManager.pauseNextIteration,
246247
status: buildStatus,
247-
hasQueuedPass: executionManager.hasQueuedPass
248+
hasScheduledIteration: executionManager.hasScheduledIteration
248249
};
249250
}
250251

@@ -261,9 +262,9 @@ export function tryEnableBuildStatusWebSocketServer(
261262
parallelism: 1,
262263
debugMode: false,
263264
verbose: true,
264-
runNextPassBehavior: 'automatic',
265+
pauseNextIteration: false,
265266
status: buildStatus,
266-
hasQueuedPass: false
267+
hasScheduledIteration: false
267268
},
268269
lastExecutionResults: executionManager
269270
? convertToExecutionStateArray(executionManager.lastExecutionResults.values())
@@ -278,10 +279,13 @@ export function tryEnableBuildStatusWebSocketServer(
278279

279280
manager.addTerminalDestination(new WebSocketTerminalWritable(webSockets));
280281

281-
hooks.beforeExecuteOperationsAsync.tap(
282+
hooks.beforeExecuteIterationAsync.tap(
282283
PLUGIN_NAME,
283-
(operationsToExecute: ReadonlyMap<Operation, IOperationExecutionResult>): void => {
284-
// Clear queuedStates when the pass begins executing
284+
(
285+
operationsToExecute: ReadonlyMap<Operation, IOperationExecutionResult>,
286+
iterationOptions: IOperationExecutionIterationOptions
287+
): void => {
288+
// Clear queuedStates when the iteration begins executing
285289
queuedStates = undefined;
286290
for (const [operation, result] of operationsToExecute) {
287291
operationStates.set(operation.name, result);
@@ -296,7 +300,7 @@ export function tryEnableBuildStatusWebSocketServer(
296300
}
297301
);
298302

299-
hooks.afterExecuteOperationsAsync.tap(
303+
hooks.afterExecuteIterationAsync.tap(
300304
PLUGIN_NAME,
301305
(
302306
status: OperationStatus,
@@ -332,13 +336,13 @@ export function tryEnableBuildStatusWebSocketServer(
332336
}
333337
);
334338

335-
// Capture queued operations for next pass
336-
hooks.onPassQueued.tap(
339+
// Capture queued operations for next iteration
340+
hooks.onIterationScheduled.tap(
337341
PLUGIN_NAME,
338342
(queuedMap: ReadonlyMap<Operation, IOperationExecutionResult>): void => {
339343
queuedStates = Array.from(queuedMap.values());
340344
const message: IWebSocketPassQueuedEventMessage = {
341-
event: 'pass-queued',
345+
event: 'iteration-scheduled',
342346
queuedStates: convertToExecutionStateArray(queuedStates)
343347
};
344348
sendWebSocketMessage(message);
@@ -441,7 +445,7 @@ export function tryEnableBuildStatusWebSocketServer(
441445
}
442446

443447
case 'abort-execution': {
444-
void executionManager?.abortCurrentPassAsync();
448+
void executionManager?.abortCurrentIterationAsync();
445449
break;
446450
}
447451

@@ -457,8 +461,8 @@ export function tryEnableBuildStatusWebSocketServer(
457461
case 'execute': {
458462
if (executionManager) {
459463
const definedExecutionManager: IOperationExecutionManager = executionManager;
460-
void definedExecutionManager.queuePassAsync({}).then(() => {
461-
return definedExecutionManager.executeQueuedPassAsync();
464+
void definedExecutionManager.scheduleIterationAsync({}).then(() => {
465+
return definedExecutionManager.executeScheduledIterationAsync();
462466
});
463467
}
464468
break;
@@ -474,12 +478,9 @@ export function tryEnableBuildStatusWebSocketServer(
474478
break;
475479
}
476480

477-
case 'set-run-next-pass-behavior': {
478-
if (
479-
executionManager &&
480-
(parsedMessage.value === 'automatic' || parsedMessage.value === 'manual')
481-
) {
482-
executionManager.runNextPassBehavior = parsedMessage.value;
481+
case 'set-pause-next-iteration': {
482+
if (executionManager && typeof parsedMessage.value === 'boolean') {
483+
executionManager.pauseNextIteration = parsedMessage.value;
483484
}
484485
break;
485486
}

0 commit comments

Comments
 (0)