Skip to content

Commit 013ecde

Browse files
committed
LINE: avoid runtime lookup during onboarding
1 parent 8240fd9 commit 013ecde

File tree

2 files changed

+37
-12
lines changed

2 files changed

+37
-12
lines changed

extensions/line/src/config-adapter.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import { createScopedChannelConfigAdapter } from "openclaw/plugin-sdk/channel-config-helpers";
2-
import type { OpenClawConfig, ResolvedLineAccount } from "../api.js";
3-
import { getLineRuntime } from "./runtime.js";
4-
5-
function resolveLineRuntimeAccount(cfg: OpenClawConfig, accountId?: string | null) {
6-
return getLineRuntime().channel.line.resolveLineAccount({
7-
cfg,
8-
accountId: accountId ?? undefined,
9-
});
10-
}
2+
import {
3+
listLineAccountIds,
4+
resolveDefaultLineAccountId,
5+
resolveLineAccount,
6+
type OpenClawConfig,
7+
type ResolvedLineAccount,
8+
} from "../runtime-api.js";
119

1210
export function normalizeLineAllowFrom(entry: string): string {
1311
return entry.replace(/^line:(?:user:)?/i, "");
@@ -19,9 +17,10 @@ export const lineConfigAdapter = createScopedChannelConfigAdapter<
1917
OpenClawConfig
2018
>({
2119
sectionKey: "line",
22-
listAccountIds: (cfg) => getLineRuntime().channel.line.listLineAccountIds(cfg),
23-
resolveAccount: (cfg, accountId) => resolveLineRuntimeAccount(cfg, accountId),
24-
defaultAccountId: (cfg) => getLineRuntime().channel.line.resolveDefaultLineAccountId(cfg),
20+
listAccountIds: listLineAccountIds,
21+
resolveAccount: (cfg, accountId) =>
22+
resolveLineAccount({ cfg, accountId: accountId ?? undefined }),
23+
defaultAccountId: resolveDefaultLineAccountId,
2524
clearBaseFields: ["channelSecret", "tokenFile", "secretFile"],
2625
resolveAllowFrom: (account) => account.config.allowFrom,
2726
formatAllowFrom: (allowFrom) =>

src/commands/onboard-channels.e2e.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,32 @@ describe("setupChannels", () => {
277277
expect(multiselect).not.toHaveBeenCalled();
278278
});
279279

280+
it("renders the QuickStart channel picker without requiring the LINE runtime", async () => {
281+
const select = vi.fn(async ({ message }: { message: string }) => {
282+
if (message === "Select channel (QuickStart)") {
283+
return "__skip__";
284+
}
285+
return "__done__";
286+
});
287+
const { multiselect, text } = createUnexpectedPromptGuards();
288+
const prompter = createPrompter({
289+
select: select as unknown as WizardPrompter["select"],
290+
multiselect,
291+
text,
292+
});
293+
294+
await expect(
295+
runSetupChannels({} as OpenClawConfig, prompter, {
296+
quickstartDefaults: true,
297+
}),
298+
).resolves.toEqual({} as OpenClawConfig);
299+
300+
expect(select).toHaveBeenCalledWith(
301+
expect.objectContaining({ message: "Select channel (QuickStart)" }),
302+
);
303+
expect(multiselect).not.toHaveBeenCalled();
304+
});
305+
280306
it("continues Telegram setup when the plugin registry is empty", async () => {
281307
// Simulate missing registry entries (the scenario reported in #25545).
282308
setActivePluginRegistry(createEmptyPluginRegistry());

0 commit comments

Comments
 (0)