Skip to content

Commit

Permalink
Merge pull request #4320 from continuedev/nate/fix--1
Browse files Browse the repository at this point in the history
Nate/fix--1
  • Loading branch information
sestinj authored Feb 24, 2025
2 parents 2342207 + 670b3ef commit 7e42ebe
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 75 deletions.
18 changes: 12 additions & 6 deletions core/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function slashFromCustomCommand(
return {
name: customCommand.name,
description: customCommand.description ?? "",
run: async function* ({ input, llm, history, ide }) {
run: async function* ({ input, llm, history, ide, completionOptions }) {
// Remove slash command prefix from input
let userInput = input;
if (userInput.startsWith(`/${customCommand.name}`)) {
Expand All @@ -20,11 +20,16 @@ export function slashFromCustomCommand(
}

// Render prompt template
const promptUserInput = await renderTemplatedString(
customCommand.prompt,
ide.readFile.bind(ide),
{ input: userInput },
);
let promptUserInput: string;
if (customCommand.prompt.includes("{{{ input }}}")) {
promptUserInput = await renderTemplatedString(
customCommand.prompt,
ide.readFile.bind(ide),
{ input: userInput },
);
} else {
promptUserInput = customCommand.prompt + "\n\n" + userInput;
}

const messages = [...history];
// Find the last chat message with this slash command and replace it with the user input
Expand Down Expand Up @@ -67,6 +72,7 @@ export function slashFromCustomCommand(
for await (const chunk of llm.streamChat(
messages,
new AbortController().signal,
completionOptions,
)) {
yield renderChatMessage(chunk);
}
Expand Down
9 changes: 6 additions & 3 deletions core/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import { recentlyEditedFilesCache } from "./context/retrieval/recentlyEditedFile
import { ContinueServerClient } from "./continueServer/stubs/client";
import { getAuthUrlForTokenPage } from "./control-plane/auth/index";
import { getControlPlaneEnv } from "./control-plane/env";
import { DevDataSqliteDb } from "./data/devdataSqlite";
import { DataLogger } from "./data/log";
import { streamDiffLines } from "./edit/streamDiffLines";
import { CodebaseIndexer, PauseToken } from "./indexing/CodebaseIndexer";
import DocsService from "./indexing/docs/DocsService";
Expand All @@ -30,8 +32,6 @@ import { createNewPromptFileV2 } from "./promptFiles/v2/createNewPromptFile";
import { callTool } from "./tools/callTool";
import { ChatDescriber } from "./util/chatDescriber";
import { clipboardCache } from "./util/clipboardCache";
import { DataLogger } from "./data/log";
import { DevDataSqliteDb } from "./data/devdataSqlite";
import { GlobalContext } from "./util/GlobalContext";
import historyManager from "./util/history";
import {
Expand Down Expand Up @@ -131,7 +131,8 @@ export class Core {
});

// update additional submenu context providers registered via VSCode API
const additionalProviders = this.configHandler.getAdditionalSubmenuContextProviders();
const additionalProviders =
this.configHandler.getAdditionalSubmenuContextProviders();
if (additionalProviders.length > 0) {
this.messenger.send("refreshSubmenuItems", {
providers: additionalProviders,
Expand Down Expand Up @@ -651,6 +652,7 @@ export class Core {
params,
historyIndex,
selectedCode,
completionOptions,
} = msg.data;

const { config } = await configHandler.loadConfig();
Expand Down Expand Up @@ -699,6 +701,7 @@ export class Core {
config,
fetch: (url, init) =>
fetchwithRequestOptions(url, init, config.requestOptions),
completionOptions,
})) {
if (abortedMessageIds.has(msg.messageId)) {
abortedMessageIds.delete(msg.messageId);
Expand Down
1 change: 1 addition & 0 deletions core/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,7 @@ export interface ContinueSDK {
selectedCode: RangeInFile[];
config: ContinueConfig;
fetch: FetchFunction;
completionOptions?: LLMFullCompletionOptions;
}

export interface SlashCommand {
Expand Down
3 changes: 2 additions & 1 deletion core/protocol/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ProfileDescription } from "../config/ConfigHandler";
import { OrganizationDescription } from "../config/ProfileLifecycleManager";
import { SharedConfigSchema } from "../config/sharedConfig";

import { DevDataLogEvent } from "@continuedev/config-yaml";
import type {
BrowserSerializedContinueConfig,
ChatMessage,
Expand All @@ -27,7 +28,6 @@ import type {
SiteIndexingConfig,
ToolCall,
} from "../";
import { DevDataLogEvent } from "@continuedev/config-yaml";
import { GlobalContextModelSelections } from "../util/GlobalContext";

export type OnboardingModes = "Local" | "Best" | "Custom" | "Quickstart";
Expand Down Expand Up @@ -107,6 +107,7 @@ export type ToCoreFromIdeOrWebviewProtocol = {
params: any;
historyIndex: number;
selectedCode: RangeInFile[];
completionOptions?: LLMFullCompletionOptions;
},
AsyncGenerator<string>,
];
Expand Down
22 changes: 11 additions & 11 deletions gui/src/components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { exitEditMode } from "../redux/thunks";
import { loadLastSession, saveCurrentSession } from "../redux/thunks/session";
import { getFontSize, isMetaEquivalentKeyPressed } from "../util";
import { incrementFreeTrialCount } from "../util/freeTrial";
import { getLocalStorage, setLocalStorage } from "../util/localStorage";
import { ROUTES } from "../util/navigation";
import TextDialog from "./dialogs";
import Footer from "./Footer";
Expand Down Expand Up @@ -247,18 +246,19 @@ const Layout = () => {
}, [location]);

const useHub = useAppSelector(selectUseHub);

// Existing users that have already seen the onboarding card
// should be shown an intro card for hub.continue.dev
useEffect(() => {
if (useHub !== true) {
return;
}
const seenHubIntro = getLocalStorage("seenHubIntro");
if (!onboardingCard.show && !seenHubIntro) {
onboardingCard.setActiveTab("ExistingUserHubIntro");
}
setLocalStorage("seenHubIntro", true);
}, [onboardingCard.show, useHub]);
// useEffect(() => {
// if (useHub !== true) {
// return;
// }
// const seenHubIntro = getLocalStorage("seenHubIntro");
// if (!onboardingCard.show && !seenHubIntro) {
// onboardingCard.setActiveTab("ExistingUserHubIntro");
// }
// setLocalStorage("seenHubIntro", true);
// }, [onboardingCard.show, useHub]);

return (
<AuthProvider>
Expand Down
2 changes: 0 additions & 2 deletions gui/src/context/Auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
useEffect(() => {
ideMessenger.request("config/listProfiles", undefined).then((result) => {
if (result.status === "success") {
console.log("PROFILES: ", result.content);
dispatch(
updateProfilesThunk({
profiles: result.content,
Expand All @@ -179,7 +178,6 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
useWebviewListener(
"didChangeAvailableProfiles",
async (data) => {
console.log("AVAILABLE: ", data.profiles, data.selectedProfileId);
dispatch(
updateProfilesThunk({
profiles: data.profiles,
Expand Down
2 changes: 0 additions & 2 deletions gui/src/hooks/useSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ function useSetup() {
}
hasLoadedConfig.current = true;
dispatch(setConfigResult(configResult));
console.log("selecting 1", profileId);
dispatch(selectProfileThunk(profileId));

// Perform any actions needed with the config
Expand Down Expand Up @@ -95,7 +94,6 @@ function useSetup() {
useWebviewListener(
"configUpdate",
async (update) => {
console.log("CONFIG UPDATE: ", update);
if (!update) {
return;
}
Expand Down
71 changes: 36 additions & 35 deletions gui/src/pages/config/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ function ConfigPage() {
} = useAuth();

const changeProfileId = (id: string) => {
console.log("selecting 2", id);
dispatch(selectProfileThunk(id));
};

Expand Down Expand Up @@ -180,43 +179,45 @@ function ConfigPage() {
<PageHeader onTitleClick={() => navigate("/")} title="Chat" />

<div className="divide-x-0 divide-y-2 divide-solid divide-zinc-700 px-4">
<div className="flex flex-col">
<div className="flex max-w-[400px] flex-col gap-4 py-4">
<h2 className="mb-1 mt-0">Account</h2>
{!session ? (
<div className="flex flex-col gap-2">
<span>You are not signed in.</span>
<SecondaryButton onClick={() => login(false)}>
Sign in
</SecondaryButton>
</div>
) : (
<div className="flex flex-col gap-4">
{hubEnabled ? (
// Hub: show org selector
<div className="flex flex-col gap-1.5">
<span className="text-lightgray">{`Organization`}</span>
<ScopeSelect />
{(session || hubEnabled || controlServerBetaEnabled) && (
<div className="flex flex-col">
<div className="flex max-w-[400px] flex-col gap-4 py-4">
<h2 className="mb-1 mt-0">Account</h2>
{!session ? (
<div className="flex flex-col gap-2">
<span>You are not signed in.</span>
<SecondaryButton onClick={() => login(false)}>
Sign in
</SecondaryButton>
</div>
) : (
<div className="flex flex-col gap-4">
{hubEnabled ? (
// Hub: show org selector
<div className="flex flex-col gap-1.5">
<span className="text-lightgray">{`Organization`}</span>
<ScopeSelect />
</div>
) : (
// Continue for teams: show org text
<div>You are using Continue for Teams</div>
)}
<div className="flex flex-row items-center gap-2">
<span className="text-lightgray">
{session.account.label === ""
? "Signed in"
: `Signed in as ${session.account.label}`}
</span>
<span
onClick={logout}
className="text-lightgray cursor-pointer underline"
>{`Sign out`}</span>
</div>
) : (
// Continue for teams: show org text
<div>You are using Continue for Teams</div>
)}
<div className="flex flex-row items-center gap-2">
<span className="text-lightgray">
{session.account.label === ""
? "Signed in"
: `Signed in as ${session.account.label}`}
</span>
<span
onClick={logout}
className="text-lightgray cursor-pointer underline"
>{`Sign out`}</span>
</div>
</div>
)}
)}
</div>
</div>
</div>
)}

<div className="flex flex-col">
<div className="flex max-w-[400px] flex-col gap-4 py-6">
Expand Down
13 changes: 0 additions & 13 deletions gui/src/redux/thunks/profileAndOrg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ export const selectProfileThunk = createAsyncThunk<

let newId = id;

console.log(
"Running Thunk: ",
initialId,
newId,
state.session.availableProfiles,
);
// If no profiles, force clear
if (state.session.availableProfiles.length === 0) {
newId = null;
Expand All @@ -49,12 +43,6 @@ export const selectProfileThunk = createAsyncThunk<
}

// Only update if there's a change
console.log(
"update selected profile?",
newId,
initialId,
state.session.availableProfiles,
);
if ((newId ?? null) !== (initialId ?? null)) {
dispatch(
setSelectedProfile(
Expand Down Expand Up @@ -103,7 +91,6 @@ export const updateProfilesThunk = createAsyncThunk<
dispatch(setAvailableProfiles(profiles));

// This will trigger reselection if needed
console.log("selecting 3", selectedProfileId);
dispatch(selectProfileThunk(selectedProfileId));
});

Expand Down
4 changes: 2 additions & 2 deletions gui/src/redux/thunks/streamResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ const getSlashCommandForInput = (

if (lastText.startsWith("/")) {
slashCommandName = lastText.split(" ")[0].substring(1);
slashCommand = slashCommands.find(
(command) => command.name === slashCommandName,
slashCommand = slashCommands.find((command) =>
lastText.startsWith(`/${command.name} `),
);
}
if (!slashCommand || !slashCommandName) {
Expand Down
16 changes: 16 additions & 0 deletions gui/src/redux/thunks/streamSlashCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
RangeInFile,
SlashCommandDescription,
} from "core";
import { modelSupportsTools } from "core/llm/autodetect";
import { selectDefaultModel } from "../slices/configSlice";
import { abortStream, streamUpdate } from "../slices/sessionSlice";
import { ThunkApiType } from "../store";
Expand All @@ -30,11 +31,18 @@ export const streamSlashCommand = createAsyncThunk<
const defaultModel = selectDefaultModel(state);
const isStreaming = state.session.isStreaming;
const streamAborter = state.session.streamAborter;
const toolSettings = state.ui.toolSettings;

if (!defaultModel) {
throw new Error("Default model not defined");
}

const useTools = state.ui.useTools;
const includeTools =
useTools &&
modelSupportsTools(defaultModel) &&
state.session.mode === "chat";

const modelTitle = defaultModel.title;

const checkActiveInterval = setInterval(() => {
Expand All @@ -55,6 +63,14 @@ export const streamSlashCommand = createAsyncThunk<
params: slashCommand.params,
historyIndex,
selectedCode,
completionOptions: includeTools
? {
// Temporarily commented out until slash commands are hooked up to the tool use feedback loop
// tools: state.config.config.tools.filter(
// (tool) => toolSettings[tool.function.name] !== "disabled",
// ),
}
: {},
},
streamAborter.signal,
)) {
Expand Down

0 comments on commit 7e42ebe

Please sign in to comment.