Skip to content

Commit d9cab93

Browse files
committed
simulate(tui): silence stderr loggers, refresh summary before the report
- SDK/protocol logs written to stderr during the alt-screen session all spilled into the terminal when the TUI exited; discard them like the console and perf commands do (the agent log and run report carry the diagnostics). - The run summary, which carries the chat transcripts, could land after the TUI's last poll; refetch once at exit so the report file includes the transcripts, and say explicitly when they aren't available yet.
1 parent deb98ff commit d9cab93

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

cmd/lk/simulate_ci.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ func writeRunResults(w io.Writer, run *livekit.SimulationRun, ap *AgentProcess)
271271
if run.Summary != nil {
272272
writeRunSummary(w, run)
273273
} else {
274-
msg := "The summary for this run is not available"
274+
msg := "The summary and chat transcripts for this run are not available yet"
275275
if run.Error != "" {
276276
msg = run.Error
277277
}

cmd/lk/simulate_tui.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ package main
1717
import (
1818
"context"
1919
"fmt"
20+
"io"
21+
"log"
2022
"os"
2123
"os/signal"
2224
"path/filepath"
@@ -28,13 +30,24 @@ import (
2830
"github.com/charmbracelet/bubbles/textinput"
2931
tea "github.com/charmbracelet/bubbletea"
3032
"github.com/charmbracelet/lipgloss"
33+
"github.com/go-logr/logr"
3134

3235
"github.com/livekit/livekit-cli/v2/pkg/util"
3336
"github.com/livekit/protocol/livekit"
3437
agent "github.com/livekit/protocol/livekit/agent"
38+
"github.com/livekit/protocol/logger"
39+
lksdk "github.com/livekit/server-sdk-go/v2"
3540
)
3641

3742
func runSimulateTUI(config *simulateConfig) error {
43+
// SDK/protocol log lines go to stderr behind the alt screen and would all
44+
// spill into the terminal when the TUI exits; the agent log file and the
45+
// run report carry the diagnostics instead.
46+
discard := logger.LogRLogger(logr.Discard())
47+
logger.SetLogger(discard, "lk")
48+
lksdk.SetLogger(discard)
49+
log.SetOutput(io.Discard)
50+
3851
launcher := launchSimulationAgent(config)
3952
m := newSimulateModel(config, launcher)
4053
p := tea.NewProgram(m, tea.WithAltScreen(), tea.WithMouseCellMotion())
@@ -69,6 +82,16 @@ func runSimulateTUI(config *simulateConfig) error {
6982
}
7083
}
7184

85+
// The summary (which carries the chat transcripts) may have landed after
86+
// the TUI's last poll; refresh once so the report includes it.
87+
if m.run != nil && m.run.Summary == nil && m.runID != "" {
88+
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
89+
if run, err := getSimulationRun(ctx, config.client, m.runID); err == nil && run != nil {
90+
m.run = run
91+
}
92+
cancel()
93+
}
94+
7295
// Always leave a plain-text record of the run, like the agent log.
7396
if path := m.reporter.Finish(m.run, m.agent, m.brokenAgent, m.getDashboardURL()); path != "" {
7497
out.Statusf("Run report: %s", path)

0 commit comments

Comments
 (0)