Skip to content

Commit b93cdf9

Browse files
committed
Revert "Clean the apply output shown for resources that failed validation"
Plugin-core keeps the final state of redrawn lines instead, and the CLI always uses the latest plugins, so the CLI doesn't need its own cleanup. This reverts commit 0343d13. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016QnBk4RvQciZeR9jSeEZnf
1 parent 0343d13 commit b93cdf9

5 files changed

Lines changed: 13 additions & 81 deletions

File tree

‎src/plugins/command-output-monitor.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { stripVTControlCharacters } from 'node:util';
22

33
import { ctx, Event } from '../events/context.js';
4-
import { lastSegment } from '../utils/command-log.js';
54
import { VerbosityLevel } from '../utils/verbosity-level.js';
65
import type { RunningCommand } from './running-command.js';
76

@@ -321,3 +320,13 @@ class WatchedResource {
321320
});
322321
}
323322
}
323+
324+
/** Text after the last carriage return: what a terminal shows for progress bars that redraw a line */
325+
function lastSegment(line: string): string {
326+
const segments = line.split('\r');
327+
for (let i = segments.length - 1; i >= 0; i--) {
328+
if (segments[i].trim()) return segments[i];
329+
}
330+
331+
return '';
332+
}

‎src/ui/components/widgets/ApplyComplete.tsx‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { ApplyResult } from '../../../entities/apply-result.js';
66
import { ResourcePlan } from '../../../entities/plan.js';
77
import { formatDuration } from '../../../utils/duration.js';
88
import { applyEntryInkColor, applyEntryLabel } from '../../apply-result-formatter.js';
9-
import { cleanCommandLog } from '../../../utils/command-log.js';
109
import { prettyFormatResourcePlan } from '../../plan-pretty-printer.js';
1110
import { NoticeList } from './NoticeList.js';
1211

@@ -18,7 +17,7 @@ export function ApplyComplete({ result }: { result: ApplyResult }) {
1817
.filter((e) => e.errorData.errorType === 'apply_validation')
1918
.map((e) => ({
2019
plan: new ResourcePlan((e.errorData.data as any).plan),
21-
logs: cleanCommandLog((e.errorData.data as any).logs ?? []),
20+
logs: ((e.errorData.data as any).logs ?? []) as string[],
2221
}))
2322
: [];
2423

‎src/ui/plugin-error-formatter.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import { PluginError } from '../common/errors.js';
22
import { ResourcePlan } from '../entities/plan.js';
3-
import { cleanCommandLog } from '../utils/command-log.js';
43
import { prettyFormatResourcePlan } from './plan-pretty-printer.js';
54

65
export function formatApplyValidationError(error: PluginError): string {
76
const plan = new ResourcePlan((error.errorData.data as any).plan);
8-
const logs = cleanCommandLog((error.errorData.data as any).logs ?? []);
7+
const logs: string[] = (error.errorData.data as any).logs ?? [];
98
return [
109
`Apply validation failed: resource "${plan.id}" did not reach its desired state.`,
1110
'Changes still needed:',
1211
prettyFormatResourcePlan(plan),
13-
...(logs.length > 0 ? ['', 'Apply output:', logs.join('\n')] : []),
12+
...(logs.length > 0 ? ['', `Last ${logs.length} log lines:`, logs.join('\n')] : []),
1413
].join('\n');
1514
}

‎src/utils/command-log.test.ts‎

Lines changed: 0 additions & 28 deletions
This file was deleted.

‎src/utils/command-log.ts‎

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)