Commit graph

45 commits

Author SHA1 Message Date
jane michelle arc
9c6598361d
fix: return write errors from Program.Run (#1879)
Co-authored-by: Drew Smirnoff <drew@charm.land>
Signed-off-by: Drew Smirnoff <drew@charm.land>
2026-11-20 18:52:39 +04:00
draw me an elephant
7ab4335dac
fix: don't panic on uncomparable color.Color values (#1852)
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Co-authored-by: Drew Smirnoff <drew@charm.land>
Signed-off-by: Drew Smirnoff <drew@charm.land>
2026-11-20 18:33:00 +04:00
Ahmet Kamer Çivi
18d6fa3b34
fix: close trace file after program run (#1844)
Co-authored-by: Drew Smirnoff <drew@charm.land>
Signed-off-by: Drew Smirnoff <drew@charm.land>
2026-11-12 17:36:39 +04:00
Ricardo-M-L
7a446b73f6
fix: avoid blocking prints after program exit (#1758)
Co-authored-by: Ricardo-M-L <XuthodoreveraynWX61@elvisfan.com>
Co-authored-by: Drew Smirnoff <drew@charm.land>
2026-11-12 17:23:24 +04:00
陈志谦
55ba0f6de3
fix: allow Program.Run to be called again after the program exits (#1890)
Signed-off-by: simpleqt <2015900818@qq.com>
2026-11-12 17:21:35 +04:00
Drew Smirnoff
5982a61ef5
fix: data race with Kill() and Run() (#1774)
Signed-off-by: drew <me@andrinoff.com>
2026-11-12 17:11:18 +04:00
draw me an elephant
8b10e22689
fix: skip capability queries when input is disabled (#1801)
Co-authored-by: drew <me@andrinoff.com>
Signed-off-by: drew <me@andrinoff.com>
2026-09-24 12:05:48 +04:00
Ankit
930e18c966
fix: don't panic in ProgressBarState.String() for out-of-range values (#1748)
Co-authored-by: drew <me@andrinoff.com>
Signed-off-by: drew <me@andrinoff.com>
2026-08-19 12:21:01 +04:00
Liam Stanley
c60f0c5304
fix: prevent data race with cursedRenderer.onMouse (#1691)
- closes #1690
- adds `-race`, `-count`, and `-cpu`
- make all viable tests parallel

Signed-off-by: Liam Stanley <liam@liam.sh>
2026-05-11 21:11:40 -04:00
Ayman Bagabas
db021e2f6d
chore: test: add benchmark for tea Run method 2025-11-05 12:47:35 -05:00
Ayman Bagabas
be3c7e5427
refactor: restore options 2025-10-14 11:49:17 -04:00
Ayman Bagabas
fb3e0a4a3e
refactor: lean more into the View struct to manage terminal state 2025-10-01 13:50:37 -04:00
Ayman Bagabas
b4236df2e3
refactor: move WithFilter to Program.Filter 2025-10-01 13:50:35 -04:00
Ayman Bagabas
6b6414508e
refactor: replace WithInput and WithOutput options with Input and Output fields on Program struct 2025-10-01 13:50:33 -04:00
Ayman Bagabas
688573d200
refactor: remove WithContext and pass context to Run 2025-10-01 13:50:32 -04:00
Ayman Bagabas
c50f8089f2
Merge branch 'main' into v2-exp 2025-09-11 15:04:36 -04:00
Ayman Bagabas
9e0e8f0df1
fix: recover from nested panics in Sequence and Batch commands 2025-09-11 14:46:06 -04:00
Ayman Bagabas
68df41d242
Merge branch 'main' into v2-exp 2025-08-08 15:06:45 -04:00
Ayman Bagabas
f5da8d068a
fix: handle nested SequenceMsg in event loop and use sync.WaitGroup f… (#1463)
* fix: handle nested SequenceMsg in event loop and use sync.WaitGroup for BatchMsg

This simplifies the handling of nested BatchMsg within sequenceMsg and ensures
that all commands in a BatchMsg are executed before proceeding.
It also replaces errgroup with sync.WaitGroup for better clarity and performance
when waiting for multiple goroutines to finish.

Fixes: https://github.com/charmbracelet/bubbletea/issues/680
Supersedes: https://github.com/charmbracelet/bubbletea/pull/843

* chore: examples: bump dependencies
2025-08-08 15:04:36 -04:00
Andrey Nering
ca493b9828 chore: run modernize 2025-05-30 17:22:31 -03:00
desertwitch
9404e068c2
chore: merge branch 'stacked-patches' into v2-exp 2025-04-13 13:24:02 +02:00
desertwitch
1923181af6
fix: report only external ctx cancel as ctx error 2025-03-28 12:17:51 +01:00
desertwitch
0f9cd5b537
fix(panics): fix race condition and false nil error return 2025-03-28 12:17:50 +01:00
desertwitch
a79ab3fd2f
fix(tests): account for multiple p.Wait() 2025-03-28 12:17:50 +01:00
desertwitch
aa7a240b9a
fix: release p.Wait() on p.Kill() to prevent external deadlocks 2025-03-28 12:17:49 +01:00
Rysz
1b5fc275fc
fix: prevent deadlock on ctx cancel during msg processing 2025-03-26 10:12:40 +01:00
Ayman Bagabas
47166e9a7a
chore: remove trailing newlines and update testdata
The new renderer now always moves the cursor to the beginning of
the next line on exit.
2025-02-10 17:02:33 -05:00
Ayman Bagabas
9087113343
feat,refactor!: introduce cursor model (#1303)
This introduces a new `CursorModel` interface that can be implemented by
the main model to provide a cursor position and style. A nil cursor will
hide the cursor. Otherwise, the cursor will be shown at the position and
with the style specified. Use `NewCursor` to quickly create a cursor for
a given position with default styles. This method is called in-sync with
the `Model.View` method.

It also removes the previously introduced `Frame` type and `NewFrame`
function. The main model can now return a `string` to render the program's
UI. The main model can return a `Cursor` to set the cursor position and
style.

The old `Init` method is now back and it returns a `Cmd` instead of a
both a `Model` and a `Cmd`. This is to make the mental model more straight
forward, and to keep things backwards compatible.
2025-02-04 12:47:23 -05:00
Ayman Bagabas
d93aa0090d
refactor!: model stringer interface 2025-01-23 14:58:43 -05:00
Ayman Bagabas
023af98640
feat: add Frame type and remove cursor commands
This commit introduces a new `Frame` type that represents a single frame of
the program's output. The `Frame` type contains the frame's content and cursor
settings. The cursor settings include the cursor's position, style, blink, and
visibility.

It also removes the cursor commands from the `tea` package. The cursor
commands are now part of the `Frame` type. The cursor commands were removed
because they were not idiomatic and were not flexible enough to support
additional cursor settings.

Supersedes: https://github.com/charmbracelet/bubbletea/pull/1293
2025-01-23 14:57:54 -05:00
Ayman Bagabas
a7d49d01a4
chore: remove deprecated 2024-09-19 13:21:00 -04:00
Ayman Bagabas
16f706ac13
refactor: expose key codes and define key/mouse interfaces 2024-08-30 09:37:07 -04:00
Ayman Bagabas
ad68c4205f
feat!: make Init return the model (#1112) 2024-08-23 16:21:21 -04:00
Ayman Bagabas
d6a19f0eb5
fix: wrap ErrProgramKilled error
This gives the caller more context on _why_ the program was killed by
wrapping the error with the context error.
2024-08-12 17:01:06 -04:00
Christian Muehlhaeuser
c56884c0e2
feat: add generic event filter (#536)
`WithFilter` lets you supply an event filter that will be invoked
before Bubble Tea processes a `tea.Msg`. The event filter can return
any `tea.Msg` which will then get handled by Bubble Tea instead of
the original event. If the event filter returns nil, the event
will be ignored and Bubble Tea will not process it.

As an example, this could be used to prevent a program from
shutting down if there are unsaved changes.

Based on the fantastic work by @aschey and supersedes #521.

Resolves #472.
2023-04-17 22:02:55 +02:00
Christoffer Åström
e95e1a0db5 feat: sequence support BatchMsg 2023-02-07 10:06:46 -05:00
Christian Muehlhaeuser
e15bcb7e0e feat: tea.WithContext ProgramOption to supply a context
WithContext lets you specify a context in which to run the Program.
This is useful if you want to cancel the execution from outside.
When a Program gets cancelled it will exit with an error
ErrProgramKilled.
2022-10-23 05:59:10 +02:00
treilik
918d35746b feat: export BatchMsg
There's no good reason to keep it private. Exporting it helps
testability, debugging, and allows for a few special model.Update
implementations.
2022-10-22 22:51:46 +02:00
Christian Muehlhaeuser
3609d87e70 fix: don't block in Send after shutdown
Send should block before a tea.Program has been started, but result
in a no-op when it has already been terminated.

Fixed godocs.
2022-10-15 04:21:44 +02:00
Christian Muehlhaeuser
1ed623fdc0 fix: kill should result in Start returning an error
This fixes Kill resulting in a final nil model being returned.

We can also drop the kill channel and rely on our existing context
channel.
2022-10-12 05:26:39 +02:00
Christian Muehlhaeuser
77619d21f5 test: add sequenceMsg test 2022-10-08 19:02:54 +02:00
Christian Muehlhaeuser
9117bbc137 test: add batchMsg test 2022-10-08 18:52:09 +02:00
Christian Muehlhaeuser
6b77c8fc10 chore: rename StartReturningModel to Run
Added aliases for the old functions, but deprecated them.
2022-10-08 01:34:17 +02:00
Christian Muehlhaeuser
5d1ffa74cd test: quit/kill model after the first render 2022-09-27 05:02:33 +02:00
Christian Muehlhaeuser
e9fe942675 test: run model with provided input and check output 2022-09-22 19:40:40 +02:00