-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add opt in webview that is shown prior to enabling the coding a…
…ssistant (#200)
- Loading branch information
1 parent
3076cef
commit 489e0cc
Showing
6 changed files
with
198 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
"use strict"; | ||
|
||
import { commands, WebviewView, WebviewViewProvider } from "vscode"; | ||
|
||
type OptInMessage = { | ||
command: "opt-in"; | ||
}; | ||
|
||
export class CodingAssistantOptInProvider implements WebviewViewProvider { | ||
public static readonly viewType = "sourcery.coding_assistant_opt_in"; | ||
|
||
public async resolveWebviewView(webviewView: WebviewView) { | ||
webviewView.webview.options = { | ||
enableScripts: true, | ||
}; | ||
|
||
webviewView.webview.onDidReceiveMessage(async (_message: OptInMessage) => | ||
commands.executeCommand("sourcery.coding_assistant.opt_in") | ||
); | ||
|
||
webviewView.webview.html = `<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Opt-In Form</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
margin: 0; | ||
padding: 20px; | ||
} | ||
h2 { | ||
margin-top: 0px; | ||
margin-bottom: 20px; | ||
} | ||
p { | ||
margin-bottom: 10px; | ||
} | ||
.opt-in-form { | ||
max-width: 400px; | ||
margin: 0 auto; | ||
padding: 20px; | ||
border: 1px solid #ccc; | ||
border-radius: 5px; | ||
} | ||
.opt-in-button { | ||
display: block; | ||
width: 100%; | ||
margin-top: 15px; | ||
padding: 10px; | ||
background-color: #007bff; | ||
color: #fff; | ||
border: none; | ||
border-radius: 5px; | ||
cursor: pointer; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="opt-in-form"> | ||
<h2>Sourcery Coding Assistant</h2> | ||
<p>By enabling the Sourcery coding assistant, you agree that Sourcery can send your code to third party LLMs for analysis (OpenAI, Anthropic).</p> | ||
<p>None of your code is ever stored on our servers.</p> | ||
<form onsubmit="submitForm(event)"> | ||
<button class="opt-in-button">Enable</button> | ||
</form> | ||
</div> | ||
</body> | ||
<script> | ||
function submitForm(event) { | ||
event.preventDefault(); | ||
const vscode = acquireVsCodeApi(); | ||
vscode.postMessage({ command: 'opt-in' }); | ||
} | ||
</script> | ||
</html>`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters