Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Synchronize Panes: new feature auto-hide #360

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
webdavis wants to merge 4 commits into dracula:master
base: master
Choose a base branch
Loading
from webdavis:synchronize-panes/feature/auto-hide

Conversation

Copy link

@webdavis webdavis commented Sep 29, 2025
edited
Loading

Ello,

This PR does the following

  • Allows folks to automatically hide the sync label when it's off via @dracula-synchronize-panes-auto-hide.
  • Allows them to also set a custom refresh rate for it via @dracula-synchronize-panes-refresh-rate
    • Note: this won't effect the global refresh rate managed by @dracula-refresh-rate

Here's how to configure it in practice:

set-option -g @dracula-synchronize-panes-label "Sync"
# Defaults to 'false'
set-option -g @dracula-synchronize-panes-auto-hide true
# Defaults to no value. If no value, then @dracula-refresh-rate takes precedence
set-option -g @dracula-synchronize-panes-refresh-rate "0.5"
set-option -g @dracula-plugins "ssh-session cpu-arch synchronize-panes"

I'm already using this and I haven't noticed any issues (yet). Let me know what you think or any changes I need to make to get this merged.

Cheers!

Theoreticallyhugo and others added 3 commits September 28, 2025 19:32
...chronize-panes-auto-hide`
This allows the user to hide the Sync label (`@dracula-synchronize-panes-label`) from the status bar
when sync is in the `off` state
...panes-refresh-rate`) that takes precedence over `@dracula-refresh-rate`
This enables the user to set a custom `synchronize-panes` refresh rate,
which may need to be more frequent than other plugins
Copy link

coderabbitai bot commented Sep 29, 2025
edited
Loading

📝 Walkthrough

Walkthrough

Adds two tmux options to documentation and updates synchronize_panes.sh to support a refresh-rate override and an auto-hide output mode, alters output formatting based on status and auto-hide, and adjusts variable initialization order while preserving the sleep-based refresh.

Changes

Cohort / File(s) Summary
Docs: synchronize panes options
docs/CONFIG.md
Documents two new options: @dracula-synchronize-panes-auto-hide (default false) and @dracula-synchronize-panes-refresh-rate (no default), clarifying auto-hide behavior when sync is off.
Script: synchronize panes behavior
scripts/synchronize_panes.sh
Adds RATE override via @dracula-synchronize-panes-refresh-rate; reads @dracula-synchronize-panes-auto-hide (default "false"); changes echo logic to hide status when auto-hide is true and sync is on; reorders label assignment after rate handling; retains sleep RATE.

Sequence Diagram(s)

sequenceDiagram
 autonumber
 participant TMUX as tmux env/options
 participant Script as synchronize_panes.sh
 participant Output as Status Line
 Note over Script: Start tick
 Script->>TMUX: read synchronize_panes status (on/off)
 Script->>TMUX: read @dracula-synchronize-panes-refresh-rate
 alt RATE override set
 Script->>Script: RATE = override
 else no override
 Script->>Script: RATE = default
 end
 Script->>TMUX: read @dracula-synchronize-panes-auto-hide (default false)
 Script->>Script: set label (synchronize_panes_label)
 alt auto_hide == true and status == "on"
 Script->>Output: echo label
 Note right of Output: New conditional output (auto-hide)
 else otherwise
 Script->>Output: echo "label status"
 end
 Script->>Script: sleep RATE
 Note over Script: End tick
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title correctly highlights one of the two new features (the auto-hide option) introduced by this PR, making it related to the changeset, but it omits the custom refresh rate option which is also a significant addition; therefore it partially reflects the changes and passes the relevance criteria.
Description Check ✅ Passed The description clearly outlines both the new auto-hide and custom refresh rate features, provides configuration examples, and directly relates to the changes in the pull request.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 19e3e74 and 215af3e.

📒 Files selected for processing (1)
  • docs/CONFIG.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/CONFIG.md

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (5)
scripts/synchronize_panes.sh (4)

19-25: Per-widget refresh override: good addition; add basic validation.

Current logic accepts any string; a non-numeric value will make sleep fail. Recommend validating and falling back to the global rate.

- RATE_OVERRIDE=$(get_tmux_option "@dracula-synchronize-panes-refresh-rate" "")
- if [[ -n "$RATE_OVERRIDE" ]]; then
- RATE="$RATE_OVERRIDE"
- fi
+ RATE_OVERRIDE=$(get_tmux_option "@dracula-synchronize-panes-refresh-rate" "")
+ if [[ -n "$RATE_OVERRIDE" ]]; then
+ # accept integers or decimals like 0.5; clamp to a sane minimum to avoid busy looping
+ if [[ "$RATE_OVERRIDE" =~ ^([0-9]+)(\.[0-9]+)?$ ]]; then
+ RATE="$RATE_OVERRIDE"
+ # optional clamp
+ (( $(awk "BEGIN{print ($RATE<0.1)}") )) && RATE=0.1
+ fi
+ fi

26-26: Boolean option parsing is case-sensitive.

You compare strictly to 'true'. Consider normalizing to lowercase to avoid surprises from users setting True/TRUE.

- synchronize_panes_auto_hide=$(get_tmux_option "@dracula-synchronize-panes-auto-hide" "false")
+ synchronize_panes_auto_hide=$(get_tmux_option "@dracula-synchronize-panes-auto-hide" "false")
+ synchronize_panes_auto_hide="${synchronize_panes_auto_hide,,}"

28-36: Confirm intended UX: label-only when on, nothing when off.

With auto-hide=true: you output only the label when sync is on, and nothing when it’s off. That matches "hide when off" but also removes the "on" suffix entirely. Confirm this is desired for consistency with other widgets.

You can reduce nesting and make behavior explicit:

- if [[ "$synchronize_panes_auto_hide" == 'true' ]]; then
- if [[ "$synchronize_panes_status" == 'on' ]]; then
- echo "$synchronize_panes_label"
- fi
- else
- echo "$synchronize_panes_label $synchronize_panes_status"
- fi
+ if [[ "$synchronize_panes_auto_hide" == 'true' && "$synchronize_panes_status" == 'off' ]]; then
+ : # hide
+ elif [[ "$synchronize_panes_auto_hide" == 'true' ]]; then
+ echo "$synchronize_panes_label"
+ else
+ echo "$synchronize_panes_label $synchronize_panes_status"
+ fi

38-38: Portability of fractional sleep.

Docs suggest "0.5"; fractional sleep is GNU/coreutils-friendly but may vary with BusyBox/older BSDs. Either document the requirement or guard with integer fallback.

Add a pre-check:

- sleep $RATE
+ if ! sleep "$RATE" 2>/dev/null; then
+ # fallback to nearest integer second
+ sleep "${RATE%.*}"
+ fi
docs/CONFIG.md (1)

815-821: Clarify behavior and constraints for new options.

  • Spell out the exact behavior with auto-hide: when true, the widget shows only the label while sync is on, and hides entirely when off.
  • Note that @dracula-synchronize-panes-refresh-rate overrides this widget only; it does not change @dracula-refresh-rate.
  • Mention that boolean values are case-sensitive ('true'/'false').
  • If you intend to support decimals (e.g., "0.5"), add a brief portability note that fractional sleep requires GNU/coreutils or compatible environments.

Proposed wording:

# synchronize-panes
...
Optional:
set -g @dracula-synchronize-panes-auto-hide true # when true: shows only the label while sync is on; hides the widget when sync is off
set -g @dracula-synchronize-panes-refresh-rate "0.5" # refresh rate for this widget only; does not affect @dracula-refresh-rate
# Note: values are case-sensitive; use 'true'/'false'. Fractional rates require a shell/coreutils that support fractional `sleep`.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 91a1e09 and 19e3e74.

📒 Files selected for processing (2)
  • docs/CONFIG.md (1 hunks)
  • scripts/synchronize_panes.sh (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
scripts/synchronize_panes.sh (1)
scripts/utils.sh (1)
  • get_tmux_option (3-12)
🔇 Additional comments (1)
scripts/synchronize_panes.sh (1)

10-13: No action needed: get_tmux_window_option is defined in scripts/utils.sh and correctly sourced in scripts/synchronize_panes.sh.

@webdavis webdavis force-pushed the synchronize-panes/feature/auto-hide branch from 19e3e74 to 215af3e Compare September 29, 2025 02:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@coderabbitai coderabbitai[bot] coderabbitai[bot] left review comments

Assignees

No one assigned

Labels

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /