Documentation
¶
Overview ¶
Package inbox projects Today cards into the two stable user-facing columns.
Index ¶
- Constants
- Variables
- func Column(card today.Card, cfg *config.InboxConfig) string
- func EffectiveRules(cfg *config.InboxConfig) ([]config.InboxRule, string)
- func Label(lang i18n.Lang, c Category) string
- func Rank(c Category) int
- func RulesVersion(cfg *config.InboxConfig) string
- func TerminalCard(lang i18n.Lang, j jobstore.JobRecord, kind string) today.Card
- func TerminalCards(src TerminalSource, lang i18n.Lang, allow func(string) bool) (failed, fyi []today.Card, err error)
- func UnreadCount(items []Item) int
- func Waiting(lang i18n.Lang, cards []today.Card) []today.Card
- type Category
- type EventInfo
- type Item
- type KindInfo
- type RuleDirectory
- type Signals
- type State
- type TerminalSource
Constants ¶
const ( ColumnAction = "action" ColumnFYI = "fyi" )
const ( SourceDefault = "default" SourceConfig = "config" )
Rule sources reported by the rule directory.
const KindJobFailed = today.KindJobFailed
KindJobFailed is the card kind of a failed job a person submitted.
Variables ¶
var Categories = []Category{CatApproval, CatAnswer, CatReview, CatPlanStuck, CatFailed, CatDelivery}
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 Rank ¶ added in v0.208.0
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
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
UnreadCount counts the items of a column that are unread.
func Waiting ¶ added in v0.208.0
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.
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"`
}
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.