feat: create named feature flag for settings v2 (#1976)

This commit is contained in:
Alex Hancock
2025-04-01 14:18:03 -04:00
committed by GitHub
parent 2fbf601446
commit 177cdbe0f2
6 changed files with 20 additions and 15 deletions
+8 -7
View File
@@ -11,6 +11,7 @@ import ErrorScreen from './components/ErrorScreen';
import { ConfirmationModal } from './components/ui/ConfirmationModal'; import { ConfirmationModal } from './components/ui/ConfirmationModal';
import { ToastContainer } from 'react-toastify'; import { ToastContainer } from 'react-toastify';
import { toastService } from './toasts'; import { toastService } from './toasts';
import { settingsV2Enabled } from './flags';
import { extractExtensionName } from './components/settings/extensions/utils'; import { extractExtensionName } from './components/settings/extensions/utils';
import { GoosehintsModal } from './components/GoosehintsModal'; import { GoosehintsModal } from './components/GoosehintsModal';
import { SessionDetails } from './sessions'; import { SessionDetails } from './sessions';
@@ -75,7 +76,7 @@ export default function App() {
} }
useEffect(() => { useEffect(() => {
if (!process.env.ALPHA) { if (!settingsV2Enabled) {
return; return;
} }
@@ -86,7 +87,7 @@ export default function App() {
} }
initAttemptedRef.current = true; initAttemptedRef.current = true;
console.log(`Initializing app in alpha mode...`); console.log(`Initializing app with settings v2`);
const initializeApp = async () => { const initializeApp = async () => {
try { try {
@@ -265,7 +266,7 @@ export default function App() {
console.log(`Confirming installation of extension from: ${pendingLink}`); console.log(`Confirming installation of extension from: ${pendingLink}`);
setModalVisible(false); // Dismiss modal immediately setModalVisible(false); // Dismiss modal immediately
try { try {
if (process.env.ALPHA) { if (settingsV2Enabled) {
await addExtensionFromDeepLinkV2(pendingLink, addExtension, setView); await addExtensionFromDeepLinkV2(pendingLink, addExtension, setView);
} else { } else {
await addExtensionFromDeepLink(pendingLink, setView); await addExtensionFromDeepLink(pendingLink, setView);
@@ -292,11 +293,11 @@ export default function App() {
const { addRecentModel } = useRecentModels(); // TODO: remove const { addRecentModel } = useRecentModels(); // TODO: remove
useEffect(() => { useEffect(() => {
if (process.env.ALPHA) { if (settingsV2Enabled) {
return; return;
} }
console.log(`Initializing app in non-alpha mode...`); console.log(`Initializing app with settings v1`);
// Attempt to detect config for a stored provider // Attempt to detect config for a stored provider
const detectStoredProvider = () => { const detectStoredProvider = () => {
@@ -405,7 +406,7 @@ export default function App() {
<div className="titlebar-drag-region" /> <div className="titlebar-drag-region" />
<div> <div>
{view === 'welcome' && {view === 'welcome' &&
(process.env.ALPHA ? ( (settingsV2Enabled ? (
<ProviderSettings onClose={() => setView('chat')} isOnboarding={true} /> <ProviderSettings onClose={() => setView('chat')} isOnboarding={true} />
) : ( ) : (
<WelcomeView <WelcomeView
@@ -415,7 +416,7 @@ export default function App() {
/> />
))} ))}
{view === 'settings' && {view === 'settings' &&
(process.env.ALPHA ? ( (settingsV2Enabled ? (
<SettingsViewV2 <SettingsViewV2
onClose={() => { onClose={() => {
setView('chat'); setView('chat');
+2 -1
View File
@@ -5,6 +5,7 @@ import { Sliders } from 'lucide-react';
import { ModelRadioList } from './settings/models/ModelRadioList'; import { ModelRadioList } from './settings/models/ModelRadioList';
import { Document, ChevronUp, ChevronDown } from './icons'; import { Document, ChevronUp, ChevronDown } from './icons';
import type { View } from '../App'; import type { View } from '../App';
import { settingsV2Enabled } from '../flags';
import { BottomMenuModeSelection } from './BottomMenuModeSelection'; import { BottomMenuModeSelection } from './BottomMenuModeSelection';
import ModelsBottomBar from './settings_v2/models/bottom_bar/ModelsBottomBar'; import ModelsBottomBar from './settings_v2/models/bottom_bar/ModelsBottomBar';
@@ -78,7 +79,7 @@ export default function BottomMenu({
<BottomMenuModeSelection /> <BottomMenuModeSelection />
{/* Model Selector Dropdown */} {/* Model Selector Dropdown */}
{process.env.ALPHA ? ( {settingsV2Enabled ? (
<ModelsBottomBar dropdownRef={dropdownRef} setView={setView} /> <ModelsBottomBar dropdownRef={dropdownRef} setView={setView} />
) : ( ) : (
<div className="relative flex items-center ml-auto mr-4" ref={dropdownRef}> <div className="relative flex items-center ml-auto mr-4" ref={dropdownRef}>
@@ -7,6 +7,7 @@ import {
ModeSelectionItem, ModeSelectionItem,
} from './settings/basic/ModeSelectionItem'; } from './settings/basic/ModeSelectionItem';
import { useConfig } from './ConfigContext'; import { useConfig } from './ConfigContext';
import { settingsV2Enabled } from '../flags';
export const BottomMenuModeSelection = () => { export const BottomMenuModeSelection = () => {
const [isGooseModeMenuOpen, setIsGooseModeMenuOpen] = useState(false); const [isGooseModeMenuOpen, setIsGooseModeMenuOpen] = useState(false);
@@ -18,7 +19,7 @@ export const BottomMenuModeSelection = () => {
useEffect(() => { useEffect(() => {
const fetchCurrentMode = async () => { const fetchCurrentMode = async () => {
try { try {
if (!process.env.ALPHA) { if (!settingsV2Enabled) {
const response = await fetch(getApiUrl('/configs/get?key=GOOSE_MODE'), { const response = await fetch(getApiUrl('/configs/get?key=GOOSE_MODE'), {
method: 'GET', method: 'GET',
headers: { headers: {
@@ -85,7 +86,7 @@ export const BottomMenuModeSelection = () => {
return; return;
} }
if (!process.env.ALPHA) { if (!settingsV2Enabled) {
const storeResponse = await fetch(getApiUrl('/configs/store'), { const storeResponse = await fetch(getApiUrl('/configs/store'), {
method: 'POST', method: 'POST',
headers: { headers: {
@@ -9,7 +9,7 @@ import { ChatSmart, Idea, More, Refresh, Time, Send } from '../icons';
import { FolderOpen, Moon, Sliders, Sun } from 'lucide-react'; import { FolderOpen, Moon, Sliders, Sun } from 'lucide-react';
import { View } from '../../App'; import { View } from '../../App';
import { useConfig } from '../ConfigContext'; import { useConfig } from '../ConfigContext';
import { toastService } from '../../toasts'; import { settingsV2Enabled } from '../../flags';
interface VersionInfo { interface VersionInfo {
current_version: string; current_version: string;
@@ -257,7 +257,7 @@ export default function MoreMenu({
<span className="text-textSubtle ml-1">,</span> <span className="text-textSubtle ml-1">,</span>
</MenuButton> </MenuButton>
{process.env.ALPHA && ( {settingsV2Enabled && (
<MenuButton <MenuButton
onClick={async () => { onClick={async () => {
await remove('GOOSE_PROVIDER', false); await remove('GOOSE_PROVIDER', false);
@@ -274,7 +274,7 @@ export default function MoreMenu({
</MenuButton> </MenuButton>
)} )}
{!process.env.ALPHA && ( {!settingsV2Enabled && (
<MenuButton <MenuButton
onClick={() => { onClick={() => {
localStorage.removeItem('GOOSE_PROVIDER'); localStorage.removeItem('GOOSE_PROVIDER');
+1
View File
@@ -0,0 +1 @@
export const settingsV2Enabled = process.env.ALPHA;
+3 -2
View File
@@ -4,6 +4,7 @@ import { GOOSE_PROVIDER, GOOSE_MODEL } from '../env_vars';
import { Model } from '../components/settings/models/ModelContext'; import { Model } from '../components/settings/models/ModelContext';
import { gooseModels } from '../components/settings/models/GooseModels'; import { gooseModels } from '../components/settings/models/GooseModels';
import { initializeAgent } from '../agent'; import { initializeAgent } from '../agent';
import { settingsV2Enabled } from '../flags';
import { import {
initializeBundledExtensions, initializeBundledExtensions,
syncBundledExtensions, syncBundledExtensions,
@@ -85,7 +86,7 @@ export const initializeSystem = async (
await initializeAgent({ provider, model }); await initializeAgent({ provider, model });
// This will go away after the release of settings v2 as this is now handled in config.yaml // This will go away after the release of settings v2 as this is now handled in config.yaml
if (!process.env.ALPHA) { if (!settingsV2Enabled) {
// Sync the model state with React // Sync the model state with React
const syncedModel = syncModelWithAgent(provider, model); const syncedModel = syncModelWithAgent(provider, model);
console.log('Model synced with React state:', syncedModel); console.log('Model synced with React state:', syncedModel);
@@ -118,7 +119,7 @@ export const initializeSystem = async (
} }
} }
if (process.env.ALPHA) { if (settingsV2Enabled) {
if (!options?.getExtensions || !options?.addExtension) { if (!options?.getExtensions || !options?.addExtension) {
console.warn('Extension helpers not provided in alpha mode'); console.warn('Extension helpers not provided in alpha mode');
return; return;