Skip to content

Commit 269ddf9

Browse files
author
Eric Wheeler
committed
fix: avoid duplicate terminal output accumulation
Optimize terminal output handling to reduce memory pressure by: - Remove continuous result accumulation during line processing - Only store the same final output from the "completed" event that came from TerminalProcess Also: - Add clear error messages for undefined exit details Signed-off-by: Eric Wheeler <[email protected]>
1 parent 5be49e1 commit 269ddf9

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/core/Cline.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -966,9 +966,7 @@ export class Cline {
966966

967967
const { terminalOutputLineLimit } = (await this.providerRef.deref()?.getState()) ?? {}
968968

969-
let result = ""
970969
process.on("line", (line) => {
971-
result += line
972970
if (!didContinue) {
973971
sendCommandOutput(truncateOutput(line, terminalOutputLineLimit))
974972
} else {
@@ -977,10 +975,11 @@ export class Cline {
977975
})
978976

979977
let completed = false
978+
let result: string = ""
980979
let exitDetails: ExitCodeDetails | undefined
981980
process.once("completed", (output?: string) => {
982981
// Use provided output if available, otherwise keep existing result.
983-
result = output || result
982+
result = output ?? ""
984983
completed = true
985984
})
986985

@@ -1014,10 +1013,8 @@ export class Cline {
10141013
userFeedback.images,
10151014
),
10161015
]
1017-
}
1018-
1019-
if (completed) {
1020-
let exitStatus = "No exit code available"
1016+
} else if (completed) {
1017+
let exitStatus: string
10211018
if (exitDetails !== undefined) {
10221019
if (exitDetails.signal) {
10231020
exitStatus = `Process terminated by signal ${exitDetails.signal} (${exitDetails.signalName})`
@@ -1030,6 +1027,9 @@ export class Cline {
10301027
} else {
10311028
exitStatus = `Exit code: ${exitDetails.exitCode}`
10321029
}
1030+
} else {
1031+
result += "<VSCE exitDetails == undefined: terminal output and command execution status is unknown.>"
1032+
exitStatus = `Exit code: <undefined, notify user>`
10331033
}
10341034
const workingDirInfo = workingDir ? ` from '${workingDir.toPosix()}'` : ""
10351035

0 commit comments

Comments
 (0)