Skip to content

Commit 2e6a523

Browse files
committed
draft: try to add a setting button
1 parent 294b52e commit 2e6a523

File tree

8 files changed

+61
-0
lines changed

8 files changed

+61
-0
lines changed

src/exports/roo-code.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ type GlobalSettings = {
257257
cachedChromeHostUrl?: string | undefined
258258
enableCheckpoints?: boolean | undefined
259259
checkpointStorage?: ("task" | "workspace") | undefined
260+
showGreeting?: boolean | undefined
260261
ttsEnabled?: boolean | undefined
261262
ttsSpeed?: number | undefined
262263
soundEnabled?: boolean | undefined

src/exports/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ type GlobalSettings = {
260260
cachedChromeHostUrl?: string | undefined
261261
enableCheckpoints?: boolean | undefined
262262
checkpointStorage?: ("task" | "workspace") | undefined
263+
showGreeting?: boolean | undefined
263264
ttsEnabled?: boolean | undefined
264265
ttsSpeed?: number | undefined
265266
soundEnabled?: boolean | undefined

src/schemas/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,8 @@ export const globalSettingsSchema = z.object({
532532
enableCheckpoints: z.boolean().optional(),
533533
checkpointStorage: checkpointStoragesSchema.optional(),
534534

535+
showGreeting: z.boolean().optional(),
536+
535537
ttsEnabled: z.boolean().optional(),
536538
ttsSpeed: z.number().optional(),
537539
soundEnabled: z.boolean().optional(),
@@ -608,6 +610,8 @@ const globalSettingsRecord: GlobalSettingsRecord = {
608610
enableCheckpoints: undefined,
609611
checkpointStorage: undefined,
610612

613+
showGreeting: undefined,
614+
611615
ttsEnabled: undefined,
612616
ttsSpeed: undefined,
613617
soundEnabled: undefined,

src/shared/ExtensionMessage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ export type ExtensionState = Pick<
143143
| "remoteBrowserHost"
144144
// | "enableCheckpoints" // Optional in GlobalSettings, required here.
145145
// | "checkpointStorage" // Optional in GlobalSettings, required here.
146+
| "showGreeting"
146147
| "ttsEnabled"
147148
| "ttsSpeed"
148149
| "soundEnabled"

src/shared/WebviewMessage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ export interface WebviewMessage {
126126
| "maxReadFileLine"
127127
| "searchFiles"
128128
| "toggleApiConfigPin"
129+
| "showGreeting"
129130
text?: string
130131
disabled?: boolean
131132
askResponse?: ClineAskResponse
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { HTMLAttributes } from "react"
2+
import { useAppTranslation } from "@/i18n/TranslationContext"
3+
import { Monitor } from "lucide-react"
4+
5+
import { cn } from "@/lib/utils"
6+
import { VSCodeCheckbox } from "@vscode/webview-ui-toolkit/react"
7+
8+
import { SetCachedStateField } from "./types"
9+
import { SectionHeader } from "./SectionHeader"
10+
import { Section } from "./Section"
11+
12+
type InterfaceSettingsProps = HTMLAttributes<HTMLDivElement> & {
13+
showGreeting?: boolean
14+
setCachedStateField: SetCachedStateField<"showGreeting">
15+
}
16+
17+
export const InterfaceSettings = ({ showGreeting, setCachedStateField, ...props }: InterfaceSettingsProps) => {
18+
const { t } = useAppTranslation()
19+
20+
return (
21+
<div className={cn("flex flex-col gap-2")} {...props}>
22+
<SectionHeader>
23+
<div className="flex items-center gap-2">
24+
<Monitor className="w-4" />
25+
<div>{t("settings:sections.interface")}</div>
26+
</div>
27+
</SectionHeader>
28+
29+
<Section>
30+
<VSCodeCheckbox checked={showGreeting} onChange={(e: any) => setCachedStateField("showGreeting", e.target.checked)}>
31+
<span className="font-medium">{t("settings:sections.interface:showGreeting")}</span>
32+
</VSCodeCheckbox>
33+
</Section>
34+
</div>
35+
)
36+
}

webview-ui/src/components/settings/SettingsView.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
Globe,
1515
Info,
1616
LucideIcon,
17+
Monitor,
1718
} from "lucide-react"
1819
import { CaretSortIcon } from "@radix-ui/react-icons"
1920

@@ -47,6 +48,7 @@ import ApiOptions from "./ApiOptions"
4748
import { AutoApproveSettings } from "./AutoApproveSettings"
4849
import { BrowserSettings } from "./BrowserSettings"
4950
import { CheckpointSettings } from "./CheckpointSettings"
51+
import { InterfaceSettings } from "./InterfaceSettings"
5052
import { NotificationSettings } from "./NotificationSettings"
5153
import { ContextManagementSettings } from "./ContextManagementSettings"
5254
import { TerminalSettings } from "./TerminalSettings"
@@ -65,6 +67,7 @@ const sectionNames = [
6567
"autoApprove",
6668
"browser",
6769
"checkpoints",
70+
"interface",
6871
"notifications",
6972
"contextManagement",
7073
"terminal",
@@ -139,6 +142,7 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
139142
showRooIgnoredFiles,
140143
remoteBrowserEnabled,
141144
maxReadFileLine,
145+
showGreeting,
142146
} = cachedState
143147

144148
// Make sure apiConfiguration is initialized and managed by SettingsView.
@@ -262,6 +266,7 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
262266
vscode.postMessage({ type: "alwaysAllowSubtasks", bool: alwaysAllowSubtasks })
263267
vscode.postMessage({ type: "upsertApiConfiguration", text: currentApiConfigName, apiConfiguration })
264268
vscode.postMessage({ type: "telemetrySetting", text: telemetrySetting })
269+
vscode.postMessage({ type: "showGreeting", bool: showGreeting })
265270
setChangeDetected(false)
266271
}
267272
}
@@ -290,6 +295,7 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
290295
const autoApproveRef = useRef<HTMLDivElement>(null)
291296
const browserRef = useRef<HTMLDivElement>(null)
292297
const checkpointsRef = useRef<HTMLDivElement>(null)
298+
const interfaceRef = useRef<HTMLDivElement>(null)
293299
const notificationsRef = useRef<HTMLDivElement>(null)
294300
const contextManagementRef = useRef<HTMLDivElement>(null)
295301
const terminalRef = useRef<HTMLDivElement>(null)
@@ -305,6 +311,7 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
305311
{ id: "browser", icon: SquareMousePointer, ref: browserRef },
306312
{ id: "checkpoints", icon: GitBranch, ref: checkpointsRef },
307313
{ id: "notifications", icon: Bell, ref: notificationsRef },
314+
{ id: "interface", icon: Monitor, ref: interfaceRef},
308315
{ id: "contextManagement", icon: Database, ref: contextManagementRef },
309316
{ id: "terminal", icon: SquareTerminal, ref: terminalRef },
310317
{ id: "advanced", icon: Cog, ref: advancedRef },
@@ -479,6 +486,13 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
479486
/>
480487
</div>
481488

489+
<div ref={interfaceRef}>
490+
<InterfaceSettings
491+
showGreeting={showGreeting}
492+
setCachedStateField={setCachedStateField}
493+
/>
494+
</div>
495+
482496
<div ref={contextManagementRef}>
483497
<ContextManagementSettings
484498
maxOpenTabsContext={maxOpenTabsContext}

webview-ui/src/context/ExtensionStateContext.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export interface ExtensionStateContextType extends ExtensionState {
8686
pinnedApiConfigs?: Record<string, boolean>
8787
setPinnedApiConfigs: (value: Record<string, boolean>) => void
8888
togglePinnedApiConfig: (configName: string) => void
89+
setShowGreeting: (value: boolean) => void
8990
}
9091

9192
export const ExtensionStateContext = createContext<ExtensionStateContextType | undefined>(undefined)
@@ -123,6 +124,7 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode
123124
clineMessages: [],
124125
taskHistory: [],
125126
shouldShowAnnouncement: false,
127+
showGreeting: true,
126128
allowedCommands: [],
127129
soundEnabled: false,
128130
soundVolume: 0.5,
@@ -316,6 +318,7 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode
316318
setAwsUsePromptCache: (value) => setState((prevState) => ({ ...prevState, awsUsePromptCache: value })),
317319
setMaxReadFileLine: (value) => setState((prevState) => ({ ...prevState, maxReadFileLine: value })),
318320
setPinnedApiConfigs: (value) => setState((prevState) => ({ ...prevState, pinnedApiConfigs: value })),
321+
setShowGreeting: (value) => setState((prevState) => ({ ...prevState, shouldShowGreeting: value })),
319322
togglePinnedApiConfig: (configId) =>
320323
setState((prevState) => {
321324
const currentPinned = prevState.pinnedApiConfigs || {}

0 commit comments

Comments
 (0)