From 9b3828cd504889072e6f688294646bad3191ff31 Mon Sep 17 00:00:00 2001 From: abhay <58429105+estackk@users.noreply.github.com> Date: Fri, 30 Jan 2026 12:12:36 +0800 Subject: [PATCH] fix: Telegram reconnect, rebrand compat, and update restore step - Add "timed out" to NETWORK_ERROR_SNIPPETS in monitor.ts so grammY's getUpdates timeout message triggers reconnection instead of exiting - Add "timed out" to RECOVERABLE_MESSAGE_SNIPPETS in network-errors.ts for defense in depth - Fix LEGACY_CLI_NAME from "moltbot" to "clawdbot" and fix duplicated regex alternations in cli-name.ts and command-format.ts so the legacy binary name is recognized in PATH - Remove restore control-ui step from update-runner.ts since dist/control-ui/ is no longer git-tracked (commit 615ccf641) - Remove :!dist/control-ui/ pathspec exclusion from update-check.ts dirty check since those files are now gitignored - Add test for grammY timeout message format Co-Authored-By: Claude Opus 4.5 --- src/cli/cli-name.ts | 4 ++-- src/cli/command-format.ts | 2 +- src/infra/update-check.ts | 7 +++---- src/infra/update-runner.ts | 11 ----------- src/telegram/monitor.ts | 1 + src/telegram/network-errors.test.ts | 5 +++++ src/telegram/network-errors.ts | 1 + 7 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/cli/cli-name.ts b/src/cli/cli-name.ts index 7b943f590..c3e5bea9b 100644 --- a/src/cli/cli-name.ts +++ b/src/cli/cli-name.ts @@ -1,10 +1,10 @@ import path from "node:path"; export const DEFAULT_CLI_NAME = "moltbot"; -export const LEGACY_CLI_NAME = "moltbot"; +export const LEGACY_CLI_NAME = "clawdbot"; const KNOWN_CLI_NAMES = new Set([DEFAULT_CLI_NAME, LEGACY_CLI_NAME]); -const CLI_PREFIX_RE = /^(?:((?:pnpm|npm|bunx|npx)\s+))?(moltbot|moltbot)\b/; +const CLI_PREFIX_RE = /^(?:((?:pnpm|npm|bunx|npx)\s+))?(moltbot|clawdbot)\b/; export function resolveCliName( argv: string[] = process.argv, diff --git a/src/cli/command-format.ts b/src/cli/command-format.ts index 156a5cd2f..cd93be3d7 100644 --- a/src/cli/command-format.ts +++ b/src/cli/command-format.ts @@ -1,7 +1,7 @@ import { normalizeProfileName } from "./profile-utils.js"; import { replaceCliName, resolveCliName } from "./cli-name.js"; -const CLI_PREFIX_RE = /^(?:pnpm|npm|bunx|npx)\s+(?:moltbot|moltbot)\b|^(?:moltbot|moltbot)\b/; +const CLI_PREFIX_RE = /^(?:pnpm|npm|bunx|npx)\s+(?:moltbot|clawdbot)\b|^(?:moltbot|clawdbot)\b/; const PROFILE_FLAG_RE = /(?:^|\s)--profile(?:\s|=|$)/; const DEV_FLAG_RE = /(?:^|\s)--dev(?:\s|$)/; diff --git a/src/infra/update-check.ts b/src/infra/update-check.ts index 8e10d412b..24c5c374d 100644 --- a/src/infra/update-check.ts +++ b/src/infra/update-check.ts @@ -129,10 +129,9 @@ export async function checkGitUpdateStatus(params: { ).catch(() => null); const upstream = upstreamRes && upstreamRes.code === 0 ? upstreamRes.stdout.trim() : null; - const dirtyRes = await runCommandWithTimeout( - ["git", "-C", root, "status", "--porcelain", "--", ":!dist/control-ui/"], - { timeoutMs }, - ).catch(() => null); + const dirtyRes = await runCommandWithTimeout(["git", "-C", root, "status", "--porcelain"], { + timeoutMs, + }).catch(() => null); const dirty = dirtyRes && dirtyRes.code === 0 ? dirtyRes.stdout.trim().length > 0 : null; const fetchOk = params.fetch diff --git a/src/infra/update-runner.ts b/src/infra/update-runner.ts index 0735edb39..2e8ef5e0e 100644 --- a/src/infra/update-runner.ts +++ b/src/infra/update-runner.ts @@ -676,17 +676,6 @@ export async function runGatewayUpdate(opts: UpdateRunnerOptions = {}): Promise< ); steps.push(uiBuildStep); - // Restore dist/control-ui/ to committed state to prevent dirty repo after update - // (ui:build regenerates assets with new hashes, which would block future updates) - const restoreUiStep = await runStep( - step( - "restore control-ui", - ["git", "-C", gitRoot, "checkout", "--", "dist/control-ui/"], - gitRoot, - ), - ); - steps.push(restoreUiStep); - const doctorStep = await runStep( step( "moltbot doctor", diff --git a/src/telegram/monitor.ts b/src/telegram/monitor.ts index c3b3a5a2f..f828ca1ca 100644 --- a/src/telegram/monitor.ts +++ b/src/telegram/monitor.ts @@ -78,6 +78,7 @@ const NETWORK_ERROR_SNIPPETS = [ "fetch failed", "network", "timeout", + "timed out", "socket", "econnreset", "econnrefused", diff --git a/src/telegram/network-errors.test.ts b/src/telegram/network-errors.test.ts index db582355f..d83338609 100644 --- a/src/telegram/network-errors.test.ts +++ b/src/telegram/network-errors.test.ts @@ -31,6 +31,11 @@ describe("isRecoverableTelegramNetworkError", () => { expect(isRecoverableTelegramNetworkError(new Error("Undici: socket failure"))).toBe(true); }); + it("detects grammY getUpdates timeout format", () => { + const err = new Error("Request to 'getUpdates' timed out after 500 seconds"); + expect(isRecoverableTelegramNetworkError(err)).toBe(true); + }); + it("skips message matches for send context", () => { const err = new TypeError("fetch failed"); expect(isRecoverableTelegramNetworkError(err, { context: "send" })).toBe(false); diff --git a/src/telegram/network-errors.ts b/src/telegram/network-errors.ts index bb3432432..11bda6aa6 100644 --- a/src/telegram/network-errors.ts +++ b/src/telegram/network-errors.ts @@ -36,6 +36,7 @@ const RECOVERABLE_MESSAGE_SNIPPETS = [ "client network socket disconnected", "socket hang up", "getaddrinfo", + "timed out", ]; function normalizeCode(code?: string): string {