Final release cleanup: remove CLI banner & Generate Rule, explicit onboarding/config models, deprecation link (#12634)
* chore: remove CLI-install banner and Generate Rule feature, use explicit onboarding models - Remove CliInstallBanner component, test, and dismissal localStorage key - Remove "Generate Rule" button, GenerateRuleDialog, command, and protocol message - Convert onboarding and new-assistant template off Hub `uses:` slugs to explicit model definitions - Update deprecation banner export link to https://continue.dev/export Co-authored-by: Cursor <cursoragent@cursor.com> * chore: bump vscode extension version to 1.3.40 Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
eaa23c5a9d
commit
10639a20f2
19 changed files with 117 additions and 1424 deletions
|
|
@ -15,15 +15,28 @@ models:
|
|||
provider: openai
|
||||
model: gpt-5
|
||||
apiKey: YOUR_OPENAI_API_KEY_HERE
|
||||
- uses: ollama/qwen2.5-coder-7b
|
||||
- uses: anthropic/claude-4-sonnet
|
||||
with:
|
||||
ANTHROPIC_API_KEY: \${{ secrets.ANTHROPIC_API_KEY }}
|
||||
|
||||
# MCP Servers that Continue can access
|
||||
# https://docs.continue.dev/customization/mcp-tools
|
||||
mcpServers:
|
||||
- uses: anthropic/memory-mcp
|
||||
- name: qwen2.5-coder 7b
|
||||
provider: ollama
|
||||
model: qwen2.5-coder:7b
|
||||
roles:
|
||||
- apply
|
||||
- autocomplete
|
||||
- chat
|
||||
- edit
|
||||
- name: Claude 4 Sonnet
|
||||
provider: anthropic
|
||||
model: claude-sonnet-4-20250514
|
||||
apiKey: \${{ secrets.ANTHROPIC_API_KEY }}
|
||||
roles:
|
||||
- chat
|
||||
- edit
|
||||
- apply
|
||||
defaultCompletionOptions:
|
||||
contextLength: 200000
|
||||
maxTokens: 64000
|
||||
capabilities:
|
||||
- tool_use
|
||||
- image_input
|
||||
`;
|
||||
|
||||
export async function createNewAssistantFile(
|
||||
|
|
|
|||
|
|
@ -8,20 +8,84 @@ export const LOCAL_ONBOARDING_CHAT_TITLE = "Llama 3.1 8B";
|
|||
export const LOCAL_ONBOARDING_EMBEDDINGS_MODEL = "nomic-embed-text:latest";
|
||||
export const LOCAL_ONBOARDING_EMBEDDINGS_TITLE = "Nomic Embed";
|
||||
|
||||
const ANTHROPIC_MODEL_CONFIG = {
|
||||
slugs: ["anthropic/claude-sonnet-4-6", "anthropic/claude-opus-4-6"],
|
||||
apiKeyInputName: "ANTHROPIC_API_KEY",
|
||||
};
|
||||
const OPENAI_MODEL_CONFIG = {
|
||||
slugs: ["openai/gpt-4.1", "openai/o3", "openai/gpt-4.1-mini"],
|
||||
apiKeyInputName: "OPENAI_API_KEY",
|
||||
};
|
||||
type OnboardingModel = NonNullable<ConfigYaml["models"]>[number];
|
||||
|
||||
// TODO: These need updating on the hub
|
||||
const GEMINI_MODEL_CONFIG = {
|
||||
slugs: ["google/gemini-3.1-pro-preview", "google/gemini-3-flash-preview"],
|
||||
apiKeyInputName: "GEMINI_API_KEY",
|
||||
};
|
||||
// These model definitions are inlined copies of the corresponding Continue Hub
|
||||
// blocks (e.g. anthropic/claude-sonnet-4-6) that onboarding previously resolved
|
||||
// via `uses:` slugs. Since Hub/slug resolution has been removed, we reproduce
|
||||
// the exact block contents here, with `apiKey` substituted for the block's
|
||||
// `${{ inputs.*_API_KEY }}` placeholder. Keep these in sync with the Hub blocks.
|
||||
const ANTHROPIC_ONBOARDING_MODELS = (apiKey: string): OnboardingModel[] => [
|
||||
{
|
||||
name: "Claude Sonnet 4.6",
|
||||
provider: "anthropic",
|
||||
model: "claude-sonnet-4-6",
|
||||
apiKey,
|
||||
roles: ["chat", "edit", "apply"],
|
||||
defaultCompletionOptions: { contextLength: 200000, maxTokens: 64000 },
|
||||
capabilities: ["tool_use", "image_input"],
|
||||
},
|
||||
{
|
||||
name: "Claude Opus 4.6",
|
||||
provider: "anthropic",
|
||||
model: "claude-opus-4-6",
|
||||
apiKey,
|
||||
roles: ["chat", "edit", "apply"],
|
||||
defaultCompletionOptions: { contextLength: 200000, maxTokens: 64000 },
|
||||
capabilities: ["tool_use", "image_input"],
|
||||
},
|
||||
];
|
||||
|
||||
const OPENAI_ONBOARDING_MODELS = (apiKey: string): OnboardingModel[] => [
|
||||
{
|
||||
name: "OpenAI GPT-4.1",
|
||||
provider: "openai",
|
||||
model: "gpt-4.1-2025-04-14",
|
||||
apiKey,
|
||||
roles: ["chat", "edit", "apply"],
|
||||
defaultCompletionOptions: { contextLength: 1047576, maxTokens: 32768 },
|
||||
useLegacyCompletionsEndpoint: false,
|
||||
},
|
||||
{
|
||||
name: "o3",
|
||||
provider: "openai",
|
||||
model: "o3",
|
||||
apiKey,
|
||||
roles: ["chat"],
|
||||
defaultCompletionOptions: { contextLength: 200000, maxTokens: 100000 },
|
||||
capabilities: ["image_input"],
|
||||
},
|
||||
{
|
||||
name: "OpenAI GPT-4.1 mini",
|
||||
provider: "openai",
|
||||
model: "gpt-4.1-mini-2025-04-14",
|
||||
apiKey,
|
||||
roles: ["chat", "edit", "apply"],
|
||||
defaultCompletionOptions: { contextLength: 1047576, maxTokens: 32768 },
|
||||
useLegacyCompletionsEndpoint: false,
|
||||
},
|
||||
];
|
||||
|
||||
const GEMINI_ONBOARDING_MODELS = (apiKey: string): OnboardingModel[] => [
|
||||
{
|
||||
name: "Gemini 3 Pro Preview",
|
||||
provider: "gemini",
|
||||
model: "gemini-3-pro-preview",
|
||||
apiKey,
|
||||
roles: ["chat", "edit", "apply"],
|
||||
defaultCompletionOptions: { contextLength: 1048576, maxTokens: 65536 },
|
||||
capabilities: ["tool_use", "image_input"],
|
||||
},
|
||||
{
|
||||
name: "Gemini 3 Flash Preview",
|
||||
provider: "gemini",
|
||||
model: "gemini-3-flash-preview",
|
||||
apiKey,
|
||||
roles: ["chat", "edit", "apply"],
|
||||
defaultCompletionOptions: { contextLength: 1048576, maxTokens: 65536 },
|
||||
capabilities: ["tool_use", "image_input"],
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* We set the "best" chat + autocopmlete models by default
|
||||
|
|
@ -70,32 +134,17 @@ export function setupProviderConfig(
|
|||
provider: string,
|
||||
apiKey: string,
|
||||
): ConfigYaml {
|
||||
let newModels;
|
||||
let newModels: OnboardingModel[];
|
||||
|
||||
switch (provider) {
|
||||
case "openai":
|
||||
newModels = OPENAI_MODEL_CONFIG.slugs.map((slug) => ({
|
||||
uses: slug,
|
||||
with: {
|
||||
[OPENAI_MODEL_CONFIG.apiKeyInputName]: apiKey,
|
||||
},
|
||||
}));
|
||||
newModels = OPENAI_ONBOARDING_MODELS(apiKey);
|
||||
break;
|
||||
case "anthropic":
|
||||
newModels = ANTHROPIC_MODEL_CONFIG.slugs.map((slug) => ({
|
||||
uses: slug,
|
||||
with: {
|
||||
[ANTHROPIC_MODEL_CONFIG.apiKeyInputName]: apiKey,
|
||||
},
|
||||
}));
|
||||
newModels = ANTHROPIC_ONBOARDING_MODELS(apiKey);
|
||||
break;
|
||||
case "gemini":
|
||||
newModels = GEMINI_MODEL_CONFIG.slugs.map((slug) => ({
|
||||
uses: slug,
|
||||
with: {
|
||||
[GEMINI_MODEL_CONFIG.apiKeyInputName]: apiKey,
|
||||
},
|
||||
}));
|
||||
newModels = GEMINI_ONBOARDING_MODELS(apiKey);
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unknown provider: ${provider}`);
|
||||
|
|
@ -103,14 +152,19 @@ export function setupProviderConfig(
|
|||
|
||||
const existingModels = config.models ?? [];
|
||||
|
||||
// Update API key on existing models; add new entries for any missing slugs
|
||||
const isSameModel = (m: OnboardingModel, n: OnboardingModel) =>
|
||||
"provider" in m &&
|
||||
"provider" in n &&
|
||||
m.provider === n.provider &&
|
||||
m.model === n.model;
|
||||
|
||||
// Update API key on existing models; add new entries for any missing models
|
||||
const updatedModels = existingModels.map((m) => {
|
||||
if (!("uses" in m)) return m;
|
||||
const match = newModels.find((n) => n.uses === m.uses);
|
||||
return match ? { ...m, with: { ...m.with, ...match.with } } : m;
|
||||
const match = newModels.find((n) => isSameModel(m, n));
|
||||
return match ? { ...m, apiKey } : m;
|
||||
});
|
||||
const modelsToAdd = newModels.filter(
|
||||
(n) => !existingModels.some((m) => "uses" in m && m.uses === n.uses),
|
||||
(n) => !existingModels.some((m) => isSameModel(m, n)),
|
||||
);
|
||||
|
||||
return { ...config, models: [...updatedModels, ...modelsToAdd] };
|
||||
|
|
|
|||
|
|
@ -78,6 +78,5 @@ export type ToWebviewFromIdeProtocol = ToWebviewFromIdeOrCoreProtocol & {
|
|||
updateApplyState: [ApplyState, void];
|
||||
exitEditMode: [undefined, void];
|
||||
focusEdit: [undefined, void];
|
||||
generateRule: [undefined, void];
|
||||
addToChat: [AddToChatPayload, void];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"name": "continue",
|
||||
"icon": "media/icon.png",
|
||||
"author": "Continue Dev, Inc",
|
||||
"version": "1.3.39",
|
||||
"version": "1.3.40",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/continuedev/continue"
|
||||
|
|
@ -370,12 +370,6 @@
|
|||
"category": "Continue",
|
||||
"title": "Continue: Reject Jump Suggestion"
|
||||
},
|
||||
{
|
||||
"command": "continue.generateRule",
|
||||
"category": "Continue",
|
||||
"title": "Generate Rule",
|
||||
"group": "Continue"
|
||||
},
|
||||
{
|
||||
"command": "continue.openInNewWindow",
|
||||
"category": "Continue",
|
||||
|
|
@ -524,9 +518,6 @@
|
|||
{
|
||||
"command": "continue.enterEnterpriseLicenseKey"
|
||||
},
|
||||
{
|
||||
"command": "continue.generateRule"
|
||||
},
|
||||
{
|
||||
"command": "continue.openInNewWindow"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -323,10 +323,6 @@ const getCommandsMap: (
|
|||
editDecorationManager.clear();
|
||||
void sidebar.webviewProtocol?.request("exitEditMode", undefined);
|
||||
},
|
||||
"continue.generateRule": async () => {
|
||||
focusGUI();
|
||||
void sidebar.webviewProtocol?.request("generateRule", undefined);
|
||||
},
|
||||
"continue.writeCommentsForCode": async () => {
|
||||
streamInlineEdit(
|
||||
"comment",
|
||||
|
|
|
|||
|
|
@ -1,491 +0,0 @@
|
|||
import {
|
||||
act,
|
||||
fireEvent,
|
||||
render,
|
||||
screen,
|
||||
waitFor,
|
||||
} from "@testing-library/react";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { IdeMessengerContext } from "../context/IdeMessenger";
|
||||
import { MockIdeMessenger } from "../context/MockIdeMessenger";
|
||||
import * as util from "../util";
|
||||
import * as localStorage from "../util/localStorage";
|
||||
import { CliInstallBanner } from "./CliInstallBanner";
|
||||
|
||||
vi.mock("../util", async () => {
|
||||
const actual = await vi.importActual("../util");
|
||||
return {
|
||||
...actual,
|
||||
getPlatform: vi.fn(),
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("../util/localStorage", async () => {
|
||||
const actual = await vi.importActual("../util/localStorage");
|
||||
return {
|
||||
...actual,
|
||||
getLocalStorage: vi.fn(),
|
||||
setLocalStorage: vi.fn(),
|
||||
};
|
||||
});
|
||||
|
||||
describe("CliInstallBanner", () => {
|
||||
let mockIdeMessenger: MockIdeMessenger;
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
mockIdeMessenger = new MockIdeMessenger();
|
||||
vi.mocked(util.getPlatform).mockReturnValue("mac");
|
||||
vi.mocked(localStorage.getLocalStorage).mockReturnValue(undefined);
|
||||
});
|
||||
|
||||
const renderComponent = async (subprocessResponse: [string, string]) => {
|
||||
// Mock the subprocess call on the IDE
|
||||
vi.spyOn(mockIdeMessenger.ide, "subprocess").mockResolvedValue(
|
||||
subprocessResponse,
|
||||
);
|
||||
|
||||
return act(async () =>
|
||||
render(
|
||||
<IdeMessengerContext.Provider value={mockIdeMessenger}>
|
||||
<CliInstallBanner />
|
||||
</IdeMessengerContext.Provider>,
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
describe("CLI detection", () => {
|
||||
it("does not render when CLI is installed (subprocess returns path)", async () => {
|
||||
await renderComponent(["/usr/local/bin/cn", ""]);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.queryByText("Try out the Continue CLI"),
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it("renders when CLI is not installed (subprocess returns empty)", async () => {
|
||||
await renderComponent(["", "command not found"]);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.getByText("Try out the Continue CLI"),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it("renders when CLI is not installed (subprocess returns empty stdout)", async () => {
|
||||
await renderComponent(["", ""]);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.getByText("Try out the Continue CLI"),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it("uses 'which cn' command on mac platform", async () => {
|
||||
vi.mocked(util.getPlatform).mockReturnValue("mac");
|
||||
const subprocessSpy = vi
|
||||
.spyOn(mockIdeMessenger.ide, "subprocess")
|
||||
.mockResolvedValue(["", ""]);
|
||||
|
||||
await act(async () =>
|
||||
render(
|
||||
<IdeMessengerContext.Provider value={mockIdeMessenger}>
|
||||
<CliInstallBanner />
|
||||
</IdeMessengerContext.Provider>,
|
||||
),
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(subprocessSpy).toHaveBeenCalledWith("which cn");
|
||||
});
|
||||
});
|
||||
|
||||
it("uses 'which cn' command on linux platform", async () => {
|
||||
vi.mocked(util.getPlatform).mockReturnValue("linux");
|
||||
const subprocessSpy = vi
|
||||
.spyOn(mockIdeMessenger.ide, "subprocess")
|
||||
.mockResolvedValue(["", ""]);
|
||||
|
||||
await act(async () =>
|
||||
render(
|
||||
<IdeMessengerContext.Provider value={mockIdeMessenger}>
|
||||
<CliInstallBanner />
|
||||
</IdeMessengerContext.Provider>,
|
||||
),
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(subprocessSpy).toHaveBeenCalledWith("which cn");
|
||||
});
|
||||
});
|
||||
|
||||
it("uses 'where cn' command on windows platform", async () => {
|
||||
vi.mocked(util.getPlatform).mockReturnValue("windows");
|
||||
const subprocessSpy = vi
|
||||
.spyOn(mockIdeMessenger.ide, "subprocess")
|
||||
.mockResolvedValue(["", ""]);
|
||||
|
||||
await act(async () =>
|
||||
render(
|
||||
<IdeMessengerContext.Provider value={mockIdeMessenger}>
|
||||
<CliInstallBanner />
|
||||
</IdeMessengerContext.Provider>,
|
||||
),
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(subprocessSpy).toHaveBeenCalledWith("where cn");
|
||||
});
|
||||
});
|
||||
|
||||
it("handles subprocess errors gracefully", async () => {
|
||||
vi.spyOn(mockIdeMessenger.ide, "subprocess").mockRejectedValue(
|
||||
new Error("Command failed"),
|
||||
);
|
||||
|
||||
await act(async () =>
|
||||
render(
|
||||
<IdeMessengerContext.Provider value={mockIdeMessenger}>
|
||||
<CliInstallBanner />
|
||||
</IdeMessengerContext.Provider>,
|
||||
),
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.getByText("Try out the Continue CLI"),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Banner content", () => {
|
||||
beforeEach(async () => {
|
||||
await renderComponent(["", "not found"]);
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.getByText("Try out the Continue CLI"),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it("displays the title", () => {
|
||||
expect(screen.getByText("Try out the Continue CLI")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("displays the description with 'cn' code element", () => {
|
||||
const description = screen.getByText(/Use/);
|
||||
expect(description).toBeInTheDocument();
|
||||
expect(screen.getByText("cn")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("displays the installation command", () => {
|
||||
expect(screen.getByText("npm i -g @continuedev/cli")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("displays the Learn more link", () => {
|
||||
expect(screen.getByText("Learn more.")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("displays the close button", () => {
|
||||
// Get the styled close button (it doesn't have a text label)
|
||||
const buttons = screen.getAllByRole("button");
|
||||
// There should be multiple buttons (close, copy, run)
|
||||
expect(buttons.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it("displays the CommandLine icon", () => {
|
||||
// The icon should be present in the component
|
||||
const banner = screen
|
||||
.getByText("Try out the Continue CLI")
|
||||
.closest("div");
|
||||
expect(banner).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe("User interactions", () => {
|
||||
beforeEach(async () => {
|
||||
await renderComponent(["", "not found"]);
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.getByText("Try out the Continue CLI"),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it("dismisses banner when close button is clicked", async () => {
|
||||
const buttons = screen.getAllByRole("button");
|
||||
// First button should be the close button (CloseButton component)
|
||||
const closeButton = buttons[0];
|
||||
fireEvent.click(closeButton);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.queryByText("Try out the Continue CLI"),
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it("opens documentation URL when Learn more link is clicked", async () => {
|
||||
const postSpy = vi.spyOn(mockIdeMessenger, "post");
|
||||
const learnMoreLink = screen.getByText("Learn more.");
|
||||
|
||||
fireEvent.click(learnMoreLink);
|
||||
|
||||
expect(postSpy).toHaveBeenCalledWith(
|
||||
"openUrl",
|
||||
"https://docs.continue.dev/guides/cli",
|
||||
);
|
||||
});
|
||||
|
||||
it("displays the installation command with interactive controls", async () => {
|
||||
// The installation command should be visible
|
||||
expect(screen.getByText("npm i -g @continuedev/cli")).toBeInTheDocument();
|
||||
// The "Run" text should be visible for the run button
|
||||
expect(screen.getByText(/Run/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("runs installation command in terminal when run button is clicked", async () => {
|
||||
const postSpy = vi.spyOn(mockIdeMessenger, "post");
|
||||
|
||||
// Find the "Run" text or CommandLineIcon
|
||||
const runButton = screen.getByText(/Run/i).closest("div");
|
||||
if (runButton) {
|
||||
fireEvent.click(runButton);
|
||||
|
||||
expect(postSpy).toHaveBeenCalledWith("runCommand", {
|
||||
command: `npm i -g @continuedev/cli && cn "Explore this repo and provide a concise summary of it's contents"`,
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("Banner visibility states", () => {
|
||||
it("does not render while CLI check is loading", async () => {
|
||||
vi.spyOn(mockIdeMessenger.ide, "subprocess").mockImplementation(
|
||||
() =>
|
||||
new Promise((resolve) => setTimeout(() => resolve(["", ""]), 100)),
|
||||
);
|
||||
|
||||
await act(async () =>
|
||||
render(
|
||||
<IdeMessengerContext.Provider value={mockIdeMessenger}>
|
||||
<CliInstallBanner />
|
||||
</IdeMessengerContext.Provider>,
|
||||
),
|
||||
);
|
||||
|
||||
// Should not be visible immediately
|
||||
expect(
|
||||
screen.queryByText("Try out the Continue CLI"),
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("remains hidden after dismissal even on re-render", async () => {
|
||||
const { rerender } = await renderComponent(["", "not found"]);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.getByText("Try out the Continue CLI"),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
// Dismiss the banner
|
||||
const buttons = screen.getAllByRole("button");
|
||||
const closeButton = buttons[0];
|
||||
fireEvent.click(closeButton);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.queryByText("Try out the Continue CLI"),
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
// Re-render the component
|
||||
rerender(
|
||||
<IdeMessengerContext.Provider value={mockIdeMessenger}>
|
||||
<CliInstallBanner />
|
||||
</IdeMessengerContext.Provider>,
|
||||
);
|
||||
|
||||
// Should still be hidden
|
||||
expect(
|
||||
screen.queryByText("Try out the Continue CLI"),
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe("Edge cases", () => {
|
||||
it("handles whitespace in subprocess output", async () => {
|
||||
await renderComponent([" \n ", ""]);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.getByText("Try out the Continue CLI"),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it("detects CLI when path has trailing newline", async () => {
|
||||
await renderComponent(["/usr/local/bin/cn\n", ""]);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.queryByText("Try out the Continue CLI"),
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it("renders banner when stderr contains 'not found'", async () => {
|
||||
await renderComponent(["", "cn: command not found"]);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.getByText("Try out the Continue CLI"),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Session threshold logic", () => {
|
||||
const renderWithSessionCount = async (
|
||||
sessionCount?: number,
|
||||
sessionThreshold?: number,
|
||||
) => {
|
||||
vi.spyOn(mockIdeMessenger.ide, "subprocess").mockResolvedValue([
|
||||
"",
|
||||
"not found",
|
||||
]);
|
||||
|
||||
return act(async () =>
|
||||
render(
|
||||
<IdeMessengerContext.Provider value={mockIdeMessenger}>
|
||||
<CliInstallBanner
|
||||
sessionCount={sessionCount}
|
||||
sessionThreshold={sessionThreshold}
|
||||
/>
|
||||
</IdeMessengerContext.Provider>,
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
it("shows banner when no threshold is set", async () => {
|
||||
await renderWithSessionCount(0, undefined);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.getByText("Try out the Continue CLI"),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it("does not show banner when session count is below threshold", async () => {
|
||||
await renderWithSessionCount(2, 3);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.queryByText("Try out the Continue CLI"),
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it("shows banner when session count meets threshold", async () => {
|
||||
await renderWithSessionCount(3, 3);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.getByText("Try out the Continue CLI"),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it("shows banner when session count exceeds threshold", async () => {
|
||||
await renderWithSessionCount(5, 3);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.getByText("Try out the Continue CLI"),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Permanent dismissal with localStorage", () => {
|
||||
const renderWithPermanentDismissal = async () => {
|
||||
vi.spyOn(mockIdeMessenger.ide, "subprocess").mockResolvedValue([
|
||||
"",
|
||||
"not found",
|
||||
]);
|
||||
|
||||
return act(async () =>
|
||||
render(
|
||||
<IdeMessengerContext.Provider value={mockIdeMessenger}>
|
||||
<CliInstallBanner permanentDismissal={true} />
|
||||
</IdeMessengerContext.Provider>,
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
it("does not show banner when previously dismissed permanently", async () => {
|
||||
vi.mocked(localStorage.getLocalStorage).mockReturnValue(true);
|
||||
|
||||
await renderWithPermanentDismissal();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.queryByText("Try out the Continue CLI"),
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it("sets localStorage when dismissed with permanentDismissal=true", async () => {
|
||||
await renderWithPermanentDismissal();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.getByText("Try out the Continue CLI"),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
const buttons = screen.getAllByRole("button");
|
||||
const closeButton = buttons[0];
|
||||
fireEvent.click(closeButton);
|
||||
|
||||
expect(localStorage.setLocalStorage).toHaveBeenCalledWith(
|
||||
"hasDismissedCliInstallBanner",
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
it("does not set localStorage when dismissed with permanentDismissal=false", async () => {
|
||||
vi.spyOn(mockIdeMessenger.ide, "subprocess").mockResolvedValue([
|
||||
"",
|
||||
"not found",
|
||||
]);
|
||||
|
||||
await act(async () =>
|
||||
render(
|
||||
<IdeMessengerContext.Provider value={mockIdeMessenger}>
|
||||
<CliInstallBanner permanentDismissal={false} />
|
||||
</IdeMessengerContext.Provider>,
|
||||
),
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
screen.getByText("Try out the Continue CLI"),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
const buttons = screen.getAllByRole("button");
|
||||
const closeButton = buttons[0];
|
||||
fireEvent.click(closeButton);
|
||||
|
||||
expect(localStorage.setLocalStorage).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -1,167 +0,0 @@
|
|||
import { CommandLineIcon, XMarkIcon } from "@heroicons/react/24/outline";
|
||||
import { useContext, useEffect, useRef, useState } from "react";
|
||||
import { CloseButton } from ".";
|
||||
import { IdeMessengerContext } from "../context/IdeMessenger";
|
||||
import useCopy from "../hooks/useCopy";
|
||||
import { getPlatform } from "../util";
|
||||
import { getLocalStorage, setLocalStorage } from "../util/localStorage";
|
||||
import { CopyButton } from "./StyledMarkdownPreview/StepContainerPreToolbar/CopyButton";
|
||||
import { RunInTerminalButton } from "./StyledMarkdownPreview/StepContainerPreToolbar/RunInTerminalButton";
|
||||
import { Card } from "./ui";
|
||||
|
||||
interface CliInstallBannerProps {
|
||||
/** Number of sessions user has had - banner shows only if >= sessionThreshold */
|
||||
sessionCount?: number;
|
||||
/** Minimum sessions before showing banner (default: always show) */
|
||||
sessionThreshold?: number;
|
||||
/** If true, dismissal is permanent via localStorage (default: session only) */
|
||||
permanentDismissal?: boolean;
|
||||
}
|
||||
|
||||
export function CliInstallBanner({
|
||||
sessionCount,
|
||||
sessionThreshold,
|
||||
permanentDismissal = false,
|
||||
}: CliInstallBannerProps = {}) {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const [cliInstalled, setCliInstalled] = useState<boolean | null>(null);
|
||||
const [dismissed, setDismissed] = useState(false);
|
||||
const commandTextRef = useRef<HTMLSpanElement>(null);
|
||||
const { copyText } = useCopy("npm i -g @continuedev/cli");
|
||||
const [showCopiedMessage, setShowCopiedMessage] = useState(false);
|
||||
|
||||
const handleCommandClick = () => {
|
||||
// Select the text
|
||||
if (commandTextRef.current) {
|
||||
const selection = window.getSelection();
|
||||
const range = document.createRange();
|
||||
range.selectNodeContents(commandTextRef.current);
|
||||
selection?.removeAllRanges();
|
||||
selection?.addRange(range);
|
||||
}
|
||||
// Copy to clipboard
|
||||
copyText();
|
||||
|
||||
// Show "Copied!" message for 3 seconds
|
||||
setShowCopiedMessage(true);
|
||||
setTimeout(() => setShowCopiedMessage(false), 3000);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
// Check if user has permanently dismissed the banner
|
||||
if (permanentDismissal) {
|
||||
const hasDismissed = getLocalStorage("hasDismissedCliInstallBanner");
|
||||
if (hasDismissed) {
|
||||
setDismissed(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const checkCliInstallation = async () => {
|
||||
try {
|
||||
const platform = getPlatform();
|
||||
// Use 'which' on mac/linux, 'where' on windows
|
||||
const command = platform === "windows" ? "where cn" : "which cn";
|
||||
|
||||
const [stdout, stderr] = await ideMessenger.ide.subprocess(command);
|
||||
|
||||
// If stdout has content (path to cn), it's installed
|
||||
// If empty or stderr has "not found", it's not installed
|
||||
const isInstalled =
|
||||
stdout.trim().length > 0 && !stderr.includes("not found");
|
||||
setCliInstalled(isInstalled);
|
||||
} catch (error) {
|
||||
// If subprocess throws an error, assume CLI is not installed
|
||||
setCliInstalled(false);
|
||||
}
|
||||
};
|
||||
|
||||
void checkCliInstallation();
|
||||
}, [ideMessenger, permanentDismissal]);
|
||||
|
||||
const handleDismiss = () => {
|
||||
setDismissed(true);
|
||||
if (permanentDismissal) {
|
||||
setLocalStorage("hasDismissedCliInstallBanner", true);
|
||||
}
|
||||
};
|
||||
|
||||
// Don't show if:
|
||||
// - Still loading CLI status
|
||||
// - CLI is already installed
|
||||
// - User has dismissed it
|
||||
// - Session threshold not met (if threshold is set)
|
||||
if (
|
||||
cliInstalled === null ||
|
||||
cliInstalled === true ||
|
||||
dismissed ||
|
||||
(sessionThreshold !== undefined &&
|
||||
(sessionCount === undefined || sessionCount < sessionThreshold))
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="border-t-vsc-input-border bg-vsc-background sticky bottom-0 border-t px-4 pb-4 pt-4">
|
||||
<Card className="relative">
|
||||
<CloseButton onClick={handleDismiss}>
|
||||
<XMarkIcon className="h-5 w-5 hover:brightness-125" />
|
||||
</CloseButton>
|
||||
<div className="flex flex-col gap-3">
|
||||
<div>
|
||||
<div className="text-foreground flex items-center gap-2 font-medium">
|
||||
<CommandLineIcon className="h-5 w-5 flex-shrink-0 text-gray-400" />
|
||||
Try out the Continue CLI
|
||||
</div>
|
||||
<div className="text-description mt-1 text-sm">
|
||||
Use{" "}
|
||||
<code className="bg-vsc-background rounded px-1.5 py-0.5">
|
||||
cn
|
||||
</code>{" "}
|
||||
in your terminal interactively and then deploy Continuous AI
|
||||
workflows.{" "}
|
||||
<span
|
||||
onClick={() =>
|
||||
ideMessenger.post(
|
||||
"openUrl",
|
||||
"https://docs.continue.dev/guides/cli",
|
||||
)
|
||||
}
|
||||
className="cursor-pointer underline hover:brightness-125"
|
||||
>
|
||||
Learn more.
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-col items-start gap-2 self-stretch">
|
||||
<div className="rounded-default outline-command-border flex items-center self-stretch outline outline-1">
|
||||
<div className="bg-editor rounded-l-default relative flex-1 px-3 py-3">
|
||||
<span
|
||||
ref={commandTextRef}
|
||||
className="text-foreground cursor-pointer text-xs"
|
||||
style={{ fontFamily: "var(--vscode-editor-font-family)" }}
|
||||
onClick={handleCommandClick}
|
||||
>
|
||||
npm i -g @continuedev/cli
|
||||
</span>
|
||||
{showCopiedMessage && (
|
||||
<span className="bg-editor rounded-l-default absolute inset-0 flex items-center justify-center px-2 text-xs font-medium">
|
||||
Copied!
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<div className="bg-background rounded-r-default flex items-center gap-2 px-3 py-3">
|
||||
<CopyButton
|
||||
text={`npm i -g @continuedev/cli && cn "Explore this repo and provide a concise summary of it's contents"`}
|
||||
/>
|
||||
<RunInTerminalButton
|
||||
command={`npm i -g @continuedev/cli && cn "Explore this repo and provide a concise summary of it's contents"`}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@ import { varWithFallback } from "../styles/theme";
|
|||
import { getLocalStorage, setLocalStorage } from "../util/localStorage";
|
||||
|
||||
const EXPIRATION_DATE = new Date("2026-09-09");
|
||||
const EXPORT_URL = "https://continue.dev/settings/export";
|
||||
const EXPORT_URL = "https://continue.dev/export";
|
||||
const REPO_URL = "https://github.com/continuedev/continue/blob/main/README.md";
|
||||
|
||||
interface DeprecationBannerProps {
|
||||
|
|
|
|||
|
|
@ -1,297 +0,0 @@
|
|||
import {
|
||||
createRuleMarkdown,
|
||||
getRuleType,
|
||||
RuleType,
|
||||
RuleTypeDescriptions,
|
||||
} from "@continuedev/config-yaml";
|
||||
import { InformationCircleIcon } from "@heroicons/react/24/outline";
|
||||
import { createRuleFilePath } from "core/config/markdown/utils";
|
||||
import { CreateRuleBlockArgs } from "core/tools/implementations/createRuleBlock";
|
||||
import { useContext, useEffect, useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import Spinner from "../gui/Spinner";
|
||||
import { ToolTip } from "../gui/Tooltip";
|
||||
import { Button } from "../ui";
|
||||
import { useRuleGeneration } from "./useRuleGeneration";
|
||||
|
||||
interface GenerationScreenProps {
|
||||
inputPrompt: string;
|
||||
onBack: () => void;
|
||||
onSuccess: () => void;
|
||||
isManualMode?: boolean;
|
||||
}
|
||||
|
||||
export function GenerationScreen({
|
||||
inputPrompt,
|
||||
onBack,
|
||||
onSuccess,
|
||||
isManualMode = false,
|
||||
}: GenerationScreenProps) {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
const { register, watch, setValue, reset } = useForm<CreateRuleBlockArgs>({
|
||||
defaultValues: {
|
||||
name: "",
|
||||
description: "",
|
||||
globs: "",
|
||||
alwaysApply: undefined,
|
||||
rule: "",
|
||||
},
|
||||
});
|
||||
|
||||
const formData = watch();
|
||||
|
||||
// Track rule type separately from form data
|
||||
const [selectedRuleType, setSelectedRuleType] = useState<RuleType>(
|
||||
RuleType.Always,
|
||||
);
|
||||
const [formError, setFormError] = useState<string | null>(null);
|
||||
|
||||
// Use the generation hook with the input prompt
|
||||
const { generateRule, isGenerating, error } = useRuleGeneration(
|
||||
inputPrompt,
|
||||
(args) => {
|
||||
// Streaming causes a lot of jank, so wait until done generating
|
||||
if (!isGenerating) {
|
||||
reset(args);
|
||||
handleRuleTypeChange(getRuleType(args));
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// Start generation once when component mounts (only if not in manual mode)
|
||||
useEffect(() => {
|
||||
if (!isManualMode) {
|
||||
void generateRule();
|
||||
}
|
||||
}, [isManualMode]);
|
||||
|
||||
const handleRuleTypeChange = (newRuleType: RuleType) => {
|
||||
setSelectedRuleType(newRuleType);
|
||||
|
||||
// Update alwaysApply based on rule type
|
||||
const alwaysApply = newRuleType === RuleType.Always;
|
||||
setValue("alwaysApply", alwaysApply);
|
||||
|
||||
// Don't clear optional fields - preserve their state
|
||||
// Users can manually clear them if needed
|
||||
};
|
||||
|
||||
const handleContinue = async () => {
|
||||
// Clear any previous errors
|
||||
setFormError(null);
|
||||
|
||||
if (!formData.name) {
|
||||
setFormError("Rule name is required");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!formData.rule) {
|
||||
setFormError("Rule content is required");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const options: any = {
|
||||
alwaysApply: formData.alwaysApply,
|
||||
};
|
||||
|
||||
if (formData.description) {
|
||||
options.description = formData.description;
|
||||
}
|
||||
|
||||
if (formData.globs) {
|
||||
options.globs = formData.globs;
|
||||
}
|
||||
|
||||
const fileContent = createRuleMarkdown(
|
||||
formData.name,
|
||||
formData.rule,
|
||||
options,
|
||||
);
|
||||
|
||||
const workspaceDirs = await ideMessenger.request(
|
||||
"getWorkspaceDirs",
|
||||
undefined,
|
||||
);
|
||||
|
||||
if (workspaceDirs.status !== "success") {
|
||||
setFormError("Failed to get workspace directory");
|
||||
return;
|
||||
}
|
||||
|
||||
const localContinueDir = workspaceDirs.content[0];
|
||||
const ruleFilePath = createRuleFilePath(localContinueDir, formData.name);
|
||||
|
||||
await ideMessenger.request("writeFile", {
|
||||
path: ruleFilePath,
|
||||
contents: fileContent,
|
||||
});
|
||||
ideMessenger.post("openFile", { path: ruleFilePath });
|
||||
|
||||
onSuccess();
|
||||
} catch (err) {
|
||||
const errorMessage =
|
||||
err instanceof Error ? err.message : "Unknown error occurred";
|
||||
setFormError(`Failed to create rule file: ${errorMessage}`);
|
||||
}
|
||||
};
|
||||
|
||||
const showNameSpinner = isGenerating && !formData.name && !isManualMode;
|
||||
|
||||
return (
|
||||
<div className="px-2 pb-2 pt-4 sm:px-4">
|
||||
<div>
|
||||
<div className="text-center">
|
||||
<h2 className="mb-0">Your rule</h2>
|
||||
<p className="text-description m-0 mt-2 p-0">
|
||||
Review and edit your generated rule below
|
||||
</p>
|
||||
</div>
|
||||
<div className="mt-5">
|
||||
<div className="flex flex-col gap-4">
|
||||
{/* Rule metadata form */}
|
||||
<div className="space-y-4">
|
||||
{/* Rule Name - Always visible */}
|
||||
<div className="space-y-1">
|
||||
<label className="text-foreground text-sm font-medium">
|
||||
Rule Name
|
||||
</label>
|
||||
<div className="relative">
|
||||
<input
|
||||
type="text"
|
||||
className="border-input-border bg-input text-input-foreground placeholder:text-input-placeholder focus:border-border-focus box-border w-full rounded-md border px-3 py-2 text-xs focus:outline-none"
|
||||
placeholder={showNameSpinner ? "" : "Enter rule name..."}
|
||||
disabled={isGenerating && !isManualMode}
|
||||
{...register("name")}
|
||||
/>
|
||||
{showNameSpinner && (
|
||||
<div className="absolute left-3 top-1/2 -translate-y-1/2">
|
||||
<Spinner />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Rule Type Selector - Always visible */}
|
||||
<div className="space-y-1">
|
||||
<div className="flex items-center gap-2">
|
||||
<label className="text-foreground text-sm font-medium">
|
||||
Rule Type
|
||||
</label>
|
||||
<ToolTip
|
||||
style={{ zIndex: 100001 }}
|
||||
content={RuleTypeDescriptions[selectedRuleType]}
|
||||
>
|
||||
<InformationCircleIcon className="h-4 w-4 text-gray-500" />
|
||||
</ToolTip>
|
||||
</div>
|
||||
<div className="relative">
|
||||
<select
|
||||
className="border-input-border bg-input text-input-foreground focus:border-border-focus w-full rounded-md border px-3 py-2 text-xs focus:outline-none"
|
||||
value={isGenerating ? "" : selectedRuleType}
|
||||
onChange={(e) =>
|
||||
handleRuleTypeChange(e.target.value as RuleType)
|
||||
}
|
||||
disabled={isGenerating && !isManualMode}
|
||||
>
|
||||
{isGenerating && !isManualMode ? (
|
||||
<option value=""></option>
|
||||
) : (
|
||||
<>
|
||||
<option value={RuleType.Always}>Always</option>
|
||||
<option value={RuleType.AutoAttached}>
|
||||
Auto Attached
|
||||
</option>
|
||||
<option value={RuleType.AgentRequested}>
|
||||
Agent Requested
|
||||
</option>
|
||||
<option value={RuleType.Manual}>Manual</option>
|
||||
</>
|
||||
)}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Description (for Agent Requested only) */}
|
||||
<div
|
||||
className={`space-y-1 ${selectedRuleType === RuleType.AgentRequested ? "" : "hidden"}`}
|
||||
>
|
||||
<label className="text-foreground text-sm font-medium">
|
||||
Description
|
||||
</label>
|
||||
<textarea
|
||||
className="border-input-border bg-input text-input-foreground placeholder:text-input-placeholder focus:border-border-focus box-border w-full resize-none rounded-md border px-3 py-2 text-xs focus:outline-none"
|
||||
rows={3}
|
||||
placeholder="Description of the task this rule is helpful for..."
|
||||
{...register("description")}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* File Pattern (for Auto Attached only) */}
|
||||
<div
|
||||
className={`space-y-1 ${selectedRuleType === RuleType.AutoAttached ? "" : "hidden"}`}
|
||||
>
|
||||
<label className="text-foreground text-sm font-medium">
|
||||
File pattern matches
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
className="border-input-border bg-input text-input-foreground placeholder:text-input-placeholder focus:border-border-focus box-border w-full rounded-md border px-3 py-2 font-mono text-xs focus:outline-none"
|
||||
placeholder="*.tsx, **/*.{ts,tsx}, tests/**/*.ts ..."
|
||||
{...register("globs")}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Rule Content */}
|
||||
<div className="relative">
|
||||
<label className="text-foreground text-sm font-medium">
|
||||
Rule Content
|
||||
</label>
|
||||
<textarea
|
||||
className="border-input-border bg-input text-input-foreground placeholder:text-input-placeholder focus:border-border-focus mt-1 box-border w-full resize-none rounded border p-2 text-xs focus:outline-none"
|
||||
rows={10}
|
||||
disabled={isGenerating && !isManualMode}
|
||||
placeholder="Your rule content..."
|
||||
{...register("rule")}
|
||||
/>
|
||||
</div>
|
||||
{error && <p className="text-sm text-red-500">{error}</p>}
|
||||
|
||||
<div className="my-4 flex flex-col items-center gap-2">
|
||||
<div className="flex flex-row justify-center gap-3">
|
||||
<Button
|
||||
type="button"
|
||||
className="min-w-16"
|
||||
onClick={onBack}
|
||||
variant="outline"
|
||||
disabled={isGenerating && !isManualMode}
|
||||
>
|
||||
Back
|
||||
</Button>
|
||||
<Button
|
||||
className="min-w-16"
|
||||
onClick={handleContinue}
|
||||
disabled={
|
||||
(isGenerating && !isManualMode) ||
|
||||
(!formData.rule && !error) ||
|
||||
!formData.name
|
||||
}
|
||||
>
|
||||
Continue
|
||||
</Button>
|
||||
</div>
|
||||
{formError && (
|
||||
<span className="text-error text-center text-xs">
|
||||
Error creating rule: {formError}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
import React from "react";
|
||||
import { Button } from "../ui";
|
||||
import { RuleTemplateChip } from "./RuleTemplateChip";
|
||||
import { RuleTemplate, ruleTemplates } from "./ruleTemplates";
|
||||
|
||||
interface InputScreenProps {
|
||||
inputPrompt: string;
|
||||
onInputChange: (prompt: string) => void;
|
||||
onGenerate: (prompt: string) => void;
|
||||
onCancel: () => void;
|
||||
onManualWrite: () => void;
|
||||
}
|
||||
|
||||
export function InputScreen({
|
||||
inputPrompt,
|
||||
onInputChange,
|
||||
onGenerate,
|
||||
onCancel,
|
||||
onManualWrite,
|
||||
}: InputScreenProps) {
|
||||
const handleSubmit = (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
|
||||
if (!inputPrompt.trim()) {
|
||||
return;
|
||||
}
|
||||
|
||||
onGenerate(inputPrompt);
|
||||
};
|
||||
|
||||
const handleRuleTemplateClick = (template: RuleTemplate) => {
|
||||
onInputChange(template.template);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="px-2 pb-2 pt-4 sm:px-4">
|
||||
<div>
|
||||
<div className="text-center">
|
||||
<h2 className="mb-0">Generate Rule</h2>
|
||||
<p className="text-description m-0 mt-2 p-0">
|
||||
This will generate a new rule using the content of your chat history
|
||||
</p>
|
||||
</div>
|
||||
<div className="mt-5">
|
||||
<form onSubmit={handleSubmit} className="flex flex-col gap-1">
|
||||
<div className="mb-2 flex flex-wrap items-center justify-center gap-x-3">
|
||||
{ruleTemplates.map((template, index) => (
|
||||
<RuleTemplateChip
|
||||
key={index}
|
||||
icon={template.icon}
|
||||
text={template.title}
|
||||
onClick={() => handleRuleTemplateClick(template)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col gap-2">
|
||||
<textarea
|
||||
className="border-input-border bg-input text-input-foreground placeholder:text-input-placeholder focus:border-border-focus box-border w-full resize-none rounded border p-2 text-xs focus:outline-none"
|
||||
placeholder="Describe your rule..."
|
||||
rows={5}
|
||||
value={inputPrompt}
|
||||
onChange={(e) => onInputChange(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="my-4 flex flex-col items-center gap-2">
|
||||
<div className="flex flex-row justify-center gap-3">
|
||||
<Button
|
||||
type="button"
|
||||
className="min-w-16"
|
||||
onClick={onCancel}
|
||||
variant="outline"
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button className="min-w-16" disabled={!inputPrompt.trim()}>
|
||||
Generate
|
||||
</Button>
|
||||
</div>
|
||||
<span
|
||||
className="text-description cursor-pointer text-xs underline"
|
||||
onClick={onManualWrite}
|
||||
>
|
||||
Or, write a rule from scratch
|
||||
</span>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
import React from "react";
|
||||
import { Button } from "../ui";
|
||||
|
||||
interface RuleTemplateChipProps {
|
||||
icon: React.ComponentType<{ className?: string }>;
|
||||
text: string;
|
||||
onClick: () => void;
|
||||
}
|
||||
|
||||
export function RuleTemplateChip({
|
||||
icon: Icon,
|
||||
text,
|
||||
onClick,
|
||||
}: RuleTemplateChipProps) {
|
||||
return (
|
||||
<Button
|
||||
type="button"
|
||||
onClick={onClick}
|
||||
className="flex items-center gap-2"
|
||||
variant="secondary"
|
||||
>
|
||||
<Icon className="h-3 w-3" />
|
||||
<span className="text-xs">{text}</span>
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
import { useState } from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice";
|
||||
import { GenerationScreen } from "./GenerationScreen";
|
||||
import { InputScreen } from "./InputScreen";
|
||||
|
||||
type Screen = "input" | "generation";
|
||||
|
||||
export function GenerateRuleDialog() {
|
||||
const dispatch = useDispatch();
|
||||
const [screen, setScreen] = useState<Screen>("input");
|
||||
const [inputPrompt, setInputPrompt] = useState("");
|
||||
const [isManualMode, setIsManualMode] = useState(false);
|
||||
|
||||
const closeDialog = () => {
|
||||
setScreen("input");
|
||||
setInputPrompt("");
|
||||
setIsManualMode(false);
|
||||
dispatch(setDialogMessage(undefined));
|
||||
dispatch(setShowDialog(false));
|
||||
};
|
||||
|
||||
const handleGenerate = (prompt: string) => {
|
||||
setInputPrompt(prompt);
|
||||
setIsManualMode(false);
|
||||
setScreen("generation");
|
||||
};
|
||||
|
||||
const handleManualWrite = () => {
|
||||
setIsManualMode(true);
|
||||
setScreen("generation");
|
||||
};
|
||||
|
||||
const handleBack = () => {
|
||||
setScreen("input");
|
||||
};
|
||||
|
||||
const handleSuccess = () => {
|
||||
closeDialog();
|
||||
};
|
||||
|
||||
if (screen === "input") {
|
||||
return (
|
||||
<InputScreen
|
||||
inputPrompt={inputPrompt}
|
||||
onInputChange={setInputPrompt}
|
||||
onGenerate={handleGenerate}
|
||||
onCancel={closeDialog}
|
||||
onManualWrite={handleManualWrite}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<GenerationScreen
|
||||
inputPrompt={inputPrompt}
|
||||
onBack={handleBack}
|
||||
onSuccess={handleSuccess}
|
||||
isManualMode={isManualMode}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
import {
|
||||
AtSymbolIcon,
|
||||
CodeBracketIcon,
|
||||
GlobeAltIcon,
|
||||
SparklesIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
|
||||
export interface RuleTemplate {
|
||||
icon: React.ComponentType<{ className?: string }>;
|
||||
title: string;
|
||||
template: string;
|
||||
}
|
||||
|
||||
export const ruleTemplates: RuleTemplate[] = [
|
||||
{
|
||||
icon: GlobeAltIcon,
|
||||
title: "Always Applied",
|
||||
template: "Create an always applied rule where for all files...",
|
||||
},
|
||||
{
|
||||
icon: CodeBracketIcon,
|
||||
title: "Auto attached",
|
||||
template:
|
||||
"Create an auto-attached rule where for all {FILE_EXTENSIONS} files...",
|
||||
},
|
||||
{
|
||||
icon: SparklesIcon,
|
||||
title: "Agent Requested",
|
||||
template: "Create an agent requested rule where...",
|
||||
},
|
||||
{
|
||||
icon: AtSymbolIcon,
|
||||
title: "Manual",
|
||||
template: "Create a manually requested rule where...",
|
||||
},
|
||||
];
|
||||
|
|
@ -1,139 +0,0 @@
|
|||
import { ToolCallDelta } from "core";
|
||||
import { createRuleBlock } from "core/tools/definitions/createRuleBlock";
|
||||
import { CreateRuleBlockArgs } from "core/tools/implementations/createRuleBlock";
|
||||
import { useCallback, useContext, useState } from "react";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import { useAppSelector } from "../../redux/hooks";
|
||||
import { selectSelectedChatModel } from "../../redux/slices/configSlice";
|
||||
import { constructMessages } from "../../redux/util/constructMessages";
|
||||
import { addToolCallDeltaToState } from "../../util/toolCallState";
|
||||
|
||||
const RULE_GENERATION_SYSTEM_MESSAGE = `You are an expert at creating effective rules for AI coding assistants. Create concise, actionable rules that follow these guidelines:
|
||||
|
||||
FOCUS:
|
||||
- Keep rules focused on a single, specific concern
|
||||
- Be specific and actionable - avoid vague guidance
|
||||
- Write in imperative language ("Use X", "Always do Y", "Avoid Z")
|
||||
|
||||
EXAMPLES FROM CHAT HISTORY:
|
||||
- Use concrete examples from the chat history when possible
|
||||
- If they say "don't do X", find instances where "X" was done incorrectly
|
||||
- Include before/after code examples using this format:
|
||||
|
||||
**Example**
|
||||
\`\`\`typescript
|
||||
// Bad: Don't do this
|
||||
const badExample = "from chat history";
|
||||
|
||||
// Good: Do this instead
|
||||
const goodExample = "corrected version";
|
||||
\`\`\`
|
||||
|
||||
Be concise but comprehensive. The chat history contains real examples of what to do or avoid.`;
|
||||
|
||||
export interface UseRuleGenerationReturn {
|
||||
generateRule: () => Promise<void>;
|
||||
isGenerating: boolean;
|
||||
error: string | null;
|
||||
reset: () => void;
|
||||
}
|
||||
|
||||
export function useRuleGeneration(
|
||||
inputPrompt: string,
|
||||
onGenerate?: (args: CreateRuleBlockArgs) => void,
|
||||
): UseRuleGenerationReturn {
|
||||
const [isGenerating, setIsGenerating] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const currentHistory = useAppSelector((state) => state.session.history);
|
||||
const selectedChatModel = useAppSelector(selectSelectedChatModel);
|
||||
|
||||
const generateRule = useCallback(async () => {
|
||||
if (!selectedChatModel) {
|
||||
setError("No chat model selected");
|
||||
return;
|
||||
}
|
||||
|
||||
setIsGenerating(true);
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
// Convert current history to ChatHistoryItem format
|
||||
|
||||
// Add our rule generation prompt with instruction to use the tool
|
||||
const history = [
|
||||
{
|
||||
message: {
|
||||
role: "system" as const,
|
||||
content: RULE_GENERATION_SYSTEM_MESSAGE,
|
||||
},
|
||||
contextItems: [],
|
||||
},
|
||||
...currentHistory,
|
||||
{
|
||||
message: {
|
||||
role: "user" as const,
|
||||
content: `The user has requested that we write a new rule. You MUST USE the create_rule_block tool to generate a well-structured rule. Do not say anything else, only call this tool. Here is their request: ${inputPrompt}`,
|
||||
},
|
||||
contextItems: [],
|
||||
},
|
||||
];
|
||||
|
||||
const { messages } = constructMessages(history, undefined, [], {});
|
||||
|
||||
// Create abort controller for this request
|
||||
const abortController = new AbortController();
|
||||
|
||||
// Stream the response with createRuleBlock tool
|
||||
const gen = ideMessenger.llmStreamChat(
|
||||
{
|
||||
messages,
|
||||
completionOptions: {
|
||||
tools: [createRuleBlock],
|
||||
},
|
||||
title: selectedChatModel.title,
|
||||
},
|
||||
abortController.signal,
|
||||
);
|
||||
|
||||
let toolCallState: any = undefined;
|
||||
|
||||
// Process each chunk
|
||||
for await (const chunks of gen) {
|
||||
for (const chunk of chunks) {
|
||||
// Handle tool calls - this is what we care about
|
||||
if (chunk.role === "assistant" && chunk.toolCalls?.length) {
|
||||
const toolCallDelta: ToolCallDelta = chunk.toolCalls[0];
|
||||
toolCallState = addToolCallDeltaToState(
|
||||
toolCallDelta,
|
||||
toolCallState,
|
||||
);
|
||||
|
||||
// Call the callback if provided with the parsed args
|
||||
if (toolCallState?.parsedArgs) {
|
||||
onGenerate?.(toolCallState.parsedArgs);
|
||||
}
|
||||
}
|
||||
// Ignore regular assistant content - we only care about the tool call
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : "An error occurred");
|
||||
} finally {
|
||||
setIsGenerating(false);
|
||||
}
|
||||
}, [ideMessenger, currentHistory, selectedChatModel, inputPrompt]);
|
||||
|
||||
const reset = useCallback(() => {
|
||||
setError(null);
|
||||
setIsGenerating(false);
|
||||
}, []);
|
||||
|
||||
return {
|
||||
generateRule,
|
||||
isGenerating,
|
||||
error,
|
||||
reset,
|
||||
};
|
||||
}
|
||||
|
|
@ -9,14 +9,13 @@ import { LocalStorageProvider } from "../context/LocalStorage";
|
|||
import { useWebviewListener } from "../hooks/useWebviewListener";
|
||||
import { useAppDispatch, useAppSelector } from "../redux/hooks";
|
||||
import { setCodeToEdit } from "../redux/slices/editState";
|
||||
import { setDialogMessage, setShowDialog } from "../redux/slices/uiSlice";
|
||||
import { setShowDialog } from "../redux/slices/uiSlice";
|
||||
import { enterEdit, exitEdit } from "../redux/thunks/edit";
|
||||
import { saveCurrentSession } from "../redux/thunks/session";
|
||||
import { fontSize, isMetaEquivalentKeyPressed } from "../util";
|
||||
import { ROUTES } from "../util/navigation";
|
||||
import { FatalErrorIndicator } from "./config/FatalErrorNotice";
|
||||
import TextDialog from "./dialogs";
|
||||
import { GenerateRuleDialog } from "./GenerateRuleDialog";
|
||||
import { useMainEditor } from "./mainInput/TipTapEditor";
|
||||
import {
|
||||
isNewUserOnboarding,
|
||||
|
|
@ -170,15 +169,6 @@ const Layout = () => {
|
|||
[],
|
||||
);
|
||||
|
||||
useWebviewListener(
|
||||
"generateRule",
|
||||
async () => {
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(setDialogMessage(<GenerateRuleDialog />));
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const handleKeyDown = (event: any) => {
|
||||
if (isMetaEquivalentKeyPressed(event) && event.code === "KeyC") {
|
||||
|
|
|
|||
|
|
@ -1,19 +1,13 @@
|
|||
import {
|
||||
ArrowsPointingInIcon,
|
||||
BarsArrowDownIcon,
|
||||
PencilSquareIcon,
|
||||
TrashIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { ChatHistoryItem } from "core";
|
||||
import { modelSupportsNativeTools } from "core/llm/toolSupport";
|
||||
import { renderChatMessage } from "core/util/messageContent";
|
||||
import { useMemo } from "react";
|
||||
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
|
||||
import { selectSelectedChatModel } from "../../redux/slices/configSlice";
|
||||
import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice";
|
||||
import { useAppSelector } from "../../redux/hooks";
|
||||
import { useCompactConversation } from "../../util/compactConversation";
|
||||
import { FeedbackButtons } from "../FeedbackButtons";
|
||||
import { GenerateRuleDialog } from "../GenerateRuleDialog";
|
||||
import { CopyIconButton } from "../gui/CopyIconButton";
|
||||
import HeaderButtonWithToolTip from "../gui/HeaderButtonWithToolTip";
|
||||
|
||||
|
|
@ -34,15 +28,10 @@ export default function ResponseActions({
|
|||
onDelete,
|
||||
isLast,
|
||||
}: ResponseActionsProps) {
|
||||
const dispatch = useAppDispatch();
|
||||
const selectedModel = useAppSelector(selectSelectedChatModel);
|
||||
const contextPercentage = useAppSelector(
|
||||
(state) => state.session.contextPercentage,
|
||||
);
|
||||
const isPruned = useAppSelector((state) => state.session.isPruned);
|
||||
const ruleGenerationSupported = useMemo(() => {
|
||||
return selectedModel && modelSupportsNativeTools(selectedModel);
|
||||
}, [selectedModel]);
|
||||
|
||||
const percent = Math.round((contextPercentage ?? 0) * 100);
|
||||
const buttonColorClass =
|
||||
|
|
@ -54,11 +43,6 @@ export default function ResponseActions({
|
|||
|
||||
const compactConversation = useCompactConversation();
|
||||
|
||||
const onGenerateRule = () => {
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(setDialogMessage(<GenerateRuleDialog />));
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="text-description-muted mx-2 flex cursor-default items-center justify-end space-x-1 bg-transparent pb-0 text-xs">
|
||||
<HeaderButtonWithToolTip
|
||||
|
|
@ -85,16 +69,6 @@ export default function ResponseActions({
|
|||
</div>
|
||||
</HeaderButtonWithToolTip>
|
||||
|
||||
{isLast && ruleGenerationSupported && (
|
||||
<HeaderButtonWithToolTip
|
||||
tabIndex={-1}
|
||||
text="Generate rule"
|
||||
onClick={onGenerateRule}
|
||||
>
|
||||
<PencilSquareIcon className="text-description-muted h-3.5 w-3.5" />
|
||||
</HeaderButtonWithToolTip>
|
||||
)}
|
||||
|
||||
{isTruncated && (
|
||||
<HeaderButtonWithToolTip
|
||||
tabIndex={-1}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import { Divider } from "../../components/ui/Divider";
|
|||
import { TabGroup } from "../../components/ui/TabGroup";
|
||||
import { useNavigationListener } from "../../hooks/useNavigationListener";
|
||||
import { bottomTabSections, getAllTabs, topTabSections } from "./configTabs";
|
||||
import { CliInstallBanner } from "../../components/CliInstallBanner";
|
||||
import { DeprecationBanner } from "../../components/DeprecationBanner";
|
||||
import { AccountDropdown } from "./features/account/AccountDropdown";
|
||||
|
||||
|
|
@ -84,7 +83,6 @@ function ConfigPage() {
|
|||
<div className="space-y-6 px-4 py-4">
|
||||
{allTabs.find((tab) => tab.id === activeTab)?.component}
|
||||
</div>
|
||||
<CliInstallBanner permanentDismissal={true} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ import { isJetBrains, isMetaEquivalentKeyPressed } from "../../util";
|
|||
import { ToolCallDiv } from "./ToolCallDiv";
|
||||
|
||||
import { useStore } from "react-redux";
|
||||
import { CliInstallBanner } from "../../components/CliInstallBanner";
|
||||
import FeedbackDialog from "../../components/dialogs/FeedbackDialog";
|
||||
|
||||
import { DeprecationBanner } from "../../components/DeprecationBanner";
|
||||
|
|
@ -125,9 +124,6 @@ export function Chat() {
|
|||
const isInEdit = useAppSelector((store) => store.session.isInEdit);
|
||||
|
||||
const lastSessionId = useAppSelector((state) => state.session.lastSessionId);
|
||||
const allSessionMetadata = useAppSelector(
|
||||
(state) => state.session.allSessionMetadata,
|
||||
);
|
||||
const hasDismissedExploreDialog = useAppSelector(
|
||||
(state) => state.ui.hasDismissedExploreDialog,
|
||||
);
|
||||
|
|
@ -425,12 +421,6 @@ export function Chat() {
|
|||
inputId={MAIN_EDITOR_INPUT_ID}
|
||||
/>
|
||||
|
||||
<CliInstallBanner
|
||||
sessionCount={allSessionMetadata.length}
|
||||
sessionThreshold={3}
|
||||
permanentDismissal={true}
|
||||
/>
|
||||
|
||||
<div
|
||||
style={{
|
||||
pointerEvents: isStreaming ? "none" : "auto",
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ type LocalStorageTypes = {
|
|||
showTutorialCard: boolean;
|
||||
shownProfilesIntroduction: boolean;
|
||||
disableIndexing: boolean;
|
||||
hasDismissedCliInstallBanner: boolean;
|
||||
hasDismissedDeprecationBanner: boolean;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue