snapshot

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 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 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.

Types

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"`
	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"`
	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