Skip to content

feat: give widget commands the path of StableBar and of their configuration - #734

Open
Seb-GRAF wants to merge 4 commits into
mainfrom
feat/301-script-bar-environment
Open

Seb-GRAF wants to merge 4 commits into
mainfrom
feat/301-script-bar-environment

Conversation

@Seb-GRAF

Copy link
Copy Markdown
Owner

Problem

A widget script that calls the command line doesn't know which StableBar runs it or which configuration file that bar uses, so --refresh, --popup and --query reach the default configuration instead of the bar that ran the script.

Closes #301

Changes

  • Every widget, action and provider command gets STABLEBAR, the running executable's path, and STABLEBAR_CONFIG, the configuration file the bar was started with. Like NAME and CONFIG_DIR, the top-level, widget and provider environment and event data can't replace them.
  • STABLEBAR_CONFIG is the shared file the bar was started with, not a screen setup's own bar file, because the control endpoint is keyed on that file.
  • Without --config, the command line uses STABLEBAR_CONFIG as its configuration, so "$STABLEBAR" --refresh weather in a widget reaches its own bar.
  • Docs: the variables table and a "$STABLEBAR" example in the widget guide, the provider note, and --config and --trigger in the command-line page.

The open question: --trigger keeps broadcasting. Without --config, --trigger and --reload still reach every bar, even when STABLEBAR_CONFIG is set. This changes no existing behavior: a widget whose trigger is meant for widgets in another bar keeps working, and yabai's signal check, which treats a plain --trigger yabai as reaching every bar, stays right. The bar that ran the script still gets the event. A script that wants only its own bar adds --config "$STABLEBAR_CONFIG", which the command-line page now says. If you'd rather have scripts target one bar, it's a one-line change to targeted in LaunchCommand.

Not handled: a widget script that runs "$STABLEBAR" with no arguments now tries to start a second bar on its own configuration and fails because that configuration already has a running bar. Before this change it started a bar on the default configuration.

Testing

  • swift build --build-tests, then swift test --skip-build on the script, provider, runtime control, triage, bug report and uninstall tests: 238 passed.
  • scriptEnvironmentCombinesConfigurationWidgetAndEventContext now checks both variables, set wrongly in the configuration and in event data.
  • By hand, with scratch files only: STABLEBAR_CONFIG=<scratch> StableBar --validate validated the scratch file; --query reported that no bar runs with the STABLEBAR_CONFIG path, and with --config it named the --config path instead.
  • scripts/check.sh --quick passed.
  • Nothing visible changes, so there are no screenshots.

Merging

One commit; any merge method works.

Claude Opus 5.5 via Claude Code (T3 Code)

@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between f9fb8fd and 690d24a.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

Provider and widget command environments now include the running StableBar executable and configuration paths. Live commands use the supplied configuration path when --config is absent. Tests and documentation cover the environment values and command behavior.

Changes: Widget command context

Layer / File(s) Summary
Provide protected bar context
Sources/StableBar/BarStore.swift, Sources/StableBar/ScriptWidget.swift, Tests/StableBarTests/ScriptEventTests.swift, docs/providers.md
Provider and widget command environments now include STABLEBAR and STABLEBAR_CONFIG. Tests check that event data cannot replace these values and retain precedence checks for other environment values. Provider documentation describes both variables.
Select configuration for live commands
Sources/StableBar/LaunchCommand.swift, docs/command-line.md, docs/create-a-widget.md
When --config is absent, LaunchCommand uses STABLEBAR_CONFIG if set and otherwise uses the default configuration path. Documentation describes this behavior, --trigger broadcasting, and invoking commands through STABLEBAR.

Severity of issue fixed: Medium

Merge Risk: Minimal · previous review f9fb8

Widget and provider commands now receive the running executable and configuration paths, and live commands use that configuration by default. The change is additive and tested, and no merge-blocking risk was found.

Pre-merge checks: Passed 3

Check name Status Explanation
Description check Passed The description is thorough and covers the problem, the changes, testing, and the merge method. It closes issue #301 and explains the open --trigger question. It also notes a known regression for `"…
Linked Issues check Passed Issue #301 has one direct linked issue with these coding requirements:
1. Commands get STABLEBAR and STABLEBAR_CONFIG, and event data cannot replace them. BarStore.swift adds both to provider and …
Out of Scope Changes check Passed All changed areas relate to #301: the environment injection in BarStore.swift and ScriptWidget.swift, the default configuration in LaunchCommand.swift, the test update in ScriptEventTests.swift, and t…
Full details: Description check

Explanation

The description is thorough and covers the problem, the changes, testing, and the merge method. It closes issue #301 and explains the open --trigger question. It also notes a known regression for "$STABLEBAR" run without arguments. The template's final line asks for the model and harness that did the work. The description gives "Claude Opus 5.5 via Claude Code (T3 Code)" as its last line, which satisfies that requirement. Every template section is present and substantive.

Full details: Linked Issues check

Explanation

Issue #301 has one direct linked issue with these coding requirements:

  1. Commands get STABLEBAR and STABLEBAR_CONFIG, and event data cannot replace them. BarStore.swift adds both to provider and widget command environments. ScriptWidget.swift copies them in ScriptEvent.commandEnvironment and in the provider ScriptWidget.start path, next to the protected NAME and CONFIG_DIR. ScriptEventTests.swift checks both variables against wrong configuration and event-data values.
  2. Without --config, the command line uses STABLEBAR_CONFIG. LaunchCommand.swift init(arguments:) uses that value as its default configuration path, and an explicit --config still overrides it.
  3. Guide examples use "$STABLEBAR". docs/create-a-widget.md now has a "$STABLEBAR" --refresh weather example and a variables table. The external --trigger examples in the same guide still use the absolute executable path. This is correct, because those hooks run outside a widget, where STABLEBAR is not set.

Open question: the PR keeps --trigger and --reload broadcasting without --config. The issue marks this as an open question. The PR states the choice, documents it in docs/command-line.md, and gives a one-line alternative. The bar that ran the script still receives the event, so the stated proposal behavior is met. Repository inspection was limited to the widget guide and the summary, so the code paths in BarStore.swift and LaunchCommand.swift were checked only through the summary.

Full details: Out of Scope Changes check

Explanation

All changed areas relate to #301: the environment injection in BarStore.swift and ScriptWidget.swift, the default configuration in LaunchCommand.swift, the test update in ScriptEventTests.swift, and the documentation in command-line.md, create-a-widget.md and providers.md. The docs changes describe the new variables and the --config behavior. No unrelated behavior change appears in the summary. The --trigger broadcast behavior is unchanged, so it does not add scope.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 9ac8fb0 and f9fb8fd.

Files selected for processing: 7

  • Sources/StableBar/BarStore.swift
  • Sources/StableBar/LaunchCommand.swift
  • Sources/StableBar/ScriptWidget.swift
  • Tests/StableBarTests/ScriptEventTests.swift
  • docs/command-line.md
  • docs/create-a-widget.md
  • docs/providers.md

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Before and after

main at c82c27b → this pull request at 690d24a · 184 screens drawn · 0 changed

184 unchanged screens

docs/essentials-clock-settings-dark, docs/essentials-clock-settings-light, docs/essentials-dark, docs/essentials-light, docs/essentials-settings-dark, docs/essentials-settings-light, docs/hero-dark, docs/hero-light, docs/popups-dark, docs/popups-light, docs/settings-dark, docs/settings-light, docs/themes-dark, docs/themes-light, scenes/accessibility-guide-dark, scenes/accessibility-guide-light, scenes/app-menu-popup-dark, scenes/app-menu-popup-light, scenes/apple-menu-settings-dark, scenes/apple-menu-settings-light, scenes/bottom-bar-popup-dark, scenes/bottom-bar-popup-light, scenes/chat-popup-dark, scenes/chat-popup-light, scenes/crowded-edit-bar-dark, scenes/crowded-edit-bar-light, scenes/disk-meter-bar-dark, scenes/disk-meter-bar-light, scenes/dock-badges-bar-dark, scenes/dock-badges-bar-light, scenes/edit-bar-wide-group-dark, scenes/edit-bar-wide-group-light, scenes/essentials-clock-popup-dark, scenes/essentials-clock-popup-light, scenes/essentials-disk-popup-dark, scenes/essentials-disk-popup-light, scenes/filled-slider-popup-dark, scenes/filled-slider-popup-light, scenes/group-members-bar-dark, scenes/group-members-bar-light, scenes/gruvbox-bar-dark, scenes/gruvbox-bar-light, scenes/horizontal-list-popup-dark, scenes/horizontal-list-popup-light, scenes/increase-contrast-bar-dark, scenes/increase-contrast-bar-light, scenes/increase-contrast-popup-dark, scenes/increase-contrast-popup-light, scenes/input-source-popup-dark, scenes/input-source-popup-light, scenes/merged-status-bar-dark, scenes/merged-status-bar-light, scenes/notch-flare-bar-dark, scenes/notch-flare-bar-light, scenes/output-device-popup-dark, scenes/output-device-popup-light, scenes/popup-gap-bar-dark, scenes/popup-gap-bar-light, scenes/popup-spacing-bar-dark, scenes/popup-spacing-bar-light, scenes/popup-view-dark, scenes/popup-view-light, scenes/privacy-both-bar-dark, scenes/privacy-both-bar-light, scenes/privacy-hide-when-idle-bar-dark, scenes/privacy-hide-when-idle-bar-light, scenes/privacy-idle-bar-dark, scenes/privacy-idle-bar-light, scenes/privacy-microphone-bar-dark, scenes/privacy-microphone-bar-light, scenes/privacy-settings-dark, scenes/privacy-settings-light, scenes/reduce-transparency-bar-dark, scenes/reduce-transparency-bar-light, scenes/reduce-transparency-glass-bar-dark, scenes/reduce-transparency-glass-bar-light, scenes/ring-bar-dark, scenes/ring-bar-light, scenes/settings-bar-dark, scenes/settings-bar-light, scenes/settings-bar-placement-bottom-dark, scenes/settings-bar-placement-bottom-light, scenes/settings-bar-placement-dark, scenes/settings-bar-placement-light, scenes/settings-crashes-dark, scenes/settings-crashes-light, scenes/settings-disk-widget-dark, scenes/settings-disk-widget-light, scenes/settings-feedback-dark, scenes/settings-feedback-light, scenes/settings-general-dark, scenes/settings-general-light, scenes/settings-general-macos15-dark, scenes/settings-general-macos15-light, scenes/settings-general-move-dark, scenes/settings-general-move-failed-dark, scenes/settings-general-move-failed-light, scenes/settings-general-move-light, scenes/settings-general-move-moving-dark, scenes/settings-general-move-moving-light, scenes/settings-general-move-replace-dark, scenes/settings-general-move-replace-light, scenes/settings-general-setup-open-dark, scenes/settings-general-setup-open-light, scenes/settings-general-spaces-dark, scenes/settings-general-spaces-light, scenes/settings-help-dark, scenes/settings-help-light, scenes/settings-help-starred-dark, scenes/settings-help-starred-light, scenes/settings-narrow-dark, scenes/settings-narrow-light, scenes/settings-package-dark, scenes/settings-package-light, scenes/settings-package-widget-dark, scenes/settings-package-widget-light, scenes/settings-profiles-dark, scenes/settings-profiles-light, scenes/settings-profiles-theme-dark, scenes/settings-profiles-theme-light, scenes/settings-store-dark, scenes/settings-store-light, scenes/settings-theme-dark, scenes/settings-theme-light, scenes/settings-theme-link-dark, scenes/settings-theme-link-light, scenes/settings-uninstall-dark, scenes/settings-uninstall-failed-dark, scenes/settings-uninstall-failed-light, scenes/settings-uninstall-light, scenes/settings-widget-backgrounds-dark, scenes/settings-widget-backgrounds-light, scenes/settings-workspace-hidden-dark, scenes/settings-workspace-hidden-light, scenes/setup-look-below-menu-bar-dark, scenes/setup-look-dark, scenes/setup-look-no-notch-dark, scenes/setup-move-existing-dark, scenes/setup-move-failed-dark, scenes/setup-move-ready-dark, scenes/setup-move-replace-dark, scenes/setup-omniwm-connection-dark, scenes/setup-permissions-dark, scenes/setup-permissions-spaces-dark, scenes/setup-permissions-spaces-ready-dark, scenes/setup-placement-bottom-dark, scenes/setup-placement-dark, scenes/setup-touches-dark, scenes/setup-touches-macos15-dark, scenes/setup-touches-spaces-dark, scenes/setup-try-dark, scenes/setup-yabai-connection-dark, scenes/slider-end-stop-popup-dark, scenes/slider-end-stop-popup-light, scenes/stablebar-widget-bar-dark, scenes/stablebar-widget-bar-light, scenes/stablebar-widget-settings-dark, scenes/stablebar-widget-settings-light, scenes/starter-bar-dark, scenes/starter-bar-light, scenes/starter-edit-bar-dark, scenes/starter-edit-bar-light, scenes/symbol-variants-bar-dark, scenes/symbol-variants-bar-light, scenes/system-monitor-memory-bar-dark, scenes/system-monitor-memory-bar-light, scenes/system-monitor-shows-settings-dark, scenes/system-monitor-shows-settings-light, scenes/system-monitor-split-warning-bar-dark, scenes/system-monitor-split-warning-bar-light, scenes/update-popup-dark, scenes/update-popup-light, scenes/update-popup-star-github-cli-dark, scenes/update-popup-star-github-cli-light, scenes/update-popup-star-thanks-dark, scenes/update-popup-star-thanks-light, scenes/workspace-badges-bar-dark, scenes/workspace-badges-bar-light, scenes/workspace-focused-window-bar-dark, scenes/workspace-focused-window-bar-light, scenes/workspace-focused-window-padding-bar-dark, scenes/workspace-focused-window-padding-bar-light, scenes/workspace-hidden-apps-bar-dark, scenes/workspace-hidden-apps-bar-light

Visual review: 184 screens, none changed.

@Seb-GRAF

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Action not completed

No files to review.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Let widget scripts reach the bar that runs them

1 participant