mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
JPMC Modifications (#11882)
This commit is contained in:
parent
59ca8bd9a8
commit
1d9cf72e39
@ -70,6 +70,11 @@ RUNTIME_CONVERSATION_URL = RUNTIME_URL_PATTERN + (
|
||||
else '/api/conversations/{conversation_id}'
|
||||
)
|
||||
|
||||
RUNTIME_USERNAME = os.getenv('RUNTIME_USERNAME')
|
||||
SU_TO_USER = os.getenv('SU_TO_USER', 'false')
|
||||
truthy = {'1', 'true', 't', 'yes', 'y', 'on'}
|
||||
SU_TO_USER = str(SU_TO_USER.lower() in truthy).lower()
|
||||
|
||||
# Time in seconds before a Redis entry is considered expired if not refreshed
|
||||
_REDIS_ENTRY_TIMEOUT_SECONDS = 300
|
||||
|
||||
@ -772,7 +777,11 @@ class SaasNestedConversationManager(ConversationManager):
|
||||
env_vars['SERVE_FRONTEND'] = '0'
|
||||
env_vars['RUNTIME'] = 'local'
|
||||
# TODO: In the long term we may come up with a more secure strategy for user management within the nested runtime.
|
||||
env_vars['USER'] = 'openhands' if config.run_as_openhands else 'root'
|
||||
env_vars['USER'] = (
|
||||
RUNTIME_USERNAME
|
||||
if RUNTIME_USERNAME
|
||||
else ('openhands' if config.run_as_openhands else 'root')
|
||||
)
|
||||
env_vars['PERMITTED_CORS_ORIGINS'] = ','.join(PERMITTED_CORS_ORIGINS)
|
||||
env_vars['port'] = '60000'
|
||||
# TODO: These values are static in the runtime-api project, but do not get copied into the runtime ENV
|
||||
@ -789,6 +798,7 @@ class SaasNestedConversationManager(ConversationManager):
|
||||
env_vars['INITIAL_NUM_WARM_SERVERS'] = '1'
|
||||
env_vars['INIT_GIT_IN_EMPTY_WORKSPACE'] = '1'
|
||||
env_vars['ENABLE_V1'] = '0'
|
||||
env_vars['SU_TO_USER'] = SU_TO_USER
|
||||
|
||||
# We need this for LLM traces tracking to identify the source of the LLM calls
|
||||
env_vars['WEB_HOST'] = WEB_HOST
|
||||
|
||||
@ -95,7 +95,7 @@ export function ExpandableMessage({
|
||||
const statusIconClasses = "h-4 w-4 ml-2 inline";
|
||||
|
||||
if (
|
||||
config?.FEATURE_FLAGS.ENABLE_BILLING &&
|
||||
config?.FEATURE_FLAGS?.ENABLE_BILLING &&
|
||||
config?.APP_MODE === "saas" &&
|
||||
id === I18nKey.STATUS$ERROR_LLM_OUT_OF_CREDITS
|
||||
) {
|
||||
|
||||
@ -25,7 +25,14 @@ export function AccountSettingsContextMenu({
|
||||
const { data: config } = useConfig();
|
||||
|
||||
const isSaas = config?.APP_MODE === "saas";
|
||||
const navItems = (isSaas ? SAAS_NAV_ITEMS : OSS_NAV_ITEMS).map((item) => ({
|
||||
|
||||
// Get navigation items and filter out LLM settings if the feature flag is enabled
|
||||
let items = isSaas ? SAAS_NAV_ITEMS : OSS_NAV_ITEMS;
|
||||
if (config?.FEATURE_FLAGS?.HIDE_LLM_SETTINGS) {
|
||||
items = items.filter((item) => item.to !== "/settings");
|
||||
}
|
||||
|
||||
const navItems = items.map((item) => ({
|
||||
...item,
|
||||
icon: React.cloneElement(item.icon, {
|
||||
width: 16,
|
||||
|
||||
@ -34,13 +34,7 @@ export function Sidebar() {
|
||||
|
||||
const { pathname } = useLocation();
|
||||
|
||||
// TODO: Remove HIDE_LLM_SETTINGS check once released
|
||||
const shouldHideLlmSettings =
|
||||
config?.FEATURE_FLAGS.HIDE_LLM_SETTINGS && config?.APP_MODE === "saas";
|
||||
|
||||
React.useEffect(() => {
|
||||
if (shouldHideLlmSettings) return;
|
||||
|
||||
if (location.pathname === "/settings") {
|
||||
setSettingsModalIsOpen(false);
|
||||
} else if (
|
||||
|
||||
@ -13,6 +13,6 @@ export const useBalance = () => {
|
||||
enabled:
|
||||
!isOnTosPage &&
|
||||
config?.APP_MODE === "saas" &&
|
||||
config?.FEATURE_FLAGS.ENABLE_BILLING,
|
||||
config?.FEATURE_FLAGS?.ENABLE_BILLING,
|
||||
});
|
||||
};
|
||||
|
||||
@ -34,6 +34,15 @@ export const clientLoader = async ({ request }: Route.ClientLoaderArgs) => {
|
||||
return redirect("/settings");
|
||||
}
|
||||
|
||||
// If LLM settings are hidden and user tries to access the LLM settings page
|
||||
if (config?.FEATURE_FLAGS?.HIDE_LLM_SETTINGS && pathname === "/settings") {
|
||||
// Redirect to the first available settings page
|
||||
if (isSaas) {
|
||||
return redirect("/settings/user");
|
||||
}
|
||||
return redirect("/settings/mcp");
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
@ -52,13 +61,24 @@ function SettingsScreen() {
|
||||
} else {
|
||||
items.push(...OSS_NAV_ITEMS);
|
||||
}
|
||||
|
||||
// Filter out LLM settings if the feature flag is enabled
|
||||
if (config?.FEATURE_FLAGS?.HIDE_LLM_SETTINGS) {
|
||||
return items.filter((item) => item.to !== "/settings");
|
||||
}
|
||||
|
||||
return items;
|
||||
}, [isSaas]);
|
||||
}, [isSaas, config?.FEATURE_FLAGS?.HIDE_LLM_SETTINGS]);
|
||||
|
||||
// Current section title for the main content area
|
||||
const currentSectionTitle = useMemo(() => {
|
||||
const currentItem = navItems.find((item) => item.to === location.pathname);
|
||||
return currentItem ? currentItem.text : "SETTINGS$NAV_LLM";
|
||||
if (currentItem) {
|
||||
return currentItem.text;
|
||||
}
|
||||
|
||||
// Default to the first available navigation item if current page is not found
|
||||
return navItems.length > 0 ? navItems[0].text : "SETTINGS$TITLE";
|
||||
}, [navItems, location.pathname]);
|
||||
|
||||
return (
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user