Skip to content

Commit ff9a55c

Browse files
committed
fix telegram thread binding review blockers
1 parent 801308c commit ff9a55c

4 files changed

Lines changed: 26 additions & 3 deletions

File tree

extensions/telegram/src/channel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ export const telegramPlugin = createChatChannelPlugin({
682682
},
683683
conversationBindings: {
684684
supportsCurrentConversationBinding: true,
685-
defaultTopLevelPlacement: "current",
685+
defaultTopLevelPlacement: "child",
686686
resolveConversationRef: ({
687687
accountId: _accountId,
688688
conversationId,

extensions/telegram/src/thread-bindings.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { getSessionBindingService } from "openclaw/plugin-sdk/conversation-runti
66
import { resolveStateDir } from "openclaw/plugin-sdk/state-paths";
77
import { importFreshModule } from "openclaw/plugin-sdk/test-fixtures";
88
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
9+
import { telegramPlugin } from "./channel.js";
910

1011
const writeJsonFileAtomicallyMock = vi.hoisted(() => vi.fn());
1112
const readAcpSessionEntryMock = vi.hoisted(() => vi.fn());
@@ -65,6 +66,15 @@ async function flushMicrotasks(): Promise<void> {
6566
await new Promise<void>((resolve) => queueMicrotask(resolve));
6667
}
6768

69+
describe("telegram thread binding placement", () => {
70+
it("keeps loaded plugin placement aligned with the bundled public artifact", async () => {
71+
const api = await import("../thread-binding-api.js");
72+
73+
expect(telegramPlugin.conversationBindings?.defaultTopLevelPlacement).toBe("child");
74+
expect(api.defaultTopLevelPlacement).toBe("child");
75+
});
76+
});
77+
6878
describe("telegram thread bindings", () => {
6979
const originalStateDir = process.env.OPENCLAW_STATE_DIR;
7080
let stateDirOverride: string | undefined;

src/agents/sessions-spawn-hooks.test.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@ import {
55
} from "./subagent-spawn.test-helpers.js";
66

77
type GatewayRequest = { method?: string; params?: Record<string, unknown> };
8+
type TestSubagentSpawningResult =
9+
| undefined
10+
| { status: "error"; error: string }
11+
| {
12+
status: "ok";
13+
threadBindingReady: boolean;
14+
deliveryOrigin?: {
15+
channel: string;
16+
to: string;
17+
accountId?: string;
18+
threadId?: string;
19+
};
20+
};
821

922
const hoisted = vi.hoisted(() => ({
1023
callGatewayMock: vi.fn(),
@@ -14,7 +27,7 @@ const hoisted = vi.hoisted(() => ({
1427

1528
const hookRunnerMocks = vi.hoisted(() => ({
1629
hasSubagentEndedHook: true,
17-
runSubagentSpawning: vi.fn(async (event: unknown) => {
30+
runSubagentSpawning: vi.fn(async (event: unknown): Promise<TestSubagentSpawningResult> => {
1831
const input = event as {
1932
threadRequested?: boolean;
2033
requester?: { channel?: string };

src/agents/subagent-spawn.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ function resolveBoundThreadDeliveryOrigin(params: {
698698
}): DeliveryContext | undefined {
699699
const bindings = getSessionBindingService()
700700
.listBySession(params.childSessionKey)
701-
.filter((binding) => binding.status !== "inactive");
701+
.filter((binding) => binding.status === "active");
702702
for (const binding of bindings) {
703703
const conversation = binding.conversation;
704704
if (!conversation.parentConversationId) {

0 commit comments

Comments
 (0)