Skip to content

Commit 54eed25

Browse files
committed
fix commit msg
1 parent dcea6af commit 54eed25

File tree

4 files changed

+121
-44
lines changed

4 files changed

+121
-44
lines changed

apps/web/app/routes/ws/jobs.tsx

Lines changed: 107 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
} from "~/components/ui/breadcrumb";
1010
import { Separator } from "~/components/ui/separator";
1111
import { SidebarTrigger } from "~/components/ui/sidebar";
12+
import { Skeleton } from "~/components/ui/skeleton";
1213
import {
1314
Table,
1415
TableBody,
@@ -68,9 +69,10 @@ export default function Jobs() {
6869
});
6970

7071
const jobs = jobQuery.data?.items ?? [];
72+
const isLoading = jobQuery.isLoading;
7173

7274
return (
73-
<>
75+
<div className="flex h-full flex-col">
7476
<header className="flex h-16 shrink-0 items-center justify-between gap-2 border-b px-4">
7577
<div className="flex items-center gap-2">
7678
<SidebarTrigger className="-ml-1" />
@@ -87,41 +89,111 @@ export default function Jobs() {
8789
</Breadcrumb>
8890
</div>
8991
</header>
90-
<Table>
91-
<TableHeader>
92-
<TableRow className="bg-muted/50">
93-
<TableHead className="text-muted-foreground">ID</TableHead>
94-
<TableHead className="text-muted-foreground">Status</TableHead>
95-
<TableHead className="text-muted-foreground">Created At</TableHead>
96-
<TableHead className="text-muted-foreground">Updated At</TableHead>
97-
</TableRow>
98-
</TableHeader>
9992

100-
<TableBody>
101-
{jobs.map(({ job }) => {
102-
return (
103-
<TableRow key={job.id}>
104-
<TableCell className="font-mono">{job.id}</TableCell>
105-
<TableCell>
106-
<JobStatusBadge status={job.status} />
107-
</TableCell>
108-
<TableCell>
109-
{prettyMs(
110-
new Date(job.createdAt).getTime() -
111-
new Date(job.updatedAt).getTime(),
112-
)}
113-
</TableCell>
114-
<TableCell>
115-
{prettyMs(
116-
new Date(job.updatedAt).getTime() -
117-
new Date(job.createdAt).getTime(),
118-
)}
119-
</TableCell>
93+
<div className="flex-1 overflow-auto">
94+
{isLoading ? (
95+
<div className="space-y-4 p-4">
96+
<Skeleton className="h-12 w-full" />
97+
<Skeleton className="h-12 w-full" />
98+
<Skeleton className="h-12 w-full" />
99+
</div>
100+
) : jobs.length === 0 ? (
101+
<div className="flex flex-col items-center justify-center py-16 text-center">
102+
<div className="rounded-full bg-muted p-4">
103+
<svg
104+
className="h-8 w-8 text-muted-foreground"
105+
fill="none"
106+
viewBox="0 0 24 24"
107+
stroke="currentColor"
108+
>
109+
<path
110+
strokeLinecap="round"
111+
strokeLinejoin="round"
112+
strokeWidth={2}
113+
d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"
114+
/>
115+
</svg>
116+
</div>
117+
<h3 className="mt-4 text-lg font-semibold">No jobs yet</h3>
118+
<p className="mt-2 text-sm text-muted-foreground">
119+
Jobs will appear here when deployments are executed
120+
</p>
121+
</div>
122+
) : (
123+
<Table className="border-b">
124+
<TableHeader>
125+
<TableRow className="bg-muted/50">
126+
<TableHead className="font-medium">Deployment</TableHead>
127+
<TableHead className="font-medium">Environment</TableHead>
128+
<TableHead className="font-medium">Resource</TableHead>
129+
<TableHead className="font-medium">Version</TableHead>
130+
<TableHead className="font-medium">External ID</TableHead>
131+
<TableHead className="font-medium">Status</TableHead>
132+
<TableHead className="font-medium">Created</TableHead>
133+
<TableHead className="font-medium">Updated</TableHead>
120134
</TableRow>
121-
);
122-
})}
123-
</TableBody>
124-
</Table>
125-
</>
135+
</TableHeader>
136+
137+
<TableBody>
138+
{jobs.map(
139+
({ job, resource, environment, deployment, release }) => {
140+
return (
141+
<TableRow
142+
key={job.id}
143+
className="cursor-pointer hover:bg-muted/50"
144+
>
145+
<TableCell className="font-medium">
146+
{deployment?.name ?? (
147+
<span className="text-muted-foreground"></span>
148+
)}
149+
</TableCell>
150+
<TableCell>
151+
{environment?.name ?? (
152+
<span className="text-muted-foreground"></span>
153+
)}
154+
</TableCell>
155+
<TableCell>
156+
{resource?.name ?? (
157+
<span className="text-muted-foreground"></span>
158+
)}
159+
</TableCell>
160+
<TableCell className="font-mono font-medium">
161+
{release.version.tag}
162+
</TableCell>
163+
<TableCell className="font-mono font-medium">
164+
{job.externalId ?? (
165+
<span className="text-muted-foreground"></span>
166+
)}
167+
</TableCell>
168+
<TableCell>
169+
<JobStatusBadge status={job.status} />
170+
</TableCell>
171+
<TableCell className="text-muted-foreground">
172+
{prettyMs(
173+
Date.now() - new Date(job.createdAt).getTime(),
174+
{
175+
compact: true,
176+
},
177+
)}{" "}
178+
ago
179+
</TableCell>
180+
<TableCell className="text-muted-foreground">
181+
{prettyMs(
182+
Date.now() - new Date(job.updatedAt).getTime(),
183+
{
184+
compact: true,
185+
},
186+
)}{" "}
187+
ago
188+
</TableCell>
189+
</TableRow>
190+
);
191+
},
192+
)}
193+
</TableBody>
194+
</Table>
195+
)}
196+
</div>
197+
</div>
126198
);
127199
}

apps/workspace-engine/pkg/events/handler/handler.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,15 @@ func (el *EventListener) ListenAndRoute(ctx context.Context, msg *kafka.Message)
159159
log.Error("Handler failed to process event",
160160
"eventType", rawEvent.EventType,
161161
"error", err)
162-
return nil, fmt.Errorf("handler failed to process event %s: %w", rawEvent.EventType, err)
162+
return ws, fmt.Errorf("handler failed to process event %s: %w", rawEvent.EventType, err)
163163
}
164164

165165
releaseTargetChanges, err := ws.ReleaseManager().ProcessChanges(ctx, changeSet)
166166
if err != nil {
167167
span.RecordError(err)
168168
span.SetStatus(codes.Error, "failed to process target changes")
169169
log.Error("Failed to process target changes", "error", err)
170-
return nil, fmt.Errorf("failed to process target changes: %w", err)
170+
return ws, fmt.Errorf("failed to process target changes: %w", err)
171171
}
172172

173173
span.SetAttributes(attribute.Int("release-target.changed", len(releaseTargetChanges.Keys())))
@@ -176,7 +176,7 @@ func (el *EventListener) ListenAndRoute(ctx context.Context, msg *kafka.Message)
176176
span.RecordError(err)
177177
span.SetStatus(codes.Error, "failed to flush changeset")
178178
log.Error("Failed to flush changeset", "error", err)
179-
return nil, fmt.Errorf("failed to flush changeset: %w", err)
179+
return ws, fmt.Errorf("failed to flush changeset: %w", err)
180180
}
181181

182182
span.SetStatus(codes.Ok, "event processed successfully")

apps/workspace-engine/pkg/kafka/kafka.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,16 @@ func RunConsumer(ctx context.Context) error {
137137
ws, err := handler.ListenAndRoute(ctx, msg)
138138
if err != nil {
139139
log.Error("Failed to route message", "error", err)
140+
}
141+
142+
// Commit offset to Kafka
143+
if _, err := consumer.CommitMessage(msg); err != nil {
144+
log.Error("Failed to commit message", "error", err)
145+
continue
146+
}
147+
148+
if ws == nil {
149+
log.Error("Workspace not found", "workspaceID", msg.Key)
140150
continue
141151
}
142152

@@ -150,11 +160,5 @@ func RunConsumer(ctx context.Context) error {
150160
if err := workspace.Save(ctx, storage, ws, snapshot); err != nil {
151161
log.Error("Failed to save workspace", "workspaceID", ws.ID, "snapshotPath", snapshot.Path, "error", err)
152162
}
153-
154-
// Commit offset to Kafka
155-
if _, err := consumer.CommitMessage(msg); err != nil {
156-
log.Error("Failed to commit message", "error", err)
157-
continue
158-
}
159163
}
160164
}

apps/workspace-engine/pkg/workspace/loader.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ func Save(ctx context.Context, storage StorageClient, workspace *Workspace, snap
4343
}
4444

4545
log.Info("Workspace saved to storage", "workspaceID", workspace.ID)
46+
4647
return nil
4748
}
4849

0 commit comments

Comments
 (0)