You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: give widget commands the path of StableBar and of their configuration - #734
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.
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.
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: 3
Check name
Status
Explanation
Description check
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
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
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:
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.
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.
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.
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.
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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,--popupand--queryreach the default configuration instead of the bar that ran the script.Closes #301
Changes
STABLEBAR, the running executable's path, andSTABLEBAR_CONFIG, the configuration file the bar was started with. LikeNAMEandCONFIG_DIR, the top-level, widget and providerenvironmentand event data can't replace them.STABLEBAR_CONFIGis 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.--config, the command line usesSTABLEBAR_CONFIGas its configuration, so"$STABLEBAR" --refresh weatherin a widget reaches its own bar."$STABLEBAR"example in the widget guide, the provider note, and--configand--triggerin the command-line page.The open question:
--triggerkeeps broadcasting. Without--config,--triggerand--reloadstill reach every bar, even whenSTABLEBAR_CONFIGis 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 yabaias 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 totargetedinLaunchCommand.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, thenswift test --skip-buildon the script, provider, runtime control, triage, bug report and uninstall tests: 238 passed.scriptEnvironmentCombinesConfigurationWidgetAndEventContextnow checks both variables, set wrongly in the configuration and in event data.STABLEBAR_CONFIG=<scratch> StableBar --validatevalidated the scratch file;--queryreported that no bar runs with theSTABLEBAR_CONFIGpath, and with--configit named the--configpath instead.scripts/check.sh --quickpassed.Merging
One commit; any merge method works.
Claude Opus 5.5 via Claude Code (T3 Code)