feat(08-03): simplify completion messages to back-only button

- Update Format Immediate Result for start/restart actions
- Update Format Confirmed Stop Result for stop action
- Update Format Update Complete for update action
- Update Format No Update Needed for already-up-to-date case
- Success shows only "Back to Containers" button
- Errors show "Try Again" + "Back to Containers" buttons
- Removes action buttons from completion state per UX spec

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Lucas Berger
2026-02-03 16:34:10 -05:00
parent a6548b300f
commit 3e11dea2ed
+4 -4
View File
@@ -2923,7 +2923,7 @@
},
{
"parameters": {
"jsCode": "// Parse immediate action result and update submenu\nconst stdout = $input.item.json.stdout;\nconst prevData = $('Build Immediate Action Command').item.json;\nconst containerName = prevData.containerName;\nconst action = prevData.action;\nconst chatId = prevData.chatId;\nconst messageId = prevData.messageId;\n\nconst statusCode = parseInt(stdout.trim());\n\n// 204: Success, 304: Already in state (also success)\nconst success = statusCode === 204 || statusCode === 304;\n\nconst verb = action === 'start' ? 'started' : 'restarted';\nconst icon = success ? '\\u2705' : '\\u274C';\nconst resultText = success ? `${containerName} ${verb} successfully` : `Failed to ${action} ${containerName}`;\n\n// Build updated keyboard based on new state (assume action succeeded)\nconst keyboard = [];\nif (action === 'start') {\n // Container is now running\n keyboard.push([\n { text: '\\u23F9\\uFE0F Stop', callback_data: `action:stop:${containerName}` },\n { text: '\\u{1F504} Restart', callback_data: `action:restart:${containerName}` }\n ]);\n} else {\n // Restart - container is still running\n keyboard.push([\n { text: '\\u23F9\\uFE0F Stop', callback_data: `action:stop:${containerName}` },\n { text: '\\u{1F504} Restart', callback_data: `action:restart:${containerName}` }\n ]);\n}\n\nkeyboard.push([\n { text: '\\u{1F4CB} Logs', callback_data: `action:logs:${containerName}` },\n { text: '\\u2B06\\uFE0F Update', callback_data: `action:update:${containerName}` }\n]);\n\nkeyboard.push([\n { text: '\\u25C0\\uFE0F Back to List', callback_data: 'list:0' }\n]);\n\nconst stateIcon = action === 'start' || success ? '\\u{1F7E2}' : '\\u26AA';\nlet text = `${stateIcon} <b>${containerName}</b>\\n\\n`;\ntext += `${icon} ${resultText}`;\n\nreturn {\n json: {\n chatId,\n messageId,\n text,\n reply_markup: { inline_keyboard: keyboard }\n }\n};"
"jsCode": "// Build action completion message (success shows back only, error shows retry + back)\nconst stdout = $input.item.json.stdout;\nconst prevData = $('Build Immediate Action Command').item.json;\nconst containerName = prevData.containerName;\nconst action = prevData.action;\nconst chatId = prevData.chatId;\nconst messageId = prevData.messageId;\n\nconst statusCode = parseInt(stdout.trim());\n\n// 204: Success, 304: Already in state (also success)\nconst success = statusCode === 204 || statusCode === 304;\n\n// Build message based on action type and result\nconst successMessages = {\n start: `\\u25B6\\uFE0F <b>${containerName}</b> started`,\n restart: `\\u{1F504} <b>${containerName}</b> restarted`\n};\n\nlet text;\nlet keyboard;\n\nif (success) {\n text = successMessages[action] || `Action completed on ${containerName}`;\n // Success: only back button\n keyboard = {\n inline_keyboard: [\n [{ text: '\\u25C0\\uFE0F Back to Containers', callback_data: 'list:0' }]\n ]\n };\n} else {\n text = `\\u274C Failed to ${action} <b>${containerName}</b>`;\n // Error: retry and back buttons\n keyboard = {\n inline_keyboard: [\n [{ text: '\\u{1F504} Try Again', callback_data: `action:${action}:${containerName}` }],\n [{ text: '\\u25C0\\uFE0F Back to Containers', callback_data: 'list:0' }]\n ]\n };\n}\n\nreturn {\n json: {\n chatId,\n messageId,\n text,\n reply_markup: keyboard\n }\n};"
},
"id": "code-format-immediate-result",
"name": "Format Immediate Result",
@@ -3339,7 +3339,7 @@
},
{
"parameters": {
"jsCode": "// Parse stop result and update message\nconst stdout = $input.item.json.stdout;\nconst prevData = $('Build Confirmed Stop Command').item.json;\nconst containerName = prevData.containerName;\nconst chatId = prevData.chatId;\nconst messageId = prevData.messageId;\n\nconst statusCode = parseInt(stdout.trim());\n\n// 204: Success, 304: Already stopped\nconst success = statusCode === 204 || statusCode === 304;\n\nconst icon = success ? '\\u2705' : '\\u274C';\nconst resultText = success ? `${containerName} stopped successfully` : `Failed to stop ${containerName}`;\n\n// Build updated keyboard (container is now stopped)\nconst keyboard = [\n [{ text: '\\u25B6\\uFE0F Start', callback_data: `action:start:${containerName}` }],\n [\n { text: '\\u{1F4CB} Logs', callback_data: `action:logs:${containerName}` },\n { text: '\\u2B06\\uFE0F Update', callback_data: `action:update:${containerName}` }\n ],\n [{ text: '\\u25C0\\uFE0F Back to List', callback_data: 'list:0' }]\n];\n\nconst stateIcon = success ? '\\u26AA' : '\\u{1F7E2}';\nlet text = `${stateIcon} <b>${containerName}</b>\\n\\n`;\ntext += `${icon} ${resultText}`;\n\nreturn {\n json: {\n chatId,\n messageId,\n text,\n reply_markup: { inline_keyboard: keyboard }\n }\n};"
"jsCode": "// Build stop completion message (success shows back only, error shows retry + back)\nconst stdout = $input.item.json.stdout;\nconst prevData = $('Build Confirmed Stop Command').item.json;\nconst containerName = prevData.containerName;\nconst chatId = prevData.chatId;\nconst messageId = prevData.messageId;\n\nconst statusCode = parseInt(stdout.trim());\n\n// 204: Success, 304: Already stopped\nconst success = statusCode === 204 || statusCode === 304;\n\nlet text;\nlet keyboard;\n\nif (success) {\n text = `\\u23F9\\uFE0F <b>${containerName}</b> stopped`;\n // Success: only back button\n keyboard = {\n inline_keyboard: [\n [{ text: '\\u25C0\\uFE0F Back to Containers', callback_data: 'list:0' }]\n ]\n };\n} else {\n text = `\\u274C Failed to stop <b>${containerName}</b>`;\n // Error: retry and back buttons\n const timestamp = Math.floor(Date.now() / 1000);\n keyboard = {\n inline_keyboard: [\n [{ text: '\\u{1F504} Try Again', callback_data: `confirm:stop:${containerName}:${timestamp}` }],\n [{ text: '\\u25C0\\uFE0F Back to Containers', callback_data: 'list:0' }]\n ]\n };\n}\n\nreturn {\n json: {\n chatId,\n messageId,\n text,\n reply_markup: keyboard\n }\n};"
},
"id": "code-format-confirmed-stop-result",
"name": "Format Confirmed Stop Result",
@@ -3555,7 +3555,7 @@
},
{
"parameters": {
"jsCode": "// Container is already up to date - show result\nconst data = $input.item.json;\nconst containerName = data.containerName;\nconst chatId = data.chatId;\nconst messageId = data.messageId;\n\n// Build keyboard\nconst keyboard = [\n [\n { text: '\\u23F9\\uFE0F Stop', callback_data: `action:stop:${containerName}` },\n { text: '\\u{1F504} Restart', callback_data: `action:restart:${containerName}` }\n ],\n [\n { text: '\\u{1F4CB} Logs', callback_data: `action:logs:${containerName}` },\n { text: '\\u2B06\\uFE0F Update', callback_data: `action:update:${containerName}` }\n ],\n [{ text: '\\u25C0\\uFE0F Back to List', callback_data: 'list:0' }]\n];\n\nlet text = `\\u{1F7E2} <b>${containerName}</b>\\n\\n`;\ntext += `\\u2705 Already up to date - no changes needed.`;\n\nreturn {\n json: {\n chatId,\n messageId,\n text,\n reply_markup: { inline_keyboard: keyboard }\n }\n};"
"jsCode": "// Container is already up to date - show completion with back button only\nconst data = $input.item.json;\nconst containerName = data.containerName;\nconst chatId = data.chatId;\nconst messageId = data.messageId;\n\n// Completion message shows only navigation button (removes action buttons)\nconst keyboard = {\n inline_keyboard: [\n [{ text: '\\u25C0\\uFE0F Back to Containers', callback_data: 'list:0' }]\n ]\n};\n\nconst text = `\\u2705 <b>${containerName}</b> already up to date\\n\\nNo changes needed.`;\n\nreturn {\n json: {\n chatId,\n messageId,\n text,\n reply_markup: keyboard\n }\n};"
},
"id": "code-format-no-update-needed",
"name": "Format No Update Needed",
@@ -3700,7 +3700,7 @@
},
{
"parameters": {
"jsCode": "// Parse start result and format success message\nconst stdout = $input.item.json.stdout;\nconst prevData = $('Parse Update Create Response').item.json;\nconst containerName = prevData.containerName;\nconst currentDigest = prevData.currentDigest;\nconst newDigest = prevData.newDigest;\nconst currentImageId = prevData.currentImageId;\nconst chatId = prevData.chatId;\nconst messageId = prevData.messageId;\n\nconst statusCode = parseInt(stdout.trim());\n\n// 204: started, 304: already running\nconst success = statusCode === 204 || statusCode === 304;\n\nconst icon = success ? '\\u2705' : '\\u274C';\nconst resultText = success ? `${containerName} updated: ${currentDigest} \\u2192 ${newDigest}` : `Failed to start ${containerName} after update`;\n\n// Build updated keyboard\nconst keyboard = [\n [\n { text: '\\u23F9\\uFE0F Stop', callback_data: `action:stop:${containerName}` },\n { text: '\\u{1F504} Restart', callback_data: `action:restart:${containerName}` }\n ],\n [\n { text: '\\u{1F4CB} Logs', callback_data: `action:logs:${containerName}` },\n { text: '\\u2B06\\uFE0F Update', callback_data: `action:update:${containerName}` }\n ],\n [{ text: '\\u25C0\\uFE0F Back to List', callback_data: 'list:0' }]\n];\n\nconst stateIcon = success ? '\\u{1F7E2}' : '\\u26AA';\nlet text = `${stateIcon} <b>${containerName}</b>\\n\\n`;\ntext += `${icon} ${resultText}`;\n\nreturn {\n json: {\n chatId,\n messageId,\n text,\n reply_markup: { inline_keyboard: keyboard },\n currentImageId\n }\n};"
"jsCode": "// Build update completion message (success shows back only, error shows retry + back)\nconst stdout = $input.item.json.stdout;\nconst prevData = $('Parse Update Create Response').item.json;\nconst containerName = prevData.containerName;\nconst currentDigest = prevData.currentDigest;\nconst newDigest = prevData.newDigest;\nconst currentImageId = prevData.currentImageId;\nconst chatId = prevData.chatId;\nconst messageId = prevData.messageId;\n\nconst statusCode = parseInt(stdout.trim());\n\n// 204: started, 304: already running\nconst success = statusCode === 204 || statusCode === 304;\n\nlet text;\nlet keyboard;\n\nif (success) {\n text = `\\u2705 <b>${containerName}</b> updated successfully\\n\\n${currentDigest} \\u2192 ${newDigest}`;\n // Success: only back button\n keyboard = {\n inline_keyboard: [\n [{ text: '\\u25C0\\uFE0F Back to Containers', callback_data: 'list:0' }]\n ]\n };\n} else {\n text = `\\u274C Failed to start <b>${containerName}</b> after update`;\n // Error: retry and back buttons\n const timestamp = Math.floor(Date.now() / 1000);\n keyboard = {\n inline_keyboard: [\n [{ text: '\\u{1F504} Try Again', callback_data: `confirm:update:${containerName}:${timestamp}` }],\n [{ text: '\\u25C0\\uFE0F Back to Containers', callback_data: 'list:0' }]\n ]\n };\n}\n\nreturn {\n json: {\n chatId,\n messageId,\n text,\n reply_markup: keyboard,\n currentImageId\n }\n};"
},
"id": "code-format-update-complete",
"name": "Format Update Complete",