Skip to content

Commit f2d7cbe

Browse files
authored
Merge pull request RooCodeInc#753 from RooVetGit/visual_fixes
Slight visual fixes
2 parents 3f9b667 + 644194a commit f2d7cbe

File tree

6 files changed

+82
-59
lines changed

6 files changed

+82
-59
lines changed

src/core/__tests__/mode-validator.test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ describe("mode-validator", () => {
99
it("allows all code mode tools", () => {
1010
const mode = getModeConfig(codeMode)
1111
// Code mode has all groups
12-
Object.entries(TOOL_GROUPS).forEach(([_, tools]) => {
13-
tools.forEach((tool) => {
12+
Object.entries(TOOL_GROUPS).forEach(([_, config]) => {
13+
config.tools.forEach((tool: string) => {
1414
expect(isToolAllowedForMode(tool, codeMode, [])).toBe(true)
1515
})
1616
})
@@ -25,7 +25,11 @@ describe("mode-validator", () => {
2525
it("allows configured tools", () => {
2626
const mode = getModeConfig(architectMode)
2727
// Architect mode has read, browser, and mcp groups
28-
const architectTools = [...TOOL_GROUPS.read, ...TOOL_GROUPS.browser, ...TOOL_GROUPS.mcp]
28+
const architectTools = [
29+
...TOOL_GROUPS.read.tools,
30+
...TOOL_GROUPS.browser.tools,
31+
...TOOL_GROUPS.mcp.tools,
32+
]
2933
architectTools.forEach((tool) => {
3034
expect(isToolAllowedForMode(tool, architectMode, [])).toBe(true)
3135
})
@@ -36,7 +40,7 @@ describe("mode-validator", () => {
3640
it("allows configured tools", () => {
3741
const mode = getModeConfig(askMode)
3842
// Ask mode has read, browser, and mcp groups
39-
const askTools = [...TOOL_GROUPS.read, ...TOOL_GROUPS.browser, ...TOOL_GROUPS.mcp]
43+
const askTools = [...TOOL_GROUPS.read.tools, ...TOOL_GROUPS.browser.tools, ...TOOL_GROUPS.mcp.tools]
4044
askTools.forEach((tool) => {
4145
expect(isToolAllowedForMode(tool, askMode, [])).toBe(true)
4246
})

src/core/prompts/tools/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export function getToolDescriptionsForMode(
6666
const groupName = getGroupName(groupEntry)
6767
const toolGroup = TOOL_GROUPS[groupName]
6868
if (toolGroup) {
69-
toolGroup.forEach((tool) => {
69+
toolGroup.tools.forEach((tool) => {
7070
if (isToolAllowedForMode(tool as ToolName, mode, customModes ?? [], experiments ?? {})) {
7171
tools.add(tool)
7272
}

src/shared/modes.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ export function getToolsForMode(groups: readonly GroupEntry[]): string[] {
5959
// Add tools from each group
6060
groups.forEach((group) => {
6161
const groupName = getGroupName(group)
62-
TOOL_GROUPS[groupName].forEach((tool) => tools.add(tool))
62+
const groupConfig = TOOL_GROUPS[groupName]
63+
groupConfig.tools.forEach((tool: string) => tools.add(tool))
6364
})
6465

6566
// Always add required tools
@@ -190,8 +191,10 @@ export function isToolAllowedForMode(
190191
const groupName = getGroupName(group)
191192
const options = getGroupOptions(group)
192193

193-
// If the tool isn't in this group, continue to next group
194-
if (!TOOL_GROUPS[groupName].includes(tool)) {
194+
const groupConfig = TOOL_GROUPS[groupName]
195+
196+
// If the tool isn't in this group's tools, continue to next group
197+
if (!groupConfig.tools.includes(tool)) {
195198
continue
196199
}
197200

src/shared/tool-groups.ts

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
// Define tool group values
2-
export type ToolGroupValues = readonly string[]
1+
// Define tool group configuration
2+
export type ToolGroupConfig = {
3+
tools: readonly string[]
4+
alwaysAvailable?: boolean // Whether this group is always available and shouldn't show in prompts view
5+
}
36

47
// Map of tool slugs to their display names
58
export const TOOL_DISPLAY_NAMES = {
@@ -20,13 +23,26 @@ export const TOOL_DISPLAY_NAMES = {
2023
} as const
2124

2225
// Define available tool groups
23-
export const TOOL_GROUPS: Record<string, ToolGroupValues> = {
24-
read: ["read_file", "search_files", "list_files", "list_code_definition_names"],
25-
edit: ["write_to_file", "apply_diff", "insert_content", "search_and_replace"],
26-
browser: ["browser_action"],
27-
command: ["execute_command"],
28-
mcp: ["use_mcp_tool", "access_mcp_resource"],
29-
modes: ["switch_mode", "new_task"],
26+
export const TOOL_GROUPS: Record<string, ToolGroupConfig> = {
27+
read: {
28+
tools: ["read_file", "search_files", "list_files", "list_code_definition_names"],
29+
},
30+
edit: {
31+
tools: ["write_to_file", "apply_diff", "insert_content", "search_and_replace"],
32+
},
33+
browser: {
34+
tools: ["browser_action"],
35+
},
36+
command: {
37+
tools: ["execute_command"],
38+
},
39+
mcp: {
40+
tools: ["use_mcp_tool", "access_mcp_resource"],
41+
},
42+
modes: {
43+
tools: ["switch_mode", "new_task"],
44+
alwaysAvailable: true,
45+
},
3046
}
3147

3248
export type ToolGroup = keyof typeof TOOL_GROUPS

webview-ui/src/components/chat/ChatView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
994994
}}>
995995
{showAnnouncement && <Announcement version={version} hideAnnouncement={hideAnnouncement} />}
996996
<div style={{ padding: "0 20px", flexShrink: 0 }}>
997-
<h2>What can I do for you?</h2>
997+
<h2>What can Roo do for you?</h2>
998998
<p>
999999
Thanks to the latest breakthroughs in agentic coding capabilities, I can handle complex
10001000
software development tasks step-by-step. With tools that let me create & edit files, explore

webview-ui/src/components/prompts/PromptsView.tsx

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ import {
2626
import { TOOL_GROUPS, GROUP_DISPLAY_NAMES, ToolGroup } from "../../../../src/shared/tool-groups"
2727
import { vscode } from "../../utils/vscode"
2828

29-
// Get all available groups from GROUP_DISPLAY_NAMES
30-
const availableGroups = Object.keys(TOOL_GROUPS) as ToolGroup[]
29+
// Get all available groups that should show in prompts view
30+
const availableGroups = (Object.keys(TOOL_GROUPS) as ToolGroup[]).filter((group) => !TOOL_GROUPS[group].alwaysAvailable)
3131

3232
type PromptsViewProps = {
3333
onDone: () => void
@@ -65,6 +65,7 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
6565
const [isToolsEditMode, setIsToolsEditMode] = useState(false)
6666
const [isCreateModeDialogOpen, setIsCreateModeDialogOpen] = useState(false)
6767
const [activeSupportTab, setActiveSupportTab] = useState<SupportPromptType>("ENHANCE")
68+
const [selectedModeTab, setSelectedModeTab] = useState<string>(mode)
6869

6970
// Direct update functions
7071
const updateAgentPrompt = useCallback(
@@ -110,26 +111,23 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
110111
text: slug,
111112
})
112113
}, [])
113-
114-
// Handle mode switching with explicit state initialization
114+
// Handle mode tab selection without actually switching modes
115115
const handleModeSwitch = useCallback(
116116
(modeConfig: ModeConfig) => {
117-
if (modeConfig.slug === mode) return // Prevent unnecessary updates
118-
119-
// First switch the mode
120-
switchMode(modeConfig.slug)
117+
if (modeConfig.slug === selectedModeTab) return // Prevent unnecessary updates
121118

122-
// Exit tools edit mode when switching modes
119+
// Update selected tab and reset tools edit mode
120+
setSelectedModeTab(modeConfig.slug)
123121
setIsToolsEditMode(false)
124122
},
125-
[mode, switchMode, setIsToolsEditMode],
123+
[selectedModeTab, setIsToolsEditMode],
126124
)
127125

128126
// Helper function to get current mode's config
129127
const getCurrentMode = useCallback((): ModeConfig | undefined => {
130-
const findMode = (m: ModeConfig): boolean => m.slug === mode
128+
const findMode = (m: ModeConfig): boolean => m.slug === selectedModeTab
131129
return customModes?.find(findMode) || modes.find(findMode)
132-
}, [mode, customModes, modes])
130+
}, [selectedModeTab, customModes, modes])
133131

134132
// Helper function to safely access mode properties
135133
const getModeProperty = <T extends keyof ModeConfig>(
@@ -155,6 +153,11 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
155153
}
156154
}, [isCreateModeDialogOpen])
157155

156+
// Keep selected tab in sync with actual mode
157+
useEffect(() => {
158+
setSelectedModeTab(mode)
159+
}, [mode])
160+
158161
// Helper function to generate a unique slug from a name
159162
const generateSlug = useCallback((name: string, attempt = 0): string => {
160163
const baseSlug = name
@@ -184,22 +187,13 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
184187
groups: newModeGroups,
185188
}
186189
updateCustomMode(newModeSlug, newMode)
187-
switchMode(newModeSlug)
188190
setIsCreateModeDialogOpen(false)
189191
setNewModeName("")
190192
setNewModeSlug("")
191193
setNewModeRoleDefinition("")
192194
setNewModeCustomInstructions("")
193195
setNewModeGroups(availableGroups)
194-
}, [
195-
newModeName,
196-
newModeSlug,
197-
newModeRoleDefinition,
198-
newModeCustomInstructions,
199-
newModeGroups,
200-
updateCustomMode,
201-
switchMode,
202-
])
196+
}, [newModeName, newModeSlug, newModeRoleDefinition, newModeCustomInstructions, newModeGroups, updateCustomMode])
203197

204198
const isNameOrSlugTaken = useCallback(
205199
(name: string, slug: string) => {
@@ -479,7 +473,7 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
479473
padding: "4px 0",
480474
}}>
481475
{modes.map((modeConfig) => {
482-
const isActive = mode === modeConfig.slug
476+
const isActive = selectedModeTab === modeConfig.slug
483477
return (
484478
<button
485479
key={modeConfig.slug}
@@ -507,20 +501,22 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
507501

508502
<div style={{ marginBottom: "20px" }}>
509503
{/* Only show name and delete for custom modes */}
510-
{mode && findModeBySlug(mode, customModes) && (
504+
{selectedModeTab && findModeBySlug(selectedModeTab, customModes) && (
511505
<div style={{ display: "flex", gap: "12px", marginBottom: "16px" }}>
512506
<div style={{ flex: 1 }}>
513507
<div style={{ fontWeight: "bold", marginBottom: "4px" }}>Name</div>
514508
<div style={{ display: "flex", gap: "8px" }}>
515509
<VSCodeTextField
516-
value={getModeProperty(findModeBySlug(mode, customModes), "name") ?? ""}
510+
value={
511+
getModeProperty(findModeBySlug(selectedModeTab, customModes), "name") ?? ""
512+
}
517513
onChange={(e: Event | React.FormEvent<HTMLElement>) => {
518514
const target =
519515
(e as CustomEvent)?.detail?.target ||
520516
((e as any).target as HTMLInputElement)
521-
const customMode = findModeBySlug(mode, customModes)
517+
const customMode = findModeBySlug(selectedModeTab, customModes)
522518
if (customMode) {
523-
updateCustomMode(mode, {
519+
updateCustomMode(selectedModeTab, {
524520
...customMode,
525521
name: target.value,
526522
})
@@ -534,7 +530,7 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
534530
onClick={() => {
535531
vscode.postMessage({
536532
type: "deleteCustomMode",
537-
slug: mode,
533+
slug: selectedModeTab,
538534
})
539535
}}>
540536
<span className="codicon codicon-trash"></span>
@@ -552,7 +548,7 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
552548
marginBottom: "4px",
553549
}}>
554550
<div style={{ fontWeight: "bold" }}>Role Definition</div>
555-
{!findModeBySlug(mode, customModes) && (
551+
{!findModeBySlug(selectedModeTab, customModes) && (
556552
<VSCodeButton
557553
appearance="icon"
558554
onClick={() => {
@@ -578,24 +574,28 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
578574
</div>
579575
<VSCodeTextArea
580576
value={(() => {
581-
const customMode = findModeBySlug(mode, customModes)
582-
const prompt = customModePrompts?.[mode] as PromptComponent
583-
return customMode?.roleDefinition ?? prompt?.roleDefinition ?? getRoleDefinition(mode)
577+
const customMode = findModeBySlug(selectedModeTab, customModes)
578+
const prompt = customModePrompts?.[selectedModeTab] as PromptComponent
579+
return (
580+
customMode?.roleDefinition ??
581+
prompt?.roleDefinition ??
582+
getRoleDefinition(selectedModeTab)
583+
)
584584
})()}
585585
onChange={(e) => {
586586
const value =
587587
(e as CustomEvent)?.detail?.target?.value ||
588588
((e as any).target as HTMLTextAreaElement).value
589-
const customMode = findModeBySlug(mode, customModes)
589+
const customMode = findModeBySlug(selectedModeTab, customModes)
590590
if (customMode) {
591591
// For custom modes, update the JSON file
592-
updateCustomMode(mode, {
592+
updateCustomMode(selectedModeTab, {
593593
...customMode,
594594
roleDefinition: value.trim() || "",
595595
})
596596
} else {
597597
// For built-in modes, update the prompts
598-
updateAgentPrompt(mode, {
598+
updateAgentPrompt(selectedModeTab, {
599599
roleDefinition: value.trim() || undefined,
600600
})
601601
}
@@ -760,25 +760,25 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
760760
</div>
761761
<VSCodeTextArea
762762
value={(() => {
763-
const customMode = findModeBySlug(mode, customModes)
764-
const prompt = customModePrompts?.[mode] as PromptComponent
763+
const customMode = findModeBySlug(selectedModeTab, customModes)
764+
const prompt = customModePrompts?.[selectedModeTab] as PromptComponent
765765
return customMode?.customInstructions ?? prompt?.customInstructions ?? ""
766766
})()}
767767
onChange={(e) => {
768768
const value =
769769
(e as CustomEvent)?.detail?.target?.value ||
770770
((e as any).target as HTMLTextAreaElement).value
771-
const customMode = findModeBySlug(mode, customModes)
771+
const customMode = findModeBySlug(selectedModeTab, customModes)
772772
if (customMode) {
773773
// For custom modes, update the JSON file
774-
updateCustomMode(mode, {
774+
updateCustomMode(selectedModeTab, {
775775
...customMode,
776776
customInstructions: value.trim() || undefined,
777777
})
778778
} else {
779779
// For built-in modes, update the prompts
780-
const existingPrompt = customModePrompts?.[mode] as PromptComponent
781-
updateAgentPrompt(mode, {
780+
const existingPrompt = customModePrompts?.[selectedModeTab] as PromptComponent
781+
updateAgentPrompt(selectedModeTab, {
782782
...existingPrompt,
783783
customInstructions: value.trim() || undefined,
784784
})

0 commit comments

Comments
 (0)