{tabs.map((tab) => (
setActiveTab(tab.id)}
diff --git a/gui/src/pages/gui/Chat.test.tsx b/gui/src/pages/gui/Chat.test.tsx
index 90b90f943..292266ab0 100644
--- a/gui/src/pages/gui/Chat.test.tsx
+++ b/gui/src/pages/gui/Chat.test.tsx
@@ -59,4 +59,51 @@ describe("Chat page test", () => {
});
expect(await screen.findByText("Hello, world!")).toBeInTheDocument();
});
+
+ it("should handle apply updates and display the accept / reject all buttons", async () => {
+ const { ideMessenger } = await renderWithProviders();
+
+ // Use queryByText which returns null when element isn't found
+ const acceptAllButton = screen.queryByText("Accept All");
+ const rejectAllButton = screen.queryByText("Reject All");
+
+ // Assert that the buttons don't exist
+ expect(acceptAllButton).not.toBeInTheDocument();
+ expect(rejectAllButton).not.toBeInTheDocument();
+
+ for (let i = 0; i < 5; i++) {
+ ideMessenger.mockMessageToWebview("updateApplyState", {
+ status: "streaming",
+ streamId: `12345`,
+ });
+ }
+
+ ideMessenger.mockMessageToWebview("updateApplyState", {
+ status: "done",
+ streamId: "12345",
+ });
+
+ // Wait for the buttons to appear
+ await waitFor(() => {
+ expect(
+ screen.getByTestId("accept-reject-all-buttons"),
+ ).toBeInTheDocument();
+ });
+
+ // IDE sends back message that it is done
+ ideMessenger.mockMessageToWebview("updateApplyState", {
+ status: "closed",
+ streamId: "12345",
+ });
+
+ // Wait for the buttons to disappear
+ await waitFor(() => {
+ expect(
+ screen.queryByTestId("edit-accept-button"),
+ ).not.toBeInTheDocument();
+ expect(
+ screen.queryByTestId("edit-reject-button"),
+ ).not.toBeInTheDocument();
+ });
+ });
});
diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx
index 2514909bc..ff19b3515 100644
--- a/gui/src/pages/gui/Chat.tsx
+++ b/gui/src/pages/gui/Chat.tsx
@@ -320,6 +320,7 @@ export function Chat() {
isMainInput={false}
editorState={item.editorState}
contextItems={item.contextItems}
+ appliedRules={item.appliedRules}
inputId={item.message.id}
/>
>
diff --git a/gui/src/pages/gui/ToolCallDiv/CreateFile.tsx b/gui/src/pages/gui/ToolCallDiv/CreateFile.tsx
index a3e81355b..d0a843104 100644
--- a/gui/src/pages/gui/ToolCallDiv/CreateFile.tsx
+++ b/gui/src/pages/gui/ToolCallDiv/CreateFile.tsx
@@ -8,6 +8,10 @@ interface CreateFileToolCallProps {
}
export function CreateFile(props: CreateFileToolCallProps) {
+ if (!props.fileContents) {
+ return null;
+ }
+
const src = `\`\`\`${getMarkdownLanguageTagForFile(props.relativeFilepath ?? "output.txt")} ${props.relativeFilepath}\n${props.fileContents ?? ""}\n\`\`\``;
return props.relativeFilepath ? (
diff --git a/gui/src/pages/gui/ToolCallDiv/EditFile.tsx b/gui/src/pages/gui/ToolCallDiv/EditFile.tsx
index 0c27ecee8..a4a487d42 100644
--- a/gui/src/pages/gui/ToolCallDiv/EditFile.tsx
+++ b/gui/src/pages/gui/ToolCallDiv/EditFile.tsx
@@ -16,13 +16,12 @@ type EditToolCallProps = {
};
export function EditFile(props: EditToolCallProps) {
- const src = `\`\`\`${getMarkdownLanguageTagForFile(props.relativeFilePath ?? "test.txt")} ${props.relativeFilePath}\n${props.changes ?? ""}\n\`\`\``;
-
const dispatch = useAppDispatch();
- const isStreaming = useAppSelector((state) => state.session.isStreaming);
+
const applyState = useAppSelector((state) =>
selectApplyStateByToolCallId(state, props.toolCallId),
);
+
useEffect(() => {
if (!applyState) {
dispatch(
@@ -35,10 +34,12 @@ export function EditFile(props: EditToolCallProps) {
}
}, [applyState, props.toolCallId]);
- if (!props.relativeFilePath) {
+ if (!props.relativeFilePath || !props.changes) {
return null;
}
+ const src = `\`\`\`${getMarkdownLanguageTagForFile(props.relativeFilePath ?? "test.txt")} ${props.relativeFilePath}\n${props.changes}\n\`\`\``;
+
return (
diff --git a/gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx b/gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx
index cec59e220..3342eabda 100644
--- a/gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx
+++ b/gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx
@@ -61,7 +61,7 @@ export function SimpleToolCallUI({
diff --git a/gui/src/redux/slices/sessionSlice.ts b/gui/src/redux/slices/sessionSlice.ts
index e81545d8b..3fe15881c 100644
--- a/gui/src/redux/slices/sessionSlice.ts
+++ b/gui/src/redux/slices/sessionSlice.ts
@@ -15,6 +15,7 @@ import {
FileSymbolMap,
MessageModes,
PromptLog,
+ RuleWithSource,
Session,
SessionMetadata,
ToolCallDelta,
@@ -247,6 +248,19 @@ export const sessionSlice = createSlice({
...payload.contextItems,
];
},
+ setAppliedRulesAtIndex: (
+ state,
+ {
+ payload,
+ }: PayloadAction<{
+ index: number;
+ appliedRules: RuleWithSource[];
+ }>,
+ ) => {
+ if (state.history[payload.index]) {
+ state.history[payload.index].appliedRules = payload.appliedRules;
+ }
+ },
setInactive: (state) => {
const curMessage = state.history.at(-1);
@@ -698,6 +712,7 @@ export const {
updateFileSymbols,
setContextItemsAtIndex,
addContextItemsAtIndex,
+ setAppliedRulesAtIndex,
setInactive,
streamUpdate,
newSession,
diff --git a/gui/src/redux/thunks/streamResponse.ts b/gui/src/redux/thunks/streamResponse.ts
index 5ab6f036e..c9a21a30c 100644
--- a/gui/src/redux/thunks/streamResponse.ts
+++ b/gui/src/redux/thunks/streamResponse.ts
@@ -1,12 +1,14 @@
import { createAsyncThunk, unwrapResult } from "@reduxjs/toolkit";
import { JSONContent } from "@tiptap/core";
-import { InputModifiers } from "core";
+import { InputModifiers, ToolResultChatMessage, UserChatMessage } from "core";
import { constructMessages } from "core/llm/constructMessages";
+import { getApplicableRules } from "core/llm/rules/getSystemMessageWithRules";
import posthog from "posthog-js";
import { v4 as uuidv4 } from "uuid";
import { getBaseSystemMessage } from "../../util";
import { selectSelectedChatModel } from "../slices/configSlice";
import {
+ setAppliedRulesAtIndex,
submitEditorAndInitAtIndex,
updateHistoryItemAtIndex,
} from "../slices/sessionSlice";
@@ -84,17 +86,41 @@ export const streamResponseThunk = createAsyncThunk<
}),
);
- // Construct messages from updated history
+ // Get updated history after the update
const updatedHistory = getState().session.history;
- const messageMode = getState().session.mode
- const baseChatOrAgentSystemMessage = getBaseSystemMessage(selectedChatModel, messageMode)
+ // Determine which rules apply to this message
+ const userMsg = updatedHistory[inputIndex].message;
+ const rules = getState().config.config.rules;
+
+ // Calculate applicable rules once
+ // We need to check the message type to match what getApplicableRules expects
+ const applicableRules = getApplicableRules(
+ userMsg.role === "user" || userMsg.role === "tool"
+ ? (userMsg as UserChatMessage | ToolResultChatMessage)
+ : undefined,
+ rules,
+ );
+
+ // Store in history for UI display
+ dispatch(
+ setAppliedRulesAtIndex({
+ index: inputIndex,
+ appliedRules: applicableRules,
+ }),
+ );
+
+ const messageMode = getState().session.mode;
+ const baseChatOrAgentSystemMessage = getBaseSystemMessage(
+ selectedChatModel,
+ messageMode,
+ );
const messages = constructMessages(
messageMode,
[...updatedHistory],
baseChatOrAgentSystemMessage,
- state.config.config.rules,
+ applicableRules,
);
posthog.capture("step run", {
diff --git a/gui/src/util/test/render.tsx b/gui/src/util/test/render.tsx
index 21a7d7e67..0ca3c7e3c 100644
--- a/gui/src/util/test/render.tsx
+++ b/gui/src/util/test/render.tsx
@@ -72,6 +72,7 @@ export async function renderWithProviders(
return {
user,
store,
+ ideMessenger,
...rendered!,
};
}
diff --git a/gui/tailwind.config.cjs b/gui/tailwind.config.cjs
index 2a7960b0a..941429d2e 100644
--- a/gui/tailwind.config.cjs
+++ b/gui/tailwind.config.cjs
@@ -43,6 +43,7 @@ module.exports = {
// TODO make it all non-IDE-specific naming
"find-match-selected":
"var(--vscode-editor-findMatchHighlightBackground, rgba(255, 223, 0))",
+ "table-odd-rows":"var(--vscode-tree-tableOddRowsBackground, #1bbe84)",
"list-active": "var(--vscode-list-activeSelectionBackground, #1bbe84)",
"list-active-foreground":
"var(--vscode-quickInputList-focusForeground, var(--vscode-editor-foreground))",
diff --git a/packages/config-yaml/src/registryClient.test.ts b/packages/config-yaml/src/registryClient.test.ts
index d820579ab..bff0b9e84 100644
--- a/packages/config-yaml/src/registryClient.test.ts
+++ b/packages/config-yaml/src/registryClient.test.ts
@@ -3,6 +3,7 @@ import * as http from "node:http";
import { AddressInfo } from "node:net";
import * as os from "node:os";
import * as path from "node:path";
+import { pathToFileURL } from "url";
import { PackageIdentifier } from "./interfaces/slugs.js";
import { RegistryClient } from "./registryClient.js";
@@ -134,6 +135,7 @@ describe("RegistryClient", () => {
describe("getContentFromFilePath", () => {
let absoluteFilePath: string;
+ let fileUrl: string;
let relativeFilePath: string;
beforeEach(() => {
@@ -141,6 +143,11 @@ describe("RegistryClient", () => {
absoluteFilePath = path.join(tempDir, "absolute-path.yaml");
fs.writeFileSync(absoluteFilePath, "absolute file content", "utf8");
+ const urlFilePath = path.join(tempDir, "file-url-path.yaml");
+ fs.writeFileSync(urlFilePath, "file:// file content", "utf8");
+ const url = pathToFileURL(urlFilePath);
+ fileUrl = url.toString();
+
// Create a subdirectory and file in the temp directory
const subDir = path.join(tempDir, "sub");
fs.mkdirSync(subDir, { recursive: true });
@@ -160,6 +167,14 @@ describe("RegistryClient", () => {
expect(result).toBe("absolute file content");
});
+ it("should read from local file url directly", () => {
+ const client = new RegistryClient();
+
+ const result = (client as any).getContentFromFilePath(fileUrl);
+
+ expect(result).toBe("file:// file content");
+ });
+
it("should use rootPath for relative paths when provided", () => {
const client = new RegistryClient({ rootPath: tempDir });
diff --git a/packages/config-yaml/src/registryClient.ts b/packages/config-yaml/src/registryClient.ts
index 73ca9fefd..3dab5e062 100644
--- a/packages/config-yaml/src/registryClient.ts
+++ b/packages/config-yaml/src/registryClient.ts
@@ -38,11 +38,9 @@ export class RegistryClient implements Registry {
private getContentFromFilePath(filepath: string): string {
if (filepath.startsWith("file://")) {
- const pathWithoutProtocol = filepath.slice(7);
-
// For Windows file:///C:/path/to/file, we need to handle it properly
// On other systems, we might have file:///path/to/file
- return fs.readFileSync(decodeURIComponent(pathWithoutProtocol), "utf8");
+ return fs.readFileSync(new URL(filepath), "utf8");
} else if (path.isAbsolute(filepath)) {
return fs.readFileSync(filepath, "utf8");
} else if (this.rootPath) {
diff --git a/packages/config-yaml/src/schemas/models.ts b/packages/config-yaml/src/schemas/models.ts
index 2a1eb0a68..d98460815 100644
--- a/packages/config-yaml/src/schemas/models.ts
+++ b/packages/config-yaml/src/schemas/models.ts
@@ -49,18 +49,30 @@ export const completionOptionsSchema = z.object({
n: z.number().optional(),
reasoning: z.boolean().optional(),
reasoningBudgetTokens: z.number().optional(),
+ promptCaching: z.boolean().optional(),
});
export type CompletionOptions = z.infer
;
+export const embeddingTasksSchema = z.union([
+ z.literal("chunk"),
+ z.literal("query")
+]);
+export type EmbeddingTasks = z.infer;
+
+export const embeddingPrefixesSchema = z.record(embeddingTasksSchema, z.string());
+export type EmbeddingPrefixes = z.infer;
+
export const cacheBehaviorSchema = z.object({
cacheSystemMessage: z.boolean().optional(),
cacheConversation: z.boolean().optional(),
});
export type CacheBehavior = z.infer;
+
export const embedOptionsSchema = z.object({
maxChunkSize: z.number().optional(),
maxBatchSize: z.number().optional(),
+ embeddingPrefixes: embeddingPrefixesSchema.optional(),
});
export type EmbedOptions = z.infer;
diff --git a/scripts/install-dependencies.ps1 b/scripts/install-dependencies.ps1
index 8bf3596d0..5556e58f5 100644
--- a/scripts/install-dependencies.ps1
+++ b/scripts/install-dependencies.ps1
@@ -76,6 +76,12 @@ if (($null -eq $node)) {
Write-Host "`nInstalling root-level dependencies..." -ForegroundColor White
npm install
+Write-Host "`nBuilding config-yaml..." -ForegroundColor White
+Push-Location packages/config-yaml
+npm install
+npm run build
+Pop-Location
+
Write-Host "`nInstalling Core extension dependencies..." -ForegroundColor White
Push-Location core
npm install