inboxcount

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 10 Imported by: 0

README

inboxcount

Counts the pull requests in the app's Inbox for the desktop app's dock badge, tray text and tray icon, served as {"waiting":N} on GET /api/index?view=waiting.

The count follows the app's queue (upNext and kindOf in app/src/up-next.tsx) over the daemon's own state, read on each request:

  • the cached review index, one pull request per repository and number across clones (the clone with a saved review, then a readable store, then a clone, speaks for it);
  • the job queue, since a queued or running fix leaves the author nothing to do;
  • the review groups, since a stacked pull request with an open member under it is not ready to merge;
  • the ui-state inbox record, whose snoozes (until a time, or while the head stays the one it was held on) hide a pull request.

An open pull request counts when the user's review is requested, or when it is theirs and has changes requested, a conflict, failing checks or unresolved threads, is ready to merge, or is behind a base they can push to.

Saved inboxes left out of the app's badge are not applied: matching them needs the inbox filter language, which only the app has. Moving the whole queue into the daemon, so the app and the badge share one implementation, is tracked separately. Until then, a change to the app's queue rules belongs here too.

Documentation

Overview

Package inboxcount counts the pull requests in the app's Inbox, so the desktop app's dock badge and tray show the number the app's sidebar does.

It mirrors the app's queue (upNext, kindOf and the snooze filter in app/src/up-next.tsx). Saved inboxes whose badge is off are not applied: that needs the inbox filter language, which only the app has for now.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Count

func Count(entries []reviewindex.Entry, queue []jobs.Job, groups []reviewgroups.Group, snoozes Snoozes, now time.Time) int

Count is the number of pull requests in the Inbox: each open one asking for the user's review, and each of their own with something for them to do (fix, merge or update), less those snoozed at now. entries are the index's, in its order; jobs the queue's; groups the review groups.

func Key

func Key(pr reviewindex.Entry) string

Key names a pull request across the clones that hold it, as the app's upNextKey does.

Types

type Service

type Service struct {
	Index   func(context.Context) (reviewindex.Snapshot, error)
	Jobs    func() []jobs.Job
	Groups  func(context.Context) ([]reviewgroups.Group, error)
	Snoozes func() (json.RawMessage, error)
	Now     func() time.Time
}

Service serves the count from the daemon's own index, queue, groups and saved ui-state.

func (*Service) Count

func (s *Service) Count(ctx context.Context) (int, error)

func (*Service) Handler

func (s *Service) Handler(index http.Handler) http.Handler

Handler answers GET /api/index?view=waiting with {"waiting":N}, the Inbox count, which the desktop app polls for its badge and tray; every other request goes to index. The host applies its launch authentication first.

type Snoozes

type Snoozes struct {
	Snoozed map[string]int64  `json:"snoozed"`
	Held    map[string]string `json:"held"`
}

Snoozes is what the app saved as ui-state "inbox" that hides a pull request from the queue: until a time (Unix milliseconds) or while its head stays the one it was held on. Both are keyed by Key.

func ParseSnoozes

func ParseSnoozes(raw json.RawMessage) (Snoozes, error)

ParseSnoozes reads the ui-state "inbox" value; null, as before the app saved one, hides nothing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL