* feat(cli): move command to the end of the cli arguments
* feat(cli): allow naming panes from the command line
* fix(cli): adjust actions after pane rename
* feat(cli): zellij run completions for fish
* feat(cli): zellij run completions for bash and zsh
* style(fmt): rustfmt
* fix(e2e): fix run test and snapshot
* style(fmt): rustfmt
* zellij: Add global `DEBUG_MODE` variable
that tells us whether zellij was started with the `--debug` CLI flag.
* utils/errors: Only log thread_bus message in debug
mode, and discard the message otherwise.
* utils/logging: Increase logsize to 16 MiB
per logfile, totaling 32 MiB of logs at most (in two files).
* zellij: Set global `DEBUG` variable in server
thread and make sure the value of the `--debug` CLI flag is propagated
to the server, too.
This means that to enable debug mode, the server must be started with
the `--debug` flag. This happens when the first client that starts the
zellij session has the `--debug` flag set, because it will be forwarded
to the server. Subsequent clients attaching to the same session with the
`--debug` flag specified **do not** override the value of the `DEBUG`
variable. Hence, if the server wasn't started in debug mode, this cannot
be changed.
* feat(layouts): allow defining a global cwd
* feat(layouts): allow passing global cwd from cli
* style(fmt): rustfmt
* fix(layouts): error on mixed cwd and pane children
* fix(layouts): error on non-bare children node
* refactor(layout): consolidate split direction parsing
* refactor(layout): remove unused import
* fix(layouts): log error when there is no room for layout
* fix(layout): error on size 0
* feat(layouts): allow pane templates to override template command attributes
* style(fmt): rustfmt
* zellij/commands: Prevent recursive sessions
with session names specified in layout files. A "recursive session" is
created when, while running inside some zellij session, a user attempts
to spawn zellij and make it attach to that same session.
When attaching via CLI (`zellij attach`) we explicitly check for this
condition and error out when needed.
However, besides `zellij attach` it is also possible to declare the
session to attach to in layout files like so:
```yaml
session:
name: "foo"
```
This takes a different codepath when starting zellij, and hence bypases
the checks we already have in place to avoid recursive sessions. Hence,
we implement the check in the other codepath, too, and prevent recursive
sessions from happening for good.
Fixes: #1735
* changelog: fix recursive zellij sessions
* chore(config): default kdl keybindings config
* tests
* work
* refactor(config): move stuff around
* work
* tab merge layout
* work
* work
* layouts working
* work
* layout tests
* work
* work
* feat(parsing): kdl layouts without config
* refactor(kdl): move stuff around
* work
* tests(layout): add cases and fix bugs
* work
* fix(kdl): various bugs
* chore(layouts): move all layouts to kdl
* feat(kdl): shared keybidns
* fix(layout): do not count fixed panes toward percentile
* fix(keybinds): missing keybinds and actions
* fix(config): adjust default tips
* refactor(config): move stuff around
* fix(tests): make e2e tests pass
* fix(kdl): add verbose parsing errors
* fix(kdl): focused tab
* fix(layout): corret default_tab_template behavior
* style(code): fix compile warnings
* feat(cli): send actions through the cli
* fix(cli): exit only when action is done
* fix(cli): open embedded pane from floating pane
* fix(cli): send actions to other sessions
* feat(cli): command alias
* feat(converter): convert old config
* feat(converter): convert old layout and theme files
* feat(kdl): pretty errors
* feat(client): convert old YAML files on startup
* fix: various bugs and styling issues
* fix: e2e tests
* fix(screen): propagate errors after merge
* style(clippy): lower clippy level
* fix(tests): own session_name variable
* style(fmt): rustfmt
* fix(cli): various action fixes
* style(fmt): rustfmt
* fix(themes): loading of theme files
* style(fmt): rustfmt
* fix(tests): theme fixtures
* fix(layouts): better errors on unknown nodes
* fix(kdl): clarify valid node terminator error
* fix(e2e): adjust close tab test
* fix(e2e): adjust close tab test again
* style(code): cleanup some comments
* get command panes not to exit on command exit
* separate terminal pane_ids from raw_fds
* render frame according to exit status
* re-run command on enter and close pane on ctrl-c
* proper error when command is not found
* make ui nicer
* initial pane title for command panes
* fix pane override bug
* reap terminal_ids from os_input_output on pane close
* bool floating flag
* some ui tweaks
* fix tests
* make rustfmt happy
* e2e test for command pane
* fix various concurrency issues
* rename command to run in the cli
* rustfmt
* style(fmt): rustfmt
* fix(e2e): command => run
* fix(e2e): command => run in snapshot too!
* utils/errors: Add `ToAnyhow` trait
for converting `Result` types that don't satisfy `anyhow`s trait
constraints (`Display + Send + Sync + 'static`) conveniently.
An example of such a Result is the `SendError` returned from
`send_to_plugins`, which sends `PluginInstruction`s as message type.
One of the enum variants can contain a `mpsc::Sender`, which is `!Sync`
and hence makes the whole `SendError` be `!Sync` in this case. Add an
implementation for this case that takes the message and converts it into
an error containing the message formatted as string, with the additional
`ErrorContext` as anyhow context.
* server/tab: Remove calls to `unwrap()`
and apply error reporting via `anyhow` instead. Make all relevant
functions return `Result`s where previously a panic could occur and
attach error context.
* server/screen: Modify `update_tab!`
to accept an optional 4th parameter, a literal "?". If present, this
will append a `?` to the given closure verbatim to handle/propagate
errors from within the generated macro code.
* server/screen: Handle new `Result`s from `Tab`
and apply appropriate error context and propagate errors further up.
* server/tab/unit: `unwrap` on new `Result`s
* server/unit: Unwrap `Results` in screen tests
* server/tab: Better message for ad-hoc errors
created with `anyhow!`. Since these errors don't have an underlying
cause, we describe the cause in the macro instead and then attach the
error context as usual before `?`ing the error back up.
* utils/cargo: Activate `anyhow`s "backtrace" feature
to capture error backtraces at the error origins (i.e. where we first
receive an error and convert it to a `anyhow::Error`). Since we
propagate error back up the call stack now, the place where we `unwrap`
on errors doesn't match the place where the error originated. Hence, the
callstack, too, is quite misleading since it contains barely any
references of the functions that triggered the error.
As a consequence, we have 2 backtraces now when zellij crashes: One from
`anyhow` (that is implicitly attached to anyhows error reports), and one
from the custom panic handler (which is displayed through `miette`).
* utils/errors: Separate stack traces
in the output of miette. Since we record backtraces with `anyhow` now,
we end up having two backtraces in the output: One from the `anyhow`
error and one from the actual call to `panic`. Adds a comment explaining
the situation and another "section" to the error output of miette: We
print the backtrace from anyhow as "Stack backtrace", and the output
from the panic handler as "Panic backtrace". We keep both for the
(hopefully unlikely) case that the anyhow backtrace isn't existent, so
we still have at least something to work with.
* server/screen: Remove calls to `fatal`
and leave the `panic`ing to the calling function instead.
* server/screen: Remove needless macro
which extended `active_tab!` by passing the client IDs to the closure.
However, this isn't necessary because closures capture their environment
already, and the client_id needn't be mutable.
* server/screen: Handle unused result
* server/screen: Reintroduce arcane macro
that defaults to some default client_id if it isn't valid (e.g. when the
ScreenInstruction is sent via CLI).
* server/tab/unit: Unwrap new results
* docs: Add ERROR_HANDLING
that explains how we plan to change error handling in zellij and invites
new contributors to join the fun. Details the currently existent error
handling capabilities and gives a bunch of examples taken from #1670.
* utils/errors: Shorten docblock
by moving previous content under "Help Wanted" to the new
`docs/ERROR_HANDLING` document and link to the document instead.
* server/tab: Check suppressed panes
when writing to a pane by ID. Previously only the tiled and floating
panes would be searched for a pane of a given ID.
Fixes: #1734
* server/tab/unit: Test writing to suppressed panes
* docs: fix server panics when writing to suppressed panes
* utils: re-export "anyhow" unconditionally
even for wasm targets.
* utils/errors: Share wasm-compatible code
and move everything that can't run in wasm into a separate submodule.
* utils: Share "errors" module unconditionally
The module is now structured such that all code incompatible with wasm
targets lives in its own submodule that isn't included when compiling
for wasm targets.
* utils/errors: Add "Help wanted" doc section
that informs the reader about the endeavour to improve error handling
throughout the zellij code base.
* plugins: Handle errors returned by `zellij_tile`
now that the panic calls have been removed.
* utils/errors: Extend `anyhow::Result` with traits
that allow for easy/concise logging of `anyhow::Result` types and
panicking the application when they are fatal or non-fatal.
* utils/errors: Fix doctest
* utils/errors: Add prelude
that applications can import to conveniently access the error handling
functionality part of the module. Re-exports some parts and macros from
anyhow and the `LoggableError` and `FatalError` traits.
* server/screen: Adopt error handling
and make all fallible functions from the public API return a `Result`.
Append error contexts in all functions that can come across error types
to allow tracing where an error originates and what lead there.
* server/lib: Catch errors from `screen`
and make them `fatal`. This will log the errors first, before unwrapping
on the error type and panicking the application.
* server/unit/screen: Fix unit tests
and unwrap on the `Result` types introduced from the new error handling.
* utils/errors: Track error source
in calls to `fatal`, so we keep track of the location where the panic
really originates. Otherwise, any call to `fatal` will show the code in
`errors` as source, which of course isn't true.
Also change the error formatting and do not call `to_log` for fatal
errors anymore, because the panic is already logged and contains much
more information.
* utils/errors: Update `FatalError` docs
* plugins: Undo accidental modifications
* utils/errors: Improve module docs
explain some error handling facilities and the motivation behind using
them.
* server/screen: Remove `Result` from Infallible
functions that are part of the public API.