aboutsummaryrefslogtreecommitdiffstats
path: root/zellij-server/src/thread_bus.rs (follow)
Commit message (Collapse)AuthorAge
* fix: handle short writes in write_to_tty_stdin to prevent paste truncation ↵Edgars Nemše2026-03-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#4818) * fix: handle short writes in write_to_tty_stdin to prevent paste truncation On macOS the kernel PTY buffer is only 4-16 KiB, so a single write() call for a large paste returns a short write count rather than blocking until all bytes are accepted. The current code returns this partial count without retrying, silently dropping the remaining bytes. This wraps the write in a retry loop that handles: - Short writes (advances the buffer offset and retries) - EINTR (retries immediately) - EAGAIN (sleeps 1ms then retries) Without this fix, pasting ~1 KiB+ of text into a terminal pane loses everything beyond the first kernel-buffer-full. Includes a test that exercises the fix using a real PTY pair with O_NONBLOCK set on the master fd to force short writes. * fix: cap EAGAIN retries at 50 to prevent infinite busy-wait Per reviewer feedback, add a retry counter that caps consecutive EAGAIN retries at 50 and logs an error if the limit is reached. The counter resets on any successful write progress, so it only triggers when the PTY is genuinely stuck. * fix: use poll(POLLOUT) instead of sleep-retry loop for EAGAIN handling Replace the 50-retry sleep(1ms) busy-wait with poll(POLLOUT, 5s timeout). This properly waits for fd writability without CPU spinning and returns an error on timeout instead of silently returning Ok(partial) — which the caller (pty_writer_main) would ignore, causing silent data loss. Tests: - write_to_tty_stdin_delivers_all_bytes: remove flaky reader delay, use concurrent reader, move master close after reader join to avoid macOS kernel buffer flush race - write_all_to_fd_errors_on_stuck_pty: new test verifying timeout returns Err on stuck PTY (uses 100ms timeout for speed) * fix: re-queue partial PTY writes instead of blocking PtyWriter thread Replace the poll(POLLOUT) blocking loop with a non-blocking re-queue approach as suggested in review. On partial write or EAGAIN: - write_to_tty_stdin now drains as much as the kernel accepts in one pass and returns the count (may be 0 on EAGAIN) - PtyWriter re-queues unwritten bytes back onto its own channel, letting other terminals' writes proceed between retries - Retry count tracks consecutive zero-progress attempts (reset on any forward progress), drops bytes after 50 retries with log::error - yield_now() before re-queue on zero progress to avoid tight spin - Guard against write() returning Ok(0) on non-empty buffer - Wire up PtyWriter's self-sender (was None, now Some(&to_pty_writer)) * fix: per-terminal write buffering to handle short writes and EAGAIN Replace re-queue approach with per-terminal pending write buffers (HashMap<u32, VecDeque<PendingWrite>>). Uses recv_timeout(10ms) when pending data exists, blocking recv when idle. 10MB per-terminal cap drops buffer on overflow. Terminal errors clear the queue. Adds Bus::recv_timeout via crossbeam Select::select_timeout. Removes tcdrain from write path. * use safe accessor methods and saturating substitutions * add tests for ptywriter * rustfmt * fix tests by not assuming kernel buffer sizes * rustfmt * add pr --------- Co-authored-by: Aram Drevekenin <aram@poor.dev>
* Feature: allow overriding a layout for a currently running tab (change ↵Aram Drevekenin2025-12-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | layout at runtime) (#4566) * add tests for LayoutApplier * initial untested implementation of override functions * add override-layout cli action with stub in screen * filter run instructions to ignore * implement override-layout roundtrip through plugin and pty threads * initial full-cycle working override implementation * fix some bugs (eg. actually start new terminals) * fix some bugs with focus after override * fix floating pane matching bug in layout applier * formatting * use first tab, error on more than 1 tab * fix some floating_panes ordering and shell issues * get new tab name to work * respect swap layouts * allow specifying tab properties on main layout node if we just have one tab * add tests for new override methods * start work on retaining panes, hard-coded things, kind of working but broken in many places * fixed most tiled pane override bugs * reset viewport before reapplying * revert constraint system changes * retain-existing-terminal-panes flag * add retain terminal panes tests * add retain plugin panes flag * add keybind * add retain plugin panes tests * add override-layout e2e test * refactor: layout_applier * style: rustfmt * some cleanups * fix cli flags * no crashy * formatting and artifacts * moar cleanups * fix: respect expanded in stack when overriding * docs(changelog): add PR
* feat(ui): swap layouts and stacked panes (#2167)Aram Drevekenin2023-02-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * relayout working with hard coded layout * work * refactor(layout): PaneLayout => TiledPaneLayout * tests passing * tests passing * tests passing * stacked panes and passing tests * tests for stacked panes * refactor(panes): stacked panes * fix: focusing into stacked panes from the left/right * fix(layouts): handle stacked layouts in the middle of the screen * fix(pane-stack): focus correctly when coming to stack from above/below * fix(stacked-panes): resize stack * fix(stacked-panes): focus with mouse * fix(stacked-panes): focus next pane * fix(layout-applier): sane focus order * fix(stacked-panes): better titles for one-liners * fix(stacked-panes): handle moving pane location in stack * fix(relayout): properly calculate display area * fix(relayout): properly calculate rounding errors * fix(stacked-panes): properly handle closing a pane near a stack * fix(swap-layouts): adjust swap layout sort order * feat(swap-layouts): ui + ux * fix(swap-layouts): include base layout * refactor(layout): remove unused method * fix(swap-layouts): respect pane contents and focus * work * fix(swap-layouts): load swap layouts from external file * fix(swap-layouts): properly truncate layout children * fix(stacked-panes): allow stacked panes to become fullscreen * fix(swap-layouts): work with multiple tabs * fix(swap-layouts): embed/eject panes properly with auto-layout * fix(stacked-panes): close last pane in stack * fix(stacked-panes): move focus for all clients in stack * fix(floating-panes): set layout damaged when moving panes * fix(relayout): move out of unfitting layout when resizing whole tab * fix(ui): background color for swap layout indicator * fix(keybinds): add switch next layout in tmux * fix(ui): swap layout indication in compact layout * fix(compact): correct swap constraint * fix(tests): tmux swap config shortcut * fix(resizes): cache resizes so as not to confuse panes (eg. vim) with multiple resizes that it debounces weirdly * feat(cli): dump swap layouts * fix(ui): stacked panes without pane frames * fix(ux): move pane forward/backwards also with floating panes * refactor(lint): remove unused stuff * refactor(tab): move swap layouts to separate file * style(fmt): rustfmt * style(fmt): rustfmt * refactor(panes): various cleanups * chore(deps): upgrade termwiz to get alt left-bracket * fix(assets): merge conflicts of binary files * style(fmt): rustfmt * style(clippy): no thank you! * chore(repo): remove garbage file
* fix(panes): show visual error when unable to split panes ↵Aram Drevekenin2022-12-14
| | | | | | | vertically/horizontally (#2025) * fix(panes): show visual error when failing to split pane vertically/horizontally * fix: lockfile
* refactor(plugins): fix plugin loading data flow (#1995)Aram Drevekenin2022-12-06
|
* refactor(plugins): change the data flow (#1934)Aram Drevekenin2022-11-15
| | | | | | | | | * refactor(plugins): do not block render loop * refactor(plugins): cleanup * style(fmt): rustfmt * fix(plugins): various rendering pipeline fixes
* zellij-server: improve thread_bus error handling (#1775)Bohdan Ivashko2022-10-07
| | | | | | | * zellij-server: improve thread_bus error handling * zellij-server/thread_bus: get rid of option.unwrap * zellij-utils/errors.rs: generic error in to_anyhow
* feat(config): switch to kdl (#1759)Aram Drevekenin2022-10-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
* fix(terminal): SGR/UTF8 mouse reporting in terminal panes (#1664)Aram Drevekenin2022-08-17
| | | | | | | | | | | | | | | | | | | | | | | * work * work * fix: selection mishandling * style(fmt): rustfmt * style(comments): remove outdated * style(clippy): make clippy happy * fix(mouse): off by one sgr/utf8 reporting * style(fmt): rustfmt * fix(mouse): correctly report drag event code * fix(input): support mouse middle click * style(fmt): rustfmt
* fix(pty): paste freeze with large amounts of text (#1383)Thomas Linford2022-05-16
| | | add pty writer thread to avoid screen thread blocking on unistd::write
* chore(tests): move all integration tests to be either unit or e2e tests - ↵Aram Drevekenin2021-06-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | remove old testing infra (#589) * tests(integration): move basic integration tests to be unit tests * fix(tests): silently fail threadbus for tests * tests(unit): move compatibility tests to become unit tests for grid * tests(unit): move close_pane tests to become unit tests for grid * tests(e2e): move basic layout test to e2e * tests(unit): move move_focus tests to be unit tests * tests(unit): move resize_down tests to be unit tests * tests(unit): move resize_left tests to be unit tests * tests(unit): move resize_right tests to be unit tests * tests(unit): move resize_up tests to be unit tests * tests(infra): remove unused infra * style(fmt): make rustfmt happy * debug * debug * debug * debug * chore(test): shift volume mounting around because github actions is a special child
* refactors for #525 (#534)kxt2021-05-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * refactor(fakes): clean up add_terminal_input * refactor(fakes): append whole buf to output_buffer in FakeStdoutWriter::write * refactor(fakes): append whole buf to output_buffer in FakeInputOutput::write_to_tty_stdin * fix(fakes): allow partial reads in read_from_tty_stdout This patch fixes two bugs in read_from_tty_stdout: * if there was a partial read (ie. `bytes.read_position` is not 0 but less than `bytes.content.len()`), subsequent calls to would fill `buf` starting at index `bytes.read_position` instead of 0, leaving range 0..`bytes.read_position` untouched. * if `buf` was smaller than `bytes.content.len()`, a panic would occur. * refactor(channels): use crossbeam instead of mpsc This patch replaces mpsc with crossbeam channels because crossbeam supports selecting on multiple channels which will be necessary in a subsequent patch. * refactor(threadbus): allow multiple receivers in Bus This patch changes Bus to use multiple receivers. Method `recv` returns data from all of them. This will be used in a subsequent patch for receiving from bounded and unbounded queues at the same time. * refactor(channels): remove SenderType enum This enum has only one variant, so the entire enum can be replaced with the innards of said variant. * refactor(channels): remove Send+Sync trait implementations The implementation of these traits is not necessary, as SenderWithContext is automatically Send and Sync for every T and ErrorContext that's Send and Sync.
* fmt and clippyKunal Mohan2021-05-16
|
* Big refactor: separate crates for client, server and utilitiesKunal Mohan2021-05-16