inbox

package
v0.209.2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 12 Imported by: 0 modules, 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 inbox projects Today cards into the two stable user-facing columns.

Index

Constants

View Source
const (
	ColumnAction = "action"
	ColumnFYI    = "fyi"
)
View Source
const (
	SourceDefault = "default"
	SourceConfig  = "config"
)

Rule sources reported by the rule directory.

View Source
const KindJobFailed = today.KindJobFailed

KindJobFailed is the card kind of a failed job a person submitted.

Variables

Categories is the judgement order: first match wins.

Functions

func Column

func Column(card today.Card, cfg *config.InboxConfig) string

Column applies first-match-wins rules. Empty rules mean the built-in policy.

func EffectiveRules added in v0.208.0

func EffectiveRules(cfg *config.InboxConfig) ([]config.InboxRule, string)

EffectiveRules returns the rules in force: server.inbox.rules, else the built-in table.

func Label added in v0.208.0

func Label(lang i18n.Lang, c Category) string

Label is the 「等谁、要什么」 text of a category in lang.

func Rank added in v0.208.0

func Rank(c Category) int

Rank is the position of c in Categories (lower = earlier); unknown sorts last.

func RulesVersion added in v0.208.0

func RulesVersion(cfg *config.InboxConfig) string

RulesVersion is a short stable digest of the effective rules (not of enabled).

func TerminalCard added in v0.208.0

func TerminalCard(lang i18n.Lang, j jobstore.JobRecord, kind string) today.Card

TerminalCard is the card of a finished job. The key is the same for both kinds so a job's read / cleared state follows it when it moves between columns (the revision changes, so it resurfaces).

func TerminalCards added in v0.208.0

func TerminalCards(src TerminalSource, lang i18n.Lang, allow func(string) bool) (failed, fyi []today.Card, err error)

TerminalCards builds the person's own terminal-job cards:

  • failed: a failed / timed-out job a person submitted themselves (job.HumanSubmitted) that nothing continued (no auto-resume, no failover, no job naming it as its source). It is a "job.failed" card and enters the 「等我」 list.
  • fyi: a done job a person submitted themselves. It is a "job.terminal" card, the only terminal an inbox shows besides the failures above.

Jobs of an agent, a session, a job credential or the system produce neither: their result already went back to whoever started them. allow, when non-nil, is the caller's project scope. Failures are ordered newest first.

func UnreadCount added in v0.208.0

func UnreadCount(items []Item) int

UnreadCount counts the items of a column that are unread.

func Waiting added in v0.208.0

func Waiting(lang i18n.Lang, cards []today.Card) []today.Card

Waiting folds the candidate cards into THE 「等我」 list. Cards whose kind carries no structured waiting fact (work items, suggestions, merges, memory, capture, ...) are left out. Cards about one subject collapse to one entry under the first matching Category, which keeps the position of the subject's first card; the input order is otherwise kept. Each returned card carries Waiting (the category id) and WaitingLabel (in lang). The result is never nil.

Types

type Category added in v0.208.0

type Category string

Category is one class of the 「等我」 (waiting on me) list. The classes are mutually exclusive and exhaustive over what may call a person (design 2026-11-01 §4.1): a subject falls into the FIRST class whose structured fact holds, in the order of Categories.

const (
	CatApproval  Category = "approval"   // 待你批准
	CatAnswer    Category = "answer"     // 待你回答
	CatReview    Category = "review"     // 待你验收
	CatPlanStuck Category = "plan_stuck" // 计划卡住
	CatFailed    Category = "failed"     // 你提交的任务失败了
	CatDelivery  Category = "delivery"   // 投递待你确认
)

func Classify added in v0.208.0

func Classify(s Signals) (Category, bool)

Classify returns the first Category whose fact holds, in Categories order; ok is false when the subject does not wait on a person at all.

type EventInfo added in v0.208.0

type EventInfo struct {
	Key            string   `json:"key"`
	Group          string   `json:"group"`
	Zh             string   `json:"zh"`
	En             string   `json:"en"`
	Kinds          []string `json:"kinds"`
	Default        bool     `json:"default"`
	DesktopDefault bool     `json:"desktop_default"`
}

EventInfo is a notify catalog event with the inbox kinds it announces. Kinds is empty for events that never reach the inbox. Default / DesktopDefault are the channels' own default subscriptions, unchanged by the inbox rules.

type Item

type Item struct {
	Key            string         `json:"key"`
	Column         string         `json:"column"`
	Kind           string         `json:"kind"`
	Title          string         `json:"title"`
	Summary        string         `json:"summary"`
	SourceRevision string         `json:"source_revision"`
	State          string         `json:"state"`
	Actions        []today.Action `json:"actions"`
	Refs           today.Refs     `json:"refs"`
	DeepLink       string         `json:"deep_link,omitempty"`
	ProjectKey     string         `json:"project_key,omitempty"`
	ActivityAt     int64          `json:"activity_at"`
	// Waiting / WaitingLabel are the 「等我」 category of an action item (see Category) and its
	// label in the request language; empty on a fyi item.
	Waiting      string `json:"waiting,omitempty"`
	WaitingLabel string `json:"waiting_label,omitempty"`
}

func NewItem

func NewItem(card today.Card, cfg *config.InboxConfig, state State) (Item, bool)

type KindInfo added in v0.208.0

type KindInfo struct {
	Kind          string `json:"kind"`
	DefaultColumn string `json:"default_column"`
	// Column is the effective column for a card of this kind with no project; "" means no
	// rule classifies it, so the item is not shown. Project-scoped rules are not applied
	// here (they depend on the card's project).
	Column string `json:"column"`
	// Source is "config" when server.inbox.rules decides, "default" for the built-in table.
	Source string   `json:"source"`
	RuleID string   `json:"rule_id,omitempty"`
	Events []string `json:"events"`
}

KindInfo is one inbox kind in the rule directory: where the built-in policy puts it, where the effective rules put it now, and which notify events announce it.

type RuleDirectory added in v0.208.0

type RuleDirectory struct {
	Enabled bool `json:"enabled"`
	// Version changes whenever the effective rules change; clients drop caches on a change.
	Version string `json:"version"`
	// Source is "config" when server.inbox.rules is set, else "default".
	Source   string             `json:"source"`
	Rules    []config.InboxRule `json:"rules"`
	Defaults []config.InboxRule `json:"defaults"`
	Kinds    []KindInfo         `json:"kinds"`
	Events   []EventInfo        `json:"events"`
}

RuleDirectory is the GET /v1/inbox/rules body.

func Directory added in v0.208.0

func Directory(cfg *config.InboxConfig) RuleDirectory

Directory builds the rule directory for the effective config. Only keys, columns and catalog descriptions are exposed: no webhook, path or secret.

type Signals added in v0.208.0

type Signals struct {
	// HeldForApproval: job status awaiting_approval (a push hold included).
	HeldForApproval bool
	// ApprovalInteraction: a pending interaction of type permission / confirmation, or a
	// terminal tool-permission prompt.
	ApprovalInteraction bool
	// Question: a gofer_ask_human decision, a pending question / choice interaction, an
	// AskUserQuestion, or a session relay turn awaiting the person's reply.
	Question bool
	// NeedsReview: job status needs_review.
	NeedsReview bool
	// PlanBlocked: plan status blocked.
	PlanBlocked bool
	// TodoNeedsReview: a plan todo whose job waits in needs_review.
	TodoNeedsReview bool
	// FailedBySelf: terminal failed / timeout, submitted by a person (job.HumanSubmitted),
	// with no follow-up job.
	FailedBySelf bool
	// DeliveryHeld: a letter held for nobody to receive, or bounced.
	DeliveryHeld bool
}

Signals are the structured facts about ONE subject (a job, a session, a plan, a decision). Every field is read from a store row or a server-stamped marker, never from a model's summary or inferred work-item status.

type State

type State struct {
	Seen    bool
	Cleared bool
}

type TerminalSource added in v0.208.0

type TerminalSource interface {
	ListJobs(q jobstore.ListQuery) ([]jobstore.JobRecord, error)
}

TerminalSource is the slice of the job store the terminal-job sources read.

Jump to

Keyboard shortcuts

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