recents

package
v0.149.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 5 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 recents is the "recently viewed" entries (migration 0018) — the session switcher's Recent view, and where home goes with no chief: per user, server-stored, so they follow their owner across devices. An entry names a dispatched agent or a mirrored tmux window, keyed exactly as a pin is (pins.MirrorKey).

🔴 EVERY METHOD RUNS UNDER THE CALLER'S PRINCIPAL. recents is under FORCE row-level security, so a request reads and writes only its own user's rows; there is no system method. The owner of a row is the principal's user (owner_id's default), never a parameter.

Index

Constants

View Source
const MaxPerOwner = 50

MaxPerOwner bounds one user's rows. Each visit prunes the oldest past it, so a mirror row whose window is gone ages out rather than piling up. Two concurrent visits may leave one row past it until the next visit: a strip that shows six does not care.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	AgentID int64
	Mirror  pins.MirrorKey
}

Entry is one recently opened subject: an agent (AgentID, Mirror zero) or a mirrored entry (Mirror, AgentID 0).

func (Entry) IsMirror

func (e Entry) IsMirror() bool

IsMirror reports whether e names a mirrored entry.

type PGStore

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

PGStore is Store on Postgres.

func NewPG

func NewPG(pool *pgxpool.Pool) *PGStore

NewPG returns a Store on pool.

func (*PGStore) List

func (s *PGStore) List(ctx context.Context) ([]Entry, error)

List is the caller's entries, newest first — all of them, which the prune keeps to about MaxPerOwner. Ties (one transaction's two visits) break by id, the later row first.

func (*PGStore) VisitAgent

func (s *PGStore) VisitAgent(ctx context.Context, agentID int64) error

VisitAgent records that the caller opened agent id now. An agent the caller cannot see (absent, or another user's) is refused by the owner trigger or the foreign key, and that error is returned as is.

func (*PGStore) VisitMirror

func (s *PGStore) VisitMirror(ctx context.Context, k pins.MirrorKey) error

VisitMirror records that the caller opened the mirrored entry at k now. The entry need not be listed: a row is an address, drawn only while it is.

type Store

type Store interface {
	// List is the caller's entries, most recently visited first.
	List(ctx context.Context) ([]Entry, error)
	VisitAgent(ctx context.Context, agentID int64) error
	VisitMirror(ctx context.Context, k pins.MirrorKey) error
}

Store is the recents persistence.

Jump to

Keyboard shortcuts

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