workspace

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Workspace path helpers match util/workspace-path: resolve relative paths against roots, abbreviate home as ~, and derive display titles from final segments.

Package workspace implements the workspace registry (S14), matching core/workspace. Records contain ID, root, session group, and resume-on-open session. storage.Domain persists them under workspace IDs with CAS writes. SHA-256 of the normalized root produces deterministic IDs, so repeated creation for the same root is idempotent. ResumeOnOpen selects the session opened by default next time.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbbreviateHome

func AbbreviateHome(path, home string) string

AbbreviateHome replaces home prefixes with ~; paths outside home are unchanged.

func ResolvePath

func ResolvePath(root, path string) string

ResolvePath joins relative paths to root; absolute paths and paths with an empty root are unchanged. POSIX, Windows drive, and UNC absolute forms are recognized.

func TitleOf

func TitleOf(path string) string

TitleOf returns the final path segment for display.

Types

type Registry

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

Registry uses storage.Domain; its backend provides concurrency safety.

func New

func New(backend storage.Backend) *Registry

New creates a workspace registry over a KV backend.

func (*Registry) ClearResumeOnOpen

func (r *Registry) ClearResumeOnOpen(ctx context.Context, id brand.WorkspaceID) (uint64, error)

ClearResumeOnOpen clears the default resumed session.

func (*Registry) Create

func (r *Registry) Create(ctx context.Context, root string) (brand.WorkspaceID, uint64, error)

Create registers or reuses a workspace, returning the same ID for the same root along with its CAS version and whether it was newly created.

func (*Registry) Get

Get reads by ID, wrapping ErrKeyNotFound when absent.

func (*Registry) List

func (r *Registry) List(ctx context.Context) ([]Workspace, error)

List returns all workspaces in deterministic lexical ID order.

func (*Registry) SetResumeOnOpen

func (r *Registry) SetResumeOnOpen(ctx context.Context, id brand.WorkspaceID, sid brand.SessionID) (uint64, error)

SetResumeOnOpen records the session opened by default for this workspace.

func (*Registry) SetSessionGroup

func (r *Registry) SetSessionGroup(ctx context.Context, id brand.WorkspaceID, group string) (uint64, error)

SetSessionGroup replaces the current session group.

type Workspace

type Workspace struct {
	ID           brand.WorkspaceID `json:"id"`
	Root         string            `json:"root"`                   // Normalized absolute path.
	SessionGroup string            `json:"sessionGroup,omitempty"` // Optional session-group identifier.
	ResumeOnOpen *brand.SessionID  `json:"resumeOnOpen,omitempty"` // Session to open by default next time; nil disables resumption.
}

Workspace records workspace information.

Jump to

Keyboard shortcuts

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