fix(bonfire): reroute only the owning console's lines to a live view

- the registered view keeps the console that started it; Println, Printf
  and status lines go above it only from that console, other consoles
  write to their own writers (bonfire.PrintAbove still reaches any view)
- runLive claims the single live slot by check and set under liveMu and
  reports when it could not, so the widget prints plain lines
- unregister, finish and wait run deferred, so a panic in work leaves no
  registration behind and still propagates (WR-02)
This commit is contained in:
Jakub Zych
2026-10-22 02:10:48 +02:00
parent b077dc3598
commit 86e4e270d3
6 changed files with 200 additions and 56 deletions

View File

@@ -149,7 +149,7 @@ func Process(ctx context.Context, out Output, operation string, items []string,
}
if c, ok := out.(*console); ok && c.live() && len(items) > 0 {
var errs []error
_ = runLive(ctx, c.out, c, newProcessModel(c.palette, operation, items), func(send func(tea.Msg)) error {
started, _ := runLive(ctx, c.out, c, newProcessModel(c.palette, operation, items), func(send func(tea.Msg)) error {
for i, item := range items {
if err := ctx.Err(); err != nil {
errs = append(errs, err)
@@ -165,7 +165,9 @@ func Process(ctx context.Context, out Output, operation string, items []string,
}
return nil
})
return errors.Join(errs...)
if started {
return errors.Join(errs...)
}
}
var errs []error
for _, item := range items {