Fix plugin settings UI toggles and debug desktop auto-enable

Use SwitchListItem for visible engine/plugin switches, add Plugins to
pre-auth overflow menu, auto-enable hello_world in debug desktop builds.

Co-authored-by: denis0001-dev <denis0001.dev@ya.ru>
This commit is contained in:
Cursor Agent
2026-09-16 22:24:33 +00:00
Unverified
parent b2ef7be57a
commit ad7b4d01b9
3 changed files with 40 additions and 33 deletions
@@ -12,6 +12,7 @@ import androidx.compose.foundation.layout.union
import androidx.compose.foundation.layout.widthIn import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.layout.windowInsetsPadding import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Extension
import androidx.compose.material.icons.filled.Info import androidx.compose.material.icons.filled.Info
import androidx.compose.material.icons.filled.MoreVert import androidx.compose.material.icons.filled.MoreVert
import androidx.compose.material.icons.outlined.BugReport import androidx.compose.material.icons.outlined.BugReport
@@ -36,6 +37,7 @@ import ru.fromchat.more
import ru.fromchat.ui.LocalNavController import ru.fromchat.ui.LocalNavController
import ru.fromchat.ui.components.Text import ru.fromchat.ui.components.Text
import ru.fromchat.ui.extraStatusBars import ru.fromchat.ui.extraStatusBars
import ru.fromchat.plugins_title
import ru.fromchat.ui.main.settings.SettingsRoutes import ru.fromchat.ui.main.settings.SettingsRoutes
/** Margin between the window edge and the wide [AuthContentFrame] panel. */ /** Margin between the window edge and the wide [AuthContentFrame] panel. */
@@ -105,6 +107,16 @@ fun PreAuthOverflowMenu() {
navController.navigate(SettingsRoutes.About) navController.navigate(SettingsRoutes.About)
}, },
) )
DropdownMenuItem(
text = { Text(stringResource(Res.string.plugins_title)) },
leadingIcon = {
Icon(Icons.Default.Extension, contentDescription = null)
},
onClick = {
menuExpanded = false
navController.navigate(SettingsRoutes.Plugins)
},
)
DropdownMenuItem( DropdownMenuItem(
text = { Text(stringResource(Res.string.logs_title)) }, text = { Text(stringResource(Res.string.logs_title)) },
leadingIcon = { leadingIcon = {
@@ -10,7 +10,6 @@ import androidx.compose.material3.Icon
import androidx.compose.material3.MediumTopAppBar import androidx.compose.material3.MediumTopAppBar
import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Scaffold import androidx.compose.material3.Scaffold
import androidx.compose.material3.Switch
import androidx.compose.material3.TopAppBarDefaults import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.rememberTopAppBarState import androidx.compose.material3.rememberTopAppBarState
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
@@ -25,6 +24,7 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import com.pr0gramm3r101.components.Category import com.pr0gramm3r101.components.Category
import com.pr0gramm3r101.components.ListItem import com.pr0gramm3r101.components.ListItem
import com.pr0gramm3r101.components.SwitchListItem
import com.pr0gramm3r101.utils.verticalScroll import com.pr0gramm3r101.utils.verticalScroll
import org.jetbrains.compose.resources.stringResource import org.jetbrains.compose.resources.stringResource
import ru.fromchat.Res import ru.fromchat.Res
@@ -68,23 +68,19 @@ fun PluginsScreen() {
.padding(innerPadding), .padding(innerPadding),
) { ) {
Category(Modifier.padding(top = 16.dp)) { Category(Modifier.padding(top = 16.dp)) {
ListItem( SwitchListItem(
headline = stringResource(Res.string.plugins_engine), headline = stringResource(Res.string.plugins_engine),
supportingText = stringResource(Res.string.plugins_engine_d), supportingText = stringResource(Res.string.plugins_engine_d),
trailingContent = { checked = engineEnabled,
Switch(checked = engineEnabled, onCheckedChange = PluginEngine::setEngineEnabled) onCheckedChange = PluginEngine::setEngineEnabled,
}, divider = true,
) )
ListItem( SwitchListItem(
headline = stringResource(Res.string.plugins_developer_mode), headline = stringResource(Res.string.plugins_developer_mode),
supportingText = stringResource(Res.string.plugins_developer_mode_d), supportingText = stringResource(Res.string.plugins_developer_mode_d),
trailingContent = { checked = developerMode,
Switch( onCheckedChange = PluginEngine::setDeveloperMode,
checked = developerMode, enabled = engineEnabled,
onCheckedChange = PluginEngine::setDeveloperMode,
enabled = engineEnabled,
)
},
) )
} }
Category(Modifier.padding(top = 8.dp)) { Category(Modifier.padding(top = 8.dp)) {
@@ -98,21 +94,20 @@ fun PluginsScreen() {
leadingContent = { Icon(Icons.Default.Extension, contentDescription = null) }, leadingContent = { Icon(Icons.Default.Extension, contentDescription = null) },
) )
} else { } else {
installed.forEach { manifest -> installed.forEachIndexed { index, manifest ->
ListItem( SwitchListItem(
headline = manifest.name, headline = manifest.name,
supportingText = manifest.description.ifBlank { manifest.id }, supportingText = manifest.description.ifBlank { manifest.id },
leadingContent = { Icon(Icons.Default.Extension, contentDescription = null) }, leadingContent = { Icon(Icons.Default.Extension, contentDescription = null) },
trailingContent = { checked = PluginEngine.isPluginEnabled(manifest.id),
Switch( onCheckedChange = { enabled ->
checked = PluginEngine.isPluginEnabled(manifest.id), PluginEngine.setPluginEnabled(manifest.id, enabled)
onCheckedChange = { enabled -> },
PluginEngine.setPluginEnabled(manifest.id, enabled) enabled = engineEnabled,
}, divider = index < installed.lastIndex,
enabled = engineEnabled, listItemOnClick = {
) navController.navigate(SettingsRoutes.pluginDetail(manifest.id))
}, },
onClick = { navController.navigate(SettingsRoutes.pluginDetail(manifest.id)) },
) )
} }
} }
@@ -174,17 +169,13 @@ fun PluginDetailScreen(pluginId: String) {
PluginEngine.getPluginSettingBoolean(pluginId, setting.key, setting.default), PluginEngine.getPluginSettingBoolean(pluginId, setting.key, setting.default),
) )
} }
ListItem( SwitchListItem(
headline = setting.text, headline = setting.text,
supportingText = setting.subtext, supportingText = setting.subtext,
trailingContent = { checked = checked,
Switch( onCheckedChange = { value ->
checked = checked, checked = value
onCheckedChange = { value -> PluginEngine.setPluginSetting(pluginId, setting.key, value.toString())
checked = value
PluginEngine.setPluginSetting(pluginId, setting.key, value.toString())
},
)
}, },
) )
} }
@@ -17,6 +17,10 @@ object DesktopPluginBootstrap {
PluginEngine.appVersionProvider = { ru.fromchat.AppBuildInfo.version } PluginEngine.appVersionProvider = { ru.fromchat.AppBuildInfo.version }
installBundledPlugin(classLoader) installBundledPlugin(classLoader)
PluginEngine.init() PluginEngine.init()
if (ru.fromchat.AppBuildInfo.isDebug) {
PluginEngine.setEngineEnabled(true)
PluginEngine.setPluginEnabled("hello_world", true)
}
PluginEngine.dispatchAppEvent(AppEvent.START) PluginEngine.dispatchAppEvent(AppEvent.START)
FeatureGate.registerDefault("calls") { ru.fromchat.config.ServerConfig.callsEnabled } FeatureGate.registerDefault("calls") { ru.fromchat.config.ServerConfig.callsEnabled }
} }