Skip to content

Commit

Permalink
fix(runner): The consoleView is not the original consoleView when pro…
Browse files Browse the repository at this point in the history
…cessing the exit code of the script
  • Loading branch information
lkk214 committed Sep 6, 2024
1 parent 6e9c54f commit 474b681
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class ShireRunFileAction : DumbAwareAction() {
val hintDisposable = Disposer.newDisposable()
val connection = ApplicationManager.getApplication().messageBus.connect(hintDisposable)
connection.subscribe(ShireRunListener.TOPIC, object : ShireRunListener {
override fun runFinish(allOutput: String, llmOutput: String, event: ProcessEvent, scriptPath: String) {
override fun runFinish(allOutput: String, llmOutput: String, event: ProcessEvent, scriptPath: String, consoleView: ShireConsoleView?) {
future.complete(llmOutput)
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@ class ShireProgramRunner : GenericProgramRunner<RunnerSettings>(), Disposable {
if (environment.runProfile !is ShireConfiguration) return null
val shireState = state as ShireRunConfigurationProfileState

var executeResult: ExecutionResult? = null
var executeResult: ExecutionResult?

val result = AtomicReference<RunContentDescriptor>()

if (!isSubscribed) {
connection.subscribe(ShireRunListener.TOPIC, object : ShireRunListener {
override fun runFinish(allOutput: String, llmOutput: String, event: ProcessEvent, scriptPath: String) {
val consoleView = (environment.state as? ShireRunConfigurationProfileState)?.console
override fun runFinish(allOutput: String, llmOutput: String, event: ProcessEvent, scriptPath: String, consoleView: ShireConsoleView?) {
environment.project.getService(ShireProcessProcessor::class.java)
.process(allOutput, event, scriptPath, consoleView)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ open class ShireRunConfigurationProfileState(
ProcessTerminatedListener.attach(processHandler)

val sb = StringBuilder()
val processAdapter = ShireProcessAdapter(sb, configuration)
val processAdapter = ShireProcessAdapter(sb, configuration, console)
processHandler.addProcessListener(processAdapter)

// start message log in here
Expand Down Expand Up @@ -118,7 +118,7 @@ class ShireConsoleView(private val executionConsole: ConsoleViewImpl) :
}
}

class ShireProcessAdapter(private val sb: StringBuilder, val configuration: ShireConfiguration) : ProcessAdapter() {
class ShireProcessAdapter(private val sb: StringBuilder, val configuration: ShireConfiguration, val consoleView: ShireConsoleView?) : ProcessAdapter() {
var result = ""
private var llmOutput: String = ""

Expand All @@ -127,7 +127,7 @@ class ShireProcessAdapter(private val sb: StringBuilder, val configuration: Shir

ApplicationManager.getApplication().messageBus
.syncPublisher(ShireRunListener.TOPIC)
.runFinish(result, llmOutput, event, configuration.getScriptPath())
.runFinish(result, llmOutput, event, configuration.getScriptPath(), consoleView)
}

override fun onTextAvailable(event: ProcessEvent, outputType: Key<*>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ interface ShireRunListener : EventListener {
* @param llmOutput LLM output
* @param event ProcessEvent
* @param scriptPath script path
* @param consoleView shire consoleView
*/
fun runFinish(allOutput: String, llmOutput: String, event: ProcessEvent, scriptPath: String)
fun runFinish(allOutput: String, llmOutput: String, event: ProcessEvent, scriptPath: String, consoleView: ShireConsoleView?)

companion object {
@Topic.AppLevel
Expand Down

0 comments on commit 474b681

Please sign in to comment.