Skip to content

Commit be08bed

Browse files
committed
refactor: put the feature behind feature flag
1 parent 1709284 commit be08bed

4 files changed

Lines changed: 32 additions & 16 deletions

File tree

main/src/feature-flags/flags.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ const featureFlagOptions: Record<FeatureFlagKey, FeatureFlagOptions> = {
2020
defaultValue: false,
2121
isExperimental: false,
2222
},
23+
[featureFlagKeys.AGENTS]: {
24+
isDisabled: false,
25+
defaultValue: false,
26+
isExperimental: false,
27+
},
2328
}
2429

2530
// Kept for one-time reconciliation migration; remove after migration grace period

renderer/src/features/chat/components/chat-input-prompt.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ import type { ChatSettings } from '../types'
3030
import { toast } from 'sonner'
3131
import { toastVariants } from '@/common/lib/toast'
3232
import { useThreadDraft } from '../hooks/use-thread-draft'
33+
import { useFeatureFlag } from '@/common/hooks/use-feature-flag'
34+
import { featureFlagKeys } from '@utils/feature-flags'
3335

3436
const errorToastConfig = {
3537
max_files: {
@@ -83,6 +85,7 @@ function InputWithAttachments({
8385
}) {
8486
const attachments = usePromptInputAttachments()
8587
const prevTextRef = useRef(text)
88+
const isAgentsEnabled = useFeatureFlag(featureFlagKeys.AGENTS)
8689

8790
// Clear attachments when text is cleared and message is ready
8891
useEffect(() => {
@@ -150,7 +153,7 @@ function InputWithAttachments({
150153
</PromptInputActionMenu>
151154
{hasProviderAndModel && (
152155
<>
153-
<AgentSelector threadId={threadId} />
156+
{isAgentsEnabled && <AgentSelector threadId={threadId} />}
154157
<ModelSelector
155158
settings={settings}
156159
onSettingsChange={updateSettings}

renderer/src/features/chat/components/playground-sidebar.tsx

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import {
2525
} from '@/common/components/ui/dropdown-menu'
2626
import { cn } from '@/common/lib/utils'
2727
import { useConfirm } from '@/common/hooks/use-confirm'
28+
import { useFeatureFlag } from '@/common/hooks/use-feature-flag'
29+
import { featureFlagKeys } from '@utils/feature-flags'
2830
import type { PlaygroundThread } from '../hooks/use-playground-threads'
2931

3032
interface PlaygroundSidebarProps {
@@ -268,8 +270,10 @@ export function PlaygroundSidebar({
268270
const starredThreads = threads.filter((t) => t.starred)
269271
const recentThreads = threads.filter((t) => !t.starred)
270272
const hasStarred = starredThreads.length > 0
273+
const isAgentsEnabled = useFeatureFlag(featureFlagKeys.AGENTS)
271274
const pathname = useRouterState({ select: (s) => s.location.pathname })
272-
const isAgentsActive = pathname.startsWith('/playground/agents')
275+
const isAgentsActive =
276+
isAgentsEnabled && pathname.startsWith('/playground/agents')
273277

274278
const renderItem = (thread: PlaygroundThread) => (
275279
<ThreadItem
@@ -289,20 +293,23 @@ export function PlaygroundSidebar({
289293
shrink-0 flex-col border-r"
290294
>
291295
<div className="flex flex-col gap-0.5 px-2 pt-2 pb-1">
292-
<Link
293-
to="/playground/agents"
294-
aria-label="Agents"
295-
className={cn(
296-
'flex w-full items-center gap-2 rounded-md px-2 py-1 text-sm',
297-
'transition-colors',
298-
isAgentsActive
299-
? 'bg-accent text-accent-foreground'
300-
: 'text-muted-foreground hover:text-foreground hover:bg-accent/60'
301-
)}
302-
>
303-
<Bot className="h-4 w-4 shrink-0" />
304-
Agents
305-
</Link>
296+
{isAgentsEnabled && (
297+
<Link
298+
to="/playground/agents"
299+
aria-label="Agents"
300+
className={cn(
301+
'flex w-full items-center gap-2 rounded-md px-2 py-1 text-sm',
302+
'transition-colors',
303+
isAgentsActive
304+
? 'bg-accent text-accent-foreground'
305+
: `text-muted-foreground hover:text-foreground
306+
hover:bg-accent/60`
307+
)}
308+
>
309+
<Bot className="h-4 w-4 shrink-0" />
310+
Agents
311+
</Link>
312+
)}
306313
<button
307314
type="button"
308315
onClick={onCreateThread}

utils/feature-flags.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export const featureFlagKeys = {
22
META_OPTIMIZER: 'meta_optimizer',
33
SKILLS: 'skills',
4+
AGENTS: 'agents',
45
} as const

0 commit comments

Comments
 (0)