situation

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 8 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package situation derives who a pull request is waiting on, and since when, from the pull request and its events alone. The host lays its own state over it: a run on the pull request, the user's mute and a pending round.

Index

Constants

View Source
const NudgeWindow = 2 * time.Hour

NudgeWindow bounds how long after a nudge is asked for its comment can be posted: the agent reads the pull request first.

View Source
const ReasonMax = 200

ReasonMax bounds a reason that comes from an agent or a CI, so a row and a notification stay one line; the host cuts its own reasons alike.

Variables

View Source
var Reasons = map[string]string{
	"merged":                  "merged",
	"closed":                  "closed",
	"round_blocked":           "round blocked: {{.why}}",
	"round_held":              "automatic round held: {{.why}}",
	"to_address":              "review to address, no workspace: {{.why}}",
	"agent_asked":             "the agent asked you something",
	"round_in_progress":       "review round in progress",
	"draft":                   "draft",
	"checks_failing":          "checks failing on the head",
	"checks_failing_named":    "checks failing: {{.checks}}",
	"checks_failing_more":     "checks failing: {{.checks}} and {{.more}} more",
	"changes_requested":       "changes requested by {{.actor}}",
	"merge_conflicts":         "merge conflicts with {{.branch}}",
	"approved_green":          "approved and green",
	"approved_checks_pending": "approved, checks pending",
	"review_requested":        "review requested, no review on the head",
	"review_requested_again":  "review requested again after your review",
	"reviewer_not_back":       "{{.author}} replied, {{.reviewer}} has not returned",
	"commented_no_reply":      "{{.actor}} commented, no reply",
	"no_reviewer_requested":   "no reviewer requested",

	"no_review_required":                "green, no review required",
	"no_review_required_checks_pending": "no review required, checks pending",
}

Reasons are the reasons Derive gives, by key, each as the English sentence agents and logs read; ui.toml's [reasons] words each for people, {{.name}} where a value goes.

Functions

func ActiveBlock

func ActiveBlock(evs []pr.Event, viewer string) (pr.Event, bool)

ActiveBlock is the newest round_blocked event of evs, oldest first, that no later event ended: a round_unblocked, a round sent or held, or a review by viewer.

func Cut

func Cut(s string) string

Cut keeps s within ReasonMax runes.

func Pending added in v0.4.0

func Pending(p pr.PR, evs []pr.Event, login string) bool

Pending says p asks login's review: it lists the request by name, and login's standing reviews are none or older than the newest event that asked it.

func Standing added in v0.4.0

func Standing(evs []pr.Event) []pr.Event

Standing are evs without the dismissals and the reviews they dismissed: the collector stores a dismissal as its own event, keyed on the review's key and its state, beside the review it dismissed.

Types

type Input

type Input struct {
	PR      pr.PR
	Events  []pr.Event
	Viewer  string   // my login
	MyTeams []string // "org/slug", any case
	Ignore  []string // actors whose comments and reviews never count: automated reviewers
	// Now is when the situation is derived: a round held by the cap holds
	// only on the local day it was held.
	Now     time.Time
	Stalled Thresholds
	// AddressedAt is when the pull request's driving turn, an address turn,
	// reached its state; zero without one.
	AddressedAt time.Time
	// ThreadsSettledAt is when a full read last found the pull request's
	// review threads, at least one, every one resolved; zero when it did not.
	ThreadsSettledAt time.Time
	// AskedAt is when the newest turn of an intent on the pull request asked
	// the user something no answer reached yet; zero without one.
	AskedAt time.Time
	// ReviewerOptional says the profile's reviewer_required does not hold for
	// the pull request: with no reviewer asked, it is ready as an approved one.
	ReviewerOptional bool
}

type Kind

type Kind string

Kind is a situation of plugin.toml's row_kinds.

const (
	KindDone         Kind = "done"
	KindHeldByCap    Kind = "held"
	KindBlocked      Kind = "blocked"
	KindToAddress    Kind = "to_address"
	KindLoopWorking  Kind = "loop_working"
	KindLoopWaiting  Kind = "loop_waiting"
	KindDraft        Kind = "draft"
	KindChecks       Kind = "checks"
	KindChanges      Kind = "changes"
	KindMerge        Kind = "merge"
	KindConflicts    Kind = "conflicts"
	KindReply        Kind = "reply"
	KindReviewerBack Kind = "reviewer_back"
	KindReview       Kind = "review"
	KindNoReviewer   Kind = "no_reviewer"
)

The situations the plugin derives.

const (
	KindMuted        Kind = "muted"
	KindRoundPending Kind = "round_pending"
	KindLoopStopped  Kind = "loop_stopped"
)

The situations only the host's overlays set, which the plugin's rows, cards and items read back.

type Result

type Result struct {
	Kind      Kind
	WaitingOn string // login(s), "me", "author", "nobody"
	Since     time.Time
	Reason    string
	// ReasonKey names Reason among Reasons, which ReasonParams fill; the plugin's profile layer words it
	// for the rows.
	ReasonKey    string
	ReasonParams map[string]string
	// Stalled is when the situation stalls: true once its threshold has
	// passed since Since, in working days; zero never stalls.
	Stalled src.Value
}

func Derive

func Derive(in Input) Result

func (Result) Situation

func (r Result) Situation() *src.Situation

Situation is r as the snapshot reports it.

func (Result) StalledAt

func (r Result) StalledAt(now time.Time) bool

StalledAt says whether r is stalled at now.

type Thresholds

type Thresholds struct {
	Review, Reply, Merge time.Duration
}

Thresholds are how long, in working days, a situation lasts before it is stalled; zero never stalls.

Jump to

Keyboard shortcuts

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