mirror of
https://github.com/farcasclaudiu/openclaw.git
synced 2026-06-28 15:01:41 +03:00
fix: tighten thread-clear and telegram retry guards
This commit is contained in:
@@ -176,7 +176,7 @@ describe("sessions", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("updateLastRoute clears threadId when deliveryContext explicitly omits it", async () => {
|
||||
it("updateLastRoute clears threadId when explicit route omits threadId", async () => {
|
||||
const mainSessionKey = "agent:main:main";
|
||||
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-sessions-"));
|
||||
const storePath = path.join(dir, "sessions.json");
|
||||
@@ -209,7 +209,6 @@ describe("sessions", () => {
|
||||
deliveryContext: {
|
||||
channel: "telegram",
|
||||
to: "222",
|
||||
threadId: undefined,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -440,10 +440,21 @@ export async function updateLastRoute(params: {
|
||||
});
|
||||
const mergedInput = mergeDeliveryContext(explicitContext, inlineContext);
|
||||
const explicitDeliveryContext = params.deliveryContext;
|
||||
const clearThreadFromFallback =
|
||||
const explicitThreadFromDeliveryContext =
|
||||
explicitDeliveryContext != null &&
|
||||
Object.prototype.hasOwnProperty.call(explicitDeliveryContext, "threadId") &&
|
||||
explicitDeliveryContext.threadId == null;
|
||||
Object.prototype.hasOwnProperty.call(explicitDeliveryContext, "threadId")
|
||||
? explicitDeliveryContext.threadId
|
||||
: undefined;
|
||||
const explicitThreadValue =
|
||||
explicitThreadFromDeliveryContext ??
|
||||
(threadId != null && threadId !== "" ? threadId : undefined);
|
||||
const explicitRouteProvided = Boolean(
|
||||
explicitContext?.channel ||
|
||||
explicitContext?.to ||
|
||||
inlineContext?.channel ||
|
||||
inlineContext?.to,
|
||||
);
|
||||
const clearThreadFromFallback = explicitRouteProvided && explicitThreadValue == null;
|
||||
const fallbackContext = clearThreadFromFallback
|
||||
? removeThreadFromDeliveryContext(deliveryContextFromSession(existing))
|
||||
: deliveryContextFromSession(existing);
|
||||
|
||||
Reference in New Issue
Block a user