Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrVersionConflict = errors.New("workspace has been modified")
Functions ¶
This section is empty.
Types ¶
type Patch ¶
type Patch struct {
Title *string
Description *string
Workdir *string
DefaultAgent *string
DefaultModel *string
}
Patch contains only fields the caller explicitly owns. Nil leaves a field unchanged; a non-nil empty string clears an optional field.
type RecentDirsService ¶
type RecentDirsService interface {
List() ([]string, error)
Add(ctx context.Context, dir string) error
}
RecentDirsService owns the recently-used workspace directory list.
func NewRecentDirsService ¶
func NewRecentDirsService() (RecentDirsService, error)
type Service ¶
type Service interface {
Create(ws *model.Workspace) error
Get(id string) (*model.Workspace, bool)
List() []*model.Workspace
Patch(id string, expectedVersion uint64, patch Patch) (*model.Workspace, error)
ClearAgentDefaults(agentID string) error
SetFavorite(id string, favorite bool) (*model.Workspace, error)
Reorder(ids []string) error
Revision() uint64
// TrustedFileWorkspaceRoots returns the set of workspace Workdirs that
// pass internal workdir validation, used to scope file-browsing endpoints.
TrustedFileWorkspaceRoots() []string
// MarkDeleted flips the Deleted flag so Get / List start returning nothing
// for this workspace. The flag is persisted to meta.json but the directory
// and in-memory entry stay in place. Used by the handler to close the
// TOCTOU window while it cascades Job cleanup: once this returns, no new
// Job can bind to the workspace (resolveWorkspaceID / any Get-based lookup
// sees it as gone), and the caller can safely enumerate and delete jobs
// without racing new arrivals. A subsequent Delete() finalizes removal
// (map entry + disk). Persisting the flag makes the two-phase deletion
// crash-safe: if the process dies between MarkDeleted and Delete, LoadAll
// on next boot skips the Deleted=true entry instead of resurrecting it.
MarkDeleted(id string) error
Delete(id string) error
EnsureDefault() error
// DefaultWorkdir returns the canonical default workdir suggested for a
// freshly created workspace (UserHomeDir → $HOME → TempDir).
// Used by the new-workspace UI to prefill the path picker.
DefaultWorkdir() string
// GitBranch returns the checked-out git branch name for dir, or "" when dir
// is not inside a git repository or is on a detached HEAD. Used by the
// composer's workspace tag to surface the current branch next to the path.
GitBranch(dir string) string
// RegenerateAllColors assigns a fresh random color to every non-deleted
// workspace and persists the change. Returns the updated list in the same
// order as List().
RegenerateAllColors() ([]*model.Workspace, error)
}
func NewService ¶
Click to show internal directories.
Click to hide internal directories.