Skip to content

Commit 0d11b41

Browse files
committed
Revert "feat: add --verbose flag to workflow status command"
This reverts commit c68608b.
1 parent 37a6462 commit 0d11b41

2 files changed

Lines changed: 22 additions & 73 deletions

File tree

packages/cli/src/commands/workflow.test.ts

Lines changed: 10 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,8 @@ describe('workflowStatusCommand', () => {
934934
},
935935
]);
936936

937+
const startTime = new Date(Date.now() - 25 * 1000).toISOString();
938+
const endTime = new Date(Date.now() - 15 * 1000).toISOString();
937939
(workflowEventsDb.listWorkflowEvents as ReturnType<typeof mock>).mockResolvedValueOnce([
938940
{
939941
id: 'e1',
@@ -942,16 +944,16 @@ describe('workflowStatusCommand', () => {
942944
step_name: 'plan',
943945
step_index: null,
944946
data: {},
945-
created_at: new Date().toISOString(),
947+
created_at: startTime,
946948
},
947949
{
948950
id: 'e2',
949951
workflow_run_id: 'run-verbose',
950952
event_type: 'node_completed',
951953
step_name: 'plan',
952954
step_index: null,
953-
data: { node_output: 'Plan output here', duration_ms: 5000 },
954-
created_at: new Date().toISOString(),
955+
data: { node_output: 'Plan output here' },
956+
created_at: endTime,
955957
},
956958
]);
957959

@@ -961,7 +963,6 @@ describe('workflowStatusCommand', () => {
961963
expect(calls.some(c => c.includes('Nodes:'))).toBe(true);
962964
expect(calls.some(c => c.includes('✓') && c.includes('plan'))).toBe(true);
963965
expect(calls.some(c => c.includes('Plan output here'))).toBe(true);
964-
expect(calls.some(c => c.includes('Total:'))).toBe(true);
965966
});
966967

967968
it('should show error message for failed node in verbose mode', async () => {
@@ -978,6 +979,8 @@ describe('workflowStatusCommand', () => {
978979
},
979980
]);
980981

982+
const startTime = new Date(Date.now() - 20 * 1000).toISOString();
983+
const endTime = new Date(Date.now() - 10 * 1000).toISOString();
981984
(workflowEventsDb.listWorkflowEvents as ReturnType<typeof mock>).mockResolvedValueOnce([
982985
{
983986
id: 'e3',
@@ -986,16 +989,16 @@ describe('workflowStatusCommand', () => {
986989
step_name: 'implement',
987990
step_index: null,
988991
data: {},
989-
created_at: new Date().toISOString(),
992+
created_at: startTime,
990993
},
991994
{
992995
id: 'e4',
993996
workflow_run_id: 'run-failed',
994997
event_type: 'node_failed',
995998
step_name: 'implement',
996999
step_index: null,
997-
data: { error: 'Compilation failed', duration_ms: 3000 },
998-
created_at: new Date().toISOString(),
1000+
data: { error: 'Compilation failed' },
1001+
created_at: endTime,
9991002
},
10001003
]);
10011004

@@ -1006,51 +1009,6 @@ describe('workflowStatusCommand', () => {
10061009
expect(calls.some(c => c.includes('Compilation failed'))).toBe(true);
10071010
});
10081011

1009-
it('should truncate output at word boundary in verbose mode', async () => {
1010-
const workflowDb = await import('@archon/core/db/workflows');
1011-
const workflowEventsDb = await import('@archon/core/db/workflow-events');
1012-
1013-
(workflowDb.listWorkflowRuns as ReturnType<typeof mock>).mockResolvedValueOnce([
1014-
{
1015-
id: 'run-truncate',
1016-
workflow_name: 'implement',
1017-
working_path: '/path/to/worktree',
1018-
status: 'running',
1019-
started_at: new Date(Date.now() - 5 * 1000),
1020-
},
1021-
]);
1022-
1023-
// Build a 210-char string with spaces every 5 chars: "aaaaa bbbbb ccccc ..."
1024-
const words = Array.from({ length: 42 }, (_, i) =>
1025-
String.fromCharCode(97 + (i % 26)).repeat(5)
1026-
);
1027-
const longOutput = words.join(' '); // 5*42 + 41 spaces = 251 chars total
1028-
1029-
(workflowEventsDb.listWorkflowEvents as ReturnType<typeof mock>).mockResolvedValueOnce([
1030-
{
1031-
id: 'e-trunc',
1032-
workflow_run_id: 'run-truncate',
1033-
event_type: 'node_completed',
1034-
step_name: 'plan',
1035-
step_index: null,
1036-
data: { node_output: longOutput, duration_ms: 1000 },
1037-
created_at: new Date().toISOString(),
1038-
},
1039-
]);
1040-
1041-
await workflowStatusCommand(false, true);
1042-
1043-
const calls = consoleSpy.mock.calls.map((c: unknown[]) => String(c[0]));
1044-
const outputLine = calls.find(c => c.includes('Output:')) ?? '';
1045-
const preview = outputLine.replace(/^\s*Output:\s*/, '');
1046-
// Must end with '...' (was truncated)
1047-
expect(preview.endsWith('...')).toBe(true);
1048-
// The cut must be at a word boundary: char in original at cut position must be a space
1049-
const previewText = preview.slice(0, -3); // remove trailing '...'
1050-
const cutPos = previewText.length;
1051-
expect(longOutput[cutPos]).toBe(' '); // original char right after cut is a space
1052-
});
1053-
10541012
it('should not show nodes section when no events in verbose mode', async () => {
10551013
const workflowDb = await import('@archon/core/db/workflows');
10561014
const workflowEventsDb = await import('@archon/core/db/workflow-events');

packages/cli/src/commands/workflow.ts

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -588,18 +588,6 @@ function formatDuration(ms: number): string {
588588
return `${String(mins)}m${String(remSecs)}s`;
589589
}
590590

591-
/**
592-
* Truncate text at the last word boundary at or before maxLen, appending '...'.
593-
* Falls back to a hard cut at maxLen if no space is found in range.
594-
*/
595-
function truncateAtWordBoundary(text: string, maxLen: number): string {
596-
if (text.length <= maxLen) return text;
597-
const slice = text.slice(0, maxLen);
598-
const lastSpace = slice.lastIndexOf(' ');
599-
const cut = lastSpace > 0 ? lastSpace : maxLen;
600-
return text.slice(0, cut) + '...';
601-
}
602-
603591
interface NodeSummary {
604592
nodeId: string;
605593
state: 'running' | 'completed' | 'failed' | 'skipped';
@@ -613,6 +601,7 @@ interface NodeSummary {
613601
* Processes node_started / node_completed / node_failed / node_skipped* events.
614602
*/
615603
function buildNodeSummaries(events: WorkflowEventRow[]): NodeSummary[] {
604+
const startTimes = new Map<string, number>();
616605
const summaries = new Map<string, NodeSummary>();
617606

618607
for (const event of events) {
@@ -621,29 +610,35 @@ function buildNodeSummaries(events: WorkflowEventRow[]): NodeSummary[] {
621610

622611
switch (event.event_type) {
623612
case 'node_started': {
613+
startTimes.set(nodeId, new Date(event.created_at).getTime());
624614
if (!summaries.has(nodeId)) {
625615
summaries.set(nodeId, { nodeId, state: 'running' });
626616
}
627617
break;
628618
}
629619
case 'node_completed': {
620+
const started = startTimes.get(nodeId);
621+
const endTime = new Date(event.created_at).getTime();
630622
const rawOutput = event.data.node_output;
631623
const output = typeof rawOutput === 'string' ? rawOutput : undefined;
632-
const rawDuration = event.data.duration_ms;
633624
summaries.set(nodeId, {
634625
nodeId,
635626
state: 'completed',
636-
durationMs: typeof rawDuration === 'number' ? rawDuration : undefined,
637-
outputPreview: output !== undefined ? truncateAtWordBoundary(output, 200) : undefined,
627+
durationMs: started !== undefined ? endTime - started : undefined,
628+
outputPreview:
629+
output !== undefined
630+
? output.slice(0, 200) + (output.length > 200 ? '...' : '')
631+
: undefined,
638632
});
639633
break;
640634
}
641635
case 'node_failed': {
642-
const rawDuration = event.data.duration_ms;
636+
const started = startTimes.get(nodeId);
637+
const endTime = new Date(event.created_at).getTime();
643638
summaries.set(nodeId, {
644639
nodeId,
645640
state: 'failed',
646-
durationMs: typeof rawDuration === 'number' ? rawDuration : undefined,
641+
durationMs: started !== undefined ? endTime - started : undefined,
647642
error: typeof event.data.error === 'string' ? event.data.error : 'Unknown error',
648643
});
649644
break;
@@ -754,10 +749,6 @@ export async function workflowStatusCommand(json?: boolean, verbose?: boolean):
754749
console.log(` Error: ${node.error}`);
755750
}
756751
}
757-
const totalMs = nodes.reduce((sum, n) => sum + (n.durationMs ?? 0), 0);
758-
if (totalMs > 0) {
759-
console.log(` Total: ${formatDuration(totalMs)}`);
760-
}
761752
}
762753
}
763754

0 commit comments

Comments
 (0)