Skip to content

Commit d3c65ce

Browse files
authored
feature: Closable welcome message (#2541)
* draft: try to add a setting button * Add showGreeting setting and related changes * i18n: showGreeting * fix chinese i18n 'dot'
1 parent 14de489 commit d3c65ce

26 files changed

+199
-21
lines changed

src/core/webview/ClineProvider.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,6 +1242,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
12421242
telemetrySetting,
12431243
showRooIgnoredFiles,
12441244
language,
1245+
showGreeting,
12451246
maxReadFileLine,
12461247
} = await this.getState()
12471248

@@ -1323,6 +1324,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
13231324
renderContext: this.renderContext,
13241325
maxReadFileLine: maxReadFileLine ?? 500,
13251326
settingsImportedAt: this.settingsImportedAt,
1327+
showGreeting: showGreeting ?? true, // Ensure showGreeting is included in the returned state
13261328
}
13271329
}
13281330

@@ -1410,6 +1412,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
14101412
telemetrySetting: stateValues.telemetrySetting || "unset",
14111413
showRooIgnoredFiles: stateValues.showRooIgnoredFiles ?? true,
14121414
maxReadFileLine: stateValues.maxReadFileLine ?? 500,
1415+
showGreeting: stateValues.showGreeting ?? true, // Ensure showGreeting is returned by getState
14131416
}
14141417
}
14151418

src/core/webview/webviewMessageHandler.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,11 @@ export const webviewMessageHandler = async (provider: ClineProvider, message: We
645645
await updateGlobalState("diffEnabled", diffEnabled)
646646
await provider.postStateToWebview()
647647
break
648+
case "showGreeting":
649+
const showGreeting = message.bool ?? true
650+
await updateGlobalState("showGreeting", showGreeting)
651+
await provider.postStateToWebview()
652+
break
648653
case "enableCheckpoints":
649654
const enableCheckpoints = message.bool ?? true
650655
await updateGlobalState("enableCheckpoints", enableCheckpoints)

src/exports/roo-code.d.ts

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

src/exports/types.ts

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

src/schemas/index.ts

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

537+
showGreeting: z.boolean().optional(),
538+
537539
ttsEnabled: z.boolean().optional(),
538540
ttsSpeed: z.number().optional(),
539541
soundEnabled: z.boolean().optional(),
@@ -610,6 +612,8 @@ const globalSettingsRecord: GlobalSettingsRecord = {
610612
enableCheckpoints: undefined,
611613
checkpointStorage: undefined,
612614

615+
showGreeting: undefined,
616+
613617
ttsEnabled: undefined,
614618
ttsSpeed: undefined,
615619
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

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
6969
alwaysAllowSubtasks,
7070
customModes,
7171
telemetrySetting,
72+
showGreeting,
7273
} = useExtensionState()
7374

7475
//const task = messages.length > 0 ? (messages[0].say === "task" ? messages[0] : undefined) : undefined) : undefined
@@ -95,7 +96,6 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
9596
const [showScrollToBottom, setShowScrollToBottom] = useState(false)
9697
const [isAtBottom, setIsAtBottom] = useState(false)
9798
const lastTtsRef = useRef<string>("")
98-
9999
const [wasStreaming, setWasStreaming] = useState<boolean>(false)
100100
const [showCheckpointWarning, setShowCheckpointWarning] = useState<boolean>(false)
101101

@@ -1207,10 +1207,12 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
12071207
}}>
12081208
{telemetrySetting === "unset" && <TelemetryBanner />}
12091209
{showAnnouncement && <Announcement version={version} hideAnnouncement={hideAnnouncement} />}
1210-
<div style={{ padding: "0 20px", flexShrink: 0 }}>
1211-
<h2>{t("chat:greeting")}</h2>
1212-
<p>{t("chat:aboutMe")}</p>
1213-
</div>
1210+
{showGreeting === true && (
1211+
<div style={{ padding: "0 20px", flexShrink: 0 }}>
1212+
<h2>{t("chat:greeting")}</h2>
1213+
<p>{t("chat:aboutMe")}</p>
1214+
</div>
1215+
)}
12141216
{taskHistory.length > 0 && <HistoryPreview showHistoryView={showHistoryView} />}
12151217
</div>
12161218
)}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { HTMLAttributes } from "react"
2+
import { useAppTranslation } from "@/i18n/TranslationContext"
3+
import { VSCodeCheckbox } from "@vscode/webview-ui-toolkit/react"
4+
import { Monitor } from "lucide-react"
5+
6+
import { SetCachedStateField } from "./types"
7+
import { SectionHeader } from "./SectionHeader"
8+
import { Section } from "./Section"
9+
10+
type InterfaceSettingsProps = HTMLAttributes<HTMLDivElement> & {
11+
showGreeting?: boolean
12+
setCachedStateField: SetCachedStateField<"showGreeting">
13+
}
14+
15+
export const InterfaceSettings = ({ showGreeting, setCachedStateField, ...props }: InterfaceSettingsProps) => {
16+
const { t } = useAppTranslation()
17+
return (
18+
<div {...props}>
19+
<SectionHeader>
20+
<div className="flex items-center gap-2">
21+
<Monitor className="w-4" />
22+
<div>{t("settings:sections.interface")}</div>
23+
</div>
24+
</SectionHeader>
25+
26+
<Section>
27+
<div>
28+
<VSCodeCheckbox
29+
checked={showGreeting}
30+
onChange={(e: any) => setCachedStateField("showGreeting", e.target.checked)}>
31+
<span className="font-medium">{t("settings:interface.showgreeting.label")}</span>
32+
</VSCodeCheckbox>
33+
<div className="text-vscode-descriptionForeground text-sm mt-1">
34+
{t("settings:interface.showgreeting.description")}
35+
</div>
36+
</div>
37+
</Section>
38+
</div>
39+
)
40+
}

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

Lines changed: 12 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)
@@ -304,6 +310,7 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
304310
{ id: "autoApprove", icon: CheckCheck, ref: autoApproveRef },
305311
{ id: "browser", icon: SquareMousePointer, ref: browserRef },
306312
{ id: "checkpoints", icon: GitBranch, ref: checkpointsRef },
313+
{ id: "interface", icon: Monitor, ref: interfaceRef },
307314
{ id: "notifications", icon: Bell, ref: notificationsRef },
308315
{ id: "contextManagement", icon: Database, ref: contextManagementRef },
309316
{ id: "terminal", icon: SquareTerminal, ref: terminalRef },
@@ -317,6 +324,7 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
317324
autoApproveRef,
318325
browserRef,
319326
checkpointsRef,
327+
interfaceRef,
320328
notificationsRef,
321329
contextManagementRef,
322330
terminalRef,
@@ -469,6 +477,10 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
469477
/>
470478
</div>
471479

480+
<div ref={interfaceRef}>
481+
<InterfaceSettings showGreeting={showGreeting} setCachedStateField={setCachedStateField} />
482+
</div>
483+
472484
<div ref={notificationsRef}>
473485
<NotificationSettings
474486
ttsEnabled={ttsEnabled}

0 commit comments

Comments
 (0)