sessionid

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package sessionid mints terminal session IDs with a random instance segment.

Session IDs are persisted by the frontend (they become tab IDs in the tab store), so an ID must stay unique across app restarts — not just within a single Manager's lifetime. A plain incrementing counter resets to 0 on every launch, which makes a fresh process re-mint IDs an earlier run already persisted, producing two tabs that share one ID (issue #141).

Each Generator carries a random per-instance segment, so IDs minted by different processes (or different Managers) are extremely unlikely to collide even when their counters match. The ID format is "<kind>-<instance>-<n>"; the kind prefix is preserved because the frontend infers the transport from it (inferTransportFromSessionId keys off "ssh-" / "serial-" / "local-").

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

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

Generator produces unique session IDs of the form "<kind>-<instance>-<n>". It is safe for concurrent use. Must be used by pointer (atomic counter).

func NewGenerator

func NewGenerator(kind string) *Generator

NewGenerator returns a Generator whose IDs are prefixed with kind (e.g. "ssh"). The random instance segment is drawn once per Generator, giving each generator an ID namespace with negligible collision risk.

func (*Generator) Next

func (g *Generator) Next() string

Next returns the next unique session ID.

Jump to

Keyboard shortcuts

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