feat: select assistant polishes (#7218)
* add login logout buttons and remove padding * remove logout button from list * create a new assistant file when signed out * added tooltip and hover
This commit is contained in:
parent
c37c8111f7
commit
1ce60a0091
6 changed files with 113 additions and 32 deletions
62
core/config/createNewAssistantFile.ts
Normal file
62
core/config/createNewAssistantFile.ts
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
import { IDE } from "..";
|
||||
import { joinPathsToUri } from "../util/uri";
|
||||
|
||||
const DEFAULT_ASSISTANT_FILE = `# This is an example assistant configuration file
|
||||
# It is used to define custom AI assistants within Continue
|
||||
# Each assistant file can be accessed by selecting it from the assistant dropdown
|
||||
|
||||
# To learn more, see the full assistant reference: https://docs.continue.dev/reference
|
||||
|
||||
name: Example Assistant
|
||||
version: 1.0.0
|
||||
schema: v1
|
||||
|
||||
# Models define which AI models this assistant can use
|
||||
models:
|
||||
- name: my gpt-5
|
||||
provider: openai
|
||||
model: gpt-5
|
||||
apiKey: YOUR_API_KEY_HERE
|
||||
|
||||
# Context providers define what information the assistant can access
|
||||
context:
|
||||
- provider: code
|
||||
- provider: docs
|
||||
- provider: diff
|
||||
- provider: terminal
|
||||
- provider: problems
|
||||
- provider: folder
|
||||
- provider: codebase
|
||||
`;
|
||||
|
||||
export async function createNewAssistantFile(
|
||||
ide: IDE,
|
||||
assistantPath: string | undefined,
|
||||
): Promise<void> {
|
||||
const workspaceDirs = await ide.getWorkspaceDirs();
|
||||
if (workspaceDirs.length === 0) {
|
||||
throw new Error(
|
||||
"No workspace directories found. Make sure you've opened a folder in your IDE.",
|
||||
);
|
||||
}
|
||||
|
||||
const baseDirUri = joinPathsToUri(
|
||||
workspaceDirs[0],
|
||||
assistantPath ?? ".continue/assistants",
|
||||
);
|
||||
|
||||
// Find the first available filename
|
||||
let counter = 0;
|
||||
let assistantFileUri: string;
|
||||
do {
|
||||
const suffix = counter === 0 ? "" : `-${counter}`;
|
||||
assistantFileUri = joinPathsToUri(
|
||||
baseDirUri,
|
||||
`new-assistant${suffix}.yaml`,
|
||||
);
|
||||
counter++;
|
||||
} while (await ide.fileExists(assistantFileUri));
|
||||
|
||||
await ide.writeFile(assistantFileUri, DEFAULT_ASSISTANT_FILE);
|
||||
await ide.openFile(assistantFileUri);
|
||||
}
|
||||
|
|
@ -51,6 +51,7 @@ import {
|
|||
import { BLOCK_TYPES, ConfigYaml } from "@continuedev/config-yaml";
|
||||
import { getDiffFn, GitDiffCache } from "./autocomplete/snippets/gitDiffCache";
|
||||
import { stringifyMcpPrompt } from "./commands/slash/mcpSlashCommand";
|
||||
import { createNewAssistantFile } from "./config/createNewAssistantFile";
|
||||
import { isLocalDefinitionFile } from "./config/loadLocalAssistants";
|
||||
import { CodebaseRulesCache } from "./config/markdown/loadCodebaseRules";
|
||||
import {
|
||||
|
|
@ -354,6 +355,13 @@ export class Core {
|
|||
);
|
||||
});
|
||||
|
||||
on("config/newAssistantFile", async (msg) => {
|
||||
await createNewAssistantFile(this.ide, undefined);
|
||||
await this.configHandler.reloadConfig(
|
||||
"Assistant file created (config/newAssistantFile message)",
|
||||
);
|
||||
});
|
||||
|
||||
on("config/addLocalWorkspaceBlock", async (msg) => {
|
||||
await createNewWorkspaceBlockFile(this.ide, msg.data.blockType);
|
||||
await this.configHandler.reloadConfig(
|
||||
|
|
|
|||
|
|
@ -49,8 +49,8 @@ import {
|
|||
ControlPlaneSessionInfo,
|
||||
} from "../control-plane/AuthTypes";
|
||||
import { FreeTrialStatus } from "../control-plane/client";
|
||||
import { NextEditOutcome } from "../nextEdit/types";
|
||||
import { ProcessedItem } from "../nextEdit/NextEditPrefetchQueue";
|
||||
import { NextEditOutcome } from "../nextEdit/types";
|
||||
|
||||
export enum OnboardingModes {
|
||||
API_KEY = "API Key",
|
||||
|
|
@ -86,6 +86,7 @@ export type ToCoreFromIdeOrWebviewProtocol = {
|
|||
];
|
||||
"config/addLocalWorkspaceBlock": [{ blockType: BlockType }, void];
|
||||
"config/newPromptFile": [undefined, void];
|
||||
"config/newAssistantFile": [undefined, void];
|
||||
"config/ideSettingsUpdate": [IdeSettings, void];
|
||||
"config/getSerializedProfileInfo": [
|
||||
undefined,
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] =
|
|||
"devdata/log",
|
||||
"config/addModel",
|
||||
"config/newPromptFile",
|
||||
"config/newAssistantFile",
|
||||
"config/ideSettingsUpdate",
|
||||
"config/addLocalWorkspaceBlock",
|
||||
"config/getSerializedProfileInfo",
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ class MessageTypes {
|
|||
"devdata/log",
|
||||
"config/addModel",
|
||||
"config/newPromptFile",
|
||||
"config/newAssistantFile",
|
||||
"config/ideSettingsUpdate",
|
||||
"config/addLocalWorkspaceBlock",
|
||||
"config/getSerializedProfileInfo",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,9 @@
|
|||
import { ArrowPathIcon, PlusIcon } from "@heroicons/react/24/outline";
|
||||
import {
|
||||
ArrowPathIcon,
|
||||
ArrowRightEndOnRectangleIcon,
|
||||
ArrowRightStartOnRectangleIcon,
|
||||
PlusIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { AuthType, isOnPremSession } from "core/control-plane/AuthTypes";
|
||||
import { useContext, useEffect, useRef } from "react";
|
||||
import { useAuth } from "../../context/Auth";
|
||||
|
|
@ -10,7 +15,7 @@ import {
|
|||
} from "../../redux/slices/profilesSlice";
|
||||
import { getMetaKeyLabel, isMetaEquivalentKeyPressed } from "../../util";
|
||||
import { cn } from "../../util/cn";
|
||||
import { useLump } from "../mainInput/Lump/LumpContext";
|
||||
import { ToolTip } from "../gui/Tooltip";
|
||||
import {
|
||||
Listbox,
|
||||
ListboxOption,
|
||||
|
|
@ -27,7 +32,6 @@ export function AssistantAndOrgListbox() {
|
|||
const listboxRef = useRef<HTMLDivElement>(null);
|
||||
const currentOrg = useAppSelector(selectCurrentOrg);
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const { isToolbarExpanded } = useLump();
|
||||
const {
|
||||
profiles,
|
||||
selectedProfile,
|
||||
|
|
@ -38,7 +42,6 @@ export function AssistantAndOrgListbox() {
|
|||
refreshProfiles,
|
||||
} = useAuth();
|
||||
const configLoading = useAppSelector((store) => store.config.loading);
|
||||
const smallFont = useFontSize(-3);
|
||||
const tinyFont = useFontSize(-4);
|
||||
const shouldRenderOrgInfo =
|
||||
session && organizations.length > 1 && !isOnPremSession(session);
|
||||
|
|
@ -50,10 +53,14 @@ export function AssistantAndOrgListbox() {
|
|||
}
|
||||
|
||||
function onNewAssistant() {
|
||||
void ideMessenger.request("controlPlane/openUrl", {
|
||||
path: "/new",
|
||||
orgSlug: currentOrg?.slug,
|
||||
});
|
||||
if (session) {
|
||||
void ideMessenger.request("controlPlane/openUrl", {
|
||||
path: "/new",
|
||||
orgSlug: currentOrg?.slug,
|
||||
});
|
||||
} else {
|
||||
void ideMessenger.request("config/newAssistantFile", undefined);
|
||||
}
|
||||
close();
|
||||
}
|
||||
|
||||
|
|
@ -108,12 +115,29 @@ export function AssistantAndOrgListbox() {
|
|||
<div className="relative" ref={listboxRef}>
|
||||
<SelectedAssistantButton selectedProfile={selectedProfile} />
|
||||
<Transition>
|
||||
<ListboxOptions className="-translate-x-1.5 pb-0">
|
||||
<div className="border-border border-x-0 border-t-0 border-solid px-2 py-3">
|
||||
<div className="flex flex-col gap-2 pb-1 pl-1">
|
||||
{session && session?.AUTH_TYPE !== AuthType.OnPrem && (
|
||||
<span className="text-description-muted flex items-center pb-1">
|
||||
{session?.account.id}
|
||||
<ListboxOptions
|
||||
className="-translate-x-1.5 pb-0"
|
||||
style={{ zIndex: 200 }}
|
||||
>
|
||||
<div className="border-border border-x-0 border-t-0 border-solid px-2 py-2">
|
||||
<div className="flex flex-col gap-2 pl-1">
|
||||
{session ? (
|
||||
<span className="text-description-muted flex items-center justify-between gap-x-1">
|
||||
{session?.AUTH_TYPE !== AuthType.OnPrem &&
|
||||
session?.account.id}
|
||||
<ArrowRightStartOnRectangleIcon
|
||||
className="h-3 w-3 cursor-pointer hover:brightness-125"
|
||||
onClick={onLogout}
|
||||
data-tooltip-id="logout-tooltip"
|
||||
/>
|
||||
<ToolTip id="logout-tooltip">Logout</ToolTip>
|
||||
</span>
|
||||
) : (
|
||||
<span
|
||||
className="text-description-muted flex cursor-pointer items-center justify-end gap-x-1 hover:brightness-125"
|
||||
onClick={() => login(false)}
|
||||
>
|
||||
Log In <ArrowRightEndOnRectangleIcon className="h-3 w-3" />
|
||||
</span>
|
||||
)}
|
||||
{shouldRenderOrgInfo && (
|
||||
|
|
@ -138,7 +162,7 @@ export function AssistantAndOrgListbox() {
|
|||
value="new-assistant"
|
||||
fontSizeModifier={-2}
|
||||
className="border-border border-b px-2 py-1.5"
|
||||
onClick={session ? onNewAssistant : () => login(false)}
|
||||
onClick={onNewAssistant}
|
||||
>
|
||||
<span
|
||||
className="text-description flex flex-row items-center"
|
||||
|
|
@ -170,22 +194,6 @@ export function AssistantAndOrgListbox() {
|
|||
</span>
|
||||
</ListboxOption>
|
||||
|
||||
{session && (
|
||||
<ListboxOption
|
||||
value="log-out"
|
||||
fontSizeModifier={-2}
|
||||
className="border-border border-b px-3 py-1.5"
|
||||
onClick={onLogout}
|
||||
>
|
||||
<div
|
||||
className="text-description flex flex-row items-center"
|
||||
style={{ fontSize: tinyFont }}
|
||||
>
|
||||
Log out
|
||||
</div>
|
||||
</ListboxOption>
|
||||
)}
|
||||
|
||||
<div
|
||||
className="text-description border-border flex items-center justify-between gap-1.5 border-x-0 border-b-0 border-t border-solid px-2 py-2"
|
||||
style={{ fontSize: tinyFont }}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue