Skip to content

Commit

Permalink
changed user information popup through vscode showInformationMessage (#…
Browse files Browse the repository at this point in the history
…121)


Signed-off-by: sachinsuresh-s10 <[email protected]>
  • Loading branch information
SachinS10-lab authored Nov 5, 2024
1 parent ea26426 commit 9377aa0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
25 changes: 23 additions & 2 deletions src/configureAssistant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ export class AiAssistantConfigurator {
this.apiBase = DEFAULT_API_BASE;
}

private async mightShowContinueOnboarding(configFile: string) {
const config = await readConfig(configFile);
if (!config || !config.models) {
return false;
}
return config.models.length === 1 && config.models[0].provider === "anthropic" && config.models[0].apiKey === "";
}

public async openWizard() {
if (isContinueInstalled()) {
await this.configureAssistant();
Expand All @@ -117,6 +125,8 @@ export class AiAssistantConfigurator {
if (!config) {
return vscode.window.showErrorMessage("No ~/.continue/config.json found");
}
// Check if we should show the Continue Onboarding message
const continueOnboardingMightShow = await this.mightShowContinueOnboarding(configFile);
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
const models: ModelConfig[] = config.models === undefined ? [] : config.models;
// check if model object is already in the config json
Expand Down Expand Up @@ -159,8 +169,17 @@ export class AiAssistantConfigurator {

if (updateConfig) {
await writeConfig(configFile, config);
const currentChatModel = this.request.chatModel ?? null;
let message = "Continue configuration completed.";
if (currentChatModel) {
message += ` Now select '${currentChatModel}' from Continue's chat model dropdown.`;
}
vscode.window.showInformationMessage(message);
}

if (continueOnboardingMightShow) {
vscode.window.showInformationMessage(
`Continue configuration completed.`
"If the Continue view shows onboarding options, they can safely be closed. Otherwise you risk overwriting the Granite configuration.", ""
);
}
}
Expand All @@ -177,7 +196,9 @@ function isContinueInstalled(): boolean {
return continueExt !== undefined;
}

async function readConfig(configFile: string): Promise<any> {
export const configFilePath = path.join(os.homedir(), ".continue/config.json");

export async function readConfig(configFile: string): Promise<any> {
try {
await fs.access(configFile, fs.constants.R_OK);
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion webviews/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ function App() {
<p className="m-0 mb-1">
Run <a href="https://github.com/ibm-granite/granite-code-models" target="_blank" rel="noopener noreferrer">IBM Granite Code</a> models effortlessly with
<a href="https://github.com/ollama/ollama" target="_blank" rel="noopener noreferrer"> Ollama</a> and
<a href="https://github.com/continuedev/continue" target="_blank" rel="noopener noreferrer">Continue.dev</a>.
<a href="https://github.com/continuedev/continue" target="_blank" rel="noopener noreferrer">Continue</a>.
Granite will help you write, generate, explain or document code, while your data stays secure and private on your own machine.
</p>
</div>
Expand Down

0 comments on commit 9377aa0

Please sign in to comment.