@@ -43,12 +43,14 @@ import (
4343
4444func runSimulateTUI (config * simulateConfig ) error {
4545 // SDK/protocol log lines go to stderr behind the alt screen and would all
46- // spill into the terminal when the TUI exits; capture them in a file
47- // instead, surfaced as a path on exit like the agent log.
48- cliLogPath := redirectLogsToFile ()
46+ // spill into the terminal when the TUI exits; route them into the run
47+ // report instead, interleaved with the same record CI mode prints.
48+ reporter := newRunReporter ()
49+ redirectLogs (reporter .LogWriter ())
4950
5051 launcher := launchSimulationAgent (config )
5152 m := newSimulateModel (config , launcher )
53+ m .reporter = reporter
5254 p := tea .NewProgram (m , tea .WithAltScreen (), tea .WithMouseCellMotion ())
5355 _ , runErr := p .Run ()
5456
@@ -81,10 +83,6 @@ func runSimulateTUI(config *simulateConfig) error {
8183 }
8284 }
8385
84- if cliLogPath != "" {
85- out .Statusf ("CLI logs: %s" , cliLogPath )
86- }
87-
8886 // The summary (which carries the chat transcripts) may have landed after
8987 // the TUI's last poll; refresh once so the report includes it.
9088 if m .run != nil && m .run .Summary == nil && m .runID != "" {
@@ -117,21 +115,13 @@ func runSimulateTUI(config *simulateConfig) error {
117115 return nil
118116}
119117
120- // redirectLogsToFile points the protocol/SDK/stdlib loggers at a temp file
121- // and returns its path; on failure the logs are discarded (they would
122- // otherwise corrupt the TUI and spill on exit).
123- func redirectLogsToFile () string {
124- f , err := os .CreateTemp ("" , "lk-simulate-cli-*.log" )
125- if err != nil {
126- discard := logger .LogRLogger (logr .Discard ())
127- logger .SetLogger (discard , "lk" )
128- lksdk .SetLogger (discard )
129- log .SetOutput (io .Discard )
130- return ""
131- }
118+ // redirectLogs points the protocol/SDK/stdlib loggers at w (the run report);
119+ // on failure the logs are discarded (they would otherwise corrupt the TUI and
120+ // spill on exit).
121+ func redirectLogs (w io.Writer ) {
132122 core := zapcore .NewCore (
133123 zapcore .NewConsoleEncoder (zap .NewDevelopmentEncoderConfig ()),
134- zapcore .AddSync (f ),
124+ zapcore .AddSync (w ),
135125 zapcore .InfoLevel ,
136126 )
137127 zl , err := logger .FromZapLogger (zap .New (core ), & logger.Config {Level : "info" })
@@ -143,8 +133,7 @@ func redirectLogsToFile() string {
143133 logger .SetLogger (zl , "lk" )
144134 lksdk .SetLogger (zl )
145135 }
146- log .SetOutput (f )
147- return f .Name ()
136+ log .SetOutput (w )
148137}
149138
150139// --- Styles ---
@@ -357,7 +346,6 @@ func newSimulateModel(config *simulateConfig, launcher *agentLauncher) *simulate
357346 return & simulateModel {
358347 config : config ,
359348 launcher : launcher ,
360- reporter : newRunReporter (),
361349 numSimulations : config .numSimulations ,
362350 width : 80 ,
363351 height : 24 ,
0 commit comments