Skip to content

Commit 1ff0472

Browse files
committed
feat(agent): refine output rendering by cleaning excessive newlines and optimizing line breaks #453
1 parent b24a9a2 commit 1ff0472

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

mpp-ui/src/jsMain/typescript/agents/CliRenderer.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ export class CliRenderer {
121121
// Find what's new since last output
122122
const newContent = processedContent.slice(this.lastOutputLength || 0);
123123
if (newContent.length > 0) {
124-
process.stdout.write(chalk.white(newContent));
124+
// Clean up excessive newlines - replace multiple consecutive newlines with at most 2
125+
const cleanedContent = newContent.replace(/\n{3,}/g, '\n\n');
126+
process.stdout.write(chalk.white(cleanedContent));
125127
this.lastOutputLength = processedContent.length;
126128
}
127129
}
@@ -186,7 +188,12 @@ export class CliRenderer {
186188
}
187189

188190
this.lastIterationReasoning = currentReasoning;
189-
console.log(); // Single line break after reasoning
191+
192+
// Only add a line break if the content doesn't already end with one
193+
const trimmedContent = finalContent.trimEnd();
194+
if (trimmedContent.length > 0 && !trimmedContent.endsWith('\n')) {
195+
console.log(); // Single line break after reasoning only if needed
196+
}
190197
}
191198

192199
private calculateSimilarity(str1: string, str2: string): number {

0 commit comments

Comments
 (0)