From 0a786f4b874de043d53630a62dd96bdc4b6adaf6 Mon Sep 17 00:00:00 2001 From: Juergen Klaassen Date: Wed, 22 Apr 2026 14:10:02 -0600 Subject: [PATCH] fix(tui): use newRootCmdForRecipeStep for recipe dispatcher MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow-up to PR #14 (TUI runner) + PR #15 (viper leak fix). The runner was left wiring an inline dispatcher factory because the helper from #15 didn't exist yet on that branch. With both landed, switch the TUI dispatcher to newRootCmdForRecipeStep so the TUI benefits from the same viper state reset the CLI `jc recipe run` already gets — fixes recipes that rely on a captured step's JSON output (security-audit, compliance-report) when run from the TUI. Co-Authored-By: Claude Opus 4.7 (1M context) --- internal/cmd/tui.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/internal/cmd/tui.go b/internal/cmd/tui.go index 9989556..12edd32 100644 --- a/internal/cmd/tui.go +++ b/internal/cmd/tui.go @@ -31,11 +31,10 @@ Navigate resources with keyboard shortcuts: app.NewHelpScreen = func() tui.Screen { return screen.NewHelpScreen() } // Wire the recipe dispatcher so the Recipes screen can execute steps. - // This uses a fresh root command per step (same pattern as jc recipe run) - // for isolated flag state. - screen.RecipeDispatcher = recipe.NewDispatcher(func() recipe.CobraCommand { - return NewRootCmd() - }) + // Use newRootCmdForRecipeStep which resets persistent-Set viper keys + // between steps so -t in step N doesn't corrupt step N+1's output + // format (see comments on resetViperForRecipeStep in recipe.go). + screen.RecipeDispatcher = recipe.NewDispatcher(newRootCmdForRecipeStep) p := tea.NewProgram(app, tea.WithAltScreen()) // Register the program so the recipe-run goroutine can post