Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
[![GitHub release](https://img.shields.io/github/v/release/zombocoder/ghdash)](https://github.com/zombocoder/ghdash/releases/latest)
[![License](https://img.shields.io/github/license/zombocoder/ghdash)](LICENSE)

A terminal UI dashboard for monitoring GitHub repositories, pull requests, and your review inbox. Built with Rust, ratatui, and the GitHub GraphQL API.
A terminal UI dashboard for monitoring GitHub repositories, pull requests, issues, and your review inbox. Built with Rust, ratatui, and the GitHub GraphQL API.

## Features

- Monitor repos across multiple GitHub organizations and personal accounts
- View all open pull requests in one place
- Inbox view for PRs where you're requested for review or assigned
- Switch the whole dashboard between pull requests and issues with one key, with an optional search filter for issues
- Expand/collapse organizations in the navigation tree
- Client-side search filtering across PR titles, authors, and repos
- Restrict the whole dashboard to public-only or private-only repos (handy for streaming)
Expand Down Expand Up @@ -102,6 +103,10 @@ ttl_secs = 600
[ui]
# Navigation pane width percentage (default: 30)
nav_width_percent = 30

[issues]
# Optional: extra GitHub search qualifiers for issues mode (default: all open issues)
# filter = "label:bug -label:wontfix"
```

On macOS, `~/Library/Application Support/ghdash/config.toml` is also supported.
Expand All @@ -121,6 +126,20 @@ screen. Keep a separate config for it and start with `ghdash --config ~/stream.t
Cached PR lists are keyed by visibility, so switching modes never serves data
fetched under the other one.

### Issues mode

ghdash starts on pull requests. Press `i` to switch the whole dashboard to
issues: the nav tree shows open-issue counts per repo, "All Issues" lists every
open issue across your orgs and users, and the inbox lists issues assigned to
you. Press `i` again to go back. Issues are only fetched the first time you
switch, then cached like PRs.

`issues.filter` narrows every issue list (including the inbox). It takes
[GitHub search syntax](https://docs.github.com/en/search-github/searching-on-github/searching-issues-and-pull-requests)
and is appended to `is:open is:issue`, so anything the GitHub search box
understands works here: `label:bug`, `-label:wontfix`, `no:assignee`,
`milestone:v1`, `author:alice`. `github.visibility` applies to issues too.

## Usage

```sh
Expand All @@ -143,14 +162,15 @@ ghdash --help # Show all options
| `Tab` / `Shift+Tab` | Switch between nav and content panes |
| `r` | Refresh all data |
| `o` | Open selected item in browser |
| `i` | Switch between pull requests and issues |
| `/` | Toggle search filter |
| `q` / `Ctrl+C` | Quit |

### In search mode

| Key | Action |
| --------------- | ------------------------------------ |
| Type | Filter PRs by title, author, or repo |
| Type | Filter by title, author, or repo (issues also by label) |
| `Backspace` | Delete character |
| `Esc` / `Enter` | Close search |

Expand All @@ -168,14 +188,14 @@ src/
view.rs Layout composition
github/
auth.rs Token resolution (gh CLI / env vars)
models.rs Repo, PullRequest, RateLimit types
models.rs Repo, PullRequest, Issue, RateLimit types
queries.rs GraphQL query strings
graphql.rs GithubClient with pagination
cache/
store.rs JSON file cache with TTL
ui/
theme.rs Style constants
widgets.rs Rendering functions (nav, PR table, status bar, overlays)
widgets.rs Rendering functions (nav, PR/issue tables, status bar, overlays)
util/
config.rs TOML config with XDG paths
time.rs Relative time formatting
Expand Down
17 changes: 15 additions & 2 deletions src/app/actions.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::github::models::{PrDetail, PullRequest, RateLimit, Repo};
use crate::app::state::ListMode;
use crate::github::models::{Issue, PrDetail, PullRequest, RateLimit, Repo};

#[derive(Debug)]
#[allow(dead_code)]
Expand All @@ -16,6 +17,7 @@ pub enum Action {
CloseOverlay,
ToggleHelp,
CycleMergeFilter,
ToggleListMode,
SearchInput(char),
SearchBackspace,
SearchClear,
Expand All @@ -41,6 +43,14 @@ pub enum DataPayload {
prs: Vec<PullRequest>,
rate_limit: RateLimit,
},
IssueInbox {
issues: Vec<Issue>,
rate_limit: RateLimit,
},
AllOpenIssues {
issues: Vec<Issue>,
rate_limit: RateLimit,
},
PrDetailLoaded {
/// PR url — the key into `AppState::pr_details`.
key: String,
Expand All @@ -64,11 +74,14 @@ pub enum DataPayload {

#[derive(Debug)]
pub enum SideEffect {
RefreshAll,
/// Refetch repos plus the lists backing the given mode.
RefreshAll(ListMode),
FetchOrgRepos(String),
FetchUserRepos(String),
FetchInbox,
FetchAllOpenPrs,
FetchIssueInbox,
FetchAllOpenIssues,
FetchPrDetail {
owner: String,
name: String,
Expand Down
153 changes: 130 additions & 23 deletions src/app/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use tokio::sync::{Semaphore, mpsc};
use tracing::{debug, error};

use crate::app::actions::{Action, DataPayload, SideEffect};
use crate::app::state::{AppState, DiffEntry, FocusedPane, Overlay, PrDetailEntry};
use crate::app::state::{AppState, DiffEntry, FocusedPane, ListMode, Overlay, PrDetailEntry};
use crate::app::update::update;
use crate::app::view;
use crate::cache::CacheStore;
Expand Down Expand Up @@ -71,7 +71,7 @@ async fn run_loop(
let semaphore = Arc::new(Semaphore::new(4));

// Initial data fetch
let effects = vec![SideEffect::RefreshAll];
let effects = vec![SideEffect::RefreshAll(state.mode)];
for effect in effects {
spawn_side_effect(
effect,
Expand Down Expand Up @@ -293,6 +293,7 @@ fn map_event_to_action(event: &Event, state: &AppState) -> Option<Action> {
KeyCode::Char('r') => Some(Action::Refresh),
KeyCode::Char('o') => Some(Action::OpenInBrowser),
KeyCode::Char('f') => Some(Action::CycleMergeFilter),
KeyCode::Char('i') => Some(Action::ToggleListMode),
KeyCode::Char('?') => Some(Action::ToggleHelp),
KeyCode::Char('/') => Some(Action::ToggleSearch),
_ => None,
Expand All @@ -309,7 +310,7 @@ fn spawn_side_effect(
semaphore: &Arc<Semaphore>,
) {
match effect {
SideEffect::RefreshAll => {
SideEffect::RefreshAll(mode) => {
// Invalidate cache so refresh fetches fresh data
if let Some(cache) = cache_store
&& let Err(e) = cache.invalidate_all()
Expand Down Expand Up @@ -340,26 +341,23 @@ fn spawn_side_effect(
semaphore,
);
}
// Fetch inbox
spawn_side_effect(
SideEffect::FetchInbox,
config,
client,
viewer_login,
cache_store,
action_tx,
semaphore,
);
// Fetch all open PRs
spawn_side_effect(
SideEffect::FetchAllOpenPrs,
config,
client,
viewer_login,
cache_store,
action_tx,
semaphore,
);
// Fetch only the lists the current mode shows; the other mode's
// lists are fetched when it is toggled to.
let (inbox, all_open) = match mode {
ListMode::PullRequests => (SideEffect::FetchInbox, SideEffect::FetchAllOpenPrs),
ListMode::Issues => (SideEffect::FetchIssueInbox, SideEffect::FetchAllOpenIssues),
};
for effect in [inbox, all_open] {
spawn_side_effect(
effect,
config,
client,
viewer_login,
cache_store,
action_tx,
semaphore,
);
}
}
SideEffect::FetchOrgRepos(org) => {
let client = client.clone();
Expand Down Expand Up @@ -574,6 +572,115 @@ fn spawn_side_effect(
}
});
}
SideEffect::FetchIssueInbox => {
let client = client.clone();
let tx = action_tx.clone();
let sem = semaphore.clone();
let cache = cache_store.clone();
let login = viewer_login.to_string();
let visibility = config.github.visibility;
let filter = config.issues.filter.clone();
let filter_suffix = config.issues.cache_suffix();

tokio::spawn(async move {
let _permit = sem.acquire().await;
debug!("Fetching issue inbox");

// Visibility and filter are part of the key, so neither a
// visibility switch nor a filter edit serves stale issues.
let cache_key = format!(
"issue_inbox_{}_{}_{}",
login,
visibility.cache_suffix(),
filter_suffix
);
if let Some(ref cache) = cache
&& let Some(issues) = cache.get::<Vec<crate::github::Issue>>(&cache_key)
{
let _ = tx.send(Action::DataLoaded(DataPayload::IssueInbox {
issues,
rate_limit: crate::github::RateLimit::default(),
}));
return;
}

match client.fetch_issue_inbox(&login, visibility, &filter).await {
Ok((issues, rate_limit)) => {
if let Some(ref cache) = cache
&& let Err(e) = cache.set(&cache_key, &issues)
{
error!(error = %e, "Failed to cache issue inbox");
}
let _ = tx.send(Action::DataLoaded(DataPayload::IssueInbox {
issues,
rate_limit,
}));
}
Err(e) => {
error!(error = %e, "Failed to fetch issue inbox");
let _ = tx.send(Action::LoadError(format!(
"Failed to fetch issue inbox: {}",
e
)));
}
}
});
}
SideEffect::FetchAllOpenIssues => {
let client = client.clone();
let tx = action_tx.clone();
let sem = semaphore.clone();
let cache = cache_store.clone();
let orgs = config.github.orgs.clone();
let users = config.github.users.clone();
let visibility = config.github.visibility;
let filter = config.issues.filter.clone();
let filter_suffix = config.issues.cache_suffix();

tokio::spawn(async move {
let _permit = sem.acquire().await;
debug!("Fetching all open issues");

let cache_key = format!(
"all_open_issues_{}_{}",
visibility.cache_suffix(),
filter_suffix
);
if let Some(ref cache) = cache
&& let Some(issues) = cache.get::<Vec<crate::github::Issue>>(&cache_key)
{
let _ = tx.send(Action::DataLoaded(DataPayload::AllOpenIssues {
issues,
rate_limit: crate::github::RateLimit::default(),
}));
return;
}

match client
.fetch_all_open_issues(&orgs, &users, visibility, &filter)
.await
{
Ok((issues, rate_limit)) => {
if let Some(ref cache) = cache
&& let Err(e) = cache.set(&cache_key, &issues)
{
error!(error = %e, "Failed to cache all open issues");
}
let _ = tx.send(Action::DataLoaded(DataPayload::AllOpenIssues {
issues,
rate_limit,
}));
}
Err(e) => {
error!(error = %e, "Failed to fetch all open issues");
let _ = tx.send(Action::LoadError(format!(
"Failed to fetch all open issues: {}",
e
)));
}
}
});
}
SideEffect::FetchPrDetail {
owner,
name,
Expand Down
Loading
Loading