Skip to content

Fix --no-open ignored on macOS and Windows in content-calendar viewer#92

Open
Osamaali313 wants to merge 1 commit into
nowork-studio:mainfrom
Osamaali313:fix/content-calendar-no-open-precedence
Open

Fix --no-open ignored on macOS and Windows in content-calendar viewer#92
Osamaali313 wants to merge 1 commit into
nowork-studio:mainfrom
Osamaali313:fix/content-calendar-no-open-precedence

Conversation

@Osamaali313

Copy link
Copy Markdown

Summary

The content-calendar viewer's --no-open flag ("Don't auto-open the browser") is ignored on macOS and Windows.

The auto-open guard in bin/notfair-content-calendar combines and/or without parentheses:

if not args.no_open and os.environ.get("DISPLAY", "") or sys.platform == "darwin" or sys.platform == "win32":

Since and binds tighter than or, this parses as:

(not args.no_open and DISPLAY) or (platform == "darwin") or (platform == "win32")

The two platform terms stand alone and never consult args.no_open. So on macOS and Windows — the two platforms where auto-open actually fires — the browser opens even when the user passes --no-open. (Headless Linux honored the flag, which is why it slipped through.)

Demonstration with --no-open set (correct result is False everywhere):

platform before after
darwin True False
win32 True False
linux False False

Fix

Extract the decision into a small, testable helper that short-circuits on no_open first:

def _should_auto_open(no_open: bool, platform: str, display: str) -> bool:
    """Whether to auto-open the browser. Honors --no-open on every platform."""
    if no_open:
        return False
    return bool(display) or platform == "darwin" or platform == "win32"
if _should_auto_open(args.no_open, sys.platform, os.environ.get("DISPLAY", "")):

Default-open behavior is preserved exactly: GUI platforms (macOS/Windows, or Linux with $DISPLAY) still auto-open when --no-open is not passed; headless Linux still does not.

Testing

Added test/unit/test_content_calendar_auto_open.py (loads the bin script via importlib, matching test_broken_link_checker.py):

pytest test/unit/test_content_calendar_auto_open.py
3 passed
  • --no-open suppresses auto-open on darwin / win32 / linux (this is what regressed).
  • Default opens on macOS, Windows, and Linux-with-$DISPLAY; headless Linux does not.

The auto-open guard combined `and`/`or` without parentheses:

    if not args.no_open and os.environ.get("DISPLAY", "") \
       or sys.platform == "darwin" or sys.platform == "win32":

`and` binds tighter than `or`, so this parses as
`(not no_open and DISPLAY) or darwin or win32`. The two platform terms stand
alone and ignore `args.no_open`, so on macOS and Windows the browser
auto-opens even when the user passes --no-open (the documented "Don't auto-open
the browser" flag). Linux happened to honor the flag, which hid the bug.

Extract the decision into a small, testable `_should_auto_open(no_open,
platform, display)` helper that short-circuits on no_open first.
Copilot AI review requested due to automatic review settings June 21, 2026 20:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

TheophilusChinomona added a commit to TheophilusChinomona/NotFair that referenced this pull request Jun 29, 2026
…er picker, --no-open precedence

Apply fixes from open upstream PRs that apply cleanly to our fork:

- AbortSignal (nowork-studio#80, ErnestHysa): wire signal? parameter through pickFolder
  and pickFolderMac to execFile, enabling clean cancellation of osascript.
  Also extend to the new Linux execDialog helper.

- Linux folder picker (nowork-studio#77, RohithVangalla1): implement pickFolderLinux using
  zenity (GTK) with kdialog (KDE) fallback, replacing the TODO stub.
  Linux users can now use the Browse button in the NotFair UI.

- --no-open precedence (nowork-studio#92, Osamaali313): extract the auto-open guard in
  bin/notfair-content-calendar into a _should_auto_open helper that checks
  --no-open before platform. Fixes macOS/Windows ignoring the flag.

Co-authored-by: Claude
TheophilusChinomona added a commit to TheophilusChinomona/NotFair that referenced this pull request Jun 29, 2026
Three cases tested per platform: no-open suppresses; default opens on
macOS/Windows/Linux-with-:0; headless Linux stays closed.
Mirrors the original PR nowork-studio#92 test structure using importlib.

Co-authored-by: Claude
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.

2 participants