>
@@ -356,23 +355,11 @@ export function Chat() {
- ) : false ? (
-
- ) : (
-
- )
+
}
open={
typeof stepsOpen[index] === "undefined"
- ? false
- ? false
- : true
+ ? true
: stepsOpen[index]!
}
onToggle={() => {}}
@@ -392,7 +379,7 @@ export function Chat() {
<>
{!isStreaming && mode !== "edit" && (
-
{}}
/>
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/pages/gui/ToolCallDiv/ToolCallStatusMessage.tsx b/gui/src/pages/gui/ToolCallDiv/ToolCallStatusMessage.tsx
index e4e4c6e42..7a25a7605 100644
--- a/gui/src/pages/gui/ToolCallDiv/ToolCallStatusMessage.tsx
+++ b/gui/src/pages/gui/ToolCallDiv/ToolCallStatusMessage.tsx
@@ -1,6 +1,8 @@
import { Tool, ToolCallState } from "core";
import Mustache from "mustache";
import { ReactNode } from "react";
+import { getFontSize } from "../../../util";
+import { useFontSize } from "../../../components/ui/font";
interface ToolCallStatusMessageProps {
tool: Tool | undefined;
@@ -11,6 +13,7 @@ export function ToolCallStatusMessage({
tool,
toolCallState,
}: ToolCallStatusMessageProps) {
+ const fontSize = useFontSize();
if (!tool) return "Agent tool use";
const defaultToolDescription = (
@@ -65,7 +68,7 @@ export function ToolCallStatusMessage({
message = futureMessage;
}
return (
-
+
Continue {intro} {message}
);
diff --git a/gui/src/pages/gui/useAutoScroll.ts b/gui/src/pages/gui/useAutoScroll.ts
index a787e7ec9..236ca9f76 100644
--- a/gui/src/pages/gui/useAutoScroll.ts
+++ b/gui/src/pages/gui/useAutoScroll.ts
@@ -1,16 +1,24 @@
-import { useEffect, useState } from "react";
+import { useEffect, useMemo, useState } from "react";
+import { ChatHistoryItemWithMessageId } from "../../redux/slices/sessionSlice";
+
+/**
+ * Only reset scroll state when a new user message is added to the chat.
+ * We don't want to auto-scroll on new tool response messages.
+ */
+function getNumUserMsgs(history: ChatHistoryItemWithMessageId[]) {
+ return history.filter((msg) => msg.message.role === "user").length;
+}
export const useAutoScroll = (
ref: React.RefObject
,
- history: unknown[],
+ history: ChatHistoryItemWithMessageId[],
) => {
const [userHasScrolled, setUserHasScrolled] = useState(false);
+ const numUserMsgs = useMemo(() => getNumUserMsgs(history), [history.length]);
useEffect(() => {
- if (history.length) {
- setUserHasScrolled(false);
- }
- }, [history.length]);
+ setUserHasScrolled(false);
+ }, [numUserMsgs]);
useEffect(() => {
if (!ref.current || history.length === 0) return;
diff --git a/gui/src/redux/slices/editModeState.ts b/gui/src/redux/slices/editModeState.ts
index 52a05a97e..05b41a15b 100644
--- a/gui/src/redux/slices/editModeState.ts
+++ b/gui/src/redux/slices/editModeState.ts
@@ -1,10 +1,11 @@
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
-import { ApplyState, CodeToEdit, MessageModes } from "core";
+import { ApplyState, SetCodeToEditPayload, MessageModes } from "core";
import { EDIT_MODE_STREAM_ID } from "core/edit/constants";
+
export interface EditModeState {
// Array because of previous multi-file edit functionality
// Keeping array to not break persisted redux for now
- codeToEdit: CodeToEdit[];
+ codeToEdit: SetCodeToEditPayload[];
applyState: ApplyState;
returnToMode: MessageModes;
lastNonEditSessionWasEmpty: boolean;
@@ -46,7 +47,7 @@ export const editModeStateSlice = createSlice({
{
payload,
}: PayloadAction<{
- codeToEdit: CodeToEdit | CodeToEdit[];
+ codeToEdit: SetCodeToEditPayload | SetCodeToEditPayload[];
}>,
) => {
state.codeToEdit = Array.isArray(payload.codeToEdit)
diff --git a/gui/src/redux/slices/sessionSlice.ts b/gui/src/redux/slices/sessionSlice.ts
index e81545d8b..627829da4 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,
@@ -31,7 +32,7 @@ import { findCurrentToolCall, findToolCall } from "../util";
// We need this to handle reorderings (e.g. a mid-array deletion) of the messages array.
// The proper fix is adding a UUID to all chat messages, but this is the temp workaround.
-type ChatHistoryItemWithMessageId = ChatHistoryItem & {
+export type ChatHistoryItemWithMessageId = ChatHistoryItem & {
message: ChatMessage & { id: string };
};
@@ -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/editMode.ts b/gui/src/redux/thunks/editMode.ts
index 4341b14a4..8a7771a24 100644
--- a/gui/src/redux/thunks/editMode.ts
+++ b/gui/src/redux/thunks/editMode.ts
@@ -1,6 +1,10 @@
import { createAsyncThunk } from "@reduxjs/toolkit";
import { JSONContent } from "@tiptap/core";
-import { CodeToEdit, MessageModes, RangeInFileWithContents } from "core";
+import {
+ SetCodeToEditPayload,
+ MessageModes,
+ RangeInFileWithContents,
+} from "core";
import { stripImages } from "core/util/messageContent";
import { resolveEditorContent } from "../../components/mainInput/TipTapEditor";
import {
@@ -18,7 +22,7 @@ export const streamEditThunk = createAsyncThunk<
void,
{
editorState: JSONContent;
- codeToEdit: CodeToEdit[];
+ codeToEdit: SetCodeToEditPayload[];
},
ThunkApiType
>(
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/manual-testing-sandbox/test.kt b/manual-testing-sandbox/test.kt
index bb13ae9ee..512c34c25 100644
--- a/manual-testing-sandbox/test.kt
+++ b/manual-testing-sandbox/test.kt
@@ -31,3 +31,6 @@ class Test {
}
}
+
+
+
diff --git a/packages/config-yaml/src/schemas/data/editInteraction/index.ts b/packages/config-yaml/src/schemas/data/editInteraction/index.ts
index 92edc1c06..fd1ba3657 100644
--- a/packages/config-yaml/src/schemas/data/editInteraction/index.ts
+++ b/packages/config-yaml/src/schemas/data/editInteraction/index.ts
@@ -1,6 +1,9 @@
import { z } from "zod";
import { baseDevDataAllSchema } from "../base.js";
+/**
+ * The "editInteraction" event is sent whenever the user submits an input in edit mode and the model's response is completed
+ */
export const editInteractionEventAllSchema = baseDevDataAllSchema.extend({
modelProvider: z.string(),
modelTitle: z.string(),
diff --git a/packages/config-yaml/src/schemas/data/index.ts b/packages/config-yaml/src/schemas/data/index.ts
index d1155f389..7251e12a7 100644
--- a/packages/config-yaml/src/schemas/data/index.ts
+++ b/packages/config-yaml/src/schemas/data/index.ts
@@ -23,6 +23,11 @@ import {
chatInteractionEventSchema_0_2_0,
chatInteractionEventSchema_0_2_0_noCode,
} from "./chatInteraction/v0.2.0.js";
+import { editInteractionEventAllSchema } from "./editInteraction/index.js";
+import {
+ editInteractionEventSchema_0_2_0,
+ editInteractionEventSchema_0_2_0_noCode,
+} from "./editInteraction/v0.2.0.js";
import { quickEditEventAllSchema } from "./quickEdit/index.js";
import {
quickEditEventSchema_0_1_0,
@@ -66,7 +71,7 @@ const devEventAllVersionDataSchemas = z.object({
chatFeedback: chatFeedbackEventAllSchema,
tokensGenerated: tokensGeneratedEventAllSchema,
chatInteraction: chatInteractionEventAllSchema,
- // editInteraction: editInteractionEventAllSchema,
+ editInteraction: editInteractionEventAllSchema,
});
// Version and level specific schemas are organized here
@@ -91,14 +96,14 @@ export const devDataVersionedSchemas = {
chatFeedback: chatFeedbackEventSchema_0_2_0,
tokensGenerated: tokensGeneratedEventSchema_0_2_0,
chatInteraction: chatInteractionEventSchema_0_2_0,
- // editInteraction: editInteractionEventSchema_0_2_0,
+ editInteraction: editInteractionEventSchema_0_2_0,
},
noCode: {
autocomplete: autocompleteEventSchema_0_2_0_noCode,
chatFeedback: chatFeedbackEventSchema_0_2_0_noCode,
tokensGenerated: tokensGeneratedEventSchema_0_2_0_noCode,
chatInteraction: chatInteractionEventSchema_0_2_0_noCode,
- // editInteraction: editInteractionEventSchema_0_2_0_noCode,
+ editInteraction: editInteractionEventSchema_0_2_0_noCode,
},
},
};