Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { LLMInteractionItem } from "core";
import { EXTENSION_NAME } from "core/util/constants";
import { LLMLogger } from "core/llm/logger";

Check warning on line 3 in extensions/vscode/src/ContinueConsoleWebviewViewProvider.ts

View workflow job for this annotation

GitHub Actions / vscode-checks

`core/llm/logger` import should occur before import of `core/util/constants`
import * as vscode from "vscode";

import { getStylesheetLink } from "./util/util";
import { getExtensionUri, getNonce } from "./util/vscode";

interface FromConsoleView {
Expand Down Expand Up @@ -196,7 +197,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script>const vscode = acquireVsCodeApi();</script>
<link href="${styleMainUri}" rel="stylesheet">
${getStylesheetLink(styleMainUri)}

<title>Continue</title>
</head>
Expand Down
8 changes: 6 additions & 2 deletions extensions/vscode/src/ContinueGUIWebviewViewProvider.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import * as vscode from "vscode";

import { getTheme } from "./util/getTheme";
import { getExtensionVersion, getvsCodeUriScheme } from "./util/util";
import {
getExtensionVersion,
getStylesheetLink,
getvsCodeUriScheme,
} from "./util/util";
import { getExtensionUri, getNonce, getUniqueId } from "./util/vscode";
import { VsCodeWebviewProtocol } from "./webviewProtocol";

Expand Down Expand Up @@ -51,7 +55,7 @@
}

sendMainUserInput(input: string) {
this.webview?.postMessage({

Check warning on line 58 in extensions/vscode/src/ContinueGUIWebviewViewProvider.ts

View workflow job for this annotation

GitHub Actions / vscode-checks

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
type: "userInput",
input,
});
Expand Down Expand Up @@ -133,7 +137,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script>const vscode = acquireVsCodeApi();</script>
<link href="${styleMainUri}" rel="stylesheet">
${getStylesheetLink(styleMainUri)}

<title>Continue</title>
</head>
Expand Down
4 changes: 4 additions & 0 deletions extensions/vscode/src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ export function getExtensionVersion(): string {
return extension?.packageJSON.version || "0.1.0";
}

export function getStylesheetLink(styleUri: string): string {
return `<link href="${styleUri}" rel="stylesheet" crossorigin="anonymous">`;
}

export function getvsCodeUriScheme(): string {
return vscode.env.uriScheme;
}
Expand Down
10 changes: 10 additions & 0 deletions extensions/vscode/src/util/util.vitest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";

import { getStylesheetLink } from "./util";

vi.mock("node:os", () => ({
platform: vi.fn(),
arch: vi.fn(),
Expand Down Expand Up @@ -77,3 +79,11 @@ describe("isExtensionPrerelease", () => {
expect(isExtensionPrerelease()).toBe(true);
});
});

describe("getStylesheetLink", () => {
it("requests webview stylesheets with CORS", () => {
expect(getStylesheetLink("vscode-webview://continue/gui/index.css")).toBe(
'<link href="vscode-webview://continue/gui/index.css" rel="stylesheet" crossorigin="anonymous">',
);
});
});
Loading