control

package
v0.1.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const TabName = "control"

TabName is the name of the control plane tab in zellij

Variables

This section is empty.

Functions

func EnsureControlPlane

func EnsureControlPlane(ctx context.Context, proj *project.Project) error

EnsureControlPlane ensures the control plane is running, spawning it if needed

func HandleCommentResolutionTask

func HandleCommentResolutionTask(ctx context.Context, proj *project.Project, task *db.ScheduledTask) error

HandleCommentResolutionTask handles a scheduled comment resolution check. Returns nil on success, error on failure (caller handles retry/completion).

func HandleGitHubCommentTask

func HandleGitHubCommentTask(ctx context.Context, proj *project.Project, task *db.ScheduledTask) error

HandleGitHubCommentTask handles a scheduled GitHub comment posting task. Returns nil on success, error on failure (caller handles retry/completion).

func HandleGitHubResolveThreadTask

func HandleGitHubResolveThreadTask(ctx context.Context, proj *project.Project, task *db.ScheduledTask) error

HandleGitHubResolveThreadTask handles a scheduled GitHub thread resolution task. Returns nil on success, error on failure (caller handles retry/completion).

func HandleImportPRTask

func HandleImportPRTask(ctx context.Context, proj *project.Project, task *db.ScheduledTask) error

HandleImportPRTask handles a scheduled PR import task. This sets up a worktree from an existing GitHub PR.

func HandleTaskError

func HandleTaskError(ctx context.Context, proj *project.Project, task *db.ScheduledTask, errMsg string)

HandleTaskError handles an error for a task, rescheduling with backoff if appropriate.

func ProcessAllDueTasks

func ProcessAllDueTasks(ctx context.Context, proj *project.Project)

ProcessAllDueTasks checks for and executes any scheduled tasks that are due across all works. This uses the default ControlPlane with production dependencies.

func ProcessAllDueTasksWithControlPlane

func ProcessAllDueTasksWithControlPlane(ctx context.Context, proj *project.Project, cp *ControlPlane)

ProcessAllDueTasksWithControlPlane checks for and executes any scheduled tasks with provided dependencies.

func RunControlPlaneLoop

func RunControlPlaneLoop(ctx context.Context, proj *project.Project, procManager *procmon.Manager) error

RunControlPlaneLoop runs the main control plane event loop with default dependencies.

func RunControlPlaneLoopWithControlPlane

func RunControlPlaneLoopWithControlPlane(ctx context.Context, proj *project.Project, procManager *procmon.Manager, cp *ControlPlane) error

RunControlPlaneLoopWithControlPlane runs the main control plane event loop with provided dependencies. This allows testing with mock dependencies.

func ScheduleDestroyWorktree

func ScheduleDestroyWorktree(ctx context.Context, proj *project.Project, workID string) error

ScheduleDestroyWorktree schedules a worktree destruction task for the control plane. This is the preferred way to destroy a worktree as it runs asynchronously with retry support.

func SpawnControlPlane

func SpawnControlPlane(ctx context.Context, proj *project.Project) error

SpawnControlPlane spawns the control plane in a zellij tab

func TriggerPRFeedbackCheck

func TriggerPRFeedbackCheck(ctx context.Context, proj *project.Project, workID string) error

TriggerPRFeedbackCheck schedules an immediate PR feedback check. This is called from the TUI when the user presses 'f' in the work details panel.

Types

type ControlPlane

type ControlPlane struct {
	Git                 git.Operations
	Worktree            worktree.Operations
	Zellij              zellij.SessionManager
	Mise                func(dir string) mise.Operations
	FeedbackProcessor   feedback.Processor
	OrchestratorSpawner OrchestratorSpawner
	WorkDestroyer       WorkDestroyer
}

ControlPlane manages the execution of scheduled tasks with injectable dependencies. It allows for testing without actual CLI tools, services, or file system operations.

func NewControlPlane

func NewControlPlane() *ControlPlane

NewControlPlane creates a new ControlPlane with default production dependencies.

func NewControlPlaneWithDeps

func NewControlPlaneWithDeps(
	gitOps git.Operations,
	wtOps worktree.Operations,
	zellijMgr zellij.SessionManager,
	miseOps func(dir string) mise.Operations,
	feedbackProc feedback.Processor,
	orchestratorSpawner OrchestratorSpawner,
	workDestroyer WorkDestroyer,
) *ControlPlane

NewControlPlaneWithDeps creates a new ControlPlane with provided dependencies for testing.

func (*ControlPlane) GetTaskHandlers

func (cp *ControlPlane) GetTaskHandlers() map[string]TaskHandler

GetTaskHandlers returns the task handler map for the control plane.

func (*ControlPlane) HandleCreateWorktreeTask

func (cp *ControlPlane) HandleCreateWorktreeTask(ctx context.Context, proj *project.Project, task *db.ScheduledTask) error

HandleCreateWorktreeTask handles a scheduled worktree creation task

func (*ControlPlane) HandleDestroyWorktreeTask

func (cp *ControlPlane) HandleDestroyWorktreeTask(ctx context.Context, proj *project.Project, task *db.ScheduledTask) error

HandleDestroyWorktreeTask handles a scheduled worktree destruction task

func (*ControlPlane) HandleGitPushTask

func (cp *ControlPlane) HandleGitPushTask(ctx context.Context, proj *project.Project, task *db.ScheduledTask) error

HandleGitPushTask handles a scheduled git push task with retry support. Returns nil on success, error on failure (caller handles retry/completion).

func (*ControlPlane) HandlePRFeedbackTask

func (cp *ControlPlane) HandlePRFeedbackTask(ctx context.Context, proj *project.Project, task *db.ScheduledTask) error

HandlePRFeedbackTask handles a scheduled PR feedback check. Returns nil on success, error on failure (caller handles retry/completion).

func (*ControlPlane) HandleSpawnOrchestratorTask

func (cp *ControlPlane) HandleSpawnOrchestratorTask(ctx context.Context, proj *project.Project, task *db.ScheduledTask) error

HandleSpawnOrchestratorTask handles a scheduled orchestrator spawn task

type DefaultOrchestratorSpawner

type DefaultOrchestratorSpawner struct{}

DefaultOrchestratorSpawner implements OrchestratorSpawner using the claude package.

func (*DefaultOrchestratorSpawner) SpawnWorkOrchestrator

func (d *DefaultOrchestratorSpawner) SpawnWorkOrchestrator(ctx context.Context, workID, projectName, workDir, friendlyName string, w io.Writer) error

SpawnWorkOrchestrator implements OrchestratorSpawner.

type DefaultWorkDestroyer

type DefaultWorkDestroyer struct{}

DefaultWorkDestroyer implements WorkDestroyer using the work package.

func (*DefaultWorkDestroyer) DestroyWork

func (d *DefaultWorkDestroyer) DestroyWork(ctx context.Context, proj *project.Project, workID string, w io.Writer) error

DestroyWork implements WorkDestroyer.

type OrchestratorSpawner

type OrchestratorSpawner interface {
	SpawnWorkOrchestrator(ctx context.Context, workID, projectName, workDir, friendlyName string, w io.Writer) error
}

OrchestratorSpawner defines the interface for spawning work orchestrators. This abstraction enables testing without actual zellij operations.

type SessionInitResult

type SessionInitResult struct {
	// SessionCreated is true if a new zellij session was created
	SessionCreated bool
	// SessionName is the name of the zellij session (e.g., "co-myproject")
	SessionName string
}

SessionInitResult contains information about session initialization

func InitializeSession

func InitializeSession(ctx context.Context, proj *project.Project) (*SessionInitResult, error)

InitializeSession ensures a zellij session exists with the control plane running. When a new session is created, it uses a layout to start the control plane automatically. Returns information about whether a new session was created.

type TaskHandler

type TaskHandler func(ctx context.Context, proj *project.Project, task *db.ScheduledTask) error

TaskHandler is the signature for all scheduled task handlers.

type WorkDestroyer

type WorkDestroyer interface {
	DestroyWork(ctx context.Context, proj *project.Project, workID string, w io.Writer) error
}

WorkDestroyer defines the interface for destroying work units. This abstraction enables testing without actual file system operations.

Jump to

Keyboard shortcuts

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