@link-assistant/hive-mind 0.54.1 → 0.54.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/package.json +1 -1
- package/src/telegram-bot.mjs +15 -10
- package/src/telegram-solve-queue.lib.mjs +16 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @link-assistant/hive-mind
|
|
2
2
|
|
|
3
|
+
## 0.54.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- c5f5194: Fix Telegram message getting stuck at "Starting solve command..."
|
|
8
|
+
- Add error handling to `executeAndUpdateMessage` function to catch Telegram API errors
|
|
9
|
+
- Fix critical bug where `messageInfo` was being cleared before the final message update
|
|
10
|
+
- Add proper error logging for message edit failures in both immediate and queued execution paths
|
|
11
|
+
|
|
3
12
|
## 0.54.1
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/package.json
CHANGED
package/src/telegram-bot.mjs
CHANGED
|
@@ -673,20 +673,25 @@ function validateGitHubUrl(args, options = {}) {
|
|
|
673
673
|
*/
|
|
674
674
|
async function executeAndUpdateMessage(ctx, startingMessage, commandName, args, infoBlock) {
|
|
675
675
|
const result = await executeStartScreen(commandName, args);
|
|
676
|
+
const { chat, message_id } = startingMessage;
|
|
676
677
|
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
678
|
+
// Safely edit message - catch errors to prevent stuck "Starting..." messages (issue #1062)
|
|
679
|
+
const safeEdit = async text => {
|
|
680
|
+
try {
|
|
681
|
+
await ctx.telegram.editMessageText(chat.id, message_id, undefined, text, { parse_mode: 'Markdown' });
|
|
682
|
+
} catch (e) {
|
|
683
|
+
console.error(`[telegram-bot] Failed to update message for ${commandName}: ${e.message}`);
|
|
684
|
+
}
|
|
685
|
+
};
|
|
686
|
+
|
|
687
|
+
if (result.warning) return safeEdit(`⚠️ ${result.warning}`);
|
|
681
688
|
|
|
682
689
|
if (result.success) {
|
|
683
|
-
const
|
|
684
|
-
const
|
|
685
|
-
|
|
686
|
-
await ctx.telegram.editMessageText(startingMessage.chat.id, startingMessage.message_id, undefined, response, { parse_mode: 'Markdown' });
|
|
690
|
+
const match = result.output.match(/session:\s*(\S+)/i) || result.output.match(/screen -r\s+(\S+)/);
|
|
691
|
+
const session = match ? match[1] : 'unknown';
|
|
692
|
+
await safeEdit(`✅ ${commandName.charAt(0).toUpperCase() + commandName.slice(1)} command started successfully!\n\n📊 Session: \`${session}\`\n\n${infoBlock}`);
|
|
687
693
|
} else {
|
|
688
|
-
|
|
689
|
-
await ctx.telegram.editMessageText(startingMessage.chat.id, startingMessage.message_id, undefined, response, { parse_mode: 'Markdown' });
|
|
694
|
+
await safeEdit(`❌ Error executing ${commandName} command:\n\n\`\`\`\n${result.error || result.output}\n\`\`\``);
|
|
690
695
|
}
|
|
691
696
|
}
|
|
692
697
|
|
|
@@ -667,13 +667,18 @@ export class SolveQueue {
|
|
|
667
667
|
if (sessionMatch) sessionName = sessionMatch[1];
|
|
668
668
|
}
|
|
669
669
|
|
|
670
|
+
// IMPORTANT: Save messageInfo BEFORE calling setStarted, because setStarted clears it
|
|
671
|
+
// This was a bug where the final message update never happened because messageInfo was null
|
|
672
|
+
// See: https://github.com/link-assistant/hive-mind/issues/1062
|
|
673
|
+
const savedMessageInfo = item.messageInfo;
|
|
674
|
+
|
|
670
675
|
// Update to Started status (terminal - forgets message tracking)
|
|
671
676
|
item.setStarted(sessionName);
|
|
672
677
|
this.stats.totalCompleted++;
|
|
673
678
|
|
|
674
|
-
// Final message update
|
|
675
|
-
if (item.ctx && result) {
|
|
676
|
-
const { chatId, messageId } =
|
|
679
|
+
// Final message update using saved messageInfo
|
|
680
|
+
if (item.ctx && result && savedMessageInfo) {
|
|
681
|
+
const { chatId, messageId } = savedMessageInfo;
|
|
677
682
|
if (chatId && messageId) {
|
|
678
683
|
try {
|
|
679
684
|
if (result.warning) {
|
|
@@ -685,8 +690,10 @@ export class SolveQueue {
|
|
|
685
690
|
const response = `❌ Error executing solve command:\n\n\`\`\`\n${result.error || result.output}\n\`\`\``;
|
|
686
691
|
await item.ctx.telegram.editMessageText(chatId, messageId, undefined, response, { parse_mode: 'Markdown' });
|
|
687
692
|
}
|
|
688
|
-
} catch {
|
|
689
|
-
//
|
|
693
|
+
} catch (error) {
|
|
694
|
+
// Log message edit failures for debugging
|
|
695
|
+
// See: https://github.com/link-assistant/hive-mind/issues/1062
|
|
696
|
+
console.error(`[solve-queue] Failed to update message for item ${item.id}: ${error.message}`);
|
|
690
697
|
}
|
|
691
698
|
}
|
|
692
699
|
}
|
|
@@ -704,8 +711,10 @@ export class SolveQueue {
|
|
|
704
711
|
if (chatId && messageId && item.ctx) {
|
|
705
712
|
try {
|
|
706
713
|
await item.ctx.telegram.editMessageText(chatId, messageId, undefined, `❌ Error: ${error.message}`, { parse_mode: 'Markdown' });
|
|
707
|
-
} catch {
|
|
708
|
-
//
|
|
714
|
+
} catch (editError) {
|
|
715
|
+
// Log the edit failure for debugging
|
|
716
|
+
// See: https://github.com/link-assistant/hive-mind/issues/1062
|
|
717
|
+
console.error(`[solve-queue] Failed to update error message for item ${item.id}: ${editError.message}`);
|
|
709
718
|
}
|
|
710
719
|
}
|
|
711
720
|
} finally {
|