From f759bdd4e24467eb1e7a86a4cb9477898be47d3a Mon Sep 17 00:00:00 2001 From: Valentin Gjorgjioski Date: Wed, 3 Dec 2025 23:37:37 +0100 Subject: [PATCH] feat(runtime): Implement streaming execution output (fixes #1813) Problem: Previously, the output of commands executed via was only displayed after the entire process had finished. This provided a poor user experience for long-running commands, as there was no real-time feedback on the command's progress. Solution: This commit refactors the execution logic to handle output as a stream. An callback function has been introduced and is now passed to . This callback receives output in chunks during execution, tracks the current position in the stream via the new variable, and dispatches new output to the UI immediately. This provides users with real-time feedback from their commands. --- .../src/run/DatabricksRuntime.ts | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/packages/databricks-vscode/src/run/DatabricksRuntime.ts b/packages/databricks-vscode/src/run/DatabricksRuntime.ts index 31f353bb7..344c622ea 100644 --- a/packages/databricks-vscode/src/run/DatabricksRuntime.ts +++ b/packages/databricks-vscode/src/run/DatabricksRuntime.ts @@ -181,6 +181,24 @@ export class DatabricksRuntime implements Disposable { ); this.state = "EXECUTING"; + let outputPosition = 0; + + const onStatusUpdate = (result: any) => { + if (result.results?.resultType === "text") { + const output = (result.results as any).data; + if (output && output.length > outputPosition) { + this._onDidSendOutputEmitter.fire({ + type: "out", + text: output.substring(outputPosition), + filePath: program, + line: 0, + column: 0, + }); + outputPosition = output.length; + } + } + }; + const response = await executionContext.execute( await this.compileCommandString( program, @@ -188,21 +206,13 @@ export class DatabricksRuntime implements Disposable { syncDestinationMapper, envVars ), - undefined, + onStatusUpdate, this.token, new Time(240, TimeUnits.hours) ); const result = response.result; - if (result.results!.resultType === "text") { - this._onDidSendOutputEmitter.fire({ - type: "out", - text: (result.results as any).data, - filePath: program, - line: 0, - column: 0, - }); - } else if (result.results!.resultType === "error") { + if (result.results!.resultType === "error") { const frames = parseErrorResult(result.results!); for (const frame of frames) { let localFile = "";