Skip to content

Commit 6dba5cc

Browse files
committed
fix(copilot): refresh live discovery config
1 parent 834fdc4 commit 6dba5cc

3 files changed

Lines changed: 62 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ Docs: https://docs.openclaw.ai
110110
- Memory/LanceDB: keep auto-recall and auto-capture hooks wired when those settings start disabled, so turning them on in live config starts recall and capture without waiting for a restart. Thanks @vincentkoc.
111111
- Skill Workshop: keep the tool plus `before_prompt_build` / `agent_end` hooks wired while the plugin is disabled at startup, so turning the plugin back on in live config starts guidance and capture without waiting for a restart. Thanks @vincentkoc.
112112
- Active Memory: stop reviving removed live `active-memory` config from startup snapshots, so removing the plugin entry turns the hook off immediately instead of waiting for a restart. Thanks @vincentkoc.
113+
- GitHub Copilot: re-read plugin discovery config from the live runtime snapshot, so toggling `plugins.entries.github-copilot.config.discovery.enabled` takes effect without a restart. Thanks @vincentkoc.
113114
- Agents/subagents: drop bare `NO_REPLY` from the parent turn when the session still has pending spawned children, so direct-conversation surfaces such as Telegram DMs no longer rewrite the sentinel into visible fallback chatter while waiting for the child completion event. (#69942) Thanks @neeravmakwana.
114115
- Plugins/install: keep bundled plugin dependencies off npm install while repairing them when plugins activate from a packaged install, including Feishu/Lark, Browser, and direct bundled channel setup-entry loads.
115116
- CLI/channels: skip and cache bundled channel plugin, setup, and secrets load failures during read-only discovery, so one broken unused bundled channel cannot crash `openclaw status` or bootstrap secret scans.

extensions/github-copilot/index.test.ts

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,17 @@ describe("github-copilot plugin", () => {
6161
const provider = registerProviderWithPluginConfig({ discovery: { enabled: false } });
6262

6363
const result = await provider.catalog.run({
64-
config: {},
64+
config: {
65+
plugins: {
66+
entries: {
67+
"github-copilot": {
68+
config: {
69+
discovery: { enabled: false },
70+
},
71+
},
72+
},
73+
},
74+
},
6575
agentDir: "/tmp/agent",
6676
env: { GH_TOKEN: "gh_test_token" },
6777
resolveProviderApiKey: () => ({ apiKey: "gh_test_token" }),
@@ -70,4 +80,40 @@ describe("github-copilot plugin", () => {
7080
expect(result).toBeNull();
7181
expect(resolveCopilotApiTokenMock).not.toHaveBeenCalled();
7282
});
83+
84+
it("uses live plugin config to re-enable discovery after startup disable", async () => {
85+
resolveCopilotApiTokenMock.mockResolvedValueOnce({
86+
token: "copilot_api_token",
87+
baseUrl: "https://api.githubcopilot.live",
88+
});
89+
const provider = registerProviderWithPluginConfig({ discovery: { enabled: false } });
90+
91+
const result = await provider.catalog.run({
92+
config: {
93+
plugins: {
94+
entries: {
95+
"github-copilot": {
96+
config: {
97+
discovery: { enabled: true },
98+
},
99+
},
100+
},
101+
},
102+
},
103+
agentDir: "/tmp/agent",
104+
env: { GH_TOKEN: "gh_test_token" },
105+
resolveProviderApiKey: () => ({ apiKey: "gh_test_token" }),
106+
} as never);
107+
108+
expect(resolveCopilotApiTokenMock).toHaveBeenCalledWith({
109+
githubToken: "gh_test_token",
110+
env: { GH_TOKEN: "gh_test_token" },
111+
});
112+
expect(result).toEqual({
113+
provider: {
114+
baseUrl: "https://api.githubcopilot.live",
115+
models: [],
116+
},
117+
});
118+
});
73119
});

extensions/github-copilot/index.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import {
2+
resolvePluginConfigObject,
3+
type OpenClawConfig,
4+
} from "openclaw/plugin-sdk/config-runtime";
15
import { definePluginEntry, type ProviderAuthContext } from "openclaw/plugin-sdk/plugin-entry";
26
import { ensureAuthProfileStore } from "openclaw/plugin-sdk/provider-auth";
37
import { normalizeOptionalLowercaseString } from "openclaw/plugin-sdk/text-runtime";
@@ -24,7 +28,15 @@ export default definePluginEntry({
2428
name: "GitHub Copilot Provider",
2529
description: "Bundled GitHub Copilot provider plugin",
2630
register(api) {
27-
const pluginConfig = (api.pluginConfig ?? {}) as GithubCopilotPluginConfig;
31+
const startupPluginConfig = (api.pluginConfig ?? {}) as GithubCopilotPluginConfig;
32+
33+
function resolveCurrentPluginConfig(config?: OpenClawConfig): GithubCopilotPluginConfig {
34+
const runtimePluginConfig = resolvePluginConfigObject(config, "github-copilot");
35+
if (runtimePluginConfig) {
36+
return runtimePluginConfig as GithubCopilotPluginConfig;
37+
}
38+
return config ? {} : startupPluginConfig;
39+
}
2840

2941
async function runGitHubCopilotAuth(ctx: ProviderAuthContext) {
3042
const { githubCopilotLoginCommand } = await loadGithubCopilotRuntime();
@@ -100,6 +112,7 @@ export default definePluginEntry({
100112
catalog: {
101113
order: "late",
102114
run: async (ctx) => {
115+
const pluginConfig = resolveCurrentPluginConfig(ctx.config);
103116
const discoveryEnabled =
104117
pluginConfig.discovery?.enabled ?? ctx.config?.models?.copilotDiscovery?.enabled;
105118
if (discoveryEnabled === false) {

0 commit comments

Comments
 (0)