Skip to content

Modern Docker Management, Designed for Everyone

fix: use full compose dependency tree for compose projects (#1242)

Kyle Mendellb5cb30133266
diff --git a/backend/internal/huma/handlers/projects.go b/backend/internal/huma/handlers/projects.go
index 4dd65c149..13731b9e3 100644
--- a/backend/internal/huma/handlers/projects.go
+++ b/backend/internal/huma/handlers/projects.go
@@ -15,6 +15,7 @@ import (
"github.com/getarcaneapp/arcane/backend/internal/utils"
"github.com/getarcaneapp/arcane/backend/internal/utils/mapper"
"github.com/getarcaneapp/arcane/backend/internal/utils/pagination"
+ projects "github.com/getarcaneapp/arcane/backend/internal/utils/projects"
"github.com/getarcaneapp/arcane/types/base"
"github.com/getarcaneapp/arcane/types/project"
)
@@ -390,7 +391,7 @@ func (h *ProjectHandler) GetProjectStatusCounts(ctx context.Context, input *GetP
}
// DeployProject deploys a Docker Compose project.
-func (h *ProjectHandler) DeployProject(ctx context.Context, input *DeployProjectInput) (*DeployProjectOutput, error) {
+func (h *ProjectHandler) DeployProject(ctx context.Context, input *DeployProjectInput) (*huma.StreamResponse, error) {
if h.projectService == nil {
return nil, huma.Error500InternalServerError("service not available")
}
@@ -404,16 +405,33 @@ func (h *ProjectHandler) DeployProject(ctx context.Context, input *DeployProject
return nil, huma.Error401Unauthorized((&common.NotAuthenticatedError{}).Error())
}
- if err := h.projectService.DeployProject(ctx, input.ProjectID, *user); err != nil {
- return nil, huma.Error400BadRequest((&common.ProjectDeploymentError{Err: err}).Error())
- }
+ return &huma.StreamResponse{
+ Body: func(humaCtx huma.Context) { //nolint:contextcheck // context is obtained from humaCtx.Context()
+ humaCtx.SetHeader("Content-Type", "application/x-json-stream")
+ humaCtx.SetHeader("Cache-Control", "no-cache")
+ humaCtx.SetHeader("Connection", "keep-alive")
+ humaCtx.SetHeader("X-Accel-Buffering", "no")
- return &DeployProjectOutput{
- Body: base.ApiResponse[base.MessageResponse]{
- Success: true,
- Data: base.MessageResponse{
- Message: "Project deployed successfully",
- },
+ writer := humaCtx.BodyWriter()
+
+ _, _ = writer.Write([]byte(`{"type":"deploy","phase":"begin"}` + "\n"))
+ if f, ok := writer.(http.Flusher); ok {
+ f.Flush()
+ }
+
+ deployCtx := context.WithValue(humaCtx.Context(), projects.ProgressWriterKey{}, writer)
+ if err := h.projectService.DeployProject(deployCtx, input.ProjectID, *user); err != nil {
+ _, _ = fmt.Fprintf(writer, `{"error":%q}`+"\n", err.Error())
+ if f, ok := writer.(http.Flusher); ok {
+ f.Flush()
+ }
+ return
+ }
+
+ _, _ = writer.Write([]byte(`{"type":"deploy","phase":"complete"}` + "\n"))
+ if f, ok := writer.(http.Flusher); ok {
+ f.Flush()
+ }
},
}, nil
}
diff --git a/backend/internal/job/analytics_job.go b/backend/internal/job/analytics_job.go
index a5d313e57..8bf3896ce 100644
--- a/backend/internal/job/analytics_job.go
+++ b/backend/internal/job/analytics_job.go
@@ -50,16 +50,14 @@ func NewAnalyticsJob(
func (j *AnalyticsJob) Register(ctx context.Context) error {
if j.cfg.AnalyticsDisabled || !j.cfg.Environment.IsProdEnvironment() {
- slog.InfoContext(ctx, "analytics disabled or not in production; heartbeat job not registered",
- "analyticsDisabled", j.cfg.AnalyticsDisabled, "env", j.cfg.Environment)
+ slog.InfoContext(ctx, "analytics disabled or not in production; heartbeat job not registered", "analyticsDisabled", j.cfg.AnalyticsDisabled, "env", j.cfg.Environment)
return nil
}
j.scheduler.RemoveJobByName(AnalyticsJobName)
jobDefinition := gocron.DurationJob(analyticsInterval)
- slog.InfoContext(ctx, "registering analytics heartbeat job",
- "jobName", AnalyticsJobName, "interval", analyticsInterval.String(), "endpoint", j.heartbeatURL)
+ slog.InfoContext(ctx, "registering analytics heartbeat job", "jobName", AnalyticsJobName, "interval", analyticsInterval.String(), "endpoint", j.heartbeatURL)
return j.scheduler.RegisterJob(
ctx,
@@ -72,8 +70,7 @@ func (j *AnalyticsJob) Register(ctx context.Context) error {
func (j *AnalyticsJob) Execute(parentCtx context.Context) error {
if j.cfg.AnalyticsDisabled || !j.cfg.Environment.IsProdEnvironment() {
- slog.InfoContext(parentCtx, "analytics disabled or not in production; skipping heartbeat",
- "analyticsDisabled", j.cfg.AnalyticsDisabled, "env", j.cfg.Environment)
+ slog.InfoContext(parentCtx, "analytics disabled or not in production; skipping heartbeat", "analyticsDisabled", j.cfg.AnalyticsDisabled, "env", j.cfg.Environment)
return nil
}
@@ -92,8 +89,7 @@ func (j *AnalyticsJob) Execute(parentCtx context.Context) error {
return fmt.Errorf("failed to marshal analytics heartbeat body: %w", err)
}
- slog.InfoContext(parentCtx, "sending analytics heartbeat",
- "jobName", AnalyticsJobName)
+ slog.InfoContext(parentCtx, "sending analytics heartbeat", "jobName", AnalyticsJobName)
_, err = backoff.Retry(
parentCtx,
diff --git a/backend/internal/services/project_service.go b/backend/internal/services/project_service.go
index 092c205d3..5799dca84 100644
--- a/backend/internal/services/project_service.go
+++ b/backend/internal/services/project_service.go
@@ -638,14 +638,23 @@ func (s *ProjectService) DeployProject(ctx context.Context, projectID string, us
slog.Warn("ensure images present failed (continuing to compose up)", "projectID", projectID, "error", perr)
}
- if err := projects.ComposeUp(ctx, project, project.Services.GetProfiles()); err != nil {
+ slog.Info("starting compose up with health check support", "projectID", projectID, "projectName", project.Name, "services", len(project.Services))
+ // Health/progress streaming (if any) is handled inside projects.ComposeUp via ctx.
+ if err := projects.ComposeUp(ctx, project, nil); err != nil {
slog.Error("compose up failed", "projectName", project.Name, "projectID", projectID, "error", err)
if containers, psErr := s.GetProjectServices(ctx, projectID); psErr == nil {
slog.Info("containers after failed deploy", "projectID", projectID, "containers", containers)
}
_ = s.updateProjectStatusandCountsInternal(ctx, projectID, models.ProjectStatusStopped)
+
+ // Provide more helpful error messages
+ errMsg := err.Error()
+ if strings.Contains(errMsg, "timeout") || strings.Contains(errMsg, "context deadline exceeded") {
+ return fmt.Errorf("deployment timed out - check if services with 'condition: service_healthy' have healthchecks defined: %w", err)
+ }
return fmt.Errorf("failed to deploy project: %w", err)
}
+ slog.Info("compose up completed successfully", "projectID", projectID, "projectName", project.Name)
metadata := models.JSON{"action": "deploy", "projectID": projectID, "projectName": project.Name}
if logErr := s.eventService.LogProjectEvent(ctx, models.EventTypeProjectDeploy, projectID, project.Name, user.ID, user.Username, "0", metadata); logErr != nil {
diff --git a/backend/internal/utils/projects/cmds.go b/backend/internal/utils/projects/cmds.go
index adf9b5584..36844f46e 100644
--- a/backend/internal/utils/projects/cmds.go
+++ b/backend/internal/utils/projects/cmds.go
@@ -2,7 +2,10 @@ package projects
import (
"context"
+ "encoding/json"
"io"
+ "strings"
+ "time"
"github.com/compose-spec/compose-go/v2/types"
"github.com/docker/compose/v5/pkg/api"
@@ -10,6 +13,26 @@ import (
"github.com/docker/docker/api/types/filters"
)
+// ProgressWriterKey can be set on a context to enable JSON-line progress updates.
+// The value must be an io.Writer (typically the HTTP response writer).
+type ProgressWriterKey struct{}
+
+type flusher interface{ Flush() }
+
+func writeJSONLine(w io.Writer, v any) {
+ if w == nil {
+ return
+ }
+ b, err := json.Marshal(v)
+ if err != nil {
+ return
+ }
+ _, _ = w.Write(append(b, '\n'))
+ if f, ok := w.(flusher); ok {
+ f.Flush()
+ }
+}
+
func ComposeRestart(ctx context.Context, proj *types.Project, services []string) error {
c, err := NewClient(ctx)
if err != nil {
@@ -26,16 +49,126 @@ func ComposeUp(ctx context.Context, proj *types.Project, services []string) erro
}
defer c.Close()
+ progressWriter, _ := ctx.Value(ProgressWriterKey{}).(io.Writer)
+
+ upOptions, startOptions := composeUpOptions(proj, services)
+
+ // If we don't need progress, just run compose up normally.
+ if progressWriter == nil {
+ return c.svc.Up(ctx, proj, api.UpOptions{Create: upOptions, Start: startOptions})
+ }
+
+ return composeUpWithProgress(ctx, c.svc, proj, api.UpOptions{Create: upOptions, Start: startOptions}, progressWriter)
+}
+
+func composeUpOptions(proj *types.Project, services []string) (api.CreateOptions, api.StartOptions) {
upOptions := api.CreateOptions{
- Services: proj.ServiceNames(),
+ Services: services,
+ Recreate: api.RecreateDiverged,
+ RecreateDependencies: api.RecreateDiverged,
}
+
startOptions := api.StartOptions{
Project: proj,
- Services: proj.ServiceNames(),
+ Services: services,
Wait: true,
+ // Reduced from 10 minutes to 2 minutes - if a service can't become healthy
+ // in 2 minutes, there's likely a configuration issue (missing healthcheck, etc.)
+ WaitTimeout: 2 * time.Minute,
+ // CascadeFail ensures that if a dependency fails its health check,
+ // the error propagates correctly instead of being ignored
+ OnExit: api.CascadeFail,
+ }
+
+ return upOptions, startOptions
+}
+
+func composeUpWithProgress(ctx context.Context, svc api.Compose, proj *types.Project, opts api.UpOptions, progressWriter io.Writer) error {
+ writeJSONLine(progressWriter, map[string]any{"type": "deploy", "phase": "begin"})
+
+ // Poll in a goroutine while compose up runs on the calling goroutine.
+ runCtx, cancel := context.WithCancel(ctx)
+ defer cancel()
+
+ pollDone := make(chan struct{})
+ go func() {
+ defer close(pollDone)
+ pollDeployProgress(runCtx, svc, proj.Name, progressWriter)
+ }()
+
+ err := svc.Up(runCtx, proj, opts)
+ cancel()
+ <-pollDone
+ return err
+}
+
+func pollDeployProgress(ctx context.Context, svc api.Compose, projectName string, progressWriter io.Writer) {
+ ticker := time.NewTicker(800 * time.Millisecond)
+ defer ticker.Stop()
+
+ // Dedupe emitted events so we don't spam the UI.
+ lastSig := map[string]string{}
+
+ for {
+ select {
+ case <-ctx.Done():
+ return
+ case <-ticker.C:
+ containers, err := svc.Ps(ctx, projectName, api.PsOptions{All: true})
+ if err != nil {
+ // Compose may still be creating containers.
+ continue
+ }
+ for _, cs := range containers {
+ emitDeployContainerUpdate(progressWriter, lastSig, cs)
+ }
+ }
}
+}
- return c.svc.Up(ctx, proj, api.UpOptions{Create: upOptions, Start: startOptions})
+func emitDeployContainerUpdate(w io.Writer, lastSig map[string]string, cs api.ContainerSummary) {
+ name := strings.TrimSpace(cs.Service)
+ if name == "" {
+ name = strings.TrimSpace(cs.Name)
+ }
+ if name == "" {
+ return
+ }
+
+ phase := deployPhaseFromSummary(cs)
+ sig := strings.Join([]string{phase, cs.State, cs.Health, strings.TrimSpace(cs.Status)}, "|")
+ if lastSig[name] == sig {
+ return
+ }
+ lastSig[name] = sig
+
+ payload := map[string]any{
+ "type": "deploy",
+ "phase": phase,
+ "service": name,
+ "state": cs.State,
+ "health": cs.Health,
+ }
+ if strings.TrimSpace(cs.Status) != "" {
+ payload["status"] = strings.TrimSpace(cs.Status)
+ }
+ writeJSONLine(w, payload)
+}
+
+func deployPhaseFromSummary(cs api.ContainerSummary) string {
+ state := strings.ToLower(strings.TrimSpace(cs.State))
+ health := strings.ToLower(strings.TrimSpace(cs.Health))
+
+ switch {
+ case state == "running" && health == "healthy":
+ return "service_healthy"
+ case health == "starting" || health == "unhealthy":
+ return "service_waiting_healthy"
+ case state != "running" && state != "":
+ return "service_state"
+ default:
+ return "service_status"
+ }
}
func ComposePs(ctx context.Context, proj *types.Project, services []string, all bool) ([]api.ContainerSummary, error) {
diff --git a/frontend/messages/en.json b/frontend/messages/en.json
index d48a5582c..f48e27728 100644
--- a/frontend/messages/en.json
+++ b/frontend/messages/en.json
@@ -1165,6 +1165,17 @@
"progress_waiting": "Waiting",
"progress_pull_completed": "Pull Completed",
"progress_pulling_images": "Pulling Images",
+ "progress_deploying_project": "Deploying Project",
+ "progress_deploy_starting": "Starting deployment…",
+ "progress_deploy_completed": "Deployment Completed",
+ "progress_deploy_failed": "Deployment failed",
+ "progress_deploy_failed_with_error": "Deployment failed: {error}",
+ "progress_deploy_failed_to_start": "Failed to start project deployment ({status})",
+ "progress_deploy_waiting_for_service": "Waiting for {service} to be healthy",
+ "progress_deploy_waiting_for_service_with_health": "Waiting for {service} to be healthy ({health})",
+ "progress_deploy_service_healthy": "{service} is healthy",
+ "progress_deploy_service_state": "{service} state: {state}",
+ "progress_deploy_service_status": "{service}: {status}",
"progress_layers_status": "{completed} of {total} layers",
"progress_show_layers": "Show Layers",
"_comment_image_updates": "=== IMAGE UPDATES ===",
diff --git a/frontend/src/lib/components/action-buttons.svelte b/frontend/src/lib/components/action-buttons.svelte
index 8098d6c7e..7dca62aa8 100644
--- a/frontend/src/lib/components/action-buttons.svelte
+++ b/frontend/src/lib/components/action-buttons.svelte
@@ -98,6 +98,8 @@
let pullStatusText = $state('');
let pullError = $state('');
let layerProgress = $state<Record<string, { current: number; total: number; status: string }>>({});
+ let deployServiceProgress = $state<Record<string, { phase: string; health?: string; state?: string; status?: string }>>({});
+ let deployLastNonWaitingStatus = $state('');
const isRunning = $derived(itemState === 'running' || (type === 'project' && itemState === 'partially running'));
@@ -106,6 +108,32 @@
pullStatusText = '';
pullError = '';
layerProgress = {};
+ deployServiceProgress = {};
+ deployLastNonWaitingStatus = '';
+ }
+
+ function deriveDeployStatusText(): string {
+ const entries = Object.entries(deployServiceProgress);
+ if (entries.length === 0) return m.progress_deploy_starting();
+
+ const waiting = entries.filter(([_, v]) => v.phase === 'service_waiting_healthy').sort(([a], [b]) => a.localeCompare(b));
+ if (waiting.length > 0) {
+ const [service, v] = waiting[0];
+ const health = (v.health ?? '').trim();
+ return health
+ ? m.progress_deploy_waiting_for_service_with_health({ service, health })
+ : m.progress_deploy_waiting_for_service({ service });
+ }
+
+ const stateIssues = entries
+ .filter(([_, v]) => v.phase === 'service_state' && (v.state ?? '').toLowerCase() !== 'running')
+ .sort(([a], [b]) => a.localeCompare(b));
+ if (stateIssues.length > 0) {
+ const [service, v] = stateIssues[0];
+ return m.progress_deploy_service_state({ service, state: String(v.state ?? '') });
+ }
+
+ return deployLastNonWaitingStatus || m.progress_deploy_starting();
}
function updatePullProgress() {
@@ -212,60 +240,174 @@
setLoading('start', true);
let openedPopover = false;
let hadError = false;
+ let deployPhaseStarted = false;
+
+ // Always open the popover for deploy so we can show health-wait status even
+ // when there is nothing to pull.
+ deployPullPopoverOpen = true;
+ deployPulling = true;
+ pullStatusText = m.progress_deploy_starting();
+ openedPopover = true;
try {
- const { pulled } = await projectService.deployProjectMaybePull(id, (data) => {
- if (!data) return;
+ const { pulled } = await projectService.deployProjectMaybePull(
+ id,
+ (data) => {
+ if (!data) return;
+
+ // Pull progress can still update the same popover.
+ if (isDownloadingLine(data)) {
+ pullStatusText = m.images_pull_initiating();
+ }
- if (!openedPopover && isDownloadingLine(data)) {
- deployPullPopoverOpen = true;
- deployPulling = true;
- pullStatusText = m.images_pull_initiating();
- openedPopover = true;
- }
+ if (data.error) {
+ const errMsg = typeof data.error === 'string' ? data.error : data.error.message || m.images_pull_stream_error();
+ pullError = errMsg;
+ pullStatusText = m.images_pull_failed_with_error({ error: errMsg });
+ hadError = true;
+ return;
+ }
- if (data.error) {
- const errMsg = typeof data.error === 'string' ? data.error : data.error.message || m.images_pull_stream_error();
- pullError = errMsg;
- pullStatusText = m.images_pull_failed_with_error({ error: errMsg });
- hadError = true;
- return;
- }
+ if (data.status) pullStatusText = data.status;
+
+ if (data.id) {
+ const currentLayer = layerProgress[data.id] || { current: 0, total: 0, status: '' };
+ currentLayer.status = data.status || currentLayer.status;
+ if (data.progressDetail) {
+ const { current, total } = data.progressDetail;
+ if (typeof current === 'number') currentLayer.current = current;
+ if (typeof total === 'number') currentLayer.total = total;
+ }
+ layerProgress[data.id] = currentLayer;
+ }
- if (data.status) pullStatusText = data.status;
+ updatePullProgress();
+ },
+ (deployData) => {
+ // Handle deploy streaming - health check progress
+ if (!deployData) return;
+
+ // First deploy status line: switch UI from pull -> deploy.
+ if (!deployPhaseStarted) {
+ deployPhaseStarted = true;
+ pullProgress = 0;
+ layerProgress = {};
+ pullError = '';
+ deployServiceProgress = {};
+ deployLastNonWaitingStatus = '';
+ }
- if (data.id) {
- const currentLayer = layerProgress[data.id] || { current: 0, total: 0, status: '' };
- currentLayer.status = data.status || currentLayer.status;
- if (data.progressDetail) {
- const { current, total } = data.progressDetail;
- if (typeof current === 'number') currentLayer.current = current;
- if (typeof total === 'number') currentLayer.total = total;
+ // Keep the popover in "loading" state during deployment.
+ deployPulling = true;
+ if (deployData.type === 'deploy') {
+ switch (deployData.phase) {
+ case 'begin':
+ pullStatusText = m.progress_deploy_starting();
+ break;
+ case 'service_waiting_healthy': {
+ const service = String(deployData.service ?? '').trim();
+ if (service) {
+ deployServiceProgress[service] = {
+ phase: 'service_waiting_healthy',
+ health: String(deployData.health ?? '')
+ };
+ pullStatusText = deriveDeployStatusText();
+ }
+ break;
+ }
+ case 'service_healthy':
+ {
+ const service = String(deployData.service ?? '').trim();
+ if (service) {
+ deployServiceProgress[service] = {
+ phase: 'service_healthy',
+ health: String(deployData.health ?? ''),
+ state: String(deployData.state ?? ''),
+ status: String(deployData.status ?? '')
+ };
+ deployLastNonWaitingStatus = m.progress_deploy_service_healthy({ service });
+ pullStatusText = deriveDeployStatusText();
+ }
+ }
+ break;
+ case 'service_state':
+ {
+ const service = String(deployData.service ?? '').trim();
+ if (service) {
+ deployServiceProgress[service] = {
+ phase: 'service_state',
+ state: String(deployData.state ?? ''),
+ health: String(deployData.health ?? ''),
+ status: String(deployData.status ?? '')
+ };
+ deployLastNonWaitingStatus = m.progress_deploy_service_state({
+ service,
+ state: String(deployData.state ?? '')
+ });
+ pullStatusText = deriveDeployStatusText();
+ }
+ }
+ break;
+ case 'service_status':
+ {
+ const service = String(deployData.service ?? '').trim();
+ if (service) {
+ deployServiceProgress[service] = {
+ phase: 'service_status',
+ status: String(deployData.status ?? ''),
+ state: String(deployData.state ?? ''),
+ health: String(deployData.health ?? '')
+ };
+ deployLastNonWaitingStatus = m.progress_deploy_service_status({
+ service,
+ status: String(deployData.status ?? '')
+ });
+ pullStatusText = deriveDeployStatusText();
+ }
+ }
+ break;
+ case 'complete':
+ pullStatusText = m.progress_deploy_completed();
+ break;
+ default:
+ break;
+ }
+ } else if (deployData.status) {
+ // fallback for unexpected payloads
+ pullStatusText = String(deployData.status);
+ }
+
+ if (deployData.error) {
+ const errMsg =
+ typeof deployData.error === 'string' ? deployData.error : deployData.error.message || m.progress_deploy_failed();
+ pullError = errMsg;
+ pullStatusText = m.progress_deploy_failed_with_error({ error: errMsg });
+ hadError = true;
+ deployPulling = false;
+ return;
+ }
+
+ // If we got "complete", stop the loading state
+ if (deployData.type === 'deploy' && deployData.phase === 'complete') {
+ deployPulling = false;
+ pullProgress = 100;
}
- layerProgress[data.id] = currentLayer;
}
+ );
- updatePullProgress();
- });
+ if (hadError) throw new Error(pullError || m.progress_deploy_failed());
- // If popover was shown, finish/close it nicely
- if (openedPopover) {
- updatePullProgress();
- if (hadError) throw new Error(pullError || m.images_pull_failed());
+ // Deployment finished successfully.
+ pullProgress = 100;
+ deployPulling = false;
+ pullStatusText = m.progress_deploy_completed();
+ await invalidateAll();
- if (pullProgress < 100 && areAllLayersComplete(layerProgress)) {
- pullProgress = 100;
- }
- pullStatusText = m.images_pulled_success();
- toast.success(m.images_pulled_success());
- await invalidateAll();
-
- setTimeout(() => {
- deployPullPopoverOpen = false;
- deployPulling = false;
- resetPullState();
- }, 1500);
- }
+ setTimeout(() => {
+ deployPullPopoverOpen = false;
+ deployPulling = false;
+ resetPullState();
+ }, 1500);
// Deploy already completed successfully
itemState = 'running';
@@ -389,7 +531,9 @@
<ProgressPopover
bind:open={deployPullPopoverOpen}
bind:progress={pullProgress}
- title={m.progress_pulling_images()}
+ mode="generic"
+ title={m.progress_deploying_project()}
+ completeTitle={m.progress_deploy_completed()}
statusText={pullStatusText}
error={pullError}
loading={deployPulling}
diff --git a/frontend/src/lib/components/progress-popover.svelte b/frontend/src/lib/components/progress-popover.svelte
index 83b00781a..6a3c8ca68 100644
--- a/frontend/src/lib/components/progress-popover.svelte
+++ b/frontend/src/lib/components/progress-popover.svelte
@@ -21,11 +21,13 @@
interface Props {
open?: boolean;
title?: string;
+ completeTitle?: string;
subtitle?: string;
progress?: number;
statusText?: string;
error?: string;
loading?: boolean;
+ mode?: 'pull' | 'generic';
align?: 'start' | 'center' | 'end';
sideOffset?: number;
class?: string;
@@ -40,11 +42,13 @@
let {
open = $bindable(false),
title = m.progress_title(),
+ completeTitle = '',
subtitle = m.progress_subtitle(),
progress = $bindable(0),
statusText = '',
error = '',
loading = false,
+ mode = 'pull',
align = 'center',
sideOffset = 4,
class: className = '',
@@ -78,17 +82,24 @@
// Check if we're in an indeterminate phase (extracting with no byte progress)
const isIndeterminate = $derived(isIndeterminatePhase(layers, progress));
+ const isIndeterminateGeneric = $derived(mode !== 'pull' && loading && !isComplete && !error);
- // Derive the current phase from status text using utility
+ // Derive the current phase from status text using utility (pull-mode only)
const currentPhase = $derived.by((): PullPhase => {
return getPullPhase(statusText, hasReachedComplete || isComplete, !!error);
});
// Get localized title based on phase
const displayTitle = $derived.by(() => {
+ if (mode !== 'pull') {
+ if (error) return m.error_occurred();
+ if (isComplete && !loading) return completeTitle || title;
+ return title;
+ }
+
switch (currentPhase) {
case 'error':
- return 'Error';
+ return m.error_occurred();
case 'complete':
return m.progress_pull_completed();
case 'downloading':
@@ -150,8 +161,13 @@
<Item.Description>
{#if error}
{error}
+ {:else if mode !== 'pull'}
+ {statusText || subtitle}
{:else if layerStats.total > 0}
- {m.progress_layers_status({ completed: layerStats.completed, total: layerStats.total })}
+ {statusText || subtitle}
+ <span class="text-muted-foreground">
+ · {m.progress_layers_status({ completed: layerStats.completed, total: layerStats.total })}</span
+ >
{:else}
{hasReachedComplete ? 100 : percent}% · {statusText || subtitle}
{/if}
@@ -168,7 +184,7 @@
value={hasReachedComplete || isIndeterminate ? 100 : progress}
max={100}
class="h-1.5 w-full"
- indeterminate={isIndeterminate && !hasReachedComplete}
+ indeterminate={(isIndeterminate && !hasReachedComplete) || isIndeterminateGeneric}
/>
</Item.Footer>
{/if}
diff --git a/frontend/src/lib/components/ui/progress/progress.svelte b/frontend/src/lib/components/ui/progress/progress.svelte
index 274025308..0df852660 100644
--- a/frontend/src/lib/components/ui/progress/progress.svelte
+++ b/frontend/src/lib/components/ui/progress/progress.svelte
@@ -19,35 +19,43 @@
{max}
{...restProps}
>
- <div
- class="bg-primary h-full w-full flex-1 transition-all"
- style={`transform: translateX(-${100 - (100 * (value ?? 0)) / (max ?? 1)}%)`}
- ></div>
{#if indeterminate}
- <div class="progress-shimmer absolute inset-0"></div>
+ <div class="progress-marquee absolute inset-y-0 left-0">
+ <div class="progress-marquee-shine absolute inset-0"></div>
+ </div>
+ {:else}
+ <div
+ class="bg-primary h-full w-full flex-1 transition-all"
+ style={`transform: translateX(-${100 - (100 * (value ?? 0)) / (max ?? 1)}%)`}
+ ></div>
{/if}
</ProgressPrimitive.Root>
<style>
- .progress-shimmer {
+ .progress-marquee {
+ width: 35%;
+ background: var(--primary);
+ animation: marquee 1.2s infinite ease-in-out;
+ will-change: transform;
+ }
+
+ .progress-marquee-shine {
background: linear-gradient(
90deg,
transparent 0%,
- rgba(0, 0, 0, 0.15) 40%,
- rgba(0, 0, 0, 0.25) 50%,
- rgba(0, 0, 0, 0.15) 60%,
+ color-mix(in oklch, white 35%, transparent) 45%,
+ color-mix(in oklch, white 55%, transparent) 55%,
transparent 100%
);
- background-size: 200% 100%;
- animation: shimmer 1.5s infinite linear;
+ opacity: 0.35;
}
- @keyframes shimmer {
+ @keyframes marquee {
0% {
- background-position: 200% 0;
+ transform: translateX(-140%);
}
100% {
- background-position: -200% 0;
+ transform: translateX(400%);
}
}
</style>
diff --git a/frontend/src/lib/services/project-service.ts b/frontend/src/lib/services/project-service.ts
index 970e772f2..611087e45 100644
--- a/frontend/src/lib/services/project-service.ts
+++ b/frontend/src/lib/services/project-service.ts
@@ -3,6 +3,7 @@ import { environmentStore } from '$lib/stores/environment.store.svelte';
import type { Project, ProjectStatusCounts } from '$lib/types/project.type';
import type { SearchPaginationSortRequest, Paginated } from '$lib/types/pagination.type';
import { transformPaginationParams } from '$lib/utils/params.util';
+import { m } from '$lib/paraglide/messages';
export class ProjectService extends BaseAPIService {
async getProjects(options?: SearchPaginationSortRequest): Promise<Paginated<Project>> {
@@ -12,9 +13,48 @@ export class ProjectService extends BaseAPIService {
return res.data;
}
- async deployProject(projectId: string): Promise<Project> {
+ deployProject(projectId: string): Promise<Project>;
+ deployProject(projectId: string, onLine: (data: any) => void): Promise<Project>;
+ async deployProject(projectId: string, onLine?: (data: any) => void): Promise<Project> {
const envId = await environmentStore.getCurrentEnvironmentId();
- return this.handleResponse(this.api.post(`/environments/${envId}/projects/${projectId}/up`));
+ const url = `/api/environments/${envId}/projects/${projectId}/up`;
+
+ const res = await fetch(url, { method: 'POST' });
+ if (!res.ok || !res.body) {
+ throw new Error(m.progress_deploy_failed_to_start({ status: String(res.status) }));
+ }
+
+ const reader = res.body.getReader();
+ const decoder = new TextDecoder();
+ let buffer = '';
+
+ while (true) {
+ const { value, done } = await reader.read();
+ if (done) break;
+
+ buffer += decoder.decode(value, { stream: true });
+ const lines = buffer.split('\n');
+ buffer = lines.pop() || '';
+
+ for (const line of lines) {
+ const trimmed = line.trim();
+ if (!trimmed) continue;
+ let obj: any;
+ try {
+ obj = JSON.parse(trimmed);
+ } catch {
+ continue;
+ }
+
+ onLine?.(obj);
+ if (obj?.error) {
+ throw new Error(typeof obj.error === 'string' ? obj.error : obj.error?.message || m.progress_deploy_failed());
+ }
+ }
+ }
+
+ // The deploy stream doesn't return the project object; fetch fresh details.
+ return this.getProject(projectId);
}
async downProject(projectName: string): Promise<Project> {
@@ -143,10 +183,11 @@ export class ProjectService extends BaseAPIService {
async deployProjectMaybePull(
projectId: string,
- onPullLine?: (data: any) => void
+ onPullLine?: (data: any) => void,
+ onDeployLine?: (data: any) => void
): Promise<{ pulled: boolean; project: Project }> {
const pulled = await this.streamProjectPull(projectId, onPullLine);
- const project = await this.deployProject(projectId);
+ const project = onDeployLine ? await this.deployProject(projectId, onDeployLine) : await this.deployProject(projectId);
return { pulled, project };
}
diff --git a/tests/spec/project.spec.ts b/tests/spec/project.spec.ts
index d30df1104..36613b589 100644
--- a/tests/spec/project.spec.ts
+++ b/tests/spec/project.spec.ts
@@ -35,9 +35,9 @@ test.describe('Projects Page', () => {
});
test('should display summary cards with correct counts', async ({ page }) => {
- await expect(page.getByText(`${projectCounts.totalProjects} Total Projects`)).toBeVisible();
- await expect(page.getByText(`${projectCounts.runningProjects} Running`)).toBeVisible();
- await expect(page.getByText(`${projectCounts.stoppedProjects} Stopped`)).toBeVisible();
+ await expect(page.getByText(`${projectCounts.totalProjects} Total Projects`, { exact: true })).toBeVisible();
+ await expect(page.getByText(`${projectCounts.runningProjects} Running`, { exact: true })).toBeVisible();
+ await expect(page.getByText(`${projectCounts.stoppedProjects} Stopped`, { exact: true })).toBeVisible();
});
test('should display projects list', async ({ page }) => {