control

package
v0.1.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const ControlPlaneTabName = "control"

ControlPlaneTabName is the name of the control plane tab in zellij

Variables

This section is empty.

Functions

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 ScheduleWatchWorkflowRun

func ScheduleWatchWorkflowRun(ctx context.Context, proj *project.Project, workID string, runID int64, repo string) error

ScheduleWatchWorkflowRun schedules a task to watch a workflow run. Uses the run_id as the idempotency key to prevent duplicate watchers.

func SpawnWorkflowWatchers

func SpawnWorkflowWatchers(ctx context.Context, proj *project.Project, ghClient github.ClientInterface, workID, prURL string) (int, error)

SpawnWorkflowWatchers checks for in-progress workflow runs and spawns watchers for them. This can be called immediately when a PR is created to catch fast CI runs that would otherwise complete before the first PR feedback poll. Returns the number of watchers spawned.

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
	GitHubClient        github.ClientInterface
}

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(proj *project.Project) *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,
	githubClient github.ClientInterface,
) *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

func (*ControlPlane) HandleWatchWorkflowRunTask

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

HandleWatchWorkflowRunTask watches a GitHub Actions workflow run until completion. When the run completes (success or failure), it schedules a PRFeedback task to run immediately. This replaces polling for workflow runs that are in-progress.

Required metadata: - run_id: The GitHub Actions workflow run ID to watch - repo: The repository in owner/repo format

type DefaultOrchestratorSpawner

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

DefaultOrchestratorSpawner implements OrchestratorSpawner using the work package.

func NewOrchestratorSpawner

func NewOrchestratorSpawner(database *db.DB) *DefaultOrchestratorSpawner

NewOrchestratorSpawner creates a new DefaultOrchestratorSpawner with the given database.

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 {
	// contains filtered or unexported fields
}

DefaultWorkDestroyer implements WorkDestroyer using the work package.

func NewWorkDestroyer

func NewWorkDestroyer(proj *project.Project) *DefaultWorkDestroyer

NewWorkDestroyer creates a new DefaultWorkDestroyer with a WorkService.

func (*DefaultWorkDestroyer) DestroyWork

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

DestroyWork implements WorkDestroyer.

type InitResult

type InitResult 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
}

InitResult contains information about session initialization

func EnsureControlPlane

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

EnsureControlPlane ensures the zellij session and control plane are running. Creates the session if needed, spawns control plane if missing, restarts if dead. Returns information about whether a new session was created.

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 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, 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