From 53f06795d3910e1ec5aecdbc1fde706f68649614 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Wed, 14 May 2025 14:35:01 -0700 Subject: [PATCH 01/19] feat: display rules used --- core/index.d.ts | 19 +-- core/llm/rules/getSystemMessageWithRules.ts | 41 ++++--- .../components/mainInput/ContinueInputBox.tsx | 8 +- .../mainInput/belowMainInput/RulesPeek.tsx | 115 ++++++++++++++++++ gui/src/pages/gui/Chat.tsx | 1 + gui/src/redux/slices/sessionSlice.ts | 15 +++ gui/src/redux/thunks/streamResponse.ts | 36 +++++- 7 files changed, 206 insertions(+), 29 deletions(-) create mode 100644 gui/src/components/mainInput/belowMainInput/RulesPeek.tsx diff --git a/core/index.d.ts b/core/index.d.ts index d15c73b50..501204dca 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -459,6 +459,7 @@ export interface ChatHistoryItem { toolCallState?: ToolCallState; isGatheringContext?: boolean; reasoning?: Reasoning; + appliedRules?: RuleWithSource[]; } export interface LLMFullCompletionOptions extends BaseCompletionOptions { @@ -1497,17 +1498,19 @@ export interface TerminalOptions { waitForCompletion?: boolean; } +export type RuleSource = + | "default-chat" + | "default-agent" + | "model-chat-options" + | "model-agent-options" + | "rules-block" + | "json-systemMessage" + | ".continuerules"; + export interface RuleWithSource { name?: string; slug?: string; - source: - | "default-chat" - | "default-agent" - | "model-chat-options" - | "model-agent-options" - | "rules-block" - | "json-systemMessage" - | ".continuerules"; + source: RuleSource; globs?: string | string[]; rule: string; description?: string; diff --git a/core/llm/rules/getSystemMessageWithRules.ts b/core/llm/rules/getSystemMessageWithRules.ts index dacd941bb..3d7372fef 100644 --- a/core/llm/rules/getSystemMessageWithRules.ts +++ b/core/llm/rules/getSystemMessageWithRules.ts @@ -23,6 +23,29 @@ const matchesGlobs = ( return false; }; +/** + * Filters rules that apply to the given message + */ +export const getApplicableRules = ( + userMessage: UserChatMessage | ToolResultChatMessage | undefined, + rules: RuleWithSource[], +): RuleWithSource[] => { + const filePathsFromMessage = userMessage + ? extractPathsFromCodeBlocks(renderChatMessage(userMessage)) + : []; + + return rules.filter((rule) => { + // A rule is active if it has no globs (applies to all files) + // or if at least one file path matches its globs + const hasNoGlobs = !rule.globs; + const matchesAnyFilePath = filePathsFromMessage.some((path) => + matchesGlobs(path, rule.globs), + ); + + return hasNoGlobs || matchesAnyFilePath; + }); +}; + export const getSystemMessageWithRules = ({ baseSystemMessage, userMessage, @@ -32,23 +55,11 @@ export const getSystemMessageWithRules = ({ userMessage: UserChatMessage | ToolResultChatMessage | undefined; rules: RuleWithSource[]; }) => { - const filePathsFromMessage = userMessage - ? extractPathsFromCodeBlocks(renderChatMessage(userMessage)) - : []; - + const applicableRules = getApplicableRules(userMessage, rules); let systemMessage = baseSystemMessage ?? ""; - for (const rule of rules) { - // A rule is active if it has no globs (applies to all files) - // or if at least one file path matches its globs - const hasNoGlobs = !rule.globs; - const matchesAnyFilePath = filePathsFromMessage.some((path) => - matchesGlobs(path, rule.globs), - ); - - if (hasNoGlobs || matchesAnyFilePath) { - systemMessage += `\n\n${rule.rule}`; - } + for (const rule of applicableRules) { + systemMessage += `\n\n${rule.rule}`; } return systemMessage; diff --git a/gui/src/components/mainInput/ContinueInputBox.tsx b/gui/src/components/mainInput/ContinueInputBox.tsx index c9a151079..c75e0cf68 100644 --- a/gui/src/components/mainInput/ContinueInputBox.tsx +++ b/gui/src/components/mainInput/ContinueInputBox.tsx @@ -1,11 +1,12 @@ import { Editor, JSONContent } from "@tiptap/react"; -import { ContextItemWithId, InputModifiers } from "core"; +import { ContextItemWithId, InputModifiers, RuleWithSource } from "core"; import { useMemo } from "react"; import styled, { keyframes } from "styled-components"; import { defaultBorderRadius, vscBackground } from ".."; import { useAppSelector } from "../../redux/hooks"; import { selectSlashCommandComboBoxInputs } from "../../redux/selectors"; import { ContextItemsPeek } from "./belowMainInput/ContextItemsPeek"; +import { RulesPeek } from "./belowMainInput/RulesPeek"; import { ToolbarOptions } from "./InputToolbar"; import { Lump } from "./Lump"; import { TipTapEditor } from "./TipTapEditor"; @@ -20,6 +21,7 @@ interface ContinueInputBoxProps { ) => void; editorState?: JSONContent; contextItems?: ContextItemWithId[]; + appliedRules?: RuleWithSource[]; hidden?: boolean; inputId: string; // used to keep track of things per input in redux } @@ -147,6 +149,10 @@ function ContinueInputBox(props: ContinueInputBoxProps) { contextItems={props.contextItems} isCurrentContextPeek={props.isLastUserInput} /> + ); } diff --git a/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx b/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx new file mode 100644 index 000000000..c16be1cc2 --- /dev/null +++ b/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx @@ -0,0 +1,115 @@ +import { DocumentTextIcon, GlobeAltIcon } from "@heroicons/react/24/outline"; +import { RuleSource, RuleWithSource } from "core"; +import { ComponentType, useMemo } from "react"; +import ToggleDiv from "../../ToggleDiv"; + +interface RulesPeekProps { + appliedRules?: RuleWithSource[]; + isCurrentRulesPeek: boolean; + icon?: ComponentType>; +} + +interface RulesPeekItemProps { + rule: RuleWithSource; +} + +// Convert technical source to user-friendly text +const getSourceLabel = (source: RuleSource): string => { + switch (source) { + case "default-chat": + return "Default Chat"; + case "default-agent": + return "Default Agent"; + case "model-chat-options": + return "Model Chat Options"; + case "model-agent-options": + return "Model Agent Options"; + case "rules-block": + return "Rules Block"; + case "json-systemMessage": + return "System Message"; + case ".continuerules": + return "Project Rules"; + default: + return source; + } +}; + +export function RulesPeekItem({ rule }: RulesPeekItemProps) { + const isGlobal = !rule.globs; + + return ( +
+
+ {isGlobal ? ( + + ) : ( + + )} + +
+
+ {rule.name || "Assistant rule"} +
+ +
+ {isGlobal + ? "Applies to all files" + : `Pattern: ${typeof rule.globs === "string" ? rule.globs : Array.isArray(rule.globs) ? rule.globs.join(", ") : ""}`} +
+
+
+
+ {rule.rule} +
+
+ Source: {getSourceLabel(rule.source)} +
+
+ ); +} + +export function RulesPeek({ + appliedRules, + isCurrentRulesPeek, + icon, +}: RulesPeekProps) { + const rules = useMemo(() => { + return appliedRules ?? []; + }, [appliedRules]); + + if (!rules || rules.length === 0) { + return null; + } + + const globalRules = rules.filter((r) => !r.globs); + const fileSpecificRules = rules.filter((r) => r.globs); + + return ( + 1 ? "s" : ""}`} + > + {globalRules.length > 0 && ( +
+ Global Rules +
+ )} + {globalRules.map((rule, idx) => ( + + ))} + + {fileSpecificRules.length > 0 && ( +
+ File-Specific Rules +
+ )} + {fileSpecificRules.map((rule, idx) => ( + + ))} +
+ ); +} 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/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", { From 476c3459fe6a219baef763fb90062b3399f3eaec Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Wed, 14 May 2025 16:45:35 -0700 Subject: [PATCH 02/19] test: rules peek --- extensions/vscode/e2e/selectors/GUI.selectors.ts | 8 ++++++++ gui/src/components/ToggleDiv.tsx | 10 ++++++++-- .../components/mainInput/belowMainInput/RulesPeek.tsx | 1 + 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/extensions/vscode/e2e/selectors/GUI.selectors.ts b/extensions/vscode/e2e/selectors/GUI.selectors.ts index e51bfd681..a19cb5b3b 100644 --- a/extensions/vscode/e2e/selectors/GUI.selectors.ts +++ b/extensions/vscode/e2e/selectors/GUI.selectors.ts @@ -89,6 +89,14 @@ export class GUISelectors { ); } + public static getRulesPeek(view: WebView) { + return SelectorUtils.getElementByDataTestId(view, "rules-peek"); + } + + public static getFirstRulesPeekItem(view: WebView) { + return SelectorUtils.getElementByDataTestId(view, "rules-peek-item"); + } + public static getNthHistoryTableRow(view: WebView, index: number) { return SelectorUtils.getElementByDataTestId(view, `history-row-${index}`); } diff --git a/gui/src/components/ToggleDiv.tsx b/gui/src/components/ToggleDiv.tsx index 82536fe10..634aa432e 100644 --- a/gui/src/components/ToggleDiv.tsx +++ b/gui/src/components/ToggleDiv.tsx @@ -6,9 +6,15 @@ interface ToggleProps { children: React.ReactNode; title: React.ReactNode; icon?: ComponentType>; + testId?: string; } -function ToggleDiv({ children, title, icon: Icon }: ToggleProps) { +function ToggleDiv({ + children, + title, + icon: Icon, + testId = "context-items-peek", +}: ToggleProps) { const [open, setOpen] = useState(false); const [isHovered, setIsHovered] = useState(false); @@ -24,7 +30,7 @@ function ToggleDiv({ children, title, icon: Icon }: ToggleProps) { onClick={() => setOpen((prev) => !prev)} onMouseEnter={() => setIsHovered(true)} onMouseLeave={() => setIsHovered(false)} - data-testid="context-items-peek" + data-testid={testId} >
{Icon && !isHovered && !open ? ( diff --git a/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx b/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx index c16be1cc2..21554e6d3 100644 --- a/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx +++ b/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx @@ -92,6 +92,7 @@ export function RulesPeek({ 1 ? "s" : ""}`} + testId="rules-peek" > {globalRules.length > 0 && (
From ef8c67da1e09f5ab6898a0125955d87220dfd8da Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Wed, 14 May 2025 17:22:19 -0700 Subject: [PATCH 03/19] improv: copy --- gui/src/components/mainInput/belowMainInput/RulesPeek.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx b/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx index 21554e6d3..5eed15aba 100644 --- a/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx +++ b/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx @@ -105,7 +105,7 @@ export function RulesPeek({ {fileSpecificRules.length > 0 && (
- File-Specific Rules + Dynamic Rules
)} {fileSpecificRules.map((rule, idx) => ( From 07b6b0cbefe86f2efa5488a33060ee9eb9f20e4d Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Thu, 15 May 2025 10:24:33 -0700 Subject: [PATCH 04/19] fix: failing test --- extensions/vscode/e2e/selectors/GUI.selectors.ts | 2 +- gui/src/components/ToggleDiv.tsx | 5 +---- gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/extensions/vscode/e2e/selectors/GUI.selectors.ts b/extensions/vscode/e2e/selectors/GUI.selectors.ts index a19cb5b3b..773e3cfab 100644 --- a/extensions/vscode/e2e/selectors/GUI.selectors.ts +++ b/extensions/vscode/e2e/selectors/GUI.selectors.ts @@ -46,7 +46,7 @@ export class GUISelectors { } public static getToolCallStatusMessage(view: WebView) { - return SelectorUtils.getElementByDataTestId(view, "toggle-div-title"); + return SelectorUtils.getElementByDataTestId(view, "tool-call-title"); } public static getToolButton(view: WebView) { diff --git a/gui/src/components/ToggleDiv.tsx b/gui/src/components/ToggleDiv.tsx index 634aa432e..4021f29dc 100644 --- a/gui/src/components/ToggleDiv.tsx +++ b/gui/src/components/ToggleDiv.tsx @@ -50,10 +50,7 @@ function ToggleDiv({ )}
- + {title}
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({ From 74a4638936516b62429ebdf2744137f7c408b03e Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Thu, 15 May 2025 10:32:33 -0700 Subject: [PATCH 05/19] test: rule peek --- extensions/vscode/e2e/tests/GUI.test.ts | 38 ++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/extensions/vscode/e2e/tests/GUI.test.ts b/extensions/vscode/e2e/tests/GUI.test.ts index 55493a28c..1f4e988d0 100644 --- a/extensions/vscode/e2e/tests/GUI.test.ts +++ b/extensions/vscode/e2e/tests/GUI.test.ts @@ -245,6 +245,40 @@ describe("GUI Test", () => { await GUIActions.selectModeFromDropdown(view, "Agent"); }); + it("should display rules peek and show rule details", async () => { + // Send a message to trigger the model response + const [messageInput] = await GUISelectors.getMessageInputFields(view); + await messageInput.sendKeys("Hello"); + await messageInput.sendKeys(Key.ENTER); + + // Wait for the response to appear + await TestUtils.waitForSuccess(() => + GUISelectors.getThreadMessageByText(view, "I'm going to call a tool:"), + ); + + // Verify that "1 rule" text appears + const rulesPeek = await TestUtils.waitForSuccess(() => + GUISelectors.getRulesPeek(view), + ); + const rulesPeekText = await rulesPeek.getText(); + expect(rulesPeekText).to.include("1 rule"); + + // Click on the rules peek to expand it + await rulesPeek.click(); + + // Wait for the rule details to appear + const ruleItem = await TestUtils.waitForSuccess(() => + GUISelectors.getFirstRulesPeekItem(view), + ); + + // Verify the rule content + const ruleItemText = await ruleItem.getText(); + expect(ruleItemText).to.include("Assistant rule"); + expect(ruleItemText).to.include("Applies to all files"); + expect(ruleItemText).to.include("TEST_SYS_MSG"); + expect(ruleItemText).to.include("Source: System Message"); + }).timeout(DEFAULT_TIMEOUT.MD); + it("should render tool call", async () => { const [messageInput] = await GUISelectors.getMessageInputFields(view); await messageInput.sendKeys("Hello"); @@ -258,7 +292,9 @@ describe("GUI Test", () => { expect(await statusMessage.getText()).contain( "Continue viewed the git diff", ); - }).timeout(DEFAULT_TIMEOUT.MD); + // wait for 30 seconds, promise + await new Promise((resolve) => setTimeout(resolve, 30000)); + }).timeout(DEFAULT_TIMEOUT.MD * 100); it("should call tool after approval", async () => { await GUIActions.toggleToolPolicy(view, "builtin_view_diff", 2); From ff543e8b321e4e48a088ba296ebac4504b97356b Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Thu, 15 May 2025 11:14:22 -0700 Subject: [PATCH 06/19] fix: tests --- extensions/vscode/e2e/tests/GUI.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/extensions/vscode/e2e/tests/GUI.test.ts b/extensions/vscode/e2e/tests/GUI.test.ts index 1f4e988d0..64b471e0d 100644 --- a/extensions/vscode/e2e/tests/GUI.test.ts +++ b/extensions/vscode/e2e/tests/GUI.test.ts @@ -276,7 +276,6 @@ describe("GUI Test", () => { expect(ruleItemText).to.include("Assistant rule"); expect(ruleItemText).to.include("Applies to all files"); expect(ruleItemText).to.include("TEST_SYS_MSG"); - expect(ruleItemText).to.include("Source: System Message"); }).timeout(DEFAULT_TIMEOUT.MD); it("should render tool call", async () => { From b786591415d79119845e01376bf5dc97c0676b23 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Thu, 15 May 2025 11:28:56 -0700 Subject: [PATCH 07/19] fix: tests --- extensions/vscode/e2e/tests/GUI.test.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/extensions/vscode/e2e/tests/GUI.test.ts b/extensions/vscode/e2e/tests/GUI.test.ts index 64b471e0d..d1416259c 100644 --- a/extensions/vscode/e2e/tests/GUI.test.ts +++ b/extensions/vscode/e2e/tests/GUI.test.ts @@ -271,6 +271,14 @@ describe("GUI Test", () => { GUISelectors.getFirstRulesPeekItem(view), ); + await TestUtils.waitForSuccess(async () => { + const text = await ruleItem.getText(); + if (!text || text.trim() === "") { + throw new Error("Rule item text is empty"); + } + return ruleItem; + }); + // Verify the rule content const ruleItemText = await ruleItem.getText(); expect(ruleItemText).to.include("Assistant rule"); From 55fb41db1a7fb6d8a6cdd5086fc9765be969befe Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Thu, 15 May 2025 12:32:00 -0700 Subject: [PATCH 08/19] improv: clean up --- gui/src/components/mainInput/ContinueInputBox.tsx | 5 +---- gui/src/components/mainInput/belowMainInput/RulesPeek.tsx | 7 +------ 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/gui/src/components/mainInput/ContinueInputBox.tsx b/gui/src/components/mainInput/ContinueInputBox.tsx index c75e0cf68..fddfbf966 100644 --- a/gui/src/components/mainInput/ContinueInputBox.tsx +++ b/gui/src/components/mainInput/ContinueInputBox.tsx @@ -149,10 +149,7 @@ function ContinueInputBox(props: ContinueInputBoxProps) { contextItems={props.contextItems} isCurrentContextPeek={props.isLastUserInput} /> - + ); } diff --git a/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx b/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx index 5eed15aba..f8af0a46d 100644 --- a/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx +++ b/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx @@ -5,7 +5,6 @@ import ToggleDiv from "../../ToggleDiv"; interface RulesPeekProps { appliedRules?: RuleWithSource[]; - isCurrentRulesPeek: boolean; icon?: ComponentType>; } @@ -72,11 +71,7 @@ export function RulesPeekItem({ rule }: RulesPeekItemProps) { ); } -export function RulesPeek({ - appliedRules, - isCurrentRulesPeek, - icon, -}: RulesPeekProps) { +export function RulesPeek({ appliedRules, icon }: RulesPeekProps) { const rules = useMemo(() => { return appliedRules ?? []; }, [appliedRules]); From 8f339467104858199be6b5d17eca05907d02445f Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Thu, 15 May 2025 12:44:53 -0700 Subject: [PATCH 09/19] improv: ui --- .../mainInput/belowMainInput/RulesPeek.tsx | 34 +++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx b/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx index f8af0a46d..b52da8ad4 100644 --- a/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx +++ b/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx @@ -1,6 +1,6 @@ import { DocumentTextIcon, GlobeAltIcon } from "@heroicons/react/24/outline"; import { RuleSource, RuleWithSource } from "core"; -import { ComponentType, useMemo } from "react"; +import { ComponentType, useMemo, useState } from "react"; import ToggleDiv from "../../ToggleDiv"; interface RulesPeekProps { @@ -36,6 +36,23 @@ const getSourceLabel = (source: RuleSource): string => { export function RulesPeekItem({ rule }: RulesPeekItemProps) { const isGlobal = !rule.globs; + const [expanded, setExpanded] = useState(false); + + // Define maximum length for rule text display + const maxRuleLength = 120; + const isRuleLong = rule.rule.length > maxRuleLength; + + // Get the displayed rule text based on expanded state + const displayedRule = + isRuleLong && !expanded + ? `${rule.rule.slice(0, maxRuleLength)}...` + : rule.rule; + + const toggleExpand = () => { + if (isRuleLong) { + setExpanded(!expanded); + } + }; return (
-
- {rule.rule} +
+ {displayedRule} + {isRuleLong && ( + + {expanded ? "(collapse)" : "(expand)"} + + )}
Source: {getSourceLabel(rule.source)} From 5fde07e2e8c96325084b4288b1bcc13352954d63 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Thu, 15 May 2025 12:54:28 -0700 Subject: [PATCH 10/19] improv: copy --- extensions/vscode/e2e/tests/GUI.test.ts | 2 +- gui/src/components/mainInput/belowMainInput/RulesPeek.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/vscode/e2e/tests/GUI.test.ts b/extensions/vscode/e2e/tests/GUI.test.ts index d1416259c..b05302226 100644 --- a/extensions/vscode/e2e/tests/GUI.test.ts +++ b/extensions/vscode/e2e/tests/GUI.test.ts @@ -282,7 +282,7 @@ describe("GUI Test", () => { // Verify the rule content const ruleItemText = await ruleItem.getText(); expect(ruleItemText).to.include("Assistant rule"); - expect(ruleItemText).to.include("Applies to all files"); + expect(ruleItemText).to.include("Always applied"); expect(ruleItemText).to.include("TEST_SYS_MSG"); }).timeout(DEFAULT_TIMEOUT.MD); diff --git a/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx b/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx index b52da8ad4..cee8d69cf 100644 --- a/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx +++ b/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx @@ -73,7 +73,7 @@ export function RulesPeekItem({ rule }: RulesPeekItemProps) {
{isGlobal - ? "Applies to all files" + ? "Always applied" : `Pattern: ${typeof rule.globs === "string" ? rule.globs : Array.isArray(rule.globs) ? rule.globs.join(", ") : ""}`}
From b380468f9daaa73ddd9f9b4756ac1cd35e6ce19d Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Thu, 15 May 2025 13:00:17 -0700 Subject: [PATCH 11/19] improv: ui --- gui/src/components/mainInput/belowMainInput/RulesPeek.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx b/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx index cee8d69cf..39a49bc97 100644 --- a/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx +++ b/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx @@ -39,7 +39,7 @@ export function RulesPeekItem({ rule }: RulesPeekItemProps) { const [expanded, setExpanded] = useState(false); // Define maximum length for rule text display - const maxRuleLength = 120; + const maxRuleLength = 100; const isRuleLong = rule.rule.length > maxRuleLength; // Get the displayed rule text based on expanded state @@ -71,9 +71,9 @@ export function RulesPeekItem({ rule }: RulesPeekItemProps) { {rule.name || "Assistant rule"}
-
+
{isGlobal - ? "Always applied" + ? "Applies to all files" : `Pattern: ${typeof rule.globs === "string" ? rule.globs : Array.isArray(rule.globs) ? rule.globs.join(", ") : ""}`}
From fb60c4d4b60fb29e87f4e91fecfb55022ea7a44b Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Thu, 15 May 2025 13:04:31 -0700 Subject: [PATCH 12/19] improv: ui --- gui/src/components/mainInput/belowMainInput/RulesPeek.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx b/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx index 39a49bc97..69e405937 100644 --- a/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx +++ b/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx @@ -56,8 +56,9 @@ export function RulesPeekItem({ rule }: RulesPeekItemProps) { return (
{isGlobal ? ( @@ -79,15 +80,14 @@ export function RulesPeekItem({ rule }: RulesPeekItemProps) {
{displayedRule} {isRuleLong && ( - + {expanded ? "(collapse)" : "(expand)"} )} From 9edfb401588a56a63b189db0e3cf66e52845ae31 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Thu, 15 May 2025 13:13:13 -0700 Subject: [PATCH 13/19] improv: ui --- gui/src/components/mainInput/belowMainInput/RulesPeek.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx b/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx index 69e405937..416fa5009 100644 --- a/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx +++ b/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx @@ -80,7 +80,7 @@ export function RulesPeekItem({ rule }: RulesPeekItemProps) {
Date: Thu, 15 May 2025 13:15:42 -0700 Subject: [PATCH 14/19] improv: ui --- gui/src/components/mainInput/belowMainInput/RulesPeek.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx b/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx index 416fa5009..8e1636e87 100644 --- a/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx +++ b/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx @@ -74,7 +74,7 @@ export function RulesPeekItem({ rule }: RulesPeekItemProps) {
{isGlobal - ? "Applies to all files" + ? "" : `Pattern: ${typeof rule.globs === "string" ? rule.globs : Array.isArray(rule.globs) ? rule.globs.join(", ") : ""}`}
@@ -119,7 +119,7 @@ export function RulesPeek({ appliedRules, icon }: RulesPeekProps) { > {globalRules.length > 0 && (
- Global Rules + Always Applied
)} {globalRules.map((rule, idx) => ( From 6ebabd46d306d94819d6ae9631ac0c63aa5e181a Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Thu, 15 May 2025 13:16:57 -0700 Subject: [PATCH 15/19] improv: ui --- gui/src/components/mainInput/belowMainInput/RulesPeek.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx b/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx index 8e1636e87..c426d8dba 100644 --- a/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx +++ b/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx @@ -74,7 +74,7 @@ export function RulesPeekItem({ rule }: RulesPeekItemProps) {
{isGlobal - ? "" + ? "Always applied" : `Pattern: ${typeof rule.globs === "string" ? rule.globs : Array.isArray(rule.globs) ? rule.globs.join(", ") : ""}`}
From b5ff5b537db09126dee6c7975f2993a93baf9016 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Thu, 15 May 2025 13:18:59 -0700 Subject: [PATCH 16/19] improv: ui --- .../mainInput/belowMainInput/RulesPeek.tsx | 21 ++----------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx b/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx index c426d8dba..be40ac907 100644 --- a/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx +++ b/gui/src/components/mainInput/belowMainInput/RulesPeek.tsx @@ -108,31 +108,14 @@ export function RulesPeek({ appliedRules, icon }: RulesPeekProps) { return null; } - const globalRules = rules.filter((r) => !r.globs); - const fileSpecificRules = rules.filter((r) => r.globs); - return ( 1 ? "s" : ""}`} testId="rules-peek" > - {globalRules.length > 0 && ( -
- Always Applied -
- )} - {globalRules.map((rule, idx) => ( - - ))} - - {fileSpecificRules.length > 0 && ( -
- Dynamic Rules -
- )} - {fileSpecificRules.map((rule, idx) => ( - + {rules.map((rule, idx) => ( + ))}
); From 9d65347b9e01a3155f1ffa653813e3063b46ecfd Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Thu, 15 May 2025 13:20:21 -0700 Subject: [PATCH 17/19] improv: ui --- gui/src/components/mainInput/ContinueInputBox.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/src/components/mainInput/ContinueInputBox.tsx b/gui/src/components/mainInput/ContinueInputBox.tsx index fddfbf966..317d16a39 100644 --- a/gui/src/components/mainInput/ContinueInputBox.tsx +++ b/gui/src/components/mainInput/ContinueInputBox.tsx @@ -145,11 +145,11 @@ function ContinueInputBox(props: ContinueInputBoxProps) { /> + - ); } From 89ef6e0919a2d6a1e06ea638520ca8c9de74186c Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Thu, 15 May 2025 13:34:08 -0700 Subject: [PATCH 18/19] improv: ui --- gui/src/components/ToggleDiv.tsx | 2 +- .../components/mainInput/ContinueInputBox.tsx | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/gui/src/components/ToggleDiv.tsx b/gui/src/components/ToggleDiv.tsx index 4021f29dc..988cfd22b 100644 --- a/gui/src/components/ToggleDiv.tsx +++ b/gui/src/components/ToggleDiv.tsx @@ -20,7 +20,7 @@ function ToggleDiv({ return (
- - + {(appliedRules.length > 0 || contextItems.length > 0) && ( +
+ + +
+ )} ); } From 002ecc9b519472e0968e9f227894f3143c87f1ec Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Thu, 15 May 2025 14:03:08 -0700 Subject: [PATCH 19/19] fix: failing test --- core/llm/llm.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/core/llm/llm.test.ts b/core/llm/llm.test.ts index d1067a8bc..7fb840d61 100644 --- a/core/llm/llm.test.ts +++ b/core/llm/llm.test.ts @@ -230,6 +230,7 @@ describe("LLM", () => { testFim: true, skip: false, testToolCall: true, + timeout: 60000, }, ); testLLM(