windowmanager

package
v0.3.0-beta.17 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package windowmanager owns workspace-scoped window topology and semantic mutations.

Index

Constants

View Source
const (
	NewWindowFloating          NewWindowPolicy     = "floating"
	NewWindowInsert            NewWindowPolicy     = "beside_focus"
	SmallViewportStack         SmallViewportPolicy = "stack"
	SmallViewportReject        SmallViewportPolicy = "reject"
	FocusClickDirectional      FocusPolicy         = "click_directional"
	FocusDirectional           FocusPolicy         = "directional"
	DragAwayWindow             DragAwayPolicy      = "window"
	DragAwayGroup              DragAwayPolicy      = "group"
	DesktopTransitionSlide     DesktopTransition   = "slide"
	DesktopTransitionCrossfade DesktopTransition   = "crossfade"
	DesktopTransitionInstant   DesktopTransition   = "instant"
)
View Source
const LayoutResourceVersion uint32 = 1

LayoutResourceVersion is the schema version required for a declarative window_layout resource.

View Source
const MaxWireRevision uint64 = 1<<53 - 1

MaxWireRevision is the largest revision exactly representable by JSON clients.

View Source
const SnapshotVersion uint32 = 3
View Source
const (
	WindowLayoutResourceKind resources.ResourceKind = "window_layout"
)

Variables

View Source
var (
	ErrWorkspaceNotFound             = errors.New("window manager workspace not found")
	ErrSnapshotNotFound              = errors.New("window manager snapshot not found")
	ErrRevisionConflict              = errors.New("window manager revision conflict")
	ErrInvalidCommand                = errors.New("window manager invalid command")
	ErrInvalidTopology               = errors.New("window manager invalid topology")
	ErrDesktopNotFound               = errors.New("window manager desktop not found")
	ErrWindowNotFound                = errors.New("window manager window not found")
	ErrClientNotFound                = errors.New("window manager client not found")
	ErrDestinationRequired           = errors.New("window manager destination required")
	ErrFinalDesktop                  = errors.New("window manager final desktop")
	ErrHistoryBoundary               = errors.New("window manager history boundary")
	ErrLayoutResourceNotFound        = errors.New("window manager layout resource not found")
	ErrSlowConsumer                  = errors.New("window manager slow consumer")
	ErrPresentationRevisionExhausted = errors.New("window manager presentation revision exhausted")
	ErrTopologyRevisionExhausted     = errors.New("window manager topology revision exhausted")
	ErrClosed                        = errors.New("window manager closed")
	ErrNotStacked                    = errors.New("window manager window not stacked")
	ErrWindowPinned                  = errors.New("window manager window pinned")
)

Functions

func CanonicalShortcuts

func CanonicalShortcuts(shortcuts map[string]string) (map[string]string, error)

CanonicalShortcuts validates action IDs and returns canonical, conflict-free chords.

func NewLayoutResourceCodec

func NewLayoutResourceCodec() (resources.KindCodec[LayoutResource], error)

NewLayoutResourceCodec constructs the strict declarative window-layout codec.

func ValidateSnapshot

func ValidateSnapshot(snapshot Snapshot) error

ValidateSnapshot checks every committed aggregate invariant without repairing input.

Types

type Actor

type Actor struct {
	Kind string `json:"kind,omitempty"`
	ID   string `json:"id,omitempty"`
}

Actor records the initiator without affecting command semantics.

type ArrangeLayoutCommand

type ArrangeLayoutCommand struct {
	DesktopID   DesktopID
	WindowIDs   []WindowID
	Arrangement Arrangement
	Frame       NormalizedRect
	GroupID     GroupID
	ResourceID  string
}

func (ArrangeLayoutCommand) CommandID

func (ArrangeLayoutCommand) CommandID() CommandID

type Arrangement

type Arrangement string
const (
	ArrangementHorizontal Arrangement = "horizontal"
	ArrangementVertical   Arrangement = "vertical"
	ArrangementGrid       Arrangement = "grid"
	ArrangementStack      Arrangement = "stack"
)

type Axis

type Axis string
const (
	AxisHorizontal Axis = "horizontal"
	AxisVertical   Axis = "vertical"
)

type BalanceLayoutCommand

type BalanceLayoutCommand struct {
	GroupID *GroupID
	SplitID *NodeID
}

func (BalanceLayoutCommand) CommandID

func (BalanceLayoutCommand) CommandID() CommandID

type BindingsConfig

type BindingsConfig struct {
	TopCenter    string `json:"top_center"`
	BottomCenter string `json:"bottom_center"`
}

BindingsConfig maps special snap regions to window-manager actions.

type ChangeSet

type ChangeSet struct {
	DesktopIDs     []DesktopID `json:"desktop_ids,omitempty"`
	WindowIDs      []WindowID  `json:"window_ids,omitempty"`
	GroupIDs       []GroupID   `json:"group_ids,omitempty"`
	NodeIDs        []NodeID    `json:"node_ids,omitempty"`
	ClientIDs      []ClientID  `json:"client_ids,omitempty"`
	StackGrouped   []NodeID    `json:"stack_grouped,omitempty"`
	StackUngrouped []NodeID    `json:"stack_ungrouped,omitempty"`
}

ChangeSet names the entities affected by one command.

type ClientID

type ClientID string

type ClientRegistration

type ClientRegistration struct {
	WorkspaceID     WorkspaceID
	ClientID        ClientID
	ActiveDesktopID DesktopID
}

ClientRegistration requests a live client view.

type ClientView

type ClientView struct {
	WorkspaceID          WorkspaceID         `json:"workspace_id"`
	ClientID             ClientID            `json:"client_id"`
	PresentationRevision uint64              `json:"presentation_revision"`
	ActiveDesktopID      DesktopID           `json:"active_desktop_id"`
	FocusedWindowID      *WindowID           `json:"focused_window_id,omitempty"`
	FocusOrder           []WindowID          `json:"focus_order"`
	StackActive          map[NodeID]WindowID `json:"stack_active"`
	ConnectedAt          time.Time           `json:"connected_at"`
}

ClientView is transient presentation state for one connected client.

type CloseScope

type CloseScope string
const (
	CloseScopeTab    CloseScope = ""
	CloseScopeGroup  CloseScope = "group"
	CloseScopeOthers CloseScope = "others"
	CloseScopeRight  CloseScope = "right"
)

type CloseWindowCommand

type CloseWindowCommand struct {
	WindowID WindowID   `json:"window_id"`
	Minimize bool       `json:"minimize,omitempty"`
	Scope    CloseScope `json:"scope,omitempty"`
}

CloseWindowCommand minimizes instead of deleting when Minimize is true.

func (CloseWindowCommand) CommandID

func (CloseWindowCommand) CommandID() CommandID

type ClosedEntry

type ClosedEntry struct {
	Windows   []Window       `json:"windows"`
	ActiveID  *WindowID      `json:"active_id,omitempty"`
	StackID   *NodeID        `json:"stack_id,omitempty"`
	DesktopID DesktopID      `json:"desktop_id"`
	Rect      NormalizedRect `json:"rect"`
	ClosedAt  time.Time      `json:"closed_at"`
}

ClosedEntry is one reopenable close operation, newest last in Snapshot.ClosedEntries.

type Command

type Command interface {
	CommandID() CommandID
}

Command is one typed semantic mutation payload.

type CommandID

type CommandID string
const (
	CommandDesktopCreate        CommandID = "desktop.create"
	CommandDesktopUpdate        CommandID = "desktop.update"
	CommandDesktopReorder       CommandID = "desktop.reorder"
	CommandDesktopSwitch        CommandID = "desktop.switch"
	CommandDesktopDelete        CommandID = "desktop.delete"
	CommandWindowOpen           CommandID = "window.open"
	CommandWindowNavigate       CommandID = "window.navigate"
	CommandWindowClose          CommandID = "window.close"
	CommandWindowFocus          CommandID = "window.focus"
	CommandWindowMove           CommandID = "window.move"
	CommandWindowResize         CommandID = "window.resize"
	CommandWindowSwap           CommandID = "window.swap"
	CommandWindowToggleFloating CommandID = "window.toggle_floating"
	CommandWindowZoom           CommandID = "window.zoom"
	CommandWindowStackGroup     CommandID = "window.stack.group"
	CommandWindowStackReorder   CommandID = "window.stack.reorder"
	CommandWindowStackSetActive CommandID = "window.stack.set_active"
	CommandWindowPin            CommandID = "window.pin"
	CommandWindowReopen         CommandID = "window.reopen"
	CommandLayoutArrange        CommandID = "layout.arrange"
	CommandLayoutResize         CommandID = "layout.resize"
	CommandLayoutFrameResize    CommandID = "layout.frame_resize"
	CommandLayoutBalance        CommandID = "layout.balance"
	CommandLayoutUndo           CommandID = "layout.undo"
	CommandLayoutRedo           CommandID = "layout.redo"
	CommandLayoutReplace        CommandID = "layout.replace"
)

type CommandRequest

type CommandRequest struct {
	WorkspaceID      WorkspaceID
	CommandID        CommandID
	ExpectedRevision Revision
	// ClientID is required for desktop.switch, window.focus, and window.zoom.
	ClientID *ClientID
	Actor    Actor
	Origin   string
	Rebase   *RebaseGuard
	Payload  Command
}

CommandRequest binds one semantic command to a workspace revision.

type Commit

type Commit struct {
	WorkspaceID      WorkspaceID
	ExpectedRevision Revision
	Snapshot         Snapshot
	Event            Event
}

Commit is the repository's atomic compare-and-swap unit.

type Config

type Config struct {
	NewWindowPolicy     NewWindowPolicy     `json:"new_window_policy"`
	SmallViewportPolicy SmallViewportPolicy `json:"small_viewport_policy"`
	FocusPolicy         FocusPolicy         `json:"focus_policy"`
	FocusWrap           bool                `json:"focus_wrap"`
	FocusFollowsPointer bool                `json:"focus_follows_pointer"`
	RaiseOnFocus        bool                `json:"raise_on_focus"`
	DragAwayPolicy      DragAwayPolicy      `json:"drag_away_policy"`
	GroupMoveModifier   string              `json:"group_move_modifier"`
	SwapModifier        string              `json:"swap_modifier"`
	HistoryLimit        int                 `json:"history_limit"`
	NavStackLimit       int                 `json:"nav_stack_limit"`
	ClosedEntryLimit    int                 `json:"closed_entry_limit"`
	DesktopTransition   DesktopTransition   `json:"desktop_transition"`
	Gaps                GapsConfig          `json:"gaps"`
	Snap                SnapConfig          `json:"snap"`
	Bindings            BindingsConfig      `json:"bindings"`
	Shortcuts           map[string]string   `json:"shortcuts,omitempty"`
}

Config is the effective global window-manager configuration.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns production defaults from the accepted contract.

type Conflict

type Conflict struct {
	Code      string `json:"code"`
	EntityID  string `json:"entity_id,omitempty"`
	CurrentID string `json:"current_id,omitempty"`
}

Conflict identifies one stale reference that prevented a safe rebase.

type CreateDesktopCommand

type CreateDesktopCommand struct {
	DesktopID  DesktopID
	Name       string
	Purpose    DesktopPurpose
	FocusOwner *WindowID
	AfterID    *DesktopID
}

func (CreateDesktopCommand) CommandID

func (CreateDesktopCommand) CommandID() CommandID

type DeleteDesktopCommand

type DeleteDesktopCommand struct {
	DesktopID     DesktopID
	DestinationID *DesktopID
}

func (DeleteDesktopCommand) CommandID

func (DeleteDesktopCommand) CommandID() CommandID

type Desktop

type Desktop struct {
	ID             DesktopID       `json:"id"`
	Name           string          `json:"name"`
	Order          int             `json:"order"`
	Purpose        DesktopPurpose  `json:"purpose"`
	FocusOwner     *WindowID       `json:"focus_owner,omitempty"`
	Groups         []LayoutGroup   `json:"groups"`
	Floating       []WindowID      `json:"floating"`
	FloatingStacks []FloatingStack `json:"floating_stacks"`
}

Desktop owns tiled groups and floating order.

type DesktopID

type DesktopID string

type DesktopPurpose

type DesktopPurpose string
const (
	DesktopPurposeStandard DesktopPurpose = "standard"
	DesktopPurposeFocus    DesktopPurpose = "focus"
)

type DesktopTransition

type DesktopTransition string

DesktopTransition controls the client presentation used when switching desktops.

type Diagnostic

type Diagnostic struct {
	Code    string `json:"code"`
	Path    string `json:"path,omitempty"`
	Message string `json:"message"`
}

Diagnostic identifies one stable validation failure.

type DragAwayPolicy

type DragAwayPolicy string

DragAwayPolicy controls whether dragging detaches one window or its tiled group.

type DropPlacement

type DropPlacement string
const (
	DropFloating DropPlacement = "floating"
	DropBefore   DropPlacement = "before"
	DropAfter    DropPlacement = "after"
	DropLeft     DropPlacement = "left"
	DropRight    DropPlacement = "right"
	DropTop      DropPlacement = "top"
	DropBottom   DropPlacement = "bottom"
	DropCenter   DropPlacement = "center"
)

type Event

type Event struct {
	WorkspaceID WorkspaceID `json:"workspace_id"`
	Revision    Revision    `json:"revision"`
	CommandID   CommandID   `json:"command_id"`
	Changes     ChangeSet   `json:"changes"`
	Actor       Actor       `json:"actor"`
	Origin      string      `json:"origin,omitempty"`
	OccurredAt  time.Time   `json:"occurred_at"`
}

Event is published after one durable commit.

type EventObserver

type EventObserver func(context.Context, Event)

EventObserver receives an isolated copy of one observable committed event.

type FloatingStack

type FloatingStack struct {
	ID        NodeID         `json:"id"`
	WindowIDs []WindowID     `json:"window_ids"`
	ActiveID  *WindowID      `json:"active_id,omitempty"`
	Rect      NormalizedRect `json:"rect"`
	Minimized bool           `json:"minimized"`
}

FloatingStack is one floating frame containing an ordered tab deck.

type FocusDirection

type FocusDirection string
const (
	FocusLeft  FocusDirection = "left"
	FocusRight FocusDirection = "right"
	FocusUp    FocusDirection = "up"
	FocusDown  FocusDirection = "down"
)

type FocusPolicy

type FocusPolicy string

FocusPolicy controls how pointer and directional focus interact.

type FocusWindowCommand

type FocusWindowCommand struct {
	WindowID  *WindowID
	Direction FocusDirection
}

func (FocusWindowCommand) CommandID

func (FocusWindowCommand) CommandID() CommandID

type FrameResizeLayoutCommand

type FrameResizeLayoutCommand struct {
	DesktopID DesktopID
	Edits     []GroupFrameEdit
}

FrameResizeLayoutCommand moves shared group boundaries by rewriting every affected island frame in one atomic, overlap-checked mutation.

func (FrameResizeLayoutCommand) CommandID

func (FrameResizeLayoutCommand) CommandID() CommandID

type GapsConfig

type GapsConfig struct {
	Inner  float64 `json:"inner"`
	Top    float64 `json:"top"`
	Right  float64 `json:"right"`
	Bottom float64 `json:"bottom"`
	Left   float64 `json:"left"`
}

GapsConfig defines the inner and outer layout gaps in CSS pixels.

type GroupFrameEdit

type GroupFrameEdit struct {
	GroupID GroupID
	Frame   NormalizedRect
}

GroupFrameEdit assigns one group frame inside an atomic multi-group resize.

type GroupID

type GroupID string

type GroupWindowsCommand

type GroupWindowsCommand struct {
	TargetWindowID WindowID   `json:"target_window_id"`
	WindowIDs      []WindowID `json:"window_ids"`
	InsertIndex    *int       `json:"insert_index,omitempty"`
}

func (GroupWindowsCommand) CommandID

func (GroupWindowsCommand) CommandID() CommandID

type History

type History struct {
	Undo []HistoryEntry `json:"undo"`
	Redo []HistoryEntry `json:"redo"`
}

History contains bounded undo and redo stacks.

type HistoryEntry

type HistoryEntry struct {
	CommandID CommandID
	Before    State
	After     State
	Actor     Actor
	Origin    string
	CreatedAt time.Time
}

HistoryEntry stores an exact operation boundary.

type LayoutAspectVariant

type LayoutAspectVariant string
const (
	LayoutAspectAny       LayoutAspectVariant = "any"
	LayoutAspectLandscape LayoutAspectVariant = "landscape"
	LayoutAspectPortrait  LayoutAspectVariant = "portrait"
)

type LayoutDocument

type LayoutDocument struct {
	Version     uint32              `json:"version"`
	WorkspaceID WorkspaceID         `json:"workspace_id"`
	Desktops    []Desktop           `json:"desktops"`
	Windows     map[WindowID]Window `json:"windows"`
	Overrides   WorkspaceConfig     `json:"overrides"`
}

LayoutDocument is the validated raw export and replacement contract.

type LayoutGroup

type LayoutGroup struct {
	ID    GroupID        `json:"id"`
	Frame NormalizedRect `json:"frame"`
	Root  LayoutNode     `json:"root"`
}

LayoutGroup is one independent tiled island.

type LayoutNode

type LayoutNode struct {
	ID        NodeID       `json:"id"`
	Kind      NodeKind     `json:"kind"`
	WindowID  *WindowID    `json:"window_id,omitempty"`
	Axis      *Axis        `json:"axis,omitempty"`
	Children  []LayoutNode `json:"children,omitempty"`
	Weights   []float64    `json:"weights,omitempty"`
	WindowIDs []WindowID   `json:"window_ids,omitempty"`
	ActiveID  *WindowID    `json:"active_id,omitempty"`
}

LayoutNode is a leaf, weighted split, or tabbed stack.

type LayoutOverflowPolicy

type LayoutOverflowPolicy string
const (
	LayoutOverflowStack  LayoutOverflowPolicy = "stack"
	LayoutOverflowReject LayoutOverflowPolicy = "reject"
)

type LayoutResource

type LayoutResource struct {
	Version          uint32               `json:"version"`
	ID               string               `json:"id"`
	DisplayName      string               `json:"display_name"`
	AspectVariant    LayoutAspectVariant  `json:"aspect_variant"`
	ParticipantSlots []WindowID           `json:"participant_slots,omitempty"`
	OverflowPolicy   LayoutOverflowPolicy `json:"overflow_policy"`
	Document         LayoutDocument       `json:"document"`
}

LayoutResource describes one declarative registry contribution.

func CloneLayoutResource

func CloneLayoutResource(resource LayoutResource) LayoutResource

CloneLayoutResource returns a deep copy safe for cross-package catalogs.

type LayoutResourceRegistry

type LayoutResourceRegistry interface {
	Resolve(ctx context.Context, workspaceID WorkspaceID, resourceID string) (LayoutDocument, error)
	List(ctx context.Context, workspaceID WorkspaceID) ([]LayoutResource, error)
}

LayoutResourceRegistry resolves validated declarative layout resources.

type Manager

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

Manager coordinates semantic commands, transient clients, and subscriptions.

func NewService

func NewService(
	repository Repository,
	workspaces WorkspaceResolver,
	layouts LayoutResourceRegistry,
	defaults Config,
	options ...Option,
) (*Manager, error)

NewService constructs the daemon-authoritative window manager.

func (*Manager) Clients

func (m *Manager) Clients(ctx context.Context, workspaceID WorkspaceID) ([]ClientView, error)

Clients lists connected views without leaking another workspace partition.

func (*Manager) Close

func (m *Manager) Close() error

Close terminates live subscriptions and rejects later operations.

func (*Manager) DeleteWorkspace

func (m *Manager) DeleteWorkspace(ctx context.Context, workspaceID WorkspaceID) error

DeleteWorkspace removes window state, clients, and subscriptions for an authorized workspace.

func (*Manager) Execute

func (m *Manager) Execute(ctx context.Context, request CommandRequest) (Result, error)

Execute applies one semantic command through one compare-and-swap commit.

func (*Manager) ExportLayout

func (m *Manager) ExportLayout(ctx context.Context, workspaceID WorkspaceID) (LayoutDocument, error)

ExportLayout returns a history-free declarative document.

func (*Manager) ForgetWorkspace

func (m *Manager) ForgetWorkspace(workspaceID WorkspaceID)

ForgetWorkspace tears down transient state after the workspace owner commits deletion.

func (*Manager) LayoutResources

func (m *Manager) LayoutResources(ctx context.Context, workspaceID WorkspaceID) ([]LayoutResource, error)

LayoutResources lists declarative resources visible to a workspace.

func (*Manager) Preview

func (m *Manager) Preview(ctx context.Context, request CommandRequest) (Preview, error)

Preview reduces and validates without persisting, publishing, or advancing history.

func (*Manager) RegisterClient

func (m *Manager) RegisterClient(ctx context.Context, registration ClientRegistration) (ClientView, error)

RegisterClient creates or refreshes one explicit client-local view.

func (*Manager) ReplaceLayout

func (m *Manager) ReplaceLayout(ctx context.Context, request ReplaceLayoutRequest) (Result, error)

ReplaceLayout applies a raw layout through the normal semantic command pipeline.

func (*Manager) Snapshot

func (m *Manager) Snapshot(ctx context.Context, workspaceID WorkspaceID) (Snapshot, error)

Snapshot returns a validated workspace aggregate.

func (*Manager) Subscribe

func (m *Manager) Subscribe(ctx context.Context, request SubscriptionRequest) (Subscription, error)

Subscribe returns one atomic topology/client fence followed by ordered updates.

func (*Manager) UnregisterClient

func (m *Manager) UnregisterClient(ctx context.Context, workspaceID WorkspaceID, clientID ClientID) error

UnregisterClient removes transient presentation state only.

func (*Manager) UpdateDefaults

func (m *Manager) UpdateDefaults(defaults Config) error

UpdateDefaults atomically replaces validated runtime defaults for future commands.

func (*Manager) ValidateLayout

func (m *Manager) ValidateLayout(
	ctx context.Context,
	workspaceID WorkspaceID,
	document LayoutDocument,
) (Validation, error)

ValidateLayout checks a raw document without normalization or writes.

type MemoryRepository

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

MemoryRepository is an atomic repository for composition tests and ephemeral runtimes.

func NewMemoryRepository

func NewMemoryRepository() *MemoryRepository

NewMemoryRepository creates an empty workspace-partitioned repository.

func (*MemoryRepository) Commit

func (r *MemoryRepository) Commit(ctx context.Context, commit *Commit) error

func (*MemoryRepository) Commits

func (r *MemoryRepository) Commits(workspaceID WorkspaceID) []Commit

Commits returns an immutable copy of a workspace's transaction log.

func (*MemoryRepository) DeleteWorkspace

func (r *MemoryRepository) DeleteWorkspace(ctx context.Context, workspaceID WorkspaceID) error

func (*MemoryRepository) Load

func (r *MemoryRepository) Load(ctx context.Context, workspaceID WorkspaceID) (Snapshot, error)

type MemoryWorkspaceResolver

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

MemoryWorkspaceResolver provides explicit workspace registration for tests and ephemeral use.

func NewMemoryWorkspaceResolver

func NewMemoryWorkspaceResolver(workspaceIDs ...WorkspaceID) *MemoryWorkspaceResolver

NewMemoryWorkspaceResolver registers the supplied workspaces.

func (*MemoryWorkspaceResolver) Register

func (r *MemoryWorkspaceResolver) Register(workspaceID WorkspaceID)

Register makes a workspace resolvable.

func (*MemoryWorkspaceResolver) ResolveWorkspace

func (r *MemoryWorkspaceResolver) ResolveWorkspace(ctx context.Context, workspaceID WorkspaceID) error

func (*MemoryWorkspaceResolver) Unregister

func (r *MemoryWorkspaceResolver) Unregister(workspaceID WorkspaceID)

Unregister makes a workspace unavailable.

type MoveWindowCommand

type MoveWindowCommand struct {
	WindowID             WindowID
	DestinationDesktopID DesktopID
	TargetWindowID       *WindowID
	Placement            DropPlacement
	FloatingRect         *NormalizedRect
	MoveGroup            bool
}

func (MoveWindowCommand) CommandID

func (MoveWindowCommand) CommandID() CommandID
type NavigateMode string
const (
	NavigateReplace NavigateMode = ""
	NavigatePush    NavigateMode = "push"
	NavigatePop     NavigateMode = "pop"
)
type NavigateWindowCommand struct {
	WindowID WindowID    `json:"window_id"`
	Route    RouteIntent `json:"route,omitzero"`
	// InstanceKey retargets the window to another app instance in the same
	// navigation; valid only with replace mode and resets the nav stack.
	InstanceKey *string      `json:"instance_key,omitempty"`
	Mode        NavigateMode `json:"mode,omitempty"`
}
func (NavigateWindowCommand) CommandID() CommandID

type NewWindowPolicy

type NewWindowPolicy string

NewWindowPolicy controls how newly opened windows enter a desktop.

type NodeID

type NodeID string

type NodeKind

type NodeKind string
const (
	NodeKindLeaf  NodeKind = "leaf"
	NodeKindSplit NodeKind = "split"
	NodeKindStack NodeKind = "stack"
)

type NormalizedRect

type NormalizedRect struct {
	X      float64 `json:"x"`
	Y      float64 `json:"y"`
	Width  float64 `json:"width"`
	Height float64 `json:"height"`
}

NormalizedRect is viewport-independent geometry in the closed unit square.

type OpenWindowCommand

type OpenWindowCommand struct {
	Window          WindowSpec
	RestoreWindowID *WindowID
}

func (OpenWindowCommand) CommandID

func (OpenWindowCommand) CommandID() CommandID

type Option

type Option func(*managerOptions) error

Option customizes the manager without introducing operational globals.

func WithClock

func WithClock(now func() time.Time) Option

WithClock injects deterministic commit and client timestamps.

func WithEventObserver

func WithEventObserver(observer EventObserver) Option

WithEventObserver observes lifecycle events after their durable commit succeeds.

func WithIDGenerator

func WithIDGenerator(generate func(string) (string, error)) Option

WithIDGenerator injects deterministic entity identifiers.

func WithLifecycleContext

func WithLifecycleContext(ctx context.Context) Option

WithLifecycleContext preserves boot-scoped values for detached background work.

func WithSubscriptionBuffer

func WithSubscriptionBuffer(size int) Option

WithSubscriptionBuffer configures bounded subscriber backpressure.

func WithWorkspaceConfigResolver

func WithWorkspaceConfigResolver(resolver WorkspaceConfigResolver) Option

WithWorkspaceConfigResolver resolves workspace-scoped runtime behavior.

type PinWindowCommand

type PinWindowCommand struct {
	WindowID WindowID `json:"window_id"`
	Pinned   bool     `json:"pinned"`
}

func (PinWindowCommand) CommandID

func (PinWindowCommand) CommandID() CommandID

type Preview

type Preview struct {
	Snapshot    Snapshot     `json:"snapshot"`
	Changed     bool         `json:"changed"`
	Changes     ChangeSet    `json:"changes"`
	Diagnostics []Diagnostic `json:"diagnostics,omitempty"`
	Client      *ClientView  `json:"client,omitempty"`
}

Preview reports a validated proposal without a durable write.

type RebaseGuard

type RebaseGuard struct {
	WindowID      *WindowID
	SourceNodeID  *NodeID
	TargetNodeID  *NodeID
	SplitID       *NodeID
	BoundaryIndex *int
}

RebaseGuard proves stale source and target identities are still unambiguous.

type RedoLayoutCommand

type RedoLayoutCommand struct{}

func (RedoLayoutCommand) CommandID

func (RedoLayoutCommand) CommandID() CommandID

type ReopenCommand

type ReopenCommand struct{}

func (ReopenCommand) CommandID

func (ReopenCommand) CommandID() CommandID

type ReorderDesktopCommand

type ReorderDesktopCommand struct {
	DesktopID DesktopID
	Order     int
}

func (ReorderDesktopCommand) CommandID

func (ReorderDesktopCommand) CommandID() CommandID

type ReorderStackCommand

type ReorderStackCommand struct {
	WindowID WindowID `json:"window_id"`
	Index    int      `json:"index"`
}

func (ReorderStackCommand) CommandID

func (ReorderStackCommand) CommandID() CommandID

type ReplaceLayoutCommand

type ReplaceLayoutCommand struct{ Document LayoutDocument }

func (ReplaceLayoutCommand) CommandID

func (ReplaceLayoutCommand) CommandID() CommandID

type ReplaceLayoutRequest

type ReplaceLayoutRequest struct {
	WorkspaceID      WorkspaceID
	ExpectedRevision Revision
	ClientID         *ClientID
	Actor            Actor
	Origin           string
	Document         LayoutDocument
}

ReplaceLayoutRequest applies a validated document with normal revision CAS.

type Repository

type Repository interface {
	Load(ctx context.Context, workspaceID WorkspaceID) (Snapshot, error)
	Commit(ctx context.Context, commit *Commit) error
	// DeleteWorkspace is atomic: an error leaves the workspace state unchanged.
	DeleteWorkspace(ctx context.Context, workspaceID WorkspaceID) error
}

Repository stores the complete aggregate atomically.

type ResizeLayoutCommand

type ResizeLayoutCommand struct {
	SplitID       NodeID
	BoundaryIndex int
	Delta         float64
}

func (ResizeLayoutCommand) CommandID

func (ResizeLayoutCommand) CommandID() CommandID

type ResizeWindowCommand

type ResizeWindowCommand struct {
	WindowID WindowID
	Frame    NormalizedRect
}

ResizeWindowCommand assigns a normalized frame to the unit containing the window: a floating rect, a floating stack rect, a solo group frame, or a split member that detaches into its own island at the requested frame.

func (ResizeWindowCommand) CommandID

func (ResizeWindowCommand) CommandID() CommandID

type Result

type Result struct {
	Snapshot    Snapshot     `json:"snapshot"`
	Applied     bool         `json:"applied"`
	Changes     ChangeSet    `json:"changes"`
	Diagnostics []Diagnostic `json:"diagnostics,omitempty"`
	Client      *ClientView  `json:"client,omitempty"`
	RebasedFrom *Revision    `json:"rebased_from,omitempty"`
}

Result reports one applied or no-op command.

type ReturnAnchor

type ReturnAnchor struct {
	DesktopID      DesktopID      `json:"desktop_id"`
	GroupID        *GroupID       `json:"group_id,omitempty"`
	ParentSplitID  *NodeID        `json:"parent_split_id,omitempty"`
	ChildIndex     *int           `json:"child_index,omitempty"`
	Weight         *float64       `json:"weight,omitempty"`
	NeighborIDs    []WindowID     `json:"neighbor_ids,omitempty"`
	SourceRevision Revision       `json:"source_revision"`
	SourceGroup    *LayoutGroup   `json:"source_group,omitempty"`
	SourceStack    *FloatingStack `json:"source_stack,omitempty"`
}

ReturnAnchor describes a window's prior structural slot.

type Revision

type Revision uint64

func NextTopologyRevision

func NextTopologyRevision(current Revision) (Revision, error)

NextTopologyRevision returns the next JSON-safe durable topology revision.

type RevisionConflictError

type RevisionConflictError struct {
	Expected Revision
	Current  Revision
	Details  []Conflict
}

RevisionConflictError reports the current revision and failed rebase guards.

func (*RevisionConflictError) Error

func (e *RevisionConflictError) Error() string

func (*RevisionConflictError) Unwrap

func (e *RevisionConflictError) Unwrap() error

type RouteIntent

type RouteIntent struct {
	Pathname string      `json:"pathname"`
	Search   RouteSearch `json:"search"`
}

RouteIntent is one application-internal durable navigation target.

func CanonicalRouteIntent

func CanonicalRouteIntent(route RouteIntent) (RouteIntent, error)

CanonicalRouteIntent validates and normalizes a durable application route.

func (*RouteIntent) UnmarshalJSON

func (route *RouteIntent) UnmarshalJSON(data []byte) error

UnmarshalJSON rejects incomplete, external, or non-object route intents.

type RouteSearch

type RouteSearch map[string]json.RawMessage

RouteSearch is a canonical JSON object containing durable route search state.

type Service

Service is the window-manager runtime contract.

type SetStackActiveCommand

type SetStackActiveCommand struct {
	WindowID WindowID `json:"window_id"`
}

func (SetStackActiveCommand) CommandID

func (SetStackActiveCommand) CommandID() CommandID

type SmallViewportPolicy

type SmallViewportPolicy string

SmallViewportPolicy controls layout behavior when the viewport cannot fit a tiled arrangement.

type SnapConfig

type SnapConfig struct {
	EdgeBand     float64   `json:"edge_band"`
	CornerReach  float64   `json:"corner_reach"`
	ExitSlack    float64   `json:"exit_slack"`
	RepeatRatios []float64 `json:"repeat_ratios"`
}

SnapConfig defines pointer thresholds and repeated edge-snap ratios.

type Snapshot

type Snapshot struct {
	Version       uint32              `json:"version"`
	WorkspaceID   WorkspaceID         `json:"workspace_id"`
	Revision      Revision            `json:"revision"`
	Desktops      []Desktop           `json:"desktops"`
	Windows       map[WindowID]Window `json:"windows"`
	ClosedEntries []ClosedEntry       `json:"closed_entries,omitempty"`
	History       History             `json:"history"`
	Overrides     WorkspaceConfig     `json:"overrides"`
	UpdatedAt     time.Time           `json:"updated_at"`
}

Snapshot is the complete durable workspace aggregate.

func NormalizeSnapshot

func NormalizeSnapshot(snapshot Snapshot) Snapshot

NormalizeSnapshot deterministically repairs unambiguous representational residue.

type State

type State struct {
	Desktops  []Desktop
	Windows   map[WindowID]Window
	Overrides WorkspaceConfig
}

State is the revision-independent content restored by history.

type Subscription

type Subscription interface {
	Fence() SubscriptionFence
	Updates() <-chan SubscriptionUpdate
	Err() error
	Close() error
}

Subscription fences current state and later ordered updates.

type SubscriptionFence

type SubscriptionFence struct {
	Snapshot Snapshot
	Client   *ClientView
}

SubscriptionFence atomically captures durable topology and optional presentation state.

type SubscriptionRequest

type SubscriptionRequest struct {
	WorkspaceID   WorkspaceID
	AfterRevision Revision
	ClientID      *ClientID
}

SubscriptionRequest binds an optional client view to one stream.

type SubscriptionUpdate

type SubscriptionUpdate struct {
	Event  *Event
	Client *ClientView
}

SubscriptionUpdate carries one ordered topology or client presentation change.

type SwapWindowsCommand

type SwapWindowsCommand struct {
	FirstWindowID  WindowID
	SecondWindowID WindowID
}

func (SwapWindowsCommand) CommandID

func (SwapWindowsCommand) CommandID() CommandID

type SwitchDesktopCommand

type SwitchDesktopCommand struct{ DesktopID DesktopID }

func (SwitchDesktopCommand) CommandID

func (SwitchDesktopCommand) CommandID() CommandID

type ToggleFloatingCommand

type ToggleFloatingCommand struct {
	WindowID     WindowID
	FloatingRect *NormalizedRect
}

func (ToggleFloatingCommand) CommandID

func (ToggleFloatingCommand) CommandID() CommandID

type TopologyError

type TopologyError struct {
	Diagnostics []Diagnostic
}

TopologyError reports all independently detectable topology violations.

func (*TopologyError) Error

func (e *TopologyError) Error() string

func (*TopologyError) Unwrap

func (e *TopologyError) Unwrap() error

type UndoLayoutCommand

type UndoLayoutCommand struct{}

func (UndoLayoutCommand) CommandID

func (UndoLayoutCommand) CommandID() CommandID

type UpdateDesktopCommand

type UpdateDesktopCommand struct {
	DesktopID DesktopID
	Name      string
}

func (UpdateDesktopCommand) CommandID

func (UpdateDesktopCommand) CommandID() CommandID

type Validation

type Validation struct {
	Valid       bool         `json:"valid"`
	Diagnostics []Diagnostic `json:"diagnostics,omitempty"`
}

Validation reports stable layout diagnostics.

type Window

type Window struct {
	ID           WindowID        `json:"id"`
	App          string          `json:"app"`
	InstanceKey  *string         `json:"instance_key,omitempty"`
	Route        RouteIntent     `json:"route"`
	NavStack     []RouteIntent   `json:"nav_stack"`
	Pinned       bool            `json:"pinned"`
	Placement    WindowPlacement `json:"placement"`
	DesktopID    DesktopID       `json:"desktop_id"`
	FloatingRect NormalizedRect  `json:"floating_rect"`
	Minimized    bool            `json:"minimized"`
	ReturnAnchor *ReturnAnchor   `json:"return_anchor,omitempty"`
}

Window is one durable application instance.

type WindowID

type WindowID string

type WindowPlacement

type WindowPlacement string
const (
	WindowPlacementTiled    WindowPlacement = "tiled"
	WindowPlacementStacked  WindowPlacement = "stacked"
	WindowPlacementFloating WindowPlacement = "floating"
)

type WindowSpec

type WindowSpec struct {
	ID                  WindowID       `json:"id,omitempty"`
	App                 string         `json:"app"`
	InstanceKey         *string        `json:"instance_key,omitempty"`
	Route               RouteIntent    `json:"route"`
	DesktopID           DesktopID      `json:"desktop_id"`
	FloatingRect        NormalizedRect `json:"floating_rect"`
	InsertTiled         bool           `json:"insert_tiled,omitempty"`
	StackTargetWindowID *WindowID      `json:"stack_target_window_id,omitempty"`
}

type WorkspaceConfig

type WorkspaceConfig struct {
	NewWindowPolicy     *NewWindowPolicy     `json:"new_window_policy,omitempty"`
	SmallViewportPolicy *SmallViewportPolicy `json:"small_viewport_policy,omitempty"`
	FocusPolicy         *FocusPolicy         `json:"focus_policy,omitempty"`
	FocusWrap           *bool                `json:"focus_wrap,omitempty"`
	FocusFollowsPointer *bool                `json:"focus_follows_pointer,omitempty"`
	RaiseOnFocus        *bool                `json:"raise_on_focus,omitempty"`
	DragAwayPolicy      *DragAwayPolicy      `json:"drag_away_policy,omitempty"`
	GroupMoveModifier   *string              `json:"group_move_modifier,omitempty"`
	SwapModifier        *string              `json:"swap_modifier,omitempty"`
	HistoryLimit        *int                 `json:"history_limit,omitempty"`
	NavStackLimit       *int                 `json:"nav_stack_limit,omitempty"`
	ClosedEntryLimit    *int                 `json:"closed_entry_limit,omitempty"`
	DesktopTransition   *DesktopTransition   `json:"desktop_transition,omitempty"`
	Gaps                *GapsConfig          `json:"gaps,omitempty"`
	Snap                *SnapConfig          `json:"snap,omitempty"`
	Bindings            *BindingsConfig      `json:"bindings,omitempty"`
	Shortcuts           map[string]string    `json:"shortcuts,omitempty"`
}

WorkspaceConfig contains optional workspace overrides.

type WorkspaceConfigResolver

type WorkspaceConfigResolver interface {
	ResolveWindowManagerConfig(context.Context, WorkspaceID, Config) (Config, error)
}

WorkspaceConfigResolver overlays workspace-scoped behavior onto active defaults.

type WorkspaceID

type WorkspaceID string

type WorkspaceResolver

type WorkspaceResolver interface {
	ResolveWorkspace(ctx context.Context, workspaceID WorkspaceID) error
}

WorkspaceResolver authorizes and resolves a workspace before state access.

type ZoomWindowCommand

type ZoomWindowCommand struct{ WindowID WindowID }

func (ZoomWindowCommand) CommandID

func (ZoomWindowCommand) CommandID() CommandID

Jump to

Keyboard shortcuts

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