snapshot

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 17 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 snapshot is the one picture of everything sitrep knows: the sessions that ran in the last day, their notes and queues, and the inbox. `sitrep ls --json` is its encoding (version 1), and the dashboard reads it directly. Every string in it is a textsafe.Text, so no raw text reaches a consumer.

Index

Constants

View Source
const Version = 1

Version is the version of the document.

View Source
const Window = 86400

Window is how long ago a session may have changed and still be listed, in seconds.

Variables

This section is empty.

Functions

func Encode

func Encode(w io.Writer, s Snapshot) error

Encode writes the document as indented JSON, the way `sitrep ls --json` prints it.

func Tree added in v1.6.2

func Tree(n int, id, parent func(i int) string) (order, depth []int)

Tree orders a list so that each Branch comes right after its parent, when the parent is in the list: the sessions whose parent is not in it keep their order, and the Branches of a session follow it in theirs. order holds the indexes into the list, and depth how many parents above each one are in the list. A loop of parents, which only a hand-edited file can make, starts at its first member in the list, with the rest under it.

Types

type Backup added in v1.0.7

type Backup struct {
	At    int64         `json:"at"`    // when, in epoch seconds
	Age   int64         `json:"age"`   // how long ago, in seconds
	Stale bool          `json:"stale"` // older than the limit; never true when the limit is 0
	Name  textsafe.Text `json:"name"`  // the file name of the archive
}

Backup says when the last backup was made, and whether that is longer ago than SITREP_BACKUP_WARN days.

type Builder

type Builder struct {
	Store     state.Store
	ConfigDir string // Claude Code's folder, for transcripts and the registry
	Conf      conf.Conf
	Reg       live.Registry
	Clock     clock.Clock
}

Builder makes snapshots.

func (Builder) Build

func (b Builder) Build(ctx context.Context, opt Options) Snapshot

Build reads the state folder and the registry once and returns the snapshot.

type Context added in v0.8.0

type Context struct {
	UsedPercent float64 `json:"used_percent"`
	Window      int64   `json:"window"`
	Tokens      int64   `json:"tokens"`
	At          int64   `json:"at"` // when the status line last showed these numbers, in epoch seconds
}

Context is how full a session's context window is, as its status line last said.

type Hidden

type Hidden struct {
	Ended         int `json:"ended"`
	StrandedItems int `json:"stranded_items"`
}

Hidden counts what a listing without ended sessions left out.

type Options

type Options struct {
	All bool
	Cap int
}

Options say what to include. Cap limits the items listed in each queue; below zero lists them all.

type Queue

type Queue struct {
	Count int             `json:"count"`
	Items []textsafe.Text `json:"items"`
}

Queue holds the true count and the items a cap allowed.

type Session

type Session struct {
	ID           state.ID `json:"id"`
	Short        string   `json:"short"`
	Alias        string   `json:"alias"` // the name the user gave the session, or empty
	Running      bool     `json:"running"`
	State        string   `json:"state"`
	StateLabel   string   `json:"state_label"`
	Age          int64    `json:"age"`
	StateChanged int64    `json:"state_changed"`
	QuietSecs    *int64   `json:"quiet_secs"`
	Idle         bool     `json:"idle"`
	NeedsInput   bool     `json:"needs_input"`
	Blocked      string   `json:"blocked,omitempty"` // "permission" while the session waits at a dialog; absent otherwise
	Snoozed      bool     `json:"snoozed"`
	PID          *int     `json:"pid"`
	Pinned       bool     `json:"pinned"`
	Highlight    bool     `json:"highlight"`
	AttnFaded    bool     `json:"attn_faded,omitempty"`
	Background   bool     `json:"background,omitempty"`
	Clients      []int    `json:"clients,omitempty"`
	// ContinuedFrom is the session whose terminal shows this background session after a resume moved the conversation here
	ContinuedFrom state.ID `json:"continued_from,omitempty"`
	// WindowOf is, for a session shown as ended although its terminal is open, the background session that its conversation went on as
	WindowOf state.ID `json:"window_of,omitempty"`
	// AgentName is what Claude Code calls a running session among its peers: the name that SendMessage takes, which is not its id
	AgentName *textsafe.Text `json:"agent_name,omitempty"`
	// Parent is, for a Branch, the session it was forked from: the listed session that conversation went on as after a resume, when there is one
	Parent    state.ID      `json:"parent,omitempty"`
	Dir       textsafe.Text `json:"dir"`
	Cwd       textsafe.Text `json:"cwd"`
	Objective textsafe.Text `json:"objective"`
	Progress  textsafe.Text `json:"progress"`
	Now       textsafe.Text `json:"now"`
	Queue     Queue         `json:"queue"`
	Context   *Context      `json:"context"` // how full the context window was at the last status line, or null
}

Session is one session.

func (Session) Label added in v0.6.0

func (s Session) Label() string

Label is the name a person is shown for the session: its alias, or the Short.

type Settings

type Settings struct {
	QueueItems       int    `json:"queue_items"`
	HighlightSeconds int    `json:"highlight_seconds"`
	HighlightSGR     string `json:"highlight_sgr"`
	Theme            string `json:"theme"`  // SITREP_THEME, for the dashboard
	Colors           string `json:"colors"` // SITREP_COLORS, for the dashboard
}

Settings are the values a consumer needs to draw the same way as the plain listing.

type Snapshot

type Snapshot struct {
	Version   int       `json:"version"`
	Generated int64     `json:"generated"`
	Registry  string    `json:"registry"` // "ok", or "unavailable" when no live session could be read
	Settings  Settings  `json:"settings"`
	Backup    *Backup   `json:"backup,omitempty"` // the last backup that reached a folder; absent when none has
	Hidden    Hidden    `json:"hidden"`
	Inbox     Queue     `json:"inbox"`
	Sessions  []Session `json:"sessions"`
}

Snapshot is the document `sitrep ls --json` prints. The field order is the document's order.

Jump to

Keyboard shortcuts

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