Skip to content

feat: custom browser command config option#28

Merged
emarkou merged 2 commits into
mainfrom
feat/custom-browser
May 13, 2026
Merged

feat: custom browser command config option#28
emarkou merged 2 commits into
mainfrom
feat/custom-browser

Conversation

@emarkou

@emarkou emarkou commented May 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add browser config key to ~/.config/devskim/config.toml
  • When set, URLs are opened with that command instead of the system default
  • Supports commands with arguments (e.g. "open -a Safari", "firefox --private-window")
  • Empty string (default) falls back to existing system browser behavior

Usage

browser = "firefox"
# or
browser = "open -a Safari"
# or
browser = "firefox --private-window"

Test plan

  • browser = "firefox"firefox <url> spawned on o keypress
  • browser = "open -a Safari" → args split correctly
  • browser = "" → system default browser used (existing behavior unchanged)
  • 190 tests pass, ruff + mypy clean, coverage 74% → 79%

Summary by CodeRabbit

  • New Features

    • Added an optional "browser" config to specify a custom command template for opening URLs; empty value uses the system default
    • Browser command strings with arguments are correctly parsed and launched; failures fall back to the default opener
  • Documentation

    • README updated to document the new "browser" setting and the "theme" option (auto/dark/light/named themes)
  • Tests

    • Added coverage for custom browser behavior, fallback cases, and config parsing

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 13, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6fcc0866-880c-4f48-a3e7-a419d2fd27f4

📥 Commits

Reviewing files that changed from the base of the PR and between accdcd0 and c6189b2.

📒 Files selected for processing (2)
  • devskim/app.py
  • tests/test_app_theme.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • devskim/app.py
  • tests/test_app_theme.py

📝 Walkthrough

Walkthrough

Adds an optional browser config key, parses it into Config, and makes DevSkimApp.open_url launch the configured command via subprocess (with error and blank-value fallbacks to the parent App.open_url). Tests and README documentation were updated accordingly.

Changes

Configurable Browser Command

Layer / File(s) Summary
Configuration schema and defaults
devskim/config.py, README.md
Config dataclass adds browser: str = ""; DEFAULT_CONFIG documents a commented browser line; README documents theme and browser keys.
Configuration file parsing
devskim/config.py
load_config() reads browser from config.toml and passes it into Config.
Browser command execution
devskim/app.py
Adds shlex and subprocess imports and overrides DevSkimApp.open_url() to run subprocess.Popen(shlex.split(browser) + [url]) when configured, falling back to super().open_url() on errors or when blank.
Configuration validation tests
tests/test_config.py
Adds tests asserting Config().browser defaults to empty and that load_config() reads browser = "firefox" from a file.
App open_url functionality tests
tests/test_app_theme.py
Extends async tests to validate subprocess argv splitting for custom browser strings and fallback delegation to App.open_url() when browser is blank or when Popen raises OSError/ValueError.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I nibble code and hop with glee,
A browser key now speaks to me.
Split the args, then run the call,
If errors spring, I softly fall—
Back to default, URL stands tall.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 13.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: custom browser command config option' directly and clearly describes the main feature added: a configuration option for custom browser commands. It accurately reflects the primary change across all modified files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/custom-browser

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

@codecov

codecov Bot commented May 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.30%. Comparing base (05fd3fd) to head (c6189b2).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #28      +/-   ##
==========================================
+ Coverage   73.67%   79.30%   +5.63%     
==========================================
  Files          18       18              
  Lines        1056     1068      +12     
==========================================
+ Hits          778      847      +69     
+ Misses        278      221      -57     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@devskim/app.py`:
- Around line 189-193: The open_url method currently trusts self.config.browser
and calls shlex.split and subprocess.Popen directly, which can raise ValueError
or OSError and also treats whitespace-only strings as valid; update open_url to
strip() self.config.browser, check for a non-empty value, then attempt to build
and run the command inside a try/except that catches ValueError and OSError
(from shlex.split and subprocess.Popen), log or print an error including the
exception, and on failure call super().open_url(url, new_tab=new_tab) as the
fallback.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2e31dd54-b74f-4eb4-be92-0fc14325ed50

📥 Commits

Reviewing files that changed from the base of the PR and between 05fd3fd and accdcd0.

📒 Files selected for processing (5)
  • README.md
  • devskim/app.py
  • devskim/config.py
  • tests/test_app_theme.py
  • tests/test_config.py

Comment thread devskim/app.py
@emarkou emarkou merged commit 20dee9f into main May 13, 2026
11 checks passed
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.

1 participant