Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

fix(operations): normalize recipe handoff descriptors

Juan Denis1e4922746c77
diff --git a/frontend/src/services/__tests__/operations.test.mjs b/frontend/src/services/__tests__/operations.test.mjs
index c9f8fc57..7b4ad81a 100644
--- a/frontend/src/services/__tests__/operations.test.mjs
+++ b/frontend/src/services/__tests__/operations.test.mjs
@@ -92,6 +92,30 @@ test('keeps a handoff-waiting Recipe active and attention-worthy', () => {
assert.equal(recipe.handoff.step_id, 'claim');
});
+test('keeps a boolean handoff flag out of the handoff descriptor', () => {
+ const withDescriptor = normalizeDeploymentOperation({
+ id: 'recipe-flagged',
+ kind: 'recipe.run',
+ status: 'waiting',
+ handoff: true,
+ result: { handoff: { step_id: 'credentials', title: 'Add credentials' } },
+ });
+ const flagOnly = normalizeDeploymentOperation({
+ id: 'recipe-flag-only',
+ kind: 'recipe.run',
+ status: 'waiting',
+ handoff: true,
+ });
+
+ assert.equal(withDescriptor.requiresAction, true);
+ assert.deepEqual(withDescriptor.handoff, {
+ step_id: 'credentials',
+ title: 'Add credentials',
+ });
+ assert.equal(flagOnly.requiresAction, true);
+ assert.equal(flagOnly.handoff, null);
+});
+
test('reconciles one run and marks a newly failed terminal operation unread', () => {
const current = [normalizeJobOperation({ id: 'job-1', kind: 'doctor.run', status: 'running' })];
const result = reconcileOperationStatus(current, {
diff --git a/frontend/src/services/operations.js b/frontend/src/services/operations.js
index 97411d45..fc00828b 100644
--- a/frontend/src/services/operations.js
+++ b/frontend/src/services/operations.js
@@ -85,9 +85,19 @@ function deploymentResource(job) {
return null;
}
+function deploymentHandoff(job) {
+ const candidates = [job?.handoff, job?.result?.handoff];
+ return candidates.find((candidate) => (
+ candidate !== null
+ && typeof candidate === 'object'
+ && !Array.isArray(candidate)
+ )) || null;
+}
+
export function normalizeDeploymentOperation(job) {
if (!job?.id) return null;
const target = job.app_name || job.target_server_name;
+ const handoff = deploymentHandoff(job);
return {
id: stringId(job.id),
runKind: 'deploy',
@@ -106,7 +116,7 @@ export function normalizeDeploymentOperation(job) {
canRetry: permissionFlag(job, 'can_retry', 'canRetry'),
requiresAction: permissionFlag(job, 'requires_action', 'requiresAction') || job.handoff === true,
needsAttention: permissionFlag(job, 'needs_attention', 'needsAttention'),
- handoff: job.handoff || job.result?.handoff || null,
+ handoff,
detailPath: job.detailPath || `/deployments/${encodeURIComponent(String(job.id))}`,
};
}