{text}
{isToggled && !!showIfToggled && showIfToggled}
void;
+ isSelected: boolean;
+}
+const ModeBadge = ({ text, onClick, isSelected, icon }: ModeBadgeProps) => {
+ return (
+
+ {icon}
+ {text}
+
+ );
+};
+
export const ToolPoliciesSection = () => {
+ const mode = useAppSelector((state) => state.session.mode);
+ const readOnlyMode = useAppSelector((state) => state.session.readOnlyMode);
const availableTools = useAppSelector((state) => state.config.config.tools);
const toolGroupSettings = useAppSelector(
(store) => store.ui.toolGroupSettings,
@@ -39,38 +60,57 @@ export const ToolPoliciesSection = () => {
);
}, [availableTools]);
+ const allToolsOff = mode === "chat";
+
+ const pseudoMode = mode === "chat" ? "chat" : readOnlyMode ? "plan" : "act";
+ const message =
+ pseudoMode === "chat"
+ ? "All tools are disabled in Chat mode"
+ : pseudoMode === "plan"
+ ? "Plan mode: only MCP and read-only tools"
+ : "Act mode: all tool policies apply";
+
return (
<>
- {toolsByGroup.map(([groupName, tools]) => (
-
-
-
- {groupName}
-
- dispatch(toggleToolGroupSetting(groupName))}
- text=""
- size={10}
- />
-
-
- {tools.map((tool) => (
-
+
+ {message}
+
+ {toolsByGroup.map(([groupName, tools]) => {
+ const isGroupEnabled =
+ !allToolsOff && toolGroupSettings[groupName] !== "exclude";
+ return (
+
+
+
+ {groupName}
+
+ dispatch(toggleToolGroupSetting(groupName))}
+ text=""
+ size={10}
+ disabled={allToolsOff}
/>
- ))}
+
+
+ {tools.map((tool) => (
+
+ ))}
+
-
- ))}
+ );
+ })}
>
);
};
diff --git a/gui/src/components/mainInput/Lump/sections/tool-policies/ToolPolicyItem.tsx b/gui/src/components/mainInput/Lump/sections/tool-policies/ToolPolicyItem.tsx
index b92816839..38f9416fe 100644
--- a/gui/src/components/mainInput/Lump/sections/tool-policies/ToolPolicyItem.tsx
+++ b/gui/src/components/mainInput/Lump/sections/tool-policies/ToolPolicyItem.tsx
@@ -3,6 +3,7 @@ import {
InformationCircleIcon,
} from "@heroicons/react/24/outline";
import { Tool } from "core";
+import { BUILT_IN_GROUP_NAME } from "core/tools/builtIn";
import { useEffect, useMemo, useState } from "react";
import { useDispatch } from "react-redux";
import { useAppSelector } from "../../../../../redux/hooks";
@@ -16,7 +17,7 @@ import { useFontSize } from "../../../../ui/font";
interface ToolDropdownItemProps {
tool: Tool;
duplicatesDetected: boolean;
- excluded: boolean;
+ isGroupEnabled: boolean;
}
function ToolPolicyItem(props: ToolDropdownItemProps) {
@@ -25,6 +26,7 @@ function ToolPolicyItem(props: ToolDropdownItemProps) {
(state) => state.ui.toolSettings[props.tool.function.name],
);
const [isExpanded, setIsExpanded] = useState(false);
+ const readOnlyMode = useAppSelector((state) => state.session.readOnlyMode);
useEffect(() => {
if (!policy) {
@@ -44,6 +46,12 @@ function ToolPolicyItem(props: ToolDropdownItemProps) {
const fontSize = useFontSize(-2);
+ const disabled =
+ !props.isGroupEnabled ||
+ (readOnlyMode &&
+ props.tool.group === BUILT_IN_GROUP_NAME &&
+ !props.tool.readonly);
+
if (!policy) {
return null;
}
@@ -106,8 +114,9 @@ function ToolPolicyItem(props: ToolDropdownItemProps) {
+
{
dispatch(toggleToolSetting(props.tool.function.name));
@@ -115,7 +124,7 @@ function ToolPolicyItem(props: ToolDropdownItemProps) {
e.preventDefault();
}}
>
- {props.excluded || policy === "disabled" ? (
+ {disabled || policy === "disabled" ? (
<>
Off
diff --git a/gui/src/redux/slices/sessionSlice.ts b/gui/src/redux/slices/sessionSlice.ts
index 6cd96dd8e..c48a9840d 100644
--- a/gui/src/redux/slices/sessionSlice.ts
+++ b/gui/src/redux/slices/sessionSlice.ts
@@ -54,6 +54,7 @@ type SessionState = {
mainEditorContentTrigger?: JSONContent | undefined;
symbols: FileSymbolMap;
mode: MessageModes;
+ readOnlyMode: boolean;
isInEdit: boolean;
codeBlockApplyStates: {
states: ApplyState[];
@@ -73,6 +74,7 @@ const initialState: SessionState = {
streamAborter: new AbortController(),
symbols: {},
mode: "chat",
+ readOnlyMode: false,
isInEdit: false,
codeBlockApplyStates: {
states: [],
@@ -668,6 +670,9 @@ export const sessionSlice = createSlice({
setMode: (state, action: PayloadAction) => {
state.mode = action.payload;
},
+ setReadOnly: (state, action: PayloadAction) => {
+ state.readOnlyMode = action.payload;
+ },
setIsInEdit: (state, action: PayloadAction) => {
state.isInEdit = action.payload;
},
@@ -768,6 +773,7 @@ export const {
setToolGenerated,
updateToolCallOutput,
setMode,
+ setReadOnly,
setIsSessionMetadataLoading,
setAllSessionMetadata,
addSessionMetadata,
diff --git a/gui/src/redux/store.ts b/gui/src/redux/store.ts
index 10ecdd2e5..40bd76160 100644
--- a/gui/src/redux/store.ts
+++ b/gui/src/redux/store.ts
@@ -42,6 +42,7 @@ const saveSubsetFilters = [
// Persist edit mode in case closes in middle
"mode",
+ "readOnlyMode",
// higher risk to persist
// codeBlockApplyStates
diff --git a/gui/src/redux/thunks/streamNormalInput.ts b/gui/src/redux/thunks/streamNormalInput.ts
index c7c4de02d..2d25f9e29 100644
--- a/gui/src/redux/thunks/streamNormalInput.ts
+++ b/gui/src/redux/thunks/streamNormalInput.ts
@@ -40,12 +40,16 @@ export const streamNormalInput = createAsyncThunk<
// Get tools
const activeTools = selectActiveTools(state);
const toolsSupported = modelSupportsTools(selectedChatModel);
+ const readOnlyMode = state.session.readOnlyMode;
+ const filteredTools = readOnlyMode
+ ? activeTools.filter((t) => t.readonly)
+ : activeTools;
// Construct completion options
let completionOptions: LLMFullCompletionOptions = {};
- if (toolsSupported && activeTools.length > 0) {
+ if (toolsSupported && filteredTools.length > 0) {
completionOptions = {
- tools: activeTools,
+ tools: filteredTools,
};
}
@@ -125,7 +129,7 @@ export const streamNormalInput = createAsyncThunk<
modelTitle: selectedChatModel.title,
sessionId: state.session.id,
...(state.session.mode === "agent" && {
- tools: activeTools.map((tool) => tool.function.name),
+ tools: filteredTools.map((tool) => tool.function.name),
}),
},
});