Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

fix: Include runtime metadata in CLI issue reports (#6026)

Oleg Isonenb6d4d645f55a
diff --git a/packages/cli/src/project-session.test.ts b/packages/cli/src/project-session.test.ts
index ec5ccbfea7..27bf1e4aa9 100644
--- a/packages/cli/src/project-session.test.ts
+++ b/packages/cli/src/project-session.test.ts
@@ -731,4 +731,78 @@ describe("cli project session transport", () => {
expect(requestText).toContain("project-1");
expect(requestText).not.toContain("other-project");
});
+
+ test("adds anonymous runtime metadata to issue report requests", async () => {
+ let requestBody = "";
+ const fetch = vi.fn(
+ async (request: URL | RequestInfo, init?: RequestInit) => {
+ if (request instanceof Request) {
+ requestBody = await request.clone().text();
+ } else if (typeof init?.body === "string") {
+ requestBody = init.body;
+ }
+ return new Response(
+ JSON.stringify([
+ {
+ result: {
+ data: {
+ status: "created",
+ issueNumber: 1,
+ issueUrl: "https://example.com/issues/1",
+ },
+ },
+ },
+ ]),
+ { headers: { "content-type": "application/json" } }
+ );
+ }
+ );
+ vi.stubGlobal("fetch", fetch);
+ const transport = createCliProjectSessionTransport({
+ connection: {
+ projectId: "project-1",
+ origin: "https://example.com",
+ authToken: "token",
+ },
+ });
+
+ await transport.executeServerOperation?.({
+ operationId: "reports.issue",
+ input: {
+ trigger: "user-requested",
+ category: "tool-failure",
+ deduplicationKey: "report-runtime",
+ title: "fix: Include report runtime",
+ agent: {
+ client: "Codex",
+ model: "test-model",
+ reasoningEffort: "medium",
+ },
+ report: {
+ userStory: "Use issue reporting.",
+ summary: "Runtime metadata was omitted.",
+ attemptedWorkflow: ["Submit an issue report."],
+ expectedBehavior: "The report includes runtime metadata.",
+ actualResult: "The report omitted runtime metadata.",
+ recoveryAttempts: ["Inspect the created issue."],
+ userImpact: "The report is harder to diagnose.",
+ technicalContext: "The CLI transport submitted the report.",
+ acceptanceCriteria: ["The report includes runtime metadata."],
+ },
+ },
+ });
+
+ const body = JSON.parse(requestBody) as {
+ 0: { runtime?: Record<string, unknown> };
+ };
+ expect(body[0].runtime).toEqual({
+ cliVersion: expect.any(String),
+ nodeVersion: process.versions.node,
+ os: process.platform,
+ osVersion: expect.any(String),
+ architecture: process.arch,
+ executionMode: "mcp",
+ apiContractVersion: expect.any(String),
+ });
+ });
});
diff --git a/packages/cli/src/project-session.ts b/packages/cli/src/project-session.ts
index da73f3231c..06b5f30043 100644
--- a/packages/cli/src/project-session.ts
+++ b/packages/cli/src/project-session.ts
@@ -16,6 +16,7 @@ import {
publicApiOperationRequiresServerSupport,
publicApiOperations,
type IssueReportRuntime,
+ type PublicApiCommand,
type PublishedProjectBundle,
} from "@webstudio-is/protocol";
import packageJson from "../package.json";
@@ -238,11 +239,11 @@ const getIssueReportRuntime = (): IssueReportRuntime => ({
});
export const addIssueReportRuntime = (
- operationId: string,
+ command: PublicApiCommand,
input: unknown,
runtime: IssueReportRuntime = getIssueReportRuntime()
) => {
- if (operationId !== "report-issue" || isPlainRecord(input) === false) {
+ if (command !== "report-issue" || isPlainRecord(input) === false) {
return input;
}
return { ...input, runtime };
@@ -271,7 +272,10 @@ const executePublicServerOperation = async ({
}
return await client({
...connection,
- ...(addIssueReportRuntime(operationId, input) as Record<string, unknown>),
+ ...(addIssueReportRuntime(operation.command, input) as Record<
+ string,
+ unknown
+ >),
projectId: connection.projectId,
});
};