@@ -3,6 +3,7 @@ import type { ConfigEntry, OpenCodeEvent, SessionMessageInfo, WorktreeDirectory |
3 | 3 | import { NO_PROVIDER, REMOTE_SERVER, SERVER, holdRoute, project, seed, session } from "../utils/app" |
4 | 4 | import { mockMissingLocation, mockOpenCodeServer } from "../utils/mock-server" |
5 | 5 | import { mockRemoteServer, mockWorkspace, openSession, openSettings, type WorkspaceInput } from "../utils/workspace" |
| 6 | +import { CONSOLE_URL, consoleGateway, consoleSignIn } from "../utils/console" |
6 | 7 | import { recordNotifications } from "../utils/notifications" |
7 | 8 | import { installSseTransport } from "../utils/sse-transport" |
8 | 9 |
|
@@ -783,6 +784,97 @@ test("a project plugin list that fails to load offers Retry instead of an empty |
783 | 784 | await expect(panel.getByRole("status")).toHaveCount(0) |
784 | 785 | }) |
785 | 786 |
|
| 787 | +test("project extensions link Console MCPs and skills and offer sign-in as the server-wide page does", async ({ |
| 788 | + page, |
| 789 | + context, |
| 790 | +}) => { |
| 791 | + const consoleUrl = CONSOLE_URL |
| 792 | + await context.route("https://opencode.ai/console/**", (route) => route.fulfill({ body: "Console" })) |
| 793 | + |
| 794 | + const { settings } = await open(page, { |
| 795 | + configEntries: [ |
| 796 | + { |
| 797 | + type: "document", |
| 798 | + info: { |
| 799 | + mcp: { |
| 800 | + servers: { |
| 801 | + slack: consoleGateway("slack"), |
| 802 | + github: consoleGateway("github", { protocol: "2026-07-28" }), |
| 803 | + }, |
| 804 | + }, |
| 805 | + }, |
| 806 | + }, |
| 807 | + ], |
| 808 | + mcp: [ |
| 809 | + ...["figma", "github", "slack"].map((name) => ({ name, status: { status: "connected" } })), |
| 810 | + { name: "stripe", integrationID: "stripe-oauth", status: { status: "needs_auth", error: "Sign in required" } }, |
| 811 | + ], |
| 812 | + integrations: [ |
| 813 | + consoleSignIn, |
| 814 | + { |
| 815 | + id: "stripe-oauth", |
| 816 | + name: "Stripe", |
| 817 | + methods: [{ id: "oauth", type: "oauth" }], |
| 818 | + connections: [], |
| 819 | + metadata: { source: "mcp" }, |
| 820 | + }, |
| 821 | + ], |
| 822 | + skills: [ |
| 823 | + { id: "review", name: "Code review", path: "/home/test/.config/opencode/skills/review/SKILL.md", content: "x" }, |
| 824 | + { id: "funnel", name: "Funnel analytics", path: "skill://funnel/SKILL.md", content: "x" }, |
| 825 | + ], |
| 826 | + }) |
| 827 | + |
| 828 | + await openProject(page) |
| 829 | + await settings.getByRole("tab", { name: "Extensions", exact: true }).click() |
| 830 | + |
| 831 | + // Console's servers are shared with every project, so they list under Shared. |
| 832 | + const mcps = settings.getByRole("tabpanel", { name: "MCPs", exact: true }) |
| 833 | + await mcps.getByRole("button", { name: /^Shared/ }).click() |
| 834 | + await expect(mcps.getByRole("switch", { name: "figma", exact: true })).toBeVisible() |
| 835 | + // As on the server-wide page, a dot shows each status and the words stay for assistive technology. |
| 836 | + await expect(mcps.getByRole("switch", { name: "slack", exact: true })).toHaveAccessibleDescription("Connected") |
| 837 | + await expect(mcps.getByRole("switch", { name: "github", exact: true })).toHaveCount(0) |
| 838 | + await expect(mcps.getByRole("button", { name: "Manage figma in Console", exact: true })).toHaveCount(0) |
| 839 | + // A server that needs a sign-in asks for it in the switch's place, as on the server-wide page. |
| 840 | + await expect(mcps.getByRole("button", { name: "Sign in to stripe", exact: true })).toHaveText("Sign in") |
| 841 | + await expect(mcps.getByRole("switch", { name: "stripe", exact: true })).toHaveCount(0) |
| 842 | + |
| 843 | + const connection = page.waitForEvent("popup") |
| 844 | + await mcps.getByRole("button", { name: "Connect github in Console", exact: true }).click() |
| 845 | + await expect(await connection).toHaveURL(`${consoleUrl}/org_acme/extensions?connect=github`) |
| 846 | + |
| 847 | + const manage = page.waitForEvent("popup") |
| 848 | + await mcps.getByRole("button", { name: "Manage slack in Console", exact: true }).click() |
| 849 | + await expect(await manage).toHaveURL(`${consoleUrl}/org_acme/extensions/mcp/slack`) |
| 850 | + |
| 851 | + await settings.getByRole("tab", { name: "Skills", exact: true }).click() |
| 852 | + const skills = settings.getByRole("tabpanel", { name: "Skills", exact: true }) |
| 853 | + await skills.getByRole("button", { name: /^Shared/ }).click() |
| 854 | + await expect(skills.getByText("Code review", { exact: true })).toBeVisible() |
| 855 | + await expect(skills.getByRole("button", { name: "Manage Code review in Console", exact: true })).toHaveCount(0) |
| 856 | + |
| 857 | + const skill = page.waitForEvent("popup") |
| 858 | + await skills.getByRole("button", { name: "Manage Funnel analytics in Console", exact: true }).click() |
| 859 | + await expect(await skill).toHaveURL(`${consoleUrl}/org_acme/extensions?kind=skills&search=funnel`) |
| 860 | +}) |
| 861 | + |
| 862 | +test("a Console skill links to Console's home when no Console MCP names the workspace", async ({ page, context }) => { |
| 863 | + await context.route(`${CONSOLE_URL}**`, (route) => route.fulfill({ body: "Console" })) |
| 864 | + |
| 865 | + const { settings } = await open(page, { |
| 866 | + integrations: [consoleSignIn], |
| 867 | + skills: [{ id: "funnel", name: "Funnel analytics", path: "skill://funnel/SKILL.md", content: "x" }], |
| 868 | + }) |
| 869 | + |
| 870 | + await settings.getByRole("tab", { name: "Extensions", exact: true }).click() |
| 871 | + await settings.getByRole("tab", { name: "Skills", exact: true }).click() |
| 872 | + |
| 873 | + const skill = page.waitForEvent("popup") |
| 874 | + await settings.getByRole("button", { name: "Manage Funnel analytics in Console", exact: true }).click() |
| 875 | + await expect(await skill).toHaveURL(CONSOLE_URL) |
| 876 | +}) |
| 877 | + |
786 | 878 | for (const field of [ |
787 | 879 | { |
788 | 880 | name: "color", |
@@ -1050,7 +1142,14 @@ test.describe("pages open before slow data", () => { |
1050 | 1142 | }) |
1051 | 1143 |
|
1052 | 1144 | test("extensions", async ({ page }) => { |
1053 | | - const { settings } = await open(page, { mcp: [{ name: "demo-mcp", status: { status: "connected" } }] }) |
| 1145 | + const { settings } = await open(page, { |
| 1146 | + mcp: [{ name: "demo-mcp", status: { status: "connected" } }], |
| 1147 | + skills: [ |
| 1148 | + { id: "opencode", name: "OpenCode", path: "skill://opencode/SKILL.md", content: "OpenCode help" }, |
| 1149 | + { id: "plugin-skill", name: "Plugin skill", path: "skill://plugin-skill/SKILL.md", content: "Plugin help" }, |
| 1150 | + ], |
| 1151 | + }) |
| 1152 | + |
1054 | 1153 | const mcp = await holdRoute(page, (url) => url.pathname === "/api/mcp") |
1055 | 1154 | await settings.getByRole("tab", { name: "Extensions", exact: true }).click() |
1056 | 1155 | await mcp.arrived |
@@ -1059,6 +1158,11 @@ test.describe("pages open before slow data", () => { |
1059 | 1158 | mcp.release() |
1060 | 1159 | await settings.getByRole("tab", { name: "MCPs", exact: true }).click() |
1061 | 1160 | await expect(settings.getByRole("switch", { name: "demo-mcp" })).toBeChecked() |
| 1161 | + // Without a Console sign-in, a virtual skill is never linked to Console. |
| 1162 | + await settings.getByRole("tab", { name: "Skills", exact: true }).click() |
| 1163 | + await expect(settings.getByText("OpenCode", { exact: true })).toBeVisible() |
| 1164 | + await expect(settings.getByText("Plugin skill", { exact: true })).toBeVisible() |
| 1165 | + await expect(settings.getByRole("button", { name: /in Console$/ })).toHaveCount(0) |
1062 | 1166 | }) |
1063 | 1167 |
|
1064 | 1168 | test("extensions show MCP status dots with sign-in, error, and switch controls", async ({ page, context }) => { |
@@ -1115,6 +1219,100 @@ test.describe("pages open before slow data", () => { |
1115 | 1219 | await expect(details.getByText(error, { exact: true })).toBeVisible() |
1116 | 1220 | }) |
1117 | 1221 |
|
| 1222 | + test("extensions list Console MCPs and skills with local ones", async ({ page, context }) => { |
| 1223 | + await context.route("https://opencode.ai/console/**", (route) => route.fulfill({ body: "Console" })) |
| 1224 | + const consoleUrl = CONSOLE_URL |
| 1225 | + |
| 1226 | + const actions: string[] = [] |
| 1227 | + |
| 1228 | + const { settings, push } = await open(page, { |
| 1229 | + configEntries: [ |
| 1230 | + { |
| 1231 | + type: "document", |
| 1232 | + info: { |
| 1233 | + mcp: { |
| 1234 | + servers: { |
| 1235 | + linear: consoleGateway("linear"), |
| 1236 | + github: consoleGateway("github", { protocol: "2026-07-28" }), |
| 1237 | + clickhouse: consoleGateway("clickhouse"), |
| 1238 | + }, |
| 1239 | + }, |
| 1240 | + }, |
| 1241 | + }, |
| 1242 | + { |
| 1243 | + type: "document", |
| 1244 | + path: "/home/test/.config/opencode/opencode.json", |
| 1245 | + info: { mcp: { servers: { linear: { type: "remote", url: "https://mcp.linear.app/mcp" } } } }, |
| 1246 | + }, |
| 1247 | + ], |
| 1248 | + integrations: [consoleSignIn], |
| 1249 | + mcp: ["figma", "linear", "github", "clickhouse"].map((name) => ({ name, status: { status: "connected" } })), |
| 1250 | + skills: [ |
| 1251 | + { |
| 1252 | + id: "review", |
| 1253 | + name: "Code review", |
| 1254 | + path: "/home/test/.config/opencode/skills/review/SKILL.md", |
| 1255 | + content: "Review code", |
| 1256 | + }, |
| 1257 | + { id: "opencode", name: "OpenCode", path: "skill://opencode/SKILL.md", content: "OpenCode help" }, |
| 1258 | + { id: "report", name: "Report", path: "skill://report/SKILL.md", content: "Report bugs" }, |
| 1259 | + { id: "browser", name: "Browser", path: "skill://browser/SKILL.md", content: "Browser help" }, |
| 1260 | + { id: "funnel", name: "Funnel analytics", path: "skill://funnel/SKILL.md", content: "Analyze the funnel" }, |
| 1261 | + ], |
| 1262 | + onMcpAction: (input) => { |
| 1263 | + actions.push(`${input.server}:${input.action}`) |
| 1264 | + }, |
| 1265 | + }) |
| 1266 | + |
| 1267 | + await settings.getByRole("tab", { name: "Extensions", exact: true }).click() |
| 1268 | + |
| 1269 | + // One list: a name both configs define is one row, the user's server, with Console's link kept. A Console server |
| 1270 | + // whose account isn't connected asks for the connection in the switch's place. |
| 1271 | + await expect(settings.getByRole("switch")).toHaveCount(3) |
| 1272 | + await expect(settings.getByRole("switch", { name: "linear", exact: true })).toBeChecked() |
| 1273 | + await expect(settings.getByRole("switch", { name: "figma", exact: true })).toBeChecked() |
| 1274 | + await expect(settings.getByRole("switch", { name: "github", exact: true })).toHaveCount(0) |
| 1275 | + await expect(settings.getByRole("button", { name: "Manage linear in Console" })).toHaveText( |
| 1276 | + "Replaces OpenCode Console", |
| 1277 | + ) |
| 1278 | + await expect(settings.getByRole("button", { name: "Manage github in Console" })).toHaveText("github") |
| 1279 | + await expect(settings.getByRole("button", { name: "Manage clickhouse in Console" })).toHaveText("clickhouse") |
| 1280 | + await expect(settings.getByText("OpenCode Console", { exact: true })).toHaveCount(0) |
| 1281 | + await expect(settings.getByRole("button", { name: "Manage figma in Console" })).toHaveCount(0) |
| 1282 | + |
| 1283 | + const connection = page.waitForEvent("popup") |
| 1284 | + await settings.getByRole("button", { name: "Connect github in Console" }).click() |
| 1285 | + await expect(await connection).toHaveURL(`${consoleUrl}/org_acme/extensions?connect=github`) |
| 1286 | + |
| 1287 | + const manage = page.waitForEvent("popup") |
| 1288 | + await settings.getByRole("button", { name: "Manage linear in Console" }).click() |
| 1289 | + await expect(await manage).toHaveURL(`${consoleUrl}/org_acme/extensions/mcp/linear`) |
| 1290 | + |
| 1291 | + const toggle = settings.getByRole("switch", { name: "clickhouse", exact: true }) |
| 1292 | + await toggle.press("Space") |
| 1293 | + await expect(toggle).not.toBeChecked() |
| 1294 | + expect(actions).toEqual(["clickhouse:disconnect"]) |
| 1295 | + const refreshed = page.waitForResponse((response) => new URL(response.url()).pathname === "/api/config") |
| 1296 | + await push([{ id: "evt_config_extensions", created: 1, type: "config.updated", data: {} }]) |
| 1297 | + await refreshed |
| 1298 | + await expect(toggle).not.toBeChecked() |
| 1299 | + |
| 1300 | + // One sorted list: only a skill Console delivers links to Console, filtered to that skill. |
| 1301 | + await settings.getByRole("tab", { name: "Skills", exact: true }).click() |
| 1302 | + await expect(settings.locator(".settings-extension-name")).toHaveText([ |
| 1303 | + "Browser", |
| 1304 | + "Code review", |
| 1305 | + "Funnel analytics", |
| 1306 | + "OpenCode", |
| 1307 | + "Report", |
| 1308 | + ]) |
| 1309 | + await expect(settings.getByRole("button", { name: /in Console$/ })).toHaveCount(1) |
| 1310 | + |
| 1311 | + const skill = page.waitForEvent("popup") |
| 1312 | + await settings.getByRole("button", { name: "Manage Funnel analytics in Console", exact: true }).click() |
| 1313 | + await expect(await skill).toHaveURL(`${consoleUrl}/org_acme/extensions?kind=skills&search=funnel`) |
| 1314 | + }) |
| 1315 | + |
1118 | 1316 | for (const fails of [false, true]) { |
1119 | 1317 | test(`about ${fails ? "keeps its fallback when contributors fail" : "updates contributors later"}`, async ({ |
1120 | 1318 | page, |
|