timeline

package
v0.16.521 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: AGPL-3.0 Imports: 26 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 timeline serves the conversation socket (/api/timeline): which agent session a tab's pane runs, its transcript's first screen and what it gains, switches between sessions, the reply on screen not yet written, session statistics and the resume of a past session. In production the cluster's timeline proxy is the client: it takes the transcript itself from its database and the rest from here.

Index

Constants

This section is empty.

Variables

View Source
var DefaultTiming = Timing{Heartbeat: 30 * time.Second, HeartbeatTimeout: 90 * time.Second, FileDebounce: 50 * time.Millisecond,
	WatchRetry: time.Second, SessionDebounce: 200 * time.Millisecond, PIDPoll: 10 * time.Second, InstallCheck: time.Minute,
	LiveReplyEvery: time.Second}

DefaultTiming are the intervals of the old runtime.

Functions

This section is empty.

Types

type Deps

type Deps struct {
	Tmux  Tmux
	Procs proc.Procs
	// Alive tells whether a process still runs.
	Alive func(pid int) bool
	// Providers by panel type.
	Providers map[string]*Provider
	// Keeper is the running keeper, nil while the core is off.
	Keeper func() Keeper
	Layout Layout
	// ResumeLine is the line that resumes a session in the tab of the tmux session.
	ResumeLine func(provider, sessionID, session string) (string, error)
	// ClaudeProjects holds Claude's transcripts, one folder per working folder; CodexSessions holds Codex's.
	ClaudeProjects  string
	CodexSessions   string
	AntigravityRoot string
	// MoreRoots are every folder of each kind the agents of this account were seen to write to (CLAUDE_CONFIG_DIR and
	// CODEX_HOME of a running agent), ClaudeProjects and CodexSessions among them; nil: those two only.
	MoreRoots func() (claudeProjects, codexSessions []string)
	// StatsDir holds the statusline figures of each Claude session.
	StatsDir string
	Codex    transcript.CodexOptions
	Log      func(level, msg string, kv ...any)
	Timing   Timing
}

Deps is what the timeline runs on.

type EntriesRoute

type EntriesRoute struct {
	Paths           subagents.Paths
	Codex           transcript.CodexOptions
	AntigravityRoot string
	// Authorized is the old API's check: a page session or the cli-token.
	Authorized func(*http.Request) bool
}

EntriesRoute answers GET /api/timeline/entries?jsonlPath=&beforeByte=&limit=&untilByte=: the page of a transcript before a byte offset, as the timeline scrolls back. The cluster answers it from its copy of the transcript first; the machine is asked when that copy has no such lines.

func (*EntriesRoute) Answer

func (e *EntriesRoute) Answer(r *http.Request) (int, any, http.Header)

Answer is the whole answer, refusals included.

func (*EntriesRoute) Takes

func (e *EntriesRoute) Takes(r *http.Request) bool

Takes says whether this route answers the request as the previous runtime did; the rest stays with it: a repeated parameter (its handler read an array), a negative limit (it answered offsets of NaN), a Claude transcript read far past its end (it allocated zeros up to the offset; the bytes past the end are read as zeros here too, but only so many).

type Keeper

type Keeper interface {
	NotifyLastUserMessage(session, message string)
	MarkAgentLaunch(tabID string, reset bool)
	MarkAgentGone(tabID string, endLaunch bool)
	IsSessionBusy(session string) bool
}

Keeper is the tab keeper of the running core.

type Layout

type Layout interface {
	AgentState(session, provider string, sessionID, jsonlPath, summary any)
	AgentSessionID(session, provider string, sessionID any)
	AgentSummary(session, provider string, summary any)
	LastUserMessage(session, message string)
	// Recover is the session a stored Claude tab stands for (its transcript, its stored id, its history), written back
	// to the tab.
	Recover(session string) (sessionID, jsonlPath string, ok bool)
}

Layout is the layout store's side of a tab's agent; nil values are written as null.

type Provider

type Provider struct {
	ID          string
	DisplayName string
	// Detect is the session the pane's processes run, given the shell's children.
	Detect func(children []int) (agents.SessionInfo, error)
	// Running: an agent process runs under the shell already, before it recorded a session.
	Running        func(children []int) bool
	ParsePaneTitle func(title string) *string
	// SessionIDFromPath is the session a transcript path names, "" for none.
	SessionIDFromPath func(path string) string
	ValidSessionID    func(id string) bool
	// FindSession is a session's transcript by id, "" when not found (Codex: its dated folders).
	FindSession func(id string) string
	// SessionsDir is the folder whose changes tell a session started or ended (Claude's pid files); "" for none.
	SessionsDir string
}

Provider is one coding agent the timeline follows.

type Server

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

Server holds every timeline socket of the runtime. One lock guards its state; what the layout store and the keeper are told goes out in order from one goroutine, as the old runtime awaited each of those writes.

func New

func New(d Deps) *Server

func (*Server) BroadcastSessionStats

func (s *Server) BroadcastSessionStats(stats *jsvalue.Object)

BroadcastSessionStats sends a Claude session's statusline figures to the sockets that show its transcript.

func (*Server) CodexSessionInfo

func (s *Server) CodexSessionInfo(session string, info agents.SessionInfo)

CodexSessionInfo is a session a Codex hook named for a tmux session; the session watcher of that tab takes it.

func (*Server) Count

func (s *Server) Count() int

Count is the number of open timeline sockets.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP takes an upgraded /api/timeline request (the caller checked the session).

func (*Server) Shutdown

func (s *Server) Shutdown()

Shutdown closes every socket and stops every watcher.

type Timing

type Timing struct {
	Heartbeat, HeartbeatTimeout, FileDebounce, WatchRetry  time.Duration
	SessionDebounce, PIDPoll, InstallCheck, LiveReplyEvery time.Duration
}

Timing are the old runtime's intervals; tests shorten them.

type Tmux

type Tmux interface {
	PanePID(session string) int
	PaneTitle(session string) string
	Capture(session string) (string, bool)
	CheckTerminalProcess(session string) (safe bool, process string)
	SendKeys(session, line string) error
	// SessionCwd is the pane's working folder, "" when unknown.
	SessionCwd(session string) string
	ParseSessionName(session string) (wsID, paneID, tabID string, ok bool)
}

Tmux is what the timeline asks of a tab's pane.

Jump to

Keyboard shortcuts

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