-
- Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
To repro:
echo "not git diffs" | diffnav You'll get something like as output:
The exact output behavior depends on the terminal.
The problem seems to be a bubbletea bug: charmbracelet/bubbletea#1590
Claude suggested avoiding the problem by not starting tea at all if the input has no diffs, like this:
⏺ Update(cmd/root.go) ⎿ Added 10 lines 166 fmt.Println("No input provided, exiting") 167 os.Exit(0) 168 } 169 + 170 + // Validate that input contains a parseable diff before launching the TUI. 171 + // Without this, non-diff input causes the TUI to start and immediately quit, 172 + // leaving garbage escape codes on the terminal. 173 + files, _, err := gitdiff.Parse(strings.NewReader(input + "\n")) 174 + if err != nil || len(files) == 0 { 175 + fmt.Println("No diff found in input, exiting") 176 + os.Exit(0) 177 + } 178 + 179 cfg := config.Load() 180 181 // Override config with CLI flags if specified Of course, that means parsing the input twice, which is a little inefficient. The only other workaround I could think of would be ensuring tea view has been rendered to the screen at least once before quitting. Unfortunately, I didn't see a way for the model to know if the screen has been rendered (tracking whether View() has been called yet is not enough). Waiting 100ms before allowing a quit seems to be a clunky way to do it.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels