Skip to content

Commit 2a8277b

Browse files
committed
refactor(workflow): remove disabled prop from history view and add orderIndex to events
test(event-bus): add orderIndex to test event payloads refactor(history): simplify navigation by removing disabled check docs(steps): add debug logs for resume index calculation
1 parent 1f137d5 commit 2a8277b

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

src/cli/tui/routes/workflow/components/modals/history/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import { AgentMonitorService } from "../../../../../../../agents/monitoring/inde
1717
export interface HistoryViewProps {
1818
onClose: () => void
1919
onOpenLogViewer: (monitoringId: number) => void
20-
disabled?: boolean
2120
initialSelectedIndex?: number
2221
onSelectedIndexChange?: (index: number) => void
2322
}
@@ -63,9 +62,9 @@ export function HistoryView(props: HistoryViewProps) {
6362
onOpenLogViewer: props.onOpenLogViewer,
6463
onClearHistory: handleClearHistory,
6564
onScrollToIndex: handleScrollToIndex,
66-
disabled: () => props.disabled ?? false,
6765
})
6866

67+
6968
// Sync selection when user scrolls manually with mouse
7069
createEffect(() => {
7170
const ref = scrollRef()

src/cli/tui/routes/workflow/components/modals/history/use-history-navigation.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export interface UseHistoryNavigationOptions {
1616
onOpenLogViewer: (monitoringId: number) => void
1717
onClearHistory?: () => void
1818
onScrollToIndex?: (index: number) => void
19-
disabled?: () => boolean
2019
}
2120

2221
export function useHistoryNavigation(options: UseHistoryNavigationOptions) {
@@ -60,8 +59,6 @@ export function useHistoryNavigation(options: UseHistoryNavigationOptions) {
6059
}
6160

6261
useKeyboard((evt) => {
63-
if (options.disabled?.()) return
64-
6562
if (evt.name === "h" || evt.name === "escape") {
6663
evt.preventDefault()
6764
options.onClose()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ export function WorkflowShell(props: WorkflowShellProps) {
396396

397397
<Show when={modals.isHistoryActive()}>
398398
<box position="absolute" left={0} top={0} width="100%" height="100%" zIndex={1000} backgroundColor={themeCtx.theme.background}>
399-
<HistoryView onClose={() => modals.setShowHistory(false)} onOpenLogViewer={(id) => { modals.setHistoryLogViewerMonitoringId(id); modals.setShowHistory(false) }} disabled={isCheckpointActive() || isWaitingForInput()} initialSelectedIndex={modals.historySelectedIndex()} onSelectedIndexChange={modals.setHistorySelectedIndex} />
399+
<HistoryView onClose={() => modals.setShowHistory(false)} onOpenLogViewer={(id) => { modals.setHistoryLogViewerMonitoringId(id); modals.setShowHistory(false) }} initialSelectedIndex={modals.historySelectedIndex()} onSelectedIndexChange={modals.setHistorySelectedIndex} />
400400
</box>
401401
</Show>
402402

src/shared/workflows/steps.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { readFile, writeFile } from 'node:fs/promises';
22
import { existsSync } from 'node:fs';
33
import * as path from 'node:path';
44
import type { StepData } from './template.js';
5+
import { debug } from '../logging/logger.js';
56

67
const TEMPLATE_TRACKING_FILE = 'template.json';
78

@@ -301,20 +302,26 @@ export async function clearNotCompletedSteps(cmRoot: string): Promise<void> {
301302
export async function getResumeStartIndex(cmRoot: string): Promise<number> {
302303
const { data } = await readTrackingData(cmRoot);
303304

305+
debug('[getResumeStartIndex] data: %O', { resumeFromLastStep: data.resumeFromLastStep, notCompletedSteps: data.notCompletedSteps });
306+
304307
// Check if resume feature is enabled
305308
if (!data.resumeFromLastStep) {
309+
debug('[getResumeStartIndex] resumeFromLastStep is false, returning 0');
306310
return 0;
307311
}
308312

309313
// First check for incomplete chains
310314
const chainResumeInfo = await getChainResumeInfo(cmRoot);
311315
if (chainResumeInfo) {
316+
debug('[getResumeStartIndex] Found chain resume, returning %d', chainResumeInfo.stepIndex);
312317
return chainResumeInfo.stepIndex;
313318
}
314319

315320
// Check notCompletedSteps (crash recovery)
316321
if (data.notCompletedSteps && data.notCompletedSteps.length > 0) {
317-
return Math.min(...data.notCompletedSteps);
322+
const startIndex = Math.min(...data.notCompletedSteps);
323+
debug('[getResumeStartIndex] notCompletedSteps=%O, starting at %d', data.notCompletedSteps, startIndex);
324+
return startIndex;
318325
}
319326

320327
// Check completedSteps - if all steps done, start after the last one

src/workflows/events/__tests__/event-bus.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ describe('WorkflowEventBus', () => {
7171
stepIndex: 0,
7272
totalSteps: 3,
7373
status: 'pending',
74+
orderIndex: 0,
7475
},
7576
});
7677
});
@@ -201,6 +202,7 @@ describe('Integration: Event Flow', () => {
201202
stepIndex: 0,
202203
totalSteps: 3,
203204
status: 'pending',
205+
orderIndex: 0,
204206
},
205207
});
206208

@@ -213,6 +215,7 @@ describe('Integration: Event Flow', () => {
213215
stepIndex: 1,
214216
totalSteps: 3,
215217
status: 'pending',
218+
orderIndex: 1,
216219
},
217220
});
218221

0 commit comments

Comments
 (0)