Skip to content

Commit

Permalink
Merge pull request #3846 from continuedev/nate/jb-onboarding-flow
Browse files Browse the repository at this point in the history
jb-onboarding flow
  • Loading branch information
sestinj authored Feb 12, 2025
2 parents fa1bd46 + 4ca8ee1 commit a8a5841
Show file tree
Hide file tree
Showing 18 changed files with 70 additions and 30 deletions.
2 changes: 1 addition & 1 deletion binary/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion core/config/yaml/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ async function modelConfigToBaseLLM(
return undefined;
}

const usingContinueProxy = model.provider === "continue-proxy";
const usingContinueProxy =
platformConfigMetadata && model.provider === "continue-proxy";
const modelName = usingContinueProxy
? getContinueProxyModelName(
platformConfigMetadata!.ownerSlug,
Expand Down
3 changes: 2 additions & 1 deletion core/control-plane/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import { getControlPlaneEnv } from "../env";

export async function getAuthUrlForTokenPage(
ideSettingsPromise: Promise<IdeSettings>,
useOnboarding: boolean,
): Promise<string> {
const env = await getControlPlaneEnv(ideSettingsPromise);
const url = new URL("https://api.workos.com/user_management/authorize");
const params = {
response_type: "code",
client_id: env.WORKOS_CLIENT_ID,
redirect_uri: `${env.APP_URL}tokens/callback`,
redirect_uri: `${env.APP_URL}tokens/${useOnboarding ? "onboarding-" : ""}callback`,
// redirect_uri: "http://localhost:3000/tokens/callback",
state: uuidv4(),
provider: "authkit",
Expand Down
5 changes: 4 additions & 1 deletion core/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,10 @@ export class Core {
);
});
on("auth/getAuthUrl", async (msg) => {
const url = await getAuthUrlForTokenPage(ideSettingsPromise);
const url = await getAuthUrlForTokenPage(
ideSettingsPromise,
msg.data.useOnboarding,
);
return { url };
});

Expand Down
2 changes: 1 addition & 1 deletion core/protocol/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export type ToCoreFromIdeOrWebviewProtocol = {

"profiles/switch": [{ id: string }, undefined];

"auth/getAuthUrl": [undefined, { url: string }];
"auth/getAuthUrl": [{ useOnboarding: boolean }, { url: string }];
"tools/call": [
{ toolCall: ToolCall; selectedModelTitle: string },
{ contextItems: ContextItem[] },
Expand Down
2 changes: 1 addition & 1 deletion extensions/intellij/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pluginGroup=com.github.continuedev.continueintellijextension
pluginName=continue-intellij-extension
pluginRepositoryUrl=https://github.com/continuedev/continue
# SemVer format -> https://semver.org
pluginVersion=0.0.88
pluginVersion=0.0.89
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild=223
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class ContinuePluginStartupActivity : StartupActivity, DumbAware {

connection.subscribe(AuthListener.TOPIC, object : AuthListener {
override fun startAuthFlow() {
authService.startAuthFlow(project)
authService.startAuthFlow(project, false)
}

override fun handleUpdatedSessionInfo(sessionInfo: ControlPlaneSessionInfo?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import javax.swing.JComponent
import javax.swing.JPanel
import java.awt.BorderLayout

class ContinueAuthDialog(private val onTokenEntered: (String) -> Unit) : DialogWrapper(true) {
class ContinueAuthDialog(private val useOnboarding: Boolean, private val onTokenEntered: (String) -> Unit) :
DialogWrapper(true) {
private val tokenField = JBTextField()

init {
Expand All @@ -17,7 +18,9 @@ class ContinueAuthDialog(private val onTokenEntered: (String) -> Unit) : DialogW

override fun createCenterPanel(): JComponent {
val panel = JPanel(BorderLayout())
panel.add(JBLabel("Please enter your Continue authentication token:"), BorderLayout.NORTH)
val message =
if (useOnboarding) "After onboarding you will be shown an authentication token. Please enter it here:" else "Please enter your Continue authentication token:"
panel.add(JBLabel(message), BorderLayout.NORTH)
panel.add(tokenField, BorderLayout.CENTER)
return panel
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,18 @@ class ContinueAuthService {
private const val REFRESH_TOKEN_KEY = "ContinueRefreshToken"
private const val ACCOUNT_ID_KEY = "ContinueAccountId"
private const val ACCOUNT_LABEL_KEY = "ContinueAccountLabel"
private const val CONTROL_PLANE_URL = "https://control-plane-api-service-i3dqylpbqa-uc.a.run.app"
// private const val CONTROL_PLANE_URL = "http://localhost:3001"
}

private fun getControlPlaneUrl(): String {
val env = service<ContinueExtensionSettings>().continueState.continueTestEnvironment;
when (env) {
"none" -> return "https://control-plane-api-service-i3dqylpbqa-uc.a.run.app"
"local" -> return "http://localhost:3001"
"production" -> return "https://api.continue.dev"
"test" -> return "https://api-test.continue.dev"
}

return "https://control-plane-api-service-i3dqylpbqa-uc.a.run.app"
}

init {
Expand All @@ -44,13 +54,13 @@ class ContinueAuthService {
}
}

fun startAuthFlow(project: Project) {
fun startAuthFlow(project: Project, useOnboarding: Boolean) {
// Open login page
openSignInPage(project)
openSignInPage(project, useOnboarding)

// Open a dialog where the user should paste their sign-in token
ApplicationManager.getApplication().invokeLater {
val dialog = ContinueAuthDialog() { token ->
val dialog = ContinueAuthDialog(useOnboarding) { token ->
// Store the token
updateRefreshToken(token)
}
Expand Down Expand Up @@ -78,10 +88,12 @@ class ContinueAuthService {
val lastName = user?.get("lastName") as? String
val label = "$firstName $lastName"
val id = user?.get("id") as? String
val email = user?.get("email") as? String

// Persist the session info
setRefreshToken(refreshToken!!)
val sessionInfo = ControlPlaneSessionInfo(accessToken!!, ControlPlaneSessionInfo.Account(id!!, label))
val sessionInfo =
ControlPlaneSessionInfo(accessToken!!, ControlPlaneSessionInfo.Account(email!!, label))
setControlPlaneSessionInfo(sessionInfo)

// Notify listeners
Expand Down Expand Up @@ -111,7 +123,7 @@ class ContinueAuthService {

private suspend fun refreshToken(refreshToken: String) = withContext(Dispatchers.IO) {
val client = OkHttpClient()
val url = URL(CONTROL_PLANE_URL).toURI().resolve("/auth/refresh").toURL()
val url = URL(getControlPlaneUrl()).toURI().resolve("/auth/refresh").toURL()
val jsonBody = mapOf("refreshToken" to refreshToken)
val jsonString = Gson().toJson(jsonBody)
val requestBody = jsonString.toRequestBody("application/json".toMediaType())
Expand All @@ -132,9 +144,13 @@ class ContinueAuthService {
}


private fun openSignInPage(project: Project) {
private fun openSignInPage(project: Project, useOnboarding: Boolean) {
val coreMessenger = project.service<ContinuePluginService>().coreMessenger
coreMessenger?.request("auth/getAuthUrl", null, null) { response ->
coreMessenger?.request(
"auth/getAuthUrl", mapOf(
"useOnboarding" to useOnboarding
), null
) { response ->
val authUrl = ((response as? Map<*, *>)?.get("content") as? Map<*, *>)?.get("url") as? String
if (authUrl != null) {
// Open the auth URL in the browser
Expand Down Expand Up @@ -208,7 +224,7 @@ class ContinueAuthService {
val accountId = getAccountId()
val accountLabel = getAccountLabel()

return if (accessToken != null && accountId != null && accountLabel != null) {
return if ((accessToken != null && accessToken != "") && accountId != null && accountLabel != null) {
ControlPlaneSessionInfo(
accessToken = accessToken,
account = ControlPlaneSessionInfo.Account(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class MessageTypes {
"logoutOfControlPlane",
"getTerminalContents",
"showToast",
"openUrl"
)

// Note: If updating these values, make a corresponding update in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ class GetTheme {
"--vscode-input-border" to "#80808080",
"--vscode-badge-background" to highlightHex,
"--vscode-badge-foreground" to defaultForegroundHex,
"--vscode-sideBar-border" to "#80808080"
"--vscode-sideBar-border" to "#80808080",
"--vscode-commandCenter-activeBorder" to highlightHex,
"--vscode-commandCenter-inactiveBorder" to "#80808080"
)

} catch (error: Error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class IdeProtocolClient(
"jetbrains/isOSREnabled" -> {
val isOSREnabled =
ServiceManager.getService(ContinueExtensionSettings::class.java).continueState.enableOSR
respond(isOSREnabled)
respond(isOSREnabled)
}

"jetbrains/getColors" -> {
Expand Down Expand Up @@ -96,7 +96,7 @@ class IdeProtocolClient(
val sessionInfo = authService.loadControlPlaneSessionInfo()
respond(sessionInfo)
} else {
authService.startAuthFlow(project)
authService.startAuthFlow(project, params.useOnboarding)
respond(null)
}
}
Expand All @@ -106,6 +106,10 @@ class IdeProtocolClient(
authService.signOut()
ApplicationManager.getApplication().messageBus.syncPublisher(AuthListener.TOPIC)
.handleUpdatedSessionInfo(null)

// Tell the webview that session info changed
continuePluginService.sendToWebview("didChangeControlPlaneSessionInfo", null, uuid())

respond(null)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ class IntelliJIDE(
remoteConfigSyncPeriod = settings.continueState.remoteConfigSyncPeriod,
userToken = settings.continueState.userToken ?: "",
enableControlServerBeta = settings.continueState.enableContinueTeamsBeta,
continueTestEnvironment = settings.continueState.continueTestEnvironment,
pauseCodebaseIndexOnStart = false, // TODO: Needs to be implemented
continueTestEnvironment = "none"
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.github.continuedev.continueintellijextension.protocol

import com.github.continuedev.continueintellijextension.*

data class GetControlPlaneSessionInfoParams(val silent: Boolean)
data class GetControlPlaneSessionInfoParams(val silent: Boolean, val useOnboarding: Boolean)

data class WriteFileParams(
val path: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.github.continuedev.continueintellijextension.services

import com.github.continuedev.continueintellijextension.constants.getConfigJsPath
import com.github.continuedev.continueintellijextension.constants.getConfigJsonPath
import com.intellij.execution.target.value.constant
import com.intellij.openapi.application.ApplicationInfo
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.components.*
Expand Down Expand Up @@ -33,6 +34,7 @@ class ContinueSettingsComponent : DumbAware {
val enableOSR: JCheckBox = JCheckBox("Enable Off-Screen Rendering")
val displayEditorTooltip: JCheckBox = JCheckBox("Display Editor Tooltip")
val showIDECompletionSideBySide: JCheckBox = JCheckBox("Show IDE completions side-by-side")
val enableContinueHub: JCheckBox = JCheckBox("Enable Continue Hub")

init {
val constraints = GridBagConstraints()
Expand Down Expand Up @@ -66,6 +68,8 @@ class ContinueSettingsComponent : DumbAware {
constraints.gridy++
panel.add(showIDECompletionSideBySide, constraints)
constraints.gridy++
panel.add(enableContinueHub, constraints)
constraints.gridy++

// Add a "filler" component that takes up all remaining vertical space
constraints.weighty = 1.0
Expand Down Expand Up @@ -212,7 +216,8 @@ class ContinueExtensionConfigurable : Configurable {
mySettingsComponent?.enableContinueTeamsBeta?.isSelected != settings.continueState.enableContinueTeamsBeta ||
mySettingsComponent?.enableOSR?.isSelected != settings.continueState.enableOSR ||
mySettingsComponent?.displayEditorTooltip?.isSelected != settings.continueState.displayEditorTooltip ||
mySettingsComponent?.showIDECompletionSideBySide?.isSelected != settings.continueState.showIDECompletionSideBySide
mySettingsComponent?.showIDECompletionSideBySide?.isSelected != settings.continueState.showIDECompletionSideBySide ||
(if (mySettingsComponent?.enableContinueHub?.isSelected == true) settings.continueState.continueTestEnvironment != "production" else settings.continueState.continueTestEnvironment == "production")
return modified
}

Expand All @@ -228,6 +233,8 @@ class ContinueExtensionConfigurable : Configurable {
settings.continueState.displayEditorTooltip = mySettingsComponent?.displayEditorTooltip?.isSelected ?: true
settings.continueState.showIDECompletionSideBySide =
mySettingsComponent?.showIDECompletionSideBySide?.isSelected ?: false
settings.continueState.continueTestEnvironment =
if (mySettingsComponent?.enableContinueHub?.isSelected == true) "production" else "none"

ApplicationManager.getApplication().messageBus.syncPublisher(SettingsListener.TOPIC)
.settingsUpdated(settings.continueState)
Expand All @@ -245,6 +252,8 @@ class ContinueExtensionConfigurable : Configurable {
mySettingsComponent?.displayEditorTooltip?.isSelected = settings.continueState.displayEditorTooltip
mySettingsComponent?.showIDECompletionSideBySide?.isSelected =
settings.continueState.showIDECompletionSideBySide
mySettingsComponent?.enableContinueHub?.isSelected =
settings.continueState.continueTestEnvironment == "production"

ContinueExtensionSettings.instance.addRemoteSyncJob()
}
Expand Down
4 changes: 2 additions & 2 deletions extensions/vscode/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion extensions/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "continue",
"icon": "media/icon.png",
"author": "Continue Dev, Inc",
"version": "0.9.264",
"version": "0.9.265",
"repository": {
"type": "git",
"url": "https://github.com/continuedev/continue"
Expand Down
4 changes: 2 additions & 2 deletions gui/src/components/modelSelection/platform/AssistantIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ComputerDesktopIcon, SparklesIcon } from "@heroicons/react/24/outline";
import { ProfileDescription } from "core/config/ProfileLifecycleManager";
import { isLocalProfile } from "../../../util";
import { ComputerDesktopIcon, SparklesIcon } from "@heroicons/react/24/outline";

export interface AssistantIconProps {
assistant: ProfileDescription;
Expand All @@ -10,7 +10,7 @@ export default function AssistantIcon({ assistant }: AssistantIconProps) {
if (isLocalProfile(assistant)) {
return <ComputerDesktopIcon />;
} else if (assistant.iconUrl) {
return <img src={assistant.iconUrl} className="rounded-full" />;
return <img src={assistant.iconUrl} className="h-4 w-4 rounded-full" />;
} else {
return <SparklesIcon />;
}
Expand Down

0 comments on commit a8a5841

Please sign in to comment.