notices

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package notices turns what the daemon already knows into the "notice" events the desktop app shows as operating system notifications: a review finished or failed, a review requested from the user, a change in the state of the user's own pull request (checks failing, a conflict, changes requested, ready to merge), a fix that pushed or failed, and an agent session that began waiting for its user's permission or answer. A notice is the smallest record that can name its pull request or session: kind, repository, number, the clone that routes the click, the title as GitHub returned it, the risk score the stored review already holds, a failure category, a fix's short commit, and a session's agent, id, branch and the one masked line its agent showed. It never carries review text, paths, transcripts or error messages.

The daily cap pause is not a notice: the scheduler's own "automatic" event already says it, and the app reads it there.

Index

Constants

View Source
const (
	KindFinished = "review_finished"
	KindFailed   = "review_failed"
	// KindAutomatic is a review the daemon generated without being asked, when
	// it finished. A failed automatic review is a KindFailed notice.
	KindAutomatic = "review_automatic"
	KindRequested = "review_requested"
	// The user's own pull requests, from transitions between discovery
	// snapshots.
	KindChecksFailed     = "checks_failed"
	KindConflict         = "conflict"
	KindChangesRequested = "changes_requested"
	KindReadyToMerge     = "ready_to_merge"
	// A fix job's outcome: pushed (with its short commit) or failed.
	KindFixPushed = "fix_pushed"
	KindFixFailed = "fix_failed"
	// KindDetailsFailed is a retry of a review's failed section details
	// (jobs.KindDetails) that failed. One that completes is not news: the
	// review was already there.
	KindDetailsFailed = "details_failed"
	// An agent session began waiting for the user: to allow a tool, or to
	// answer it. A finished turn is not news.
	KindSessionPermission = "session_permission"
	KindSessionInput      = "session_input"
)

Notice kinds.

Variables

This section is empty.

Functions

This section is empty.

Types

type Notice

type Notice struct {
	Kind       string `json:"kind"`
	Repository string `json:"repository"`
	PR         int    `json:"pr"`
	// Clone is the registered clone whose app page shows the pull request;
	// empty when none is registered.
	Clone string `json:"clone,omitempty"`
	Title string `json:"title,omitempty"`
	// Risk is the review's score from 1 to 5. RiskStatus is the stored
	// score's status ("lower_bound" when incomplete coverage may hide a
	// higher one).
	Risk       *int   `json:"risk,omitempty"`
	RiskStatus string `json:"risk_status,omitempty"`
	// Reason is the failure category of a failed job, such as "timeout".
	Reason string `json:"reason,omitempty"`
	// Commit is the short hash of the commit a fix pushed.
	Commit string `json:"commit,omitempty"`
	// Agent and Session name the agent session a session notice is about,
	// Branch the branch it works on and Message the line its agent showed,
	// already cleaned and masked by the tracker. PR is 0 when the branch has
	// no pull request.
	Agent   string `json:"agent,omitempty"`
	Session string `json:"session,omitempty"`
	Branch  string `json:"branch,omitempty"`
	Message string `json:"message,omitempty"`
}

Notice is the payload of the "notice" event.

type Registry

type Registry interface {
	List(context.Context) ([]repos.Clone, error)
}

Registry lists the registered clones.

type Service

type Service struct {
	Registry Registry
	// Index reads the current review index, for the title and risk score.
	Index func(context.Context) (reviewindex.Snapshot, error)
	// Publish delivers one notice; failures are the caller's to ignore.
	Publish func(Notice)
	// contains filtered or unexported fields
}

Service builds notices and hands them to Publish.

func (*Service) JobDone

func (s *Service) JobDone(ctx context.Context, job jobs.Job)

JobDone publishes the notice for a job that just finished: completed reviews and failures, a fix that pushed or failed, and a details retry that failed; a feature build has none. Cancelled, interrupted and superseded jobs are not the user's news.

func (*Service) Observe

func (s *Service) Observe(ctx context.Context, snapshot discovery.Snapshot)

Observe publishes a notice for each pull request a successful discovery snapshot shows as newly review-requested from the user. Safe for concurrent use; an older snapshot arriving late changes nothing it already saw.

When GitHub's team list was unavailable (TeamMembershipKnown is false), a false flag proves nothing: a request made through a team would be hidden. Such a pull request keeps the state the previous snapshot gave it, and one never seen before is recorded as requested without a notice, so the next complete snapshot cannot announce it as new.

The same snapshots tell what happened to the user's own pull requests: its checks began failing, it began conflicting, a review requested changes, or it became ready to merge. A pull request that changed several ways between two snapshots gets one notice, the first of those in that order. A pull request first seen, or one that left the snapshot (closed or merged), gets none; a state GitHub did not report keeps the one before it.

func (*Service) ResetIdentity

func (s *Service) ResetIdentity()

func (*Service) SessionWaiting

func (s *Service) SessionWaiting(ctx context.Context, session livesessions.Session)

SessionWaiting publishes the notice for an agent session that began waiting for its user's permission or answer. The live sessions tracker calls it once per wait; a finished turn, or any other reason, is not a notice.

Jump to

Keyboard shortcuts

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