Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
feat: show project status reason (#708)
Kyle Mendell2ec1aa6f1f6f
diff --git a/backend/internal/api/project_handler.go b/backend/internal/api/project_handler.goindex 9ab060db9..c9560039f 100644--- a/backend/internal/api/project_handler.go+++ b/backend/internal/api/project_handler.go@@ -159,6 +159,7 @@ func (h *ProjectHandler) CreateProject(c *gin.Context) {return}response.Status = string(proj.Status)+ response.StatusReason = proj.StatusReasonresponse.CreatedAt = proj.CreatedAt.Format(time.RFC3339)response.UpdatedAt = proj.UpdatedAt.Format(time.RFC3339)response.DirName = utils.DerefString(proj.DirName)diff --git a/backend/internal/dto/project_dto.go b/backend/internal/dto/project_dto.goindex a3c3a014d..74b4b8489 100644--- a/backend/internal/dto/project_dto.go+++ b/backend/internal/dto/project_dto.go@@ -13,30 +13,32 @@ type UpdateProjectDto struct {}type CreateProjectReponseDto struct {- ID string `json:"id"`- Name string `json:"name"`- DirName string `json:"dirName,omitempty"`- Path string `json:"path"`- Status string `json:"status"`- ServiceCount int `json:"serviceCount"`- RunningCount int `json:"runningCount"`- CreatedAt string `json:"createdAt"`- UpdatedAt string `json:"updatedAt"`+ ID string `json:"id"`+ Name string `json:"name"`+ DirName string `json:"dirName,omitempty"`+ Path string `json:"path"`+ Status string `json:"status"`+ StatusReason *string `json:"statusReason,omitempty"`+ ServiceCount int `json:"serviceCount"`+ RunningCount int `json:"runningCount"`+ CreatedAt string `json:"createdAt"`+ UpdatedAt string `json:"updatedAt"`}type ProjectDetailsDto struct {- ID string `json:"id"`- Name string `json:"name"`- DirName string `json:"dirName,omitempty"`- Path string `json:"path"`- ComposeContent string `json:"composeContent,omitempty"`- EnvContent string `json:"envContent,omitempty"`- Status string `json:"status"`- ServiceCount int `json:"serviceCount"`- RunningCount int `json:"runningCount"`- CreatedAt string `json:"createdAt"`- UpdatedAt string `json:"updatedAt"`- Services []any `json:"services,omitempty"`+ ID string `json:"id"`+ Name string `json:"name"`+ DirName string `json:"dirName,omitempty"`+ Path string `json:"path"`+ ComposeContent string `json:"composeContent,omitempty"`+ EnvContent string `json:"envContent,omitempty"`+ Status string `json:"status"`+ StatusReason *string `json:"statusReason,omitempty"`+ ServiceCount int `json:"serviceCount"`+ RunningCount int `json:"runningCount"`+ CreatedAt string `json:"createdAt"`+ UpdatedAt string `json:"updatedAt"`+ Services []any `json:"services,omitempty"`}type DestroyProjectDto struct {diff --git a/backend/internal/models/project.go b/backend/internal/models/project.goindex d85598e7c..5af54111a 100644--- a/backend/internal/models/project.go+++ b/backend/internal/models/project.go@@ -17,6 +17,7 @@ type Project struct {DirName *string `json:"dir_name" gorm:"unique"`Path string `json:"path" gorm:"not null"`Status ProjectStatus `json:"status" sortable:"true"`+ StatusReason *string `json:"status_reason"`ServiceCount int `json:"service_count" sortable:"true"`RunningCount int `json:"running_count" sortable:"true"`diff --git a/backend/internal/services/project_service.go b/backend/internal/services/project_service.goindex d6b0dd5cf..1a166b94f 100644--- a/backend/internal/services/project_service.go+++ b/backend/internal/services/project_service.go@@ -278,14 +278,20 @@ func (s *ProjectService) upsertProjectForDir(ctx context.Context, dirName, dirPaif errors.Is(err, gorm.ErrRecordNotFound) {// Create a minimal project entry+ reason := "Project discovered from filesystem, status pending Docker service query"proj := &models.Project{Name: dirName,DirName: &dirName,Path: dirPath,Status: models.ProjectStatusUnknown,+ StatusReason: &reason,ServiceCount: 0,RunningCount: 0,}+ slog.InfoContext(ctx, "Discovered new project with unknown status",+ "project", dirName,+ "path", dirPath,+ "reason", reason)if cerr := s.db.WithContext(ctx).Create(proj).Error; cerr != nil {return fmt.Errorf("create project for %q failed: %w", dirPath, cerr)}@@ -817,23 +823,46 @@ func (s *ProjectService) ListProjects(ctx context.Context, params pagination.QuedisplayServiceCount := project.ServiceCountdisplayRunningCount := project.RunningCountdisplayStatus := string(project.Status)+ var statusReason *string// Get live status from Dockerif services, serr := s.GetProjectServices(ctx, project.ID); serr == nil {displayServiceCount = len(services)_, displayRunningCount = s.getServiceCounts(services)displayStatus = string(s.calculateProjectStatus(services))- } else if displayServiceCount == 0 {++ // If status is unknown, set reason+ if displayStatus == string(models.ProjectStatusUnknown) && len(services) == 0 {+ reason := "No services found in project"+ statusReason = &reason+ slog.WarnContext(ctx, "Project has unknown status",+ "project_id", project.ID,+ "project_name", project.Name,+ "reason", reason)+ }+ } else {+ // Error getting services - set status to unknown with reason+ displayStatus = string(models.ProjectStatusUnknown)+ reason := fmt.Sprintf("Failed to load project services: %v", serr)+ statusReason = &reason+ slog.WarnContext(ctx, "Project has unknown status due to error",+ "project_id", project.ID,+ "project_name", project.Name,+ "reason", reason,+ "error", serr)+// Fallback: try to detect service count from compose file- if _, derr := projects.DetectComposeFile(project.Path); derr == nil {- // Get configured projects directory from settings- projectsDirSetting := s.settingsService.GetStringSetting(ctx, "projectsDirectory", "data/projects")- projectsDirectory, pdErr := fs.GetProjectsDirectory(ctx, strings.TrimSpace(projectsDirSetting))- if pdErr != nil {- projectsDirectory = "data/projects"- }- if proj, _, perr := projects.LoadComposeProjectFromDir(ctx, project.Path, project.Name, projectsDirectory); perr == nil {- displayServiceCount = len(proj.Services)+ if displayServiceCount == 0 {+ if _, derr := projects.DetectComposeFile(project.Path); derr == nil {+ // Get configured projects directory from settings+ projectsDirSetting := s.settingsService.GetStringSetting(ctx, "projectsDirectory", "data/projects")+ projectsDirectory, pdErr := fs.GetProjectsDirectory(ctx, strings.TrimSpace(projectsDirSetting))+ if pdErr != nil {+ projectsDirectory = "data/projects"+ }+ if proj, _, perr := projects.LoadComposeProjectFromDir(ctx, project.Path, project.Name, projectsDirectory); perr == nil {+ displayServiceCount = len(proj.Services)+ }}}}@@ -844,6 +873,7 @@ func (s *ProjectService) ListProjects(ctx context.Context, params pagination.QueDirName: utils.DerefString(project.DirName),Path: project.Path,Status: displayStatus,+ StatusReason: statusReason,ServiceCount: displayServiceCount,RunningCount: displayRunningCount,CreatedAt: project.CreatedAt.Format(time.RFC3339),diff --git a/backend/resources/migrations/postgres/018_add_project_status_reason.down.sql b/backend/resources/migrations/postgres/018_add_project_status_reason.down.sqlnew file mode 100644index 000000000..8b190d0e0--- /dev/null+++ b/backend/resources/migrations/postgres/018_add_project_status_reason.down.sql@@ -0,0 +1 @@+ALTER TABLE projects DROP COLUMN status_reason;diff --git a/backend/resources/migrations/postgres/018_add_project_status_reason.up.sql b/backend/resources/migrations/postgres/018_add_project_status_reason.up.sqlnew file mode 100644index 000000000..87131d0d9--- /dev/null+++ b/backend/resources/migrations/postgres/018_add_project_status_reason.up.sql@@ -0,0 +1 @@+ALTER TABLE projects ADD COLUMN status_reason TEXT;diff --git a/backend/resources/migrations/sqlite/018_add_project_status_reason.down.sql b/backend/resources/migrations/sqlite/018_add_project_status_reason.down.sqlnew file mode 100644index 000000000..8b190d0e0--- /dev/null+++ b/backend/resources/migrations/sqlite/018_add_project_status_reason.down.sql@@ -0,0 +1 @@+ALTER TABLE projects DROP COLUMN status_reason;diff --git a/backend/resources/migrations/sqlite/018_add_project_status_reason.up.sql b/backend/resources/migrations/sqlite/018_add_project_status_reason.up.sqlnew file mode 100644index 000000000..87131d0d9--- /dev/null+++ b/backend/resources/migrations/sqlite/018_add_project_status_reason.up.sql@@ -0,0 +1 @@+ALTER TABLE projects ADD COLUMN status_reason TEXT;diff --git a/frontend/src/lib/components/badges/status-badge.svelte b/frontend/src/lib/components/badges/status-badge.svelteindex dcf31df6b..fbcfc3963 100644--- a/frontend/src/lib/components/badges/status-badge.svelte+++ b/frontend/src/lib/components/badges/status-badge.svelte@@ -1,6 +1,7 @@<script lang="ts">import { cn } from '$lib/utils';import { m } from '$lib/paraglide/messages';+ import * as Tooltip from '$lib/components/ui/tooltip';type Variant =| 'red'@@ -29,6 +30,7 @@variant = 'gray',size = 'md',minWidth = '20',+ tooltip,class: className = '',...restProps} = $props<{@@ -36,6 +38,7 @@variant?: Variant;size?: Size;minWidth?: MinWidth;+ tooltip?: string;class?: string;}>();@@ -77,22 +80,35 @@};const resolvedMinWidth = minWidth as MinWidth;-</script>--<span- class={cn(+ const badgeClasses = cn(// base- 'inline-flex items-center justify-center gap-1 rounded-full font-medium whitespace-nowrap',+ 'inline-flex items-center justify-center gap-1 whitespace-nowrap rounded-full font-medium',sizeStyles[size as Size],// subtle border and translucency- 'ring-1 transition-colors ring-inset',+ 'ring-1 ring-inset transition-colors',// variant stylesvariantStyles[variant as Variant],// optional fixed widthminWidthClasses[resolvedMinWidth],className- )}- {...restProps}->- {text}-</span>+ );+</script>++{#snippet BadgeContent()}+ <span class={badgeClasses} {...restProps}>+ {text}+ </span>+{/snippet}++{#if tooltip}+ <Tooltip.Root>+ <Tooltip.Trigger>+ {@render BadgeContent()}+ </Tooltip.Trigger>+ <Tooltip.Content>+ <p class="max-w-xs text-xs">{tooltip}</p>+ </Tooltip.Content>+ </Tooltip.Root>+{:else}+ {@render BadgeContent()}+{/if}diff --git a/frontend/src/lib/types/project.type.ts b/frontend/src/lib/types/project.type.tsindex a125a2ea4..e9dc5f498 100644--- a/frontend/src/lib/types/project.type.ts+++ b/frontend/src/lib/types/project.type.ts@@ -30,6 +30,7 @@ export interface Project {runningCount: string;serviceCount: string;status: string;+ statusReason?: string;updatedAt: string;createdAt: string;services?: ProjectService[];diff --git a/frontend/src/routes/projects/[projectId]/+page.svelte b/frontend/src/routes/projects/[projectId]/+page.svelteindex 09ab0f3d7..42de761b0 100644--- a/frontend/src/routes/projects/[projectId]/+page.svelte+++ b/frontend/src/routes/projects/[projectId]/+page.svelte@@ -206,7 +206,12 @@class="block sm:hidden"/>{#if project.status}- <StatusBadge variant={getStatusVariant(project.status)} text={capitalizeFirstLetter(project.status)} />+ {@const showTooltip = project.status.toLowerCase() === 'unknown' && project.statusReason}+ <StatusBadge+ variant={getStatusVariant(project.status)}+ text={capitalizeFirstLetter(project.status)}+ tooltip={showTooltip ? project.statusReason : undefined}+ />{/if}</div>{#if project.createdAt}diff --git a/frontend/src/routes/projects/projects-table.svelte b/frontend/src/routes/projects/projects-table.svelteindex 298f0d9e0..c555dab47 100644--- a/frontend/src/routes/projects/projects-table.svelte+++ b/frontend/src/routes/projects/projects-table.svelte@@ -49,6 +49,10 @@updating: false});+ function getStatusTooltip(project: Project): string | undefined {+ return project.status.toLowerCase() === 'unknown' && project.statusReason ? project.statusReason : undefined;+ }+async function performProjectAction(action: string, id: string) {isLoading[action as keyof typeof isLoading] = true;@@ -161,7 +165,7 @@{#snippet StatusCell({ item }: { item: Project })}{@const stateVariant = getStatusVariant(item.status)}- <StatusBadge variant={stateVariant} text={capitalizeFirstLetter(item.status)} />+ <StatusBadge variant={stateVariant} text={capitalizeFirstLetter(item.status)} tooltip={getStatusTooltip(item)} />{/snippet}{#snippet CreatedCell({ value }: { value: unknown })}@@ -190,7 +194,8 @@(mobileFieldVisibility.status ?? true)? {variant: getStatusVariant(item.status),- text: capitalizeFirstLetter(item.status)+ text: capitalizeFirstLetter(item.status),+ tooltip: getStatusTooltip(item)}: null]}diff --git a/package.json b/package.jsonindex c4d38a86a..e06422e6d 100644--- a/package.json+++ b/package.json@@ -8,12 +8,12 @@],"scripts": {"preinstall": "npx only-allow pnpm",- "dev": "pnpm -C arcane-frontend dev",- "build": "pnpm -C arcane-frontend build",+ "dev": "pnpm --filter arcane-frontend dev",+ "build": "pnpm --filter arcane-frontend build","test:up": "docker compose -f tests/setup/compose.yaml up -d --build","test:down": "docker compose -f tests/setup/compose.yaml down",- "test": "pnpm test:up && pnpm -C arcane-tests test && pnpm test:down",- "format": "pnpm -C arcane-frontend format",- "check": "pnpm -C arcane-frontend check"+ "test": "pnpm test:up && pnpm --filter arcane-tests test && pnpm test:down",+ "format": "pnpm --filter arcane-frontend format",+ "check": "pnpm --filter arcane-frontend check"}}