diff --git a/Cargo.lock b/Cargo.lock index 02a0842..b1b160b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1323,9 +1323,9 @@ checksum = "f87165f0995f63a9fbeea62b64d10b4d9d8e78ec6d7d51fb2125fda7bb36788f" [[package]] name = "rustls-webpki" -version = "0.103.10" +version = "0.103.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df33b2b81ac578cabaf06b89b0631153a3f416b0a886e8a7a1707fb51abbd1ef" +checksum = "8279bb85272c9f10811ae6a6c547ff594d6a7f3c6c6b02ee9726d1d0dcfcdd06" dependencies = [ "aws-lc-rs", "ring", diff --git a/README.md b/README.md index 5548673..9dfc428 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Standalone Waybar module backends. ## Modules - `modules/agent-usage` — Codex and Claude usage -- `modules/github` — open GitHub pull requests +- `modules/github` — GitHub pull requests that request your review - `modules/linear` — unread Linear notifications - `modules/schedule` — upcoming meetings from Google Calendar diff --git a/modules/github/README.md b/modules/github/README.md index c895a80..56ef961 100644 --- a/modules/github/README.md +++ b/modules/github/README.md @@ -4,7 +4,7 @@ GitHub pull request module. ## Includes -- Fetch open pull requests for the current user +- Fetch open pull requests that request your review (excluding your own authored PRs by default) - Write Waybar output and a Gtk menu file - Open the dashboard or a selected item @@ -17,6 +17,17 @@ GitHub pull request module. | `cargo test -p waybar-github` | Run this package only | | `nix run 'path:.#github' -- status` | Run the status command | +## Query behavior + +Default search query: + +```text +is:open is:pr review-requested:@me -author:@me archived:false sort:updated-desc +``` + +Override with `WAYBAR_GITHUB_PR_QUERY` (or `PR_QUERY`) in `github-pull-requests.env`. +If your agents use dedicated bot accounts, append additional `-author:` qualifiers. + ## Usage ```bash diff --git a/modules/github/src/app.rs b/modules/github/src/app.rs index 9223661..f8f3cf1 100644 --- a/modules/github/src/app.rs +++ b/modules/github/src/app.rs @@ -99,7 +99,7 @@ fn build_status(config: &Config) -> Result { Ok(result) => { save_items(&config.items_path, &result.items)?; let status_line = if result.count > 0 { - "Open pull requests" + "Pull requests requiring review" } else { "No matching pull requests" } @@ -134,7 +134,7 @@ fn build_status(config: &Config) -> Result { } fn build_tooltip(result: &crate::github::FetchResult) -> String { - let mut lines = vec![format!("GitHub pull requests: {}", result.count)]; + let mut lines = vec![format!("GitHub review requests: {}", result.count)]; for item in &result.items { lines.push(format!( "{} #{}: {}", diff --git a/modules/github/src/config.rs b/modules/github/src/config.rs index d2d52ca..624f960 100644 --- a/modules/github/src/config.rs +++ b/modules/github/src/config.rs @@ -5,6 +5,8 @@ use anyhow::Result; use waybar_core::{XdgDirs, env_parse, env_value, load_env_file}; const MAX_ACTION_ITEMS: usize = 12; +const DEFAULT_PR_QUERY: &str = + "is:open is:pr review-requested:@me -author:@me archived:false sort:updated-desc"; #[derive(Debug, Clone, PartialEq, Eq)] pub struct Config { @@ -48,9 +50,7 @@ impl Config { ) .unwrap_or_else(|| format!("{}/graphql", api_url.trim_end_matches('/'))); let pr_query = env_value(&file_env, &["WAYBAR_GITHUB_PR_QUERY", "PR_QUERY"]) - .unwrap_or_else(|| { - "is:open is:pr involves:@me archived:false sort:updated-desc".into() - }); + .unwrap_or_else(|| DEFAULT_PR_QUERY.into()); let max_items = env_parse::(&file_env, &["WAYBAR_GITHUB_MAX_ITEMS", "MAX_ITEMS"]) .map_or(8, |value| value.clamp(1, MAX_ACTION_ITEMS)); let timeout = Duration::from_secs( @@ -84,3 +84,14 @@ impl Config { }) } } + +#[cfg(test)] +mod tests { + use super::DEFAULT_PR_QUERY; + + #[test] + fn default_query_targets_external_review_requests() { + assert!(DEFAULT_PR_QUERY.contains("review-requested:@me")); + assert!(DEFAULT_PR_QUERY.contains("-author:@me")); + } +}