feat(load): animated progress spinner for tmuxp load#1020
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1020 +/- ##
==========================================
- Coverage 81.08% 81.01% -0.08%
==========================================
Files 28 28
Lines 2506 2623 +117
Branches 463 492 +29
==========================================
+ Hits 2032 2125 +93
- Misses 352 367 +15
- Partials 122 131 +9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…1017) Add structured logging with `extra` context across all modules and clean up output channels. Every module now declares `logging.getLogger(__name__)` with structured keys (`tmux_session`, `tmux_window`, `tmux_pane`, `tmux_config_path`) for filtering and aggregation. A new `TmuxpLoggerAdapter` provides persistent identity context for session/window/pane objects, portable across Python 3.10–3.13+. - **Structured logging**: workspace builder emits INFO for session lifecycle and DEBUG for window/pane creation; finders, freezer, importers, loader, and validation modules emit DEBUG with config context; `NullHandler` added in library `__init__.py` - **Colorama removal**: replace `colorama` runtime and type-stub dependencies with stdlib ANSI escape constants - **Output channels**: route all raw `print()` calls through `tmuxp_echo()`; separate diagnostics (`logger.*()`) from user-facing output (`tmuxp_echo()`) per logging standards - **OutputFormatter.emit_object()**: single-object JSON output for `ls --json` and `debug-info --json`; `Colors.format_rule()` with Unicode box-drawing characters - **CLI log level**: default changed from INFO to WARNING so normal usage is not noisy - **Traceback suppression**: build-failure tracebacks moved from user-visible `tmuxp_echo(traceback.format_exc())` to `logger.debug(exc_info=True)`; users see `[Error] <message>`, full traceback available via `--log-level debug` - **`get_pane()` fix**: widen catch to `Exception` (matching `get_session`/`get_window`), preserve exception chain via `from e`, replace bare `print()` with structured debug log - **Log file handler**: `setup_log_file()` replaces inline handler setup in `command_load()`, respects `--log-level` flag Base PR for #1020 (animated progress spinner for `tmuxp load`).
b176f89 to
b078902
Compare
Code reviewFound 1 issue:
Lines 164 to 170 in b078902 vs. tmuxp/src/tmuxp/cli/_progress.py Lines 128 to 137 in b078902 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
… and build_event callbacks why: The builder needs to emit lifecycle events so a UI layer can render real-time progress without coupling builder logic to display code. what: - Add on_progress, on_before_script, on_script_output, on_build_event callback parameters to WorkspaceBuilder - Emit structured build events: session_created (with window_total, session_pane_total), window_started, pane_creating, window_done, workspace_built, before_script_started, before_script_done - Add on_line callback to run_before_script() for capturing script output - Add doctests for all callback types
why: The CLI needs an animated progress display during workspace builds.
A dedicated module keeps display logic decoupled from builder and load.
what:
- Add Spinner context manager with atexit cursor restore and non-TTY fallback
- Add BuildTree for tracking build state (session, windows, panes)
- Add scrolling output panel for before_script output lines
- Add PROGRESS_PRESETS (default, minimal, window, pane, verbose) with
format_template using {session}, {window}, {bar}, {progress}, etc.
- Add render_bar() with marching indicator during before_script
- Add SUCCESS_TEMPLATE and format_success() for persistent completion line
- Add _SafeFormatMap, ANSI-aware truncation, dynamic terminal width refresh
Code reviewFound 1 issue:
Lines 399 to 401 in ee73c01 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
Code reviewFound 1 issue:
Lines 39 to 41 in 92bdc95 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
202b49a to
f7fb9f0
Compare
why: Users need visual feedback during workspace builds, especially for sessions with many windows or long before_script executions. what: - Add _silence_stream_handlers() to suppress StreamHandler during spinner - Add _dispatch_build() extracting shared build/attach/error logic - Wire Spinner.on_build_event and add_output_line to builder callbacks - Add --progress-format / TMUXP_PROGRESS_FORMAT for preset or custom format - Add --progress-lines / TMUXP_PROGRESS_LINES for panel height control - Add --no-progress / TMUXP_PROGRESS=0 to disable spinner entirely - Emit persistent success line with checkmark after successful build - Stop spinner before interactive prompts (TMUX switch, error recovery)
…ld progress why: The progress spinner and its CLI wiring need thorough test coverage for BuildTree state, template rendering, bar generation, panel behavior, and CLI flag handling. what: - Add tests/cli/test_progress.py covering Spinner lifecycle, BuildTree state transitions, template presets, bar rendering, panel lines, ANSI truncation, non-TTY fallback, and success output - Add tests/workspace/test_progress.py for builder callback integration - Update tests/cli/test_load.py for progress output assertions
why: Users need documentation for the progress spinner feature. what: - Add "Progress display" section to docs/cli/load.md with presets, tokens, panel lines, disabling, and before-script behavior - Add TMUXP_PROGRESS, TMUXP_PROGRESS_FORMAT, TMUXP_PROGRESS_LINES to environmental-variables.md - Add docs/api/cli/progress.md API reference page
why: PR 2 needs changelog entry for the progress spinner feature. what: - Add "Animated progress spinner" section under What's new
Code reviewFound 1 issue:
Lines 406 to 410 in 96ede9b 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
Code review update: retracting previous findingThe issue I flagged (
No issues found. Checked for bugs, git history context, and CLAUDE.md compliance. 🤖 Generated with Claude Code |
Summary
tmuxp loadwith real-time build feedback as windows and panes are createdon_progress,on_before_script,on_script_output,on_build_event) for decoupled progress reportingSpinnerandBuildTreeclasses in_progress.pywith five built-in presets (default,minimal,window,pane,verbose)--progress-format,--progress-lines,--no-progressCLI flags and correspondingTMUXP_PROGRESS*environment variablesChanges by area
Builder callbacks (
workspace/builder.py)on_progress: Fires after each pane creation with window/pane index contexton_before_script: Fires beforerun_before_script()executionon_script_output: Receives lines frombefore_scriptvia newon_linecallback inrun_before_script()on_build_event: Structured lifecycle events (session_created,window_started,pane_created,window_finished,build_complete)Spinner module (
cli/_progress.py)Spinner: Terminal spinner with ANSI-aware truncation, atexit cursor restore, scrolling output panelBuildTree: Tracks build state, provides template context with progress tokens ({bar},{progress},{window}, etc.)PROGRESS_PRESETS: Five named format strings; custom format strings also supportedrender_bar(): Composite progress bar with window/pane segments and marching animation duringbefore_scriptCLI wiring (
cli/load.py)Spinnerinload_workspace()Documentation
docs/cli/load.md: Progress display section with presets, tokens, panel config, disablingdocs/configuration/environmental-variables.md:TMUXP_PROGRESS,TMUXP_PROGRESS_FORMAT,TMUXP_PROGRESS_LINESdocs/api/cli/progress.md: API reference for_progressmoduleTest plan
test_progress.py— spinner rendering, BuildTree state, preset resolution, format tokens, bar rendering, ANSI truncation, atexit cleanuptest_progress.py(workspace) — builder callback integration with real tmux fixturestest_load.py—--no-progressand--progress-formatflag handlinguv run ruff check .— cleanuv run mypy— cleanuv run py.test -x— all pass