triage

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package triage provides a durable, local "still to process" list for inbound Webex messages.

The list is a personal reminder, not an outward signal: nothing here is ever sent to Webex or visible to message senders. Reading an item never changes its status — that is the whole point. An item stays PENDING until the user (or an agent acting on their behalf) explicitly marks it PROCESSED via MarkProcessed. This solves the problem where reading a message in a native client clears the unread badge the user relies on as their todo reminder.

State persists to a 0600 file under the user's config dir so reminders survive restarts (the in-memory ring buffer does not).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Item

type Item struct {
	ID          string    `json:"id"`
	RoomID      string    `json:"roomId"`
	RoomTitle   string    `json:"roomTitle"`
	PersonEmail string    `json:"personEmail"`
	Text        string    `json:"text"`
	Created     time.Time `json:"created"`
	Priority    string    `json:"priority"`
	RoutedAgent string    `json:"routedAgent,omitempty"`

	Status      Status    `json:"status"`
	AddedAt     time.Time `json:"addedAt"`
	ProcessedAt time.Time `json:"processedAt,omitempty"`
}

Item is a single inbound message tracked for processing. Fields mirror buffer.NotificationMessage plus triage bookkeeping.

type Status

type Status string

Status is the processing state of a triage item.

const (
	// StatusPending means the item still needs the user's attention.
	StatusPending Status = "pending"
	// StatusProcessed means the user has explicitly dealt with the item.
	StatusProcessed Status = "processed"
)

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is a thread-safe, disk-backed triage list.

func New

func New() (*Store, error)

New creates a Store persisting to the user's config dir. Existing state is loaded if present. If the config dir can't be resolved, the store still works in-memory (persistence disabled) so the listener never fails to run.

func NewWithPath

func NewWithPath(path string) (*Store, error)

NewWithPath creates a Store at an explicit path (used in tests).

func (*Store) Add

func (s *Store) Add(item Item) error

Add records an item as PENDING. It is idempotent: re-adding an existing ID does NOT reset its status (so a message that's already been PROCESSED stays processed, and a re-delivered PENDING item isn't duplicated). Reading or re-receiving a message must never resurrect or clear a reminder.

func (*Store) Get

func (s *Store) Get(id string) (Item, bool)

Get returns a copy of the item with the given ID, or (zero, false).

func (*Store) ListPending

func (s *Store) ListPending() []Item

ListPending returns all PENDING items, newest-first by Created. Reading does not change any status.

func (*Store) MarkProcessed

func (s *Store) MarkProcessed(ids ...string) (notFound []string, err error)

MarkProcessed transitions the named items from PENDING to PROCESSED. This is the ONLY path that clears a reminder — it never happens automatically, on read, or on reply. Unknown IDs are reported in the returned slice. Returns the IDs that were not found.

func (*Store) PendingCount

func (s *Store) PendingCount() int

PendingCount returns the number of items still needing attention.

func (*Store) Prune

func (s *Store) Prune(processedBefore time.Time) (int, error)

Prune removes PROCESSED items older than the cutoff to bound file growth. PENDING items are never pruned — a reminder must not vanish on its own. Returns the number of items removed.

Jump to

Keyboard shortcuts

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