fix(telegram): fall back on ambiguous first preview sends

This commit is contained in:
Ayaan Zaidi
2026-03-11 11:23:10 +05:30
parent e37e1ed24e
commit a2e30824e6
3 changed files with 5 additions and 13 deletions

View File

@@ -365,13 +365,6 @@ export function createLaneTextDeliverer(params: CreateLaneTextDelivererParams) {
context,
});
if (typeof previewTargetAfterStop.previewMessageId !== "number") {
if (lane.stream?.sendMayHaveLanded?.()) {
params.log(
`telegram: ${laneName} first preview send may have landed despite missing message id; keeping to avoid duplicate`,
);
params.markDelivered();
return "retained";
}
return "fallback";
}
return finalizePreview(previewTargetAfterStop.previewMessageId, true, false);

View File

@@ -538,7 +538,7 @@ describe("createLaneTextDeliverer", () => {
);
});
it("retains when the first preview send may have landed without a message id", async () => {
it("falls back when the first preview send may have landed without a message id", async () => {
const stream = createTestDraftStream();
stream.sendMayHaveLanded.mockReturnValue(true);
const harness = createHarness({ answerStream: stream });
@@ -550,10 +550,9 @@ describe("createLaneTextDeliverer", () => {
infoKind: "final",
});
expect(result).toBe("preview-retained");
expect(harness.sendPayload).not.toHaveBeenCalled();
expect(harness.log).toHaveBeenCalledWith(
expect.stringContaining("first preview send may have landed despite missing message id"),
expect(result).toBe("sent");
expect(harness.sendPayload).toHaveBeenCalledWith(
expect.objectContaining({ text: "Hello final" }),
);
});