watchsession

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package watchsession implements the WatchSession use case.

WatchSession composes a SessionSource and a Clock to derive a view of the most recent activity in the focused Session for the current Project. It:

  1. Asks SessionSource.Sessions to discover all Sessions for the given cwd.
  2. Selects the most-recently-active Session (highest LastActivity).
  3. Calls SessionSource.Events to retrieve that Session's Events.
  4. Sorts Events ascending by Timestamp (chronological order).
  5. Filters Events with isVisible (ADR-007): removes opaque, meta, and tool-result-only events.
  6. Takes the last min(N, len) visible Events (default N=5).
  7. Records Clock.Now() as the snapshot time.
  8. Returns a SessionView with the focused session ID, events, and snapshot time.

No I/O is performed by the use case itself — all data access is delegated to the SessionSource port.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SessionView

type SessionView struct {
	// FocusedSession is the ID of the Session whose Events are shown.
	// Zero value (empty string) means no Sessions exist for the Project.
	FocusedSession session.ID

	// Events holds the last N Events of the focused Session in strictly
	// ascending chronological order (oldest first). May be empty.
	Events []event.Event

	// Now is the UTC instant captured from Clock at the time Run was called.
	Now time.Time

	// EmptyReason is a human-readable explanation for why Events is empty.
	// Set when there are no Sessions ("no sessions") or when the focused
	// Session has no Events. Empty string when Events is non-empty.
	EmptyReason string
}

SessionView is the output of WatchSession.Run. It is a plain data value safe to pass across layer boundaries — no Tea types, no I/O handles.

type WatchSession

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

WatchSession is the use case that surfaces the most-recently-active Session's last N Events for a Project. Construct via New.

func New

func New(source ports.SessionSource, clock ports.Clock) WatchSession

New constructs a WatchSession with the given SessionSource and Clock. The default window size is 5 (last 5 Events shown). Use WithN to override.

func (WatchSession) Run

func (w WatchSession) Run(ctx context.Context, projectCWD string) (SessionView, error)

Run executes the use case for the Project at the given absolute working directory path. It discovers Sessions, focuses the most-recently-active one, retrieves its Events, and returns a SessionView.

Returns an empty SessionView (no error) when no Sessions exist.

Jump to

Keyboard shortcuts

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