@@ -173,7 +173,7 @@ type Msg
173173 | CompilerInitialized { quiet : Bool, backendStreams : ChildProcess.StreamIO, encodedCommand : Bytes }
174174 | CompilerRan Int
175175 | CompiledForRun { path : Path, exitCode : Int }
176- | RunStarted Process.Id
176+ | RunStarted { processId : Process.Id, streams : Maybe ChildProcess.StreamIO }
177177 | RunExited Int
178178 | RedirectTerminalIO
179179 (Result
@@ -288,7 +288,7 @@ update msg model =
288288 , fsPermission = model.fsPermission
289289 , pathToString = model.pathToString
290290 , path = path
291- , onInit = \{ processId } -> RunStarted processId
291+ , onInit = RunStarted
292292 , onExit = RunExited
293293 }
294294 |> Task.onError
@@ -303,8 +303,18 @@ update msg model =
303303 else
304304 Task.execute <| Node.exitWithCode exitCode
305305
306- RunStarted _ ->
307- Cmd.none
306+ RunStarted { streams } ->
307+ when streams is
308+ Nothing ->
309+ Debug.todo "Handle missing streams on run"
310+
311+ Just { input, output, error } ->
312+ [ Task.succeed { source = output, target = model.stdout }
313+ , Task.succeed { source = model.stdin, target = input }
314+ , Task.succeed { source = error, target = model.stderr }
315+ ]
316+ |> Array.map (Task.attempt RedirectTerminalIO)
317+ |> Cmd.batch
308318
309319 RunExited exitCode ->
310320 Task.execute <| Node.exitWithCode exitCode
@@ -328,6 +338,7 @@ update msg model =
328338 Cmd.none
329339
330340 _ ->
341+ -- TODO: This is no longer only used for comms with the compiler backend. Need better error message.
331342 Stream.Log.line model.stderr ("Something went wrong when communicating with compiler backend: " ++ Stream.errorToString error)
332343 |> Task.andThen (\_ -> Node.exitWithCode 1)
333344 |> Task.execute
0 commit comments