Skip to content

Commit 16fc0e0

Browse files
committed
feat: add showCloudPromotion setting to disable cloud CTA
- Added showCloudPromotion boolean setting to global-settings.ts (defaults to true) - Updated ExtensionStateContext to handle the new setting - Modified ChatView to respect the setting when displaying RooCloudCTA - Added tests to verify the new functionality - Addresses issue #7825 - allows users to disable cloud promotion
1 parent bbd3d98 commit 16fc0e0

File tree

5 files changed

+61
-1
lines changed

5 files changed

+61
-1
lines changed

packages/types/src/global-settings.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const globalSettingsSchema = z.object({
4141
lastShownAnnouncementId: z.string().optional(),
4242
customInstructions: z.string().optional(),
4343
taskHistory: z.array(historyItemSchema).optional(),
44+
showCloudPromotion: z.boolean().optional(),
4445

4546
// Image generation settings (experimental) - flattened for simplicity
4647
openRouterImageApiKey: z.string().optional(),
@@ -321,6 +322,8 @@ export const EVALS_SETTINGS: RooCodeSettings = {
321322
mode: "code", // "architect",
322323

323324
customModes: [],
325+
326+
showCloudPromotion: true, // Default to true to maintain current behavior
324327
}
325328

326329
export const EVALS_TIMEOUT = 5 * 60 * 1_000

src/shared/ExtensionMessage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ export type ExtensionState = Pick<
209209
// | "lastShownAnnouncementId"
210210
| "customInstructions"
211211
// | "taskHistory" // Optional in GlobalSettings, required here.
212+
| "showCloudPromotion"
212213
| "autoApprovalEnabled"
213214
| "alwaysAllowReadOnly"
214215
| "alwaysAllowReadOnlyOutsideWorkspace"

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
120120
soundEnabled,
121121
soundVolume,
122122
cloudIsAuthenticated,
123+
showCloudPromotion,
123124
messageQueue = [],
124125
} = useExtensionState()
125126

@@ -1831,7 +1832,11 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
18311832
{telemetrySetting === "unset" && <TelemetryBanner />}
18321833

18331834
<div className="mb-2.5">
1834-
{cloudIsAuthenticated || taskHistory.length < 4 ? <RooTips /> : <RooCloudCTA />}
1835+
{cloudIsAuthenticated || taskHistory.length < 4 || !showCloudPromotion ? (
1836+
<RooTips />
1837+
) : (
1838+
<RooCloudCTA />
1839+
)}
18351840
</div>
18361841
{/* Show the task history preview if expanded and tasks exist */}
18371842
{taskHistory.length > 0 && isExpanded && <HistoryPreview />}

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,6 +1428,44 @@ describe("ChatView - RooCloudCTA Display Tests", () => {
14281428
expect(queryByTestId("roo-cloud-cta")).not.toBeInTheDocument()
14291429
expect(getByTestId("roo-tips")).toBeInTheDocument()
14301430
})
1431+
1432+
it("does not show RooCloudCTA when showCloudPromotion is false", () => {
1433+
const { queryByTestId, getByTestId } = renderChatView()
1434+
1435+
// Set showCloudPromotion to false
1436+
act(() => {
1437+
mockPostMessage({
1438+
showCloudPromotion: false,
1439+
cloudIsAuthenticated: false,
1440+
taskHistory: Array(5).fill({ id: "task", ts: Date.now() }),
1441+
clineMessages: [], // No active task
1442+
})
1443+
})
1444+
1445+
// Should not show RooCloudCTA when showCloudPromotion is false
1446+
expect(queryByTestId("roo-cloud-cta")).not.toBeInTheDocument()
1447+
// Should show RooTips instead
1448+
expect(getByTestId("roo-tips")).toBeInTheDocument()
1449+
})
1450+
1451+
it("shows RooCloudCTA when showCloudPromotion is true and conditions are met", async () => {
1452+
const { getByTestId } = renderChatView()
1453+
1454+
// Set showCloudPromotion to true with conditions met
1455+
act(() => {
1456+
mockPostMessage({
1457+
showCloudPromotion: true,
1458+
cloudIsAuthenticated: false,
1459+
taskHistory: Array(5).fill({ id: "task", ts: Date.now() }),
1460+
clineMessages: [], // No active task
1461+
})
1462+
})
1463+
1464+
// Should show RooCloudCTA when showCloudPromotion is true and conditions are met
1465+
await waitFor(() => {
1466+
expect(getByTestId("roo-cloud-cta")).toBeInTheDocument()
1467+
})
1468+
})
14311469
})
14321470

14331471
describe("ChatView - Message Queueing Tests", () => {

webview-ui/src/context/ExtensionStateContext.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ export interface ExtensionStateContextType extends ExtensionState {
4444
mdmCompliant?: boolean
4545
hasOpenedModeSelector: boolean // New property to track if user has opened mode selector
4646
setHasOpenedModeSelector: (value: boolean) => void // Setter for the new property
47+
showCloudPromotion: boolean // New property for cloud promotion visibility
48+
setShowCloudPromotion: (value: boolean) => void // Setter for cloud promotion
4749
alwaysAllowFollowupQuestions: boolean // New property for follow-up questions auto-approve
4850
setAlwaysAllowFollowupQuestions: (value: boolean) => void // Setter for the new property
4951
followupAutoApproveTimeoutMs: number | undefined // Timeout in ms for auto-approving follow-up questions
@@ -255,6 +257,7 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode
255257
maxDiagnosticMessages: 50,
256258
openRouterImageApiKey: "",
257259
openRouterImageGenerationSelectedModel: "",
260+
showCloudPromotion: true, // Default to true to maintain current behavior
258261
})
259262

260263
const [didHydrateState, setDidHydrateState] = useState(false)
@@ -274,6 +277,7 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode
274277
global: {},
275278
})
276279
const [includeTaskHistoryInEnhance, setIncludeTaskHistoryInEnhance] = useState(true)
280+
const [showCloudPromotion, setShowCloudPromotion] = useState(true) // Default to true
277281

278282
const setListApiConfigMeta = useCallback(
279283
(value: ProviderSettingsEntry[]) => setState((prevState) => ({ ...prevState, listApiConfigMeta: value })),
@@ -311,6 +315,10 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode
311315
if ((newState as any).includeTaskHistoryInEnhance !== undefined) {
312316
setIncludeTaskHistoryInEnhance((newState as any).includeTaskHistoryInEnhance)
313317
}
318+
// Update showCloudPromotion if present in state message
319+
if ((newState as any).showCloudPromotion !== undefined) {
320+
setShowCloudPromotion((newState as any).showCloudPromotion)
321+
}
314322
// Handle marketplace data if present in state message
315323
if (newState.marketplaceItems !== undefined) {
316324
setMarketplaceItems(newState.marketplaceItems)
@@ -527,6 +535,11 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode
527535
},
528536
includeTaskHistoryInEnhance,
529537
setIncludeTaskHistoryInEnhance,
538+
showCloudPromotion,
539+
setShowCloudPromotion: (value) => {
540+
setShowCloudPromotion(value)
541+
setState((prevState) => ({ ...prevState, showCloudPromotion: value }))
542+
},
530543
}
531544

532545
return <ExtensionStateContext.Provider value={contextValue}>{children}</ExtensionStateContext.Provider>

0 commit comments

Comments
 (0)