Skip to content

Commit 1a54287

Browse files
committed
refactor(workflow): rename 'waiting' state to 'awaiting' for clarity
Update all references to the workflow state 'waiting' to 'awaiting' to better reflect its purpose of awaiting user input. This includes state machine transitions, status checks, and UI components.
1 parent 7cc1cfc commit 1a54287

File tree

10 files changed

+39
-27
lines changed

10 files changed

+39
-27
lines changed

src/cli/tui/routes/workflow/adapters/opentui.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export interface UIActions {
4242
batchAddSubAgents(parentId: string, subAgents: SubAgentState[]): void
4343
updateSubAgentStatus(subAgentId: string, status: AgentStatus): void
4444
clearSubAgents(parentId: string): void
45-
setWorkflowStatus(status: "running" | "stopping" | "completed" | "stopped" | "checkpoint" | "paused" | "error"): void
45+
setWorkflowStatus(status: "running" | "stopping" | "completed" | "stopped" | "awaiting" | "paused" | "error"): void
4646
setCheckpointState(checkpoint: { active: boolean; reason?: string } | null): void
4747
setInputState(inputState: InputState | null): void
4848
/** @deprecated Use setInputState instead */

src/cli/tui/routes/workflow/components/output/telemetry-bar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export function TelemetryBar(props: TelemetryBarProps) {
5050
return formatTokens(newTokensIn, props.total.tokensOut)
5151
}
5252

53-
const showStatus = () => props.status === "checkpoint" || props.status === "paused" || props.status === "stopped"
53+
const showStatus = () => props.status === "awaiting" || props.status === "paused" || props.status === "stopped"
5454

5555
const statusColor = () => {
5656
switch (props.status) {
@@ -61,7 +61,7 @@ export function TelemetryBar(props: TelemetryBarProps) {
6161

6262
const statusText = () => {
6363
switch (props.status) {
64-
case "checkpoint": return "Checkpoint"
64+
case "awaiting": return "Awaiting"
6565
case "paused": return "Paused"
6666
case "stopped": return "Stopped"
6767
default: return ""

src/cli/tui/routes/workflow/components/timeline/status-utils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ export function getStatusIcon(status: AgentStatus): string {
2525
return "●" // Filled circle
2626
case "retrying":
2727
return "⟳" // Retry symbol
28-
case "checkpoint":
29-
return "◉" // Waiting for input
28+
case "awaiting":
29+
return "◉" // Awaiting user input
3030
case "paused":
3131
return "॥" // Paused
3232
default:
@@ -48,8 +48,8 @@ export function getStatusColor(status: AgentStatus, theme: Theme): RGBA {
4848
return theme.error // red for failed
4949
case "skipped":
5050
return theme.textMuted // gray/muted for skipped
51-
case "checkpoint":
52-
return theme.warning // yellow for waiting
51+
case "awaiting":
52+
return theme.warning // yellow for awaiting
5353
case "paused":
5454
return theme.warning // yellow for paused
5555
default:

src/cli/tui/routes/workflow/context/ui-state/actions/workflow-actions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function createWorkflowActions(ctx: WorkflowActionsContext) {
2828
const state = ctx.getState()
2929
ctx.setState({ ...state, checkpointState: checkpoint })
3030
if (checkpoint && checkpoint.active) {
31-
setWorkflowStatus("checkpoint")
31+
setWorkflowStatus("awaiting")
3232
} else {
3333
setWorkflowStatus("running")
3434
}

src/cli/tui/routes/workflow/state/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export type AgentStatus =
88
| "skipped"
99
| "retrying"
1010
| "paused"
11-
| "checkpoint"
11+
| "awaiting"
1212

1313
export interface AgentTelemetry {
1414
tokensIn: number
@@ -56,7 +56,7 @@ export interface LoopState {
5656
reason?: string
5757
}
5858

59-
export type WorkflowStatus = "running" | "stopping" | "completed" | "stopped" | "checkpoint" | "paused" | "error"
59+
export type WorkflowStatus = "running" | "stopping" | "completed" | "stopped" | "awaiting" | "paused" | "error"
6060

6161
export interface CheckpointState {
6262
active: boolean

src/cli/tui/routes/workflow/workflow-shell.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ export function WorkflowShell(props: WorkflowShellProps) {
6161
case "stopped":
6262
toast.show({ variant: "error", message: "Stopped by user", duration: 3000 })
6363
break
64-
case "checkpoint":
65-
toast.show({ variant: "warning", message: "Checkpoint - Review Required", duration: 5000 })
64+
case "awaiting":
65+
toast.show({ variant: "warning", message: "Awaiting - Input Required", duration: 5000 })
6666
break
6767
}
6868
}
@@ -251,7 +251,7 @@ export function WorkflowShell(props: WorkflowShellProps) {
251251
// Check if output window is showing the active agent (running or at checkpoint)
252252
const isShowingRunningAgent = createMemo(() => {
253253
const s = state()
254-
const active = s.agents.find((a) => a.status === "running" || a.status === "checkpoint")
254+
const active = s.agents.find((a) => a.status === "running" || a.status === "awaiting")
255255
if (!active) return false
256256
// If no explicit selection, we're showing the active agent
257257
if (!s.selectedAgentId) return true

src/workflows/execution/runner.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ export class WorkflowRunner {
157157
// If in waiting state, let the provider's listener handle it
158158
// The provider will return __SWITCH_TO_AUTO__ or __SWITCH_TO_MANUAL__
159159
// and handleWaiting() will call setAutoMode()
160-
if (this.machine.state === 'waiting') {
161-
debug('[Runner] In waiting state, provider will handle mode switch');
160+
if (this.machine.state === 'awaiting') {
161+
debug('[Runner] In awaiting state, provider will handle mode switch');
162162
return;
163163
}
164164
// In other states (running, idle), set auto mode directly
@@ -200,7 +200,7 @@ export class WorkflowRunner {
200200

201201
if (state === 'running') {
202202
await this.executeCurrentStep();
203-
} else if (state === 'waiting') {
203+
} else if (state === 'awaiting') {
204204
await this.handleWaiting();
205205
}
206206
}
@@ -247,7 +247,7 @@ export class WorkflowRunner {
247247
this.emitter.registerMonitoringId(uniqueAgentId, stepData.monitoringId);
248248
}
249249

250-
this.emitter.updateAgentStatus(uniqueAgentId, 'checkpoint');
250+
this.emitter.updateAgentStatus(uniqueAgentId, 'awaiting');
251251
this.emitter.logMessage(uniqueAgentId, '═'.repeat(80));
252252
this.emitter.logMessage(uniqueAgentId, `${step.agentName} resumed - waiting for input.`);
253253

@@ -347,7 +347,7 @@ export class WorkflowRunner {
347347
// In auto mode, keep status as 'running' - controller will run next
348348
// In manual mode, show checkpoint - waiting for user input
349349
if (!this.machine.context.autoMode) {
350-
this.emitter.updateAgentStatus(uniqueAgentId, 'checkpoint');
350+
this.emitter.updateAgentStatus(uniqueAgentId, 'awaiting');
351351
debug('[Runner] Agent at checkpoint, waiting for user input');
352352
} else {
353353
debug('[Runner] Auto mode - keeping status as running for controller');
@@ -387,6 +387,18 @@ export class WorkflowRunner {
387387
debug('[Runner] Handling waiting state, autoMode=%s, promptQueue=%d items, queueIndex=%d',
388388
ctx.autoMode, ctx.promptQueue.length, ctx.promptQueueIndex);
389389

390+
// No chained prompts - auto-advance to next step
391+
if (ctx.promptQueue.length === 0) {
392+
debug('[Runner] No chained prompts, auto-advancing to next step');
393+
const step = this.moduleSteps[ctx.currentStepIndex];
394+
const uniqueAgentId = `${step.agentId}-step-${ctx.currentStepIndex}`;
395+
this.emitter.logMessage(uniqueAgentId, `${step.agentName} has completed their work.`);
396+
this.emitter.logMessage(uniqueAgentId, '\n' + '═'.repeat(80) + '\n');
397+
await markStepCompleted(this.cmRoot, ctx.currentStepIndex);
398+
this.machine.send({ type: 'INPUT_RECEIVED', input: '' });
399+
return;
400+
}
401+
390402
// Build input context
391403
const inputContext: InputContext = {
392404
stepOutput: ctx.currentOutput ?? { output: '' },
@@ -409,7 +421,7 @@ export class WorkflowRunner {
409421
// Now show checkpoint since we're waiting for user input
410422
const step = this.moduleSteps[ctx.currentStepIndex];
411423
const uniqueAgentId = `${step.agentId}-step-${ctx.currentStepIndex}`;
412-
this.emitter.updateAgentStatus(uniqueAgentId, 'checkpoint');
424+
this.emitter.updateAgentStatus(uniqueAgentId, 'awaiting');
413425
// Re-run waiting with user input
414426
return;
415427
}
@@ -536,7 +548,7 @@ export class WorkflowRunner {
536548
ctx.currentMonitoringId = output.monitoringId;
537549

538550
// Back to checkpoint while waiting for next input
539-
this.emitter.updateAgentStatus(uniqueAgentId, 'checkpoint');
551+
this.emitter.updateAgentStatus(uniqueAgentId, 'awaiting');
540552

541553
// Stay in waiting state - will get more input
542554
// (The waiting handler will be called again)
@@ -545,7 +557,7 @@ export class WorkflowRunner {
545557
// Handle mode switch during execution
546558
if (modeSwitchRequested) {
547559
debug('[Runner] Step aborted due to mode switch to %s', modeSwitchRequested);
548-
this.emitter.updateAgentStatus(uniqueAgentId, 'checkpoint');
560+
this.emitter.updateAgentStatus(uniqueAgentId, 'awaiting');
549561
await this.setAutoMode(modeSwitchRequested === 'auto');
550562
}
551563
// Behavior (pause) already handled everything else

src/workflows/input/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export interface InputProvider {
5252

5353
/**
5454
* Get input for the next step
55-
* Called when workflow enters 'waiting' state
55+
* Called when workflow enters 'awaiting' state
5656
*/
5757
getInput(context: InputContext): Promise<InputResult>;
5858

src/workflows/state/machine.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export function createWorkflowMachine(initialContext: Partial<WorkflowContext> =
149149
},
150150
on: {
151151
STEP_COMPLETE: {
152-
target: 'waiting',
152+
target: 'awaiting',
153153
action: (ctx, event) => {
154154
if (event.type === 'STEP_COMPLETE') {
155155
ctx.currentOutput = event.output;
@@ -186,7 +186,7 @@ export function createWorkflowMachine(initialContext: Partial<WorkflowContext> =
186186
},
187187
],
188188
PAUSE: {
189-
target: 'waiting',
189+
target: 'awaiting',
190190
action: (ctx) => {
191191
// Pause forces manual mode
192192
ctx.autoMode = false;
@@ -199,9 +199,9 @@ export function createWorkflowMachine(initialContext: Partial<WorkflowContext> =
199199
},
200200
},
201201

202-
waiting: {
202+
awaiting: {
203203
onEnter: (ctx) => {
204-
debug('[FSM] Entering waiting state, autoMode: %s', ctx.autoMode);
204+
debug('[FSM] Entering awaiting state, autoMode: %s', ctx.autoMode);
205205
},
206206
on: {
207207
INPUT_RECEIVED: [

src/workflows/state/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type { ModuleStep } from '../templates/types.js';
1313
export type WorkflowState =
1414
| 'idle' // Not started
1515
| 'running' // Agent executing (input disabled)
16-
| 'waiting' // Waiting for input (input enabled)
16+
| 'awaiting' // Awaiting user input (input enabled)
1717
| 'completed' // All steps done
1818
| 'stopped' // User stopped
1919
| 'error'; // Fatal error

0 commit comments

Comments
 (0)