Your phone, on your command. Gotcha is world's first fully on-device AI copilot for Android that turns natural language into real device actions — safely.
fix(ci): resolve detekt failures blocking the build
Durganshu Mishrae7ab625762ce
diff --git a/app/src/main/java/com/gotcha/data/GotchaStorage.kt b/app/src/main/java/com/gotcha/data/GotchaStorage.ktindex 3212ba9..72cb73f 100644--- a/app/src/main/java/com/gotcha/data/GotchaStorage.kt+++ b/app/src/main/java/com/gotcha/data/GotchaStorage.kt@@ -152,6 +152,7 @@ object GotchaStorage {sealed class RecordingTarget {/** Pre-Q direct filesystem path, or a caller-supplied [FileResolver] path. */data class DirectFile(val file: File) : RecordingTarget()+/** Q+ MediaStore entry; [MediaRecorder] writes through the held fd. */data class MediaStoreEntry(val uri: Uri, val pfd: ParcelFileDescriptor, val displayPath: String) :RecordingTarget()diff --git a/app/src/main/java/com/gotcha/tools/MediaCaptureTool.kt b/app/src/main/java/com/gotcha/tools/MediaCaptureTool.ktindex 0f39047..201ce4c 100644--- a/app/src/main/java/com/gotcha/tools/MediaCaptureTool.kt+++ b/app/src/main/java/com/gotcha/tools/MediaCaptureTool.kt@@ -137,77 +137,9 @@ class MediaCaptureTool(private val context: Context) {recordingUri = nullrecordingPfd = nullreturn try {- if (!outputPath.isNullOrBlank()) {- val resolved = FileResolver(context).resolveForWrite(outputPath)- val file = when (resolved) {- is FileResolver.ResolveResult.Ok -> resolved.file.also { it.parentFile?.mkdirs() }- is FileResolver.ResolveResult.PermissionNeeded -> return resolved.result- is FileResolver.ResolveResult.Error -> return ToolResult.error(resolved.message)- }- recordingFile = file- recordingDisplayPath = file.absolutePath- } else {- // Default location: the system-wide public Recordings folder, not- // the per-chat working directory — recordings should be findable- // like any other device recording, independent of which chat made them.- when (- val target = com.gotcha.data.GotchaStorage.createRecordingTarget(- context,- "recording_${timestamp()}.m4a"- )- ) {- is com.gotcha.data.GotchaStorage.RecordingTarget.DirectFile -> {- recordingFile = target.file- recordingDisplayPath = target.file.absolutePath- }- is com.gotcha.data.GotchaStorage.RecordingTarget.MediaStoreEntry -> {- recordingUri = target.uri- recordingPfd = target.pfd- recordingDisplayPath = target.displayPath- }- }- }-- val audioSource = when (source?.trim()?.lowercase()) {- "voice" -> MediaRecorder.AudioSource.VOICE_RECOGNITION- "camcorder" -> MediaRecorder.AudioSource.CAMCORDER- else -> MediaRecorder.AudioSource.MIC- }-- val rec = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {- MediaRecorder(context)- } else {- @Suppress("DEPRECATION")- MediaRecorder()- }- rec.setAudioSource(audioSource)- rec.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4)- rec.setAudioEncoder(MediaRecorder.AudioEncoder.AAC)+ resolveRecordingOutputTarget(outputPath)?.let { return it }- when (quality?.trim()?.lowercase()) {- "low" -> {- rec.setAudioSamplingRate(16000)- rec.setAudioEncodingBitRate(16000)- }- "medium" -> {- rec.setAudioSamplingRate(44100)- rec.setAudioEncodingBitRate(64000)- }- "high" -> {- rec.setAudioSamplingRate(44100)- rec.setAudioEncodingBitRate(192000)- }- }-- if (maxDurationSeconds != null && maxDurationSeconds > 0) {- rec.setMaxDuration(maxDurationSeconds * 1000)- }- val pfd = recordingPfd- if (pfd != null) {- rec.setOutputFile(pfd.fileDescriptor)- } else {- rec.setOutputFile(recordingFile!!.absolutePath)- }+ val rec = createConfiguredRecorder(source, quality, maxDurationSeconds)rec.prepare()rec.start()recorder = rec@@ -228,6 +160,93 @@ class MediaCaptureTool(private val context: Context) {}}+ /**+ * Resolves where the recording will be written, setting recordingFile/recordingUri/+ * recordingPfd/recordingDisplayPath. Returns a ToolResult to return early from+ * startAudioRecording on failure, or null on success.+ */+ private fun resolveRecordingOutputTarget(outputPath: String?): ToolResult? {+ if (!outputPath.isNullOrBlank()) {+ val resolved = FileResolver(context).resolveForWrite(outputPath)+ val file = when (resolved) {+ is FileResolver.ResolveResult.Ok -> resolved.file.also { it.parentFile?.mkdirs() }+ is FileResolver.ResolveResult.PermissionNeeded -> return resolved.result+ is FileResolver.ResolveResult.Error -> return ToolResult.error(resolved.message)+ }+ recordingFile = file+ recordingDisplayPath = file.absolutePath+ } else {+ // Default location: the system-wide public Recordings folder, not+ // the per-chat working directory — recordings should be findable+ // like any other device recording, independent of which chat made them.+ when (+ val target = com.gotcha.data.GotchaStorage.createRecordingTarget(+ context,+ "recording_${timestamp()}.m4a"+ )+ ) {+ is com.gotcha.data.GotchaStorage.RecordingTarget.DirectFile -> {+ recordingFile = target.file+ recordingDisplayPath = target.file.absolutePath+ }+ is com.gotcha.data.GotchaStorage.RecordingTarget.MediaStoreEntry -> {+ recordingUri = target.uri+ recordingPfd = target.pfd+ recordingDisplayPath = target.displayPath+ }+ }+ }+ return null+ }++ private fun createConfiguredRecorder(+ source: String?,+ quality: String?,+ maxDurationSeconds: Int?+ ): MediaRecorder {+ val audioSource = when (source?.trim()?.lowercase()) {+ "voice" -> MediaRecorder.AudioSource.VOICE_RECOGNITION+ "camcorder" -> MediaRecorder.AudioSource.CAMCORDER+ else -> MediaRecorder.AudioSource.MIC+ }++ val rec = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {+ MediaRecorder(context)+ } else {+ @Suppress("DEPRECATION")+ MediaRecorder()+ }+ rec.setAudioSource(audioSource)+ rec.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4)+ rec.setAudioEncoder(MediaRecorder.AudioEncoder.AAC)++ when (quality?.trim()?.lowercase()) {+ "low" -> {+ rec.setAudioSamplingRate(16000)+ rec.setAudioEncodingBitRate(16000)+ }+ "medium" -> {+ rec.setAudioSamplingRate(44100)+ rec.setAudioEncodingBitRate(64000)+ }+ "high" -> {+ rec.setAudioSamplingRate(44100)+ rec.setAudioEncodingBitRate(192000)+ }+ }++ if (maxDurationSeconds != null && maxDurationSeconds > 0) {+ rec.setMaxDuration(maxDurationSeconds * 1000)+ }+ val pfd = recordingPfd+ if (pfd != null) {+ rec.setOutputFile(pfd.fileDescriptor)+ } else {+ rec.setOutputFile(recordingFile!!.absolutePath)+ }+ return rec+ }+fun stopAudioRecording(): ToolResult {val rec = recorder ?: return alreadyStoppedResult()return try {diff --git a/app/src/main/java/com/gotcha/ui/SettingsScreen.kt b/app/src/main/java/com/gotcha/ui/SettingsScreen.ktindex 366fcc4..df829fd 100644--- a/app/src/main/java/com/gotcha/ui/SettingsScreen.kt+++ b/app/src/main/java/com/gotcha/ui/SettingsScreen.kt@@ -255,899 +255,907 @@ fun SettingsScreen(}) { padding ->Box(modifier = Modifier.fillMaxSize().padding(padding)) {- Column(- modifier = Modifier- .fillMaxSize()- .padding(16.dp)- .verticalScroll(rememberScrollState()),- verticalArrangement = Arrangement.spacedBy(12.dp)- ) {- // ---- Appearance (always visible, applies immediately) ----- Text(- "Appearance",- style = MaterialTheme.typography.titleMedium,- fontWeight = FontWeight.Bold- )- SingleChoiceSegmentedButtonRow(modifier = Modifier.fillMaxWidth()) {- ThemeMode.values().forEachIndexed { index, mode ->- SegmentedButton(- selected = themeMode == mode,- onClick = {- themeMode = mode- onThemeChange(mode)- },- shape = SegmentedButtonDefaults.itemShape(- index = index,- count = ThemeMode.values().size- )- ) { Text(mode.label) }+ Column(+ modifier = Modifier+ .fillMaxSize()+ .padding(16.dp)+ .verticalScroll(rememberScrollState()),+ verticalArrangement = Arrangement.spacedBy(12.dp)+ ) {+ // ---- Appearance (always visible, applies immediately) ----+ Text(+ "Appearance",+ style = MaterialTheme.typography.titleMedium,+ fontWeight = FontWeight.Bold+ )+ SingleChoiceSegmentedButtonRow(modifier = Modifier.fillMaxWidth()) {+ ThemeMode.values().forEachIndexed { index, mode ->+ SegmentedButton(+ selected = themeMode == mode,+ onClick = {+ themeMode = mode+ onThemeChange(mode)+ },+ shape = SegmentedButtonDefaults.itemShape(+ index = index,+ count = ThemeMode.values().size+ )+ ) { Text(mode.label) }+ }}- }- HorizontalDivider(thickness = 1.dp)+ HorizontalDivider(thickness = 1.dp)- // ---- AI Configuration (collapsible, collapsed by default) ----- SectionHeader(- title = "AI Configuration",- expanded = aiConfigExpanded,- onToggle = { aiConfigExpanded = !aiConfigExpanded },- modifier = Modifier.testTag("settings_ai_config_header")- )- AnimatedVisibility(visible = aiConfigExpanded) {- Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {- // ---- LLM provider selector ----- ExposedDropdownMenuBox(- expanded = providerExpanded,- onExpandedChange = { providerExpanded = it }- ) {- OutlinedTextField(- value = provider.label,- onValueChange = {},- readOnly = true,- label = { Text("LLM Provider") },- trailingIcon = {- ExposedDropdownMenuDefaults.TrailingIcon(expanded = providerExpanded)- },- modifier = Modifier.fillMaxWidth().menuAnchor()- )- ExposedDropdownMenu(+ // ---- AI Configuration (collapsible, collapsed by default) ----+ SectionHeader(+ title = "AI Configuration",+ expanded = aiConfigExpanded,+ onToggle = { aiConfigExpanded = !aiConfigExpanded },+ modifier = Modifier.testTag("settings_ai_config_header")+ )+ AnimatedVisibility(visible = aiConfigExpanded) {+ Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {+ // ---- LLM provider selector ----+ ExposedDropdownMenuBox(expanded = providerExpanded,- onDismissRequest = { providerExpanded = false }+ onExpandedChange = { providerExpanded = it }) {- LlmProvider.entries.forEach { p ->- DropdownMenuItem(- text = { Text(p.label) },- onClick = {- provider = p- providerExpanded = false- }- )+ OutlinedTextField(+ value = provider.label,+ onValueChange = {},+ readOnly = true,+ label = { Text("LLM Provider") },+ trailingIcon = {+ ExposedDropdownMenuDefaults.TrailingIcon(expanded = providerExpanded)+ },+ modifier = Modifier.fillMaxWidth().menuAnchor()+ )+ ExposedDropdownMenu(+ expanded = providerExpanded,+ onDismissRequest = { providerExpanded = false }+ ) {+ LlmProvider.entries.forEach { p ->+ DropdownMenuItem(+ text = { Text(p.label) },+ onClick = {+ provider = p+ providerExpanded = false+ }+ )+ }}}- }- if (provider == LlmProvider.SAMOSA_AI) {- // ---- Samosa AI: Google sign-in (no Base URL / API key) ----- SamosaAuthSection(- email = samosaEmail,- signedIn = samosaToken.isNotBlank(),- busy = samosaBusy,- onSignIn = {- samosaBusy = true- status = "Signing in with Google…"- scope.launch {- val result = onSamosaSignIn()- result.onSuccess { (email, token) ->- samosaEmail = email- samosaToken = token- status = "Signed in as $email"- }.onFailure { e ->- status = e.message ?: "Sign-in failed."+ if (provider == LlmProvider.SAMOSA_AI) {+ // ---- Samosa AI: Google sign-in (no Base URL / API key) ----+ SamosaAuthSection(+ email = samosaEmail,+ signedIn = samosaToken.isNotBlank(),+ busy = samosaBusy,+ onSignIn = {+ samosaBusy = true+ status = "Signing in with Google…"+ scope.launch {+ val result = onSamosaSignIn()+ result.onSuccess { (email, token) ->+ samosaEmail = email+ samosaToken = token+ status = "Signed in as $email"+ }.onFailure { e ->+ status = e.message ?: "Sign-in failed."+ }+ samosaBusy = false+ }+ },+ onSignOut = {+ samosaBusy = true+ status = "Signing out…"+ scope.launch {+ onSamosaSignOut()+ samosaToken = ""+ samosaEmail = ""+ availableChatModels = emptyList()+ status = "Signed out of Samosa AI."+ samosaBusy = false}- samosaBusy = false- }- },- onSignOut = {- samosaBusy = true- status = "Signing out…"- scope.launch {- onSamosaSignOut()- samosaToken = ""- samosaEmail = ""- availableChatModels = emptyList()- status = "Signed out of Samosa AI."- samosaBusy = false- }- }- )- } else {- // ---- OpenAI-compatible: Base URL + API key (unchanged) ----- OutlinedTextField(- value = apiKey,- onValueChange = { apiKey = it },- label = { Text("API key") },- singleLine = true,- visualTransformation = if (showKey) {- VisualTransformation.None- } else {- PasswordVisualTransformation()- },- trailingIcon = {- TextButton(onClick = { showKey = !showKey }) {- Text(if (showKey) "Hide" else "Show")}- },- modifier = Modifier.fillMaxWidth().testTag("settings_api_key")- )- OutlinedTextField(- value = baseUrl,- onValueChange = { baseUrl = it },- label = { Text("Base URL (OpenAI-compatible)") },- singleLine = true,- modifier = Modifier.fillMaxWidth().testTag("settings_base_url")- )- }- ExposedDropdownMenuBox(- expanded = modelExpanded,- onExpandedChange = {- modelExpanded = it- if (it) refreshChatModelsAction()+ )+ } else {+ // ---- OpenAI-compatible: Base URL + API key (unchanged) ----+ OutlinedTextField(+ value = apiKey,+ onValueChange = { apiKey = it },+ label = { Text("API key") },+ singleLine = true,+ visualTransformation = if (showKey) {+ VisualTransformation.None+ } else {+ PasswordVisualTransformation()+ },+ trailingIcon = {+ TextButton(onClick = { showKey = !showKey }) {+ Text(if (showKey) "Hide" else "Show")+ }+ },+ modifier = Modifier.fillMaxWidth().testTag("settings_api_key")+ )+ OutlinedTextField(+ value = baseUrl,+ onValueChange = { baseUrl = it },+ label = { Text("Base URL (OpenAI-compatible)") },+ singleLine = true,+ modifier = Modifier.fillMaxWidth().testTag("settings_base_url")+ )}- ) {- OutlinedTextField(- value = model,- onValueChange = { model = it },- readOnly = false,- label = { Text("Main model") },- placeholder = { Text("(select model)") },- trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded = modelExpanded) },- modifier = Modifier.fillMaxWidth().menuAnchor().testTag("settings_model")- )- ExposedDropdownMenu(+ ExposedDropdownMenuBox(expanded = modelExpanded,- onDismissRequest = { modelExpanded = false }+ onExpandedChange = {+ modelExpanded = it+ if (it) refreshChatModelsAction()+ }) {- DropdownMenuItem(- text = { Text(if (refreshingChatModels) "Refreshing…" else "🔄 Refresh models…") },- onClick = { refreshChatModelsAction() }+ OutlinedTextField(+ value = model,+ onValueChange = { model = it },+ readOnly = false,+ label = { Text("Main model") },+ placeholder = { Text("(select model)") },+ trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded = modelExpanded) },+ modifier = Modifier.fillMaxWidth().menuAnchor().testTag("settings_model"))- if (availableChatModels.isEmpty()) {+ ExposedDropdownMenu(+ expanded = modelExpanded,+ onDismissRequest = { modelExpanded = false }+ ) {DropdownMenuItem(- text = { Text("No models found") },- onClick = { modelExpanded = false }+ text = { Text(if (refreshingChatModels) "Refreshing…" else "🔄 Refresh models…") },+ onClick = { refreshChatModelsAction() })- } else {- availableChatModels.forEach { m ->+ if (availableChatModels.isEmpty()) {DropdownMenuItem(- text = { Text(m) },- onClick = {- model = m- modelExpanded = false- }+ text = { Text("No models found") },+ onClick = { modelExpanded = false })+ } else {+ availableChatModels.forEach { m ->+ DropdownMenuItem(+ text = { Text(m) },+ onClick = {+ model = m+ modelExpanded = false+ }+ )+ }}+ // Always allow manual text input+ DropdownMenuItem(+ text = { Text("✏️ Custom model…") },+ onClick = {+ modelExpanded = false+ }+ )}- // Always allow manual text input- DropdownMenuItem(- text = { Text("✏️ Custom model…") },- onClick = {- modelExpanded = false- }- )- }- }- ExposedDropdownMenuBox(- expanded = subAgentModelExpanded,- onExpandedChange = {- subAgentModelExpanded = it- if (it) refreshChatModelsAction()}- ) {- val subLabel = if (subAgentModel.isBlank()) "Same as main agent" else subAgentModel- OutlinedTextField(- value = subLabel,- onValueChange = {},- readOnly = true,- label = { Text("Sub-agent model") },- trailingIcon = {- ExposedDropdownMenuDefaults.TrailingIcon(- expanded = subAgentModelExpanded- )- },- modifier = Modifier.fillMaxWidth().menuAnchor()- )- ExposedDropdownMenu(+ ExposedDropdownMenuBox(expanded = subAgentModelExpanded,- onDismissRequest = { subAgentModelExpanded = false }+ onExpandedChange = {+ subAgentModelExpanded = it+ if (it) refreshChatModelsAction()+ }) {- DropdownMenuItem(- text = { Text(if (refreshingChatModels) "Refreshing…" else "🔄 Refresh models…") },- onClick = { refreshChatModelsAction() }- )- DropdownMenuItem(- text = { Text("Same as main agent") },- onClick = {- subAgentModel = ""- subAgentModelExpanded = false- }- )- if (availableChatModels.isNotEmpty()) {- availableChatModels.forEach { m ->- DropdownMenuItem(- text = { Text(m) },- onClick = {- subAgentModel = m- subAgentModelExpanded = false- }+ val subLabel = if (subAgentModel.isBlank()) "Same as main agent" else subAgentModel+ OutlinedTextField(+ value = subLabel,+ onValueChange = {},+ readOnly = true,+ label = { Text("Sub-agent model") },+ trailingIcon = {+ ExposedDropdownMenuDefaults.TrailingIcon(+ expanded = subAgentModelExpanded)+ },+ modifier = Modifier.fillMaxWidth().menuAnchor()+ )+ ExposedDropdownMenu(+ expanded = subAgentModelExpanded,+ onDismissRequest = { subAgentModelExpanded = false }+ ) {+ DropdownMenuItem(+ text = { Text(if (refreshingChatModels) "Refreshing…" else "🔄 Refresh models…") },+ onClick = { refreshChatModelsAction() }+ )+ DropdownMenuItem(+ text = { Text("Same as main agent") },+ onClick = {+ subAgentModel = ""+ subAgentModelExpanded = false+ }+ )+ if (availableChatModels.isNotEmpty()) {+ availableChatModels.forEach { m ->+ DropdownMenuItem(+ text = { Text(m) },+ onClick = {+ subAgentModel = m+ subAgentModelExpanded = false+ }+ )+ }}}}- }- ExposedDropdownMenuBox(- expanded = navigatorModelExpanded,- onExpandedChange = {- navigatorModelExpanded = it- if (it) refreshChatModelsAction()- }- ) {- val navLabel = if (navigatorModel.isBlank()) "Same as main model" else navigatorModel- OutlinedTextField(- value = navLabel,- onValueChange = {},- readOnly = true,- label = { Text("Navigator model") },- trailingIcon = {- ExposedDropdownMenuDefaults.TrailingIcon(- expanded = navigatorModelExpanded- )- },- modifier = Modifier.fillMaxWidth().menuAnchor()- )- ExposedDropdownMenu(+ ExposedDropdownMenuBox(expanded = navigatorModelExpanded,- onDismissRequest = { navigatorModelExpanded = false }- ) {- DropdownMenuItem(- text = { Text(if (refreshingChatModels) "Refreshing…" else "🔄 Refresh models…") },- onClick = { refreshChatModelsAction() }- )- DropdownMenuItem(- text = { Text("Same as main model") },- onClick = {- navigatorModel = ""- navigatorModelExpanded = false- }- )- if (availableChatModels.isNotEmpty()) {- availableChatModels.forEach { m ->- DropdownMenuItem(- text = { Text(m) },- onClick = {- navigatorModel = m- navigatorModelExpanded = false- }- )- }+ onExpandedChange = {+ navigatorModelExpanded = it+ if (it) refreshChatModelsAction()}- }- }- OutlinedTextField(- value = maxToolRounds,- onValueChange = { maxToolRounds = it },- label = { Text("Max tool rounds") },- singleLine = true,- keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),- modifier = Modifier.fillMaxWidth()- )- OutlinedTextField(- value = maxRepeatedToolCalls,- onValueChange = { maxRepeatedToolCalls = it },- label = { Text("Max repeated tool calls") },- singleLine = true,- keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),- modifier = Modifier.fillMaxWidth()- )- OutlinedTextField(- value = maxNavigationToolCalls,- onValueChange = { maxNavigationToolCalls = it },- label = { Text("Max navigation tool calls") },- singleLine = true,- keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),- modifier = Modifier.fillMaxWidth()- )- OutlinedTextField(- value = maxContextTokens,- onValueChange = { maxContextTokens = it },- label = { Text("Max context tokens") },- singleLine = true,- keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),- modifier = Modifier.fillMaxWidth()- )- OutlinedTextField(- value = apiTimeoutSeconds,- onValueChange = { apiTimeoutSeconds = it },- label = { Text("API Timeout (seconds, 0 for infinite)") },- singleLine = true,- keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),- modifier = Modifier.fillMaxWidth()- )- Button(- onClick = {- onSave(currentSettings())- overlay = SettingsOverlay("Saved.")- status = null- },- enabled = when (provider) {- LlmProvider.SAMOSA_AI -> samosaToken.isNotBlank() && model.isNotBlank()- LlmProvider.OPENAI_COMPATIBLE -> baseUrl.isNotBlank() && model.isNotBlank()- },- modifier = Modifier.fillMaxWidth().testTag("settings_save")- ) { Text("Save") }- OutlinedButton(- onClick = {- testing = true- // Sticky while the request is in flight, then the result- // replaces it and fades out on its own.- overlay = SettingsOverlay("Testing connection…", sticky = true)- status = null- scope.launch {- val result = onTestConnection(currentSettings())- overlay = SettingsOverlay(- result.fold(- onSuccess = { "✓ Connected: $it" },- onFailure = { "✗ Connection failed: ${it.message}" }+ ) {+ val navLabel = if (navigatorModel.isBlank()) "Same as main model" else navigatorModel+ OutlinedTextField(+ value = navLabel,+ onValueChange = {},+ readOnly = true,+ label = { Text("Navigator model") },+ trailingIcon = {+ ExposedDropdownMenuDefaults.TrailingIcon(+ expanded = navigatorModelExpanded)+ },+ modifier = Modifier.fillMaxWidth().menuAnchor()+ )+ ExposedDropdownMenu(+ expanded = navigatorModelExpanded,+ onDismissRequest = { navigatorModelExpanded = false }+ ) {+ DropdownMenuItem(+ text = { Text(if (refreshingChatModels) "Refreshing…" else "🔄 Refresh models…") },+ onClick = { refreshChatModelsAction() })- testing = false- }- },- enabled = !testing && when (provider) {- LlmProvider.SAMOSA_AI -> samosaToken.isNotBlank()- LlmProvider.OPENAI_COMPATIBLE -> baseUrl.isNotBlank()- },- modifier = Modifier.fillMaxWidth()- ) { Text("Test connection") }- OutlinedButton(- onClick = {- onClearLlmCache()- overlay = SettingsOverlay("LLM response cache cleared.")- status = null- },- modifier = Modifier.fillMaxWidth()- ) { Text("Clear LLM cache") }- OutlinedButton(- onClick = {- onClearDebugScreenshots()- overlay = SettingsOverlay("Debug screenshots cleared.")- status = null- },- modifier = Modifier.fillMaxWidth()- ) { Text("Clear debug screenshots") }- }- }-- HorizontalDivider(thickness = 1.dp)-- // ---- Speech (collapsible, collapsed by default) ----- SectionHeader(- title = "Speech (TTS / STT)",- expanded = speechExpanded,- onToggle = { speechExpanded = !speechExpanded }- )- AnimatedVisibility(visible = speechExpanded) {- Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {- ExposedDropdownMenuBox(- expanded = ttsProviderExpanded,- onExpandedChange = { ttsProviderExpanded = it }- ) {- OutlinedTextField(- value = ttsProvider.name,- onValueChange = {},- readOnly = true,- label = { Text("TTS Provider") },- trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded = ttsProviderExpanded) },- modifier = Modifier.fillMaxWidth().menuAnchor()- )- ExposedDropdownMenu(- expanded = ttsProviderExpanded,- onDismissRequest = { ttsProviderExpanded = false }- ) {- AudioProvider.entries.forEach { provider ->DropdownMenuItem(- text = { Text(provider.name) },+ text = { Text("Same as main model") },onClick = {- ttsProvider = provider- ttsProviderExpanded = false+ navigatorModel = ""+ navigatorModelExpanded = false})+ if (availableChatModels.isNotEmpty()) {+ availableChatModels.forEach { m ->+ DropdownMenuItem(+ text = { Text(m) },+ onClick = {+ navigatorModel = m+ navigatorModelExpanded = false+ }+ )+ }+ }}}- }- if (ttsProvider == AudioProvider.API) {OutlinedTextField(- value = ttsApiBaseUrl,- onValueChange = { ttsApiBaseUrl = it },- label = { Text("TTS API Base URL") },+ value = maxToolRounds,+ onValueChange = { maxToolRounds = it },+ label = { Text("Max tool rounds") },singleLine = true,- placeholder = { Text("http://10.0.2.2:8969/v1") },+ keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),modifier = Modifier.fillMaxWidth())OutlinedTextField(- value = ttsApiKey,- onValueChange = { ttsApiKey = it },- label = { Text("TTS API Key (optional)") },+ value = maxRepeatedToolCalls,+ onValueChange = { maxRepeatedToolCalls = it },+ label = { Text("Max repeated tool calls") },singleLine = true,- placeholder = { Text("Leave blank to use main API key") },- visualTransformation = if (showTtsKey) {- VisualTransformation.None- } else {- PasswordVisualTransformation()+ keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),+ modifier = Modifier.fillMaxWidth()+ )+ OutlinedTextField(+ value = maxNavigationToolCalls,+ onValueChange = { maxNavigationToolCalls = it },+ label = { Text("Max navigation tool calls") },+ singleLine = true,+ keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),+ modifier = Modifier.fillMaxWidth()+ )+ OutlinedTextField(+ value = maxContextTokens,+ onValueChange = { maxContextTokens = it },+ label = { Text("Max context tokens") },+ singleLine = true,+ keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),+ modifier = Modifier.fillMaxWidth()+ )+ OutlinedTextField(+ value = apiTimeoutSeconds,+ onValueChange = { apiTimeoutSeconds = it },+ label = { Text("API Timeout (seconds, 0 for infinite)") },+ singleLine = true,+ keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),+ modifier = Modifier.fillMaxWidth()+ )+ Button(+ onClick = {+ onSave(currentSettings())+ overlay = SettingsOverlay("Saved.")+ status = null},- trailingIcon = {- TextButton(onClick = { showTtsKey = !showTtsKey }) {- Text(if (showTtsKey) "Hide" else "Show")+ enabled = when (provider) {+ LlmProvider.SAMOSA_AI -> samosaToken.isNotBlank() && model.isNotBlank()+ LlmProvider.OPENAI_COMPATIBLE -> baseUrl.isNotBlank() && model.isNotBlank()+ },+ modifier = Modifier.fillMaxWidth().testTag("settings_save")+ ) { Text("Save") }+ OutlinedButton(+ onClick = {+ testing = true+ // Sticky while the request is in flight, then the result+ // replaces it and fades out on its own.+ overlay = SettingsOverlay("Testing connection…", sticky = true)+ status = null+ scope.launch {+ val result = onTestConnection(currentSettings())+ overlay = SettingsOverlay(+ result.fold(+ onSuccess = { "✓ Connected: $it" },+ onFailure = { "✗ Connection failed: ${it.message}" }+ )+ )+ testing = false}},+ enabled = !testing && when (provider) {+ LlmProvider.SAMOSA_AI -> samosaToken.isNotBlank()+ LlmProvider.OPENAI_COMPATIBLE -> baseUrl.isNotBlank()+ },modifier = Modifier.fillMaxWidth()- )+ ) { Text("Test connection") }+ OutlinedButton(+ onClick = {+ onClearLlmCache()+ overlay = SettingsOverlay("LLM response cache cleared.")+ status = null+ },+ modifier = Modifier.fillMaxWidth()+ ) { Text("Clear LLM cache") }+ OutlinedButton(+ onClick = {+ onClearDebugScreenshots()+ overlay = SettingsOverlay("Debug screenshots cleared.")+ status = null+ },+ modifier = Modifier.fillMaxWidth()+ ) { Text("Clear debug screenshots") }+ }+ }++ HorizontalDivider(thickness = 1.dp)++ // ---- Speech (collapsible, collapsed by default) ----+ SectionHeader(+ title = "Speech (TTS / STT)",+ expanded = speechExpanded,+ onToggle = { speechExpanded = !speechExpanded }+ )+ AnimatedVisibility(visible = speechExpanded) {+ Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {ExposedDropdownMenuBox(- expanded = ttsModelExpanded,- onExpandedChange = {- ttsModelExpanded = it- if (it) refreshAudioModelsAction()- }+ expanded = ttsProviderExpanded,+ onExpandedChange = { ttsProviderExpanded = it }) {OutlinedTextField(- value = ttsApiModel.ifEmpty { "(select model)" },+ value = ttsProvider.name,onValueChange = {},readOnly = true,- label = { Text("TTS Model") },+ label = { Text("TTS Provider") },trailingIcon = {ExposedDropdownMenuDefaults.TrailingIcon(- expanded = ttsModelExpanded+ expanded = ttsProviderExpanded)},modifier = Modifier.fillMaxWidth().menuAnchor())ExposedDropdownMenu(- expanded = ttsModelExpanded,- onDismissRequest = { ttsModelExpanded = false }+ expanded = ttsProviderExpanded,+ onDismissRequest = { ttsProviderExpanded = false }) {- DropdownMenuItem(- text = {- Text(if (refreshingModels) "Refreshing…" else "🔄 Refresh audio models…")- },- onClick = { refreshAudioModelsAction() }- )- if (availableTtsModels.isEmpty()) {+ AudioProvider.entries.forEach { provider ->DropdownMenuItem(- text = { Text("No models found") },- onClick = { ttsModelExpanded = false }+ text = { Text(provider.name) },+ onClick = {+ ttsProvider = provider+ ttsProviderExpanded = false+ })- } else {- availableTtsModels.forEach { audioModel ->- DropdownMenuItem(- text = { Text(audioModel.id) },- onClick = {- ttsApiModel = audioModel.id- ttsModelExpanded = false- }- )- }}}}- val selectedTtsModelObj = availableTtsModels.firstOrNull { it.id == ttsApiModel }- val modelVoices = selectedTtsModelObj?.voices ?: emptyList()- if (modelVoices.isNotEmpty()) {- ExposedDropdownMenuBox(- expanded = ttsVoiceExpanded,- onExpandedChange = { ttsVoiceExpanded = it }- ) {- val selectedVoiceObj = modelVoices.firstOrNull { it.id == ttsVoice }- val defaultObj = modelVoices.firstOrNull { it.id == selectedTtsModelObj?.defaultVoice }- val defaultVoiceLabel = defaultObj?.displayLabel ?: selectedTtsModelObj?.defaultVoice ?: "af_heart"- val voiceLabel = if (ttsVoice.isEmpty()) {- "Default ($defaultVoiceLabel)"+ if (ttsProvider == AudioProvider.API) {+ OutlinedTextField(+ value = ttsApiBaseUrl,+ onValueChange = { ttsApiBaseUrl = it },+ label = { Text("TTS API Base URL") },+ singleLine = true,+ placeholder = { Text("http://10.0.2.2:8969/v1") },+ modifier = Modifier.fillMaxWidth()+ )+ OutlinedTextField(+ value = ttsApiKey,+ onValueChange = { ttsApiKey = it },+ label = { Text("TTS API Key (optional)") },+ singleLine = true,+ placeholder = { Text("Leave blank to use main API key") },+ visualTransformation = if (showTtsKey) {+ VisualTransformation.None} else {- selectedVoiceObj?.displayLabel ?: ttsVoice+ PasswordVisualTransformation()+ },+ trailingIcon = {+ TextButton(onClick = { showTtsKey = !showTtsKey }) {+ Text(if (showTtsKey) "Hide" else "Show")+ }+ },+ modifier = Modifier.fillMaxWidth()+ )+ ExposedDropdownMenuBox(+ expanded = ttsModelExpanded,+ onExpandedChange = {+ ttsModelExpanded = it+ if (it) refreshAudioModelsAction()}+ ) {OutlinedTextField(- value = voiceLabel,+ value = ttsApiModel.ifEmpty { "(select model)" },onValueChange = {},readOnly = true,- label = { Text("TTS Voice (optional)") },+ label = { Text("TTS Model") },trailingIcon = {ExposedDropdownMenuDefaults.TrailingIcon(- expanded = ttsVoiceExpanded+ expanded = ttsModelExpanded)},modifier = Modifier.fillMaxWidth().menuAnchor())ExposedDropdownMenu(- expanded = ttsVoiceExpanded,- onDismissRequest = { ttsVoiceExpanded = false }+ expanded = ttsModelExpanded,+ onDismissRequest = { ttsModelExpanded = false }) {DropdownMenuItem(- text = { Text("Default ($defaultVoiceLabel)") },- onClick = {- ttsVoice = ""- ttsVoiceExpanded = false+ text = {+ Text(if (refreshingModels) "Refreshing…" else "🔄 Refresh audio models…")+ },+ onClick = { refreshAudioModelsAction() }+ )+ if (availableTtsModels.isEmpty()) {+ DropdownMenuItem(+ text = { Text("No models found") },+ onClick = { ttsModelExpanded = false }+ )+ } else {+ availableTtsModels.forEach { audioModel ->+ DropdownMenuItem(+ text = { Text(audioModel.id) },+ onClick = {+ ttsApiModel = audioModel.id+ ttsModelExpanded = false+ }+ )}+ }+ }+ }+ val selectedTtsModelObj = availableTtsModels.firstOrNull { it.id == ttsApiModel }+ val modelVoices = selectedTtsModelObj?.voices ?: emptyList()+ if (modelVoices.isNotEmpty()) {+ ExposedDropdownMenuBox(+ expanded = ttsVoiceExpanded,+ onExpandedChange = { ttsVoiceExpanded = it }+ ) {+ val selectedVoiceObj = modelVoices.firstOrNull { it.id == ttsVoice }+ val defaultObj = modelVoices.firstOrNull { it.id == selectedTtsModelObj?.defaultVoice }+ val defaultVoiceLabel = defaultObj?.displayLabel ?: selectedTtsModelObj?.defaultVoice ?: "af_heart"+ val voiceLabel = if (ttsVoice.isEmpty()) {+ "Default ($defaultVoiceLabel)"+ } else {+ selectedVoiceObj?.displayLabel ?: ttsVoice+ }+ OutlinedTextField(+ value = voiceLabel,+ onValueChange = {},+ readOnly = true,+ label = { Text("TTS Voice (optional)") },+ trailingIcon = {+ ExposedDropdownMenuDefaults.TrailingIcon(+ expanded = ttsVoiceExpanded+ )+ },+ modifier = Modifier.fillMaxWidth().menuAnchor())- modelVoices.forEach { voiceInfo ->+ ExposedDropdownMenu(+ expanded = ttsVoiceExpanded,+ onDismissRequest = { ttsVoiceExpanded = false }+ ) {DropdownMenuItem(- text = { Text(voiceInfo.displayLabel) },+ text = { Text("Default ($defaultVoiceLabel)") },onClick = {- ttsVoice = voiceInfo.id+ ttsVoice = ""ttsVoiceExpanded = false})+ modelVoices.forEach { voiceInfo ->+ DropdownMenuItem(+ text = { Text(voiceInfo.displayLabel) },+ onClick = {+ ttsVoice = voiceInfo.id+ ttsVoiceExpanded = false+ }+ )+ }}}- }- } else {- OutlinedTextField(- value = ttsVoice,- onValueChange = { ttsVoice = it },- label = { Text("TTS Voice (optional)") },- singleLine = true,- placeholder = { Text("e.g. af_heart, alloy, echo") },- modifier = Modifier.fillMaxWidth()- )- }- }- ExposedDropdownMenuBox(- expanded = sttProviderExpanded,- onExpandedChange = { sttProviderExpanded = it }- ) {- OutlinedTextField(- value = sttProvider.name,- onValueChange = {},- readOnly = true,- label = { Text("STT Provider") },- trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded = sttProviderExpanded) },- modifier = Modifier.fillMaxWidth().menuAnchor()- )- ExposedDropdownMenu(- expanded = sttProviderExpanded,- onDismissRequest = { sttProviderExpanded = false }- ) {- AudioProvider.entries.forEach { provider ->- DropdownMenuItem(- text = { Text(provider.name) },- onClick = {- sttProvider = provider- sttProviderExpanded = false- }+ } else {+ OutlinedTextField(+ value = ttsVoice,+ onValueChange = { ttsVoice = it },+ label = { Text("TTS Voice (optional)") },+ singleLine = true,+ placeholder = { Text("e.g. af_heart, alloy, echo") },+ modifier = Modifier.fillMaxWidth())}}- }- if (sttProvider == AudioProvider.API) {- OutlinedTextField(- value = sttApiBaseUrl,- onValueChange = { sttApiBaseUrl = it },- label = { Text("STT API Base URL") },- singleLine = true,- placeholder = { Text("http://10.0.2.2:8969/v1") },- modifier = Modifier.fillMaxWidth()- )- OutlinedTextField(- value = sttApiKey,- onValueChange = { sttApiKey = it },- label = { Text("STT API Key (optional)") },- singleLine = true,- placeholder = { Text("Leave blank to use main API key") },- visualTransformation = if (showSttKey) {- VisualTransformation.None- } else {- PasswordVisualTransformation()- },- trailingIcon = {- TextButton(onClick = { showSttKey = !showSttKey }) {- Text(if (showSttKey) "Hide" else "Show")- }- },- modifier = Modifier.fillMaxWidth()- )ExposedDropdownMenuBox(- expanded = sttModelExpanded,- onExpandedChange = {- sttModelExpanded = it- if (it) refreshAudioModelsAction()- }+ expanded = sttProviderExpanded,+ onExpandedChange = { sttProviderExpanded = it }) {OutlinedTextField(- value = sttApiModel.ifEmpty { "(select model)" },+ value = sttProvider.name,onValueChange = {},readOnly = true,- label = { Text("STT Model") },+ label = { Text("STT Provider") },trailingIcon = {ExposedDropdownMenuDefaults.TrailingIcon(- expanded = sttModelExpanded+ expanded = sttProviderExpanded)},modifier = Modifier.fillMaxWidth().menuAnchor())ExposedDropdownMenu(+ expanded = sttProviderExpanded,+ onDismissRequest = { sttProviderExpanded = false }+ ) {+ AudioProvider.entries.forEach { provider ->+ DropdownMenuItem(+ text = { Text(provider.name) },+ onClick = {+ sttProvider = provider+ sttProviderExpanded = false+ }+ )+ }+ }+ }+ if (sttProvider == AudioProvider.API) {+ OutlinedTextField(+ value = sttApiBaseUrl,+ onValueChange = { sttApiBaseUrl = it },+ label = { Text("STT API Base URL") },+ singleLine = true,+ placeholder = { Text("http://10.0.2.2:8969/v1") },+ modifier = Modifier.fillMaxWidth()+ )+ OutlinedTextField(+ value = sttApiKey,+ onValueChange = { sttApiKey = it },+ label = { Text("STT API Key (optional)") },+ singleLine = true,+ placeholder = { Text("Leave blank to use main API key") },+ visualTransformation = if (showSttKey) {+ VisualTransformation.None+ } else {+ PasswordVisualTransformation()+ },+ trailingIcon = {+ TextButton(onClick = { showSttKey = !showSttKey }) {+ Text(if (showSttKey) "Hide" else "Show")+ }+ },+ modifier = Modifier.fillMaxWidth()+ )+ ExposedDropdownMenuBox(expanded = sttModelExpanded,- onDismissRequest = { sttModelExpanded = false }+ onExpandedChange = {+ sttModelExpanded = it+ if (it) refreshAudioModelsAction()+ }) {- DropdownMenuItem(- text = {- Text(if (refreshingModels) "Refreshing…" else "🔄 Refresh audio models…")+ OutlinedTextField(+ value = sttApiModel.ifEmpty { "(select model)" },+ onValueChange = {},+ readOnly = true,+ label = { Text("STT Model") },+ trailingIcon = {+ ExposedDropdownMenuDefaults.TrailingIcon(+ expanded = sttModelExpanded+ )},- onClick = { refreshAudioModelsAction() }+ modifier = Modifier.fillMaxWidth().menuAnchor())- if (availableSttModels.isEmpty()) {+ ExposedDropdownMenu(+ expanded = sttModelExpanded,+ onDismissRequest = { sttModelExpanded = false }+ ) {DropdownMenuItem(- text = { Text("No models found") },- onClick = { sttModelExpanded = false }+ text = {+ Text(if (refreshingModels) "Refreshing…" else "🔄 Refresh audio models…")+ },+ onClick = { refreshAudioModelsAction() })- } else {- availableSttModels.forEach { audioModel ->+ if (availableSttModels.isEmpty()) {DropdownMenuItem(- text = { Text(audioModel.id) },- onClick = {- sttApiModel = audioModel.id- sttModelExpanded = false- }+ text = { Text("No models found") },+ onClick = { sttModelExpanded = false })+ } else {+ availableSttModels.forEach { audioModel ->+ DropdownMenuItem(+ text = { Text(audioModel.id) },+ onClick = {+ sttApiModel = audioModel.id+ sttModelExpanded = false+ }+ )+ }}}}- }- val selectedSttModelObj = availableSttModels.firstOrNull { it.id == sttApiModel }- val languagesList = selectedSttModelObj?.languages?.takeIf { it.isNotEmpty() }- ?: COMMON_STT_LANGUAGES- ExposedDropdownMenuBox(- expanded = sttLanguageExpanded,- onExpandedChange = { sttLanguageExpanded = it }- ) {- OutlinedTextField(- value = sttLanguage,- onValueChange = { sttLanguage = it },- label = { Text("STT Language (optional)") },- placeholder = { Text("Auto-detect / Default (or select below)") },- trailingIcon = {- ExposedDropdownMenuDefaults.TrailingIcon(- expanded = sttLanguageExpanded- )- },- modifier = Modifier.fillMaxWidth().menuAnchor()- )- ExposedDropdownMenu(+ val selectedSttModelObj = availableSttModels.firstOrNull { it.id == sttApiModel }+ val languagesList = selectedSttModelObj?.languages?.takeIf { it.isNotEmpty() }+ ?: COMMON_STT_LANGUAGES+ ExposedDropdownMenuBox(expanded = sttLanguageExpanded,- onDismissRequest = { sttLanguageExpanded = false }+ onExpandedChange = { sttLanguageExpanded = it }) {- DropdownMenuItem(- text = { Text("Auto-detect / Default (empty)") },- onClick = {- sttLanguage = ""- sttLanguageExpanded = false- }+ OutlinedTextField(+ value = sttLanguage,+ onValueChange = { sttLanguage = it },+ label = { Text("STT Language (optional)") },+ placeholder = { Text("Auto-detect / Default (or select below)") },+ trailingIcon = {+ ExposedDropdownMenuDefaults.TrailingIcon(+ expanded = sttLanguageExpanded+ )+ },+ modifier = Modifier.fillMaxWidth().menuAnchor())- languagesList.forEach { lang ->+ ExposedDropdownMenu(+ expanded = sttLanguageExpanded,+ onDismissRequest = { sttLanguageExpanded = false }+ ) {DropdownMenuItem(- text = { Text(lang) },+ text = { Text("Auto-detect / Default (empty)") },onClick = {- sttLanguage = lang+ sttLanguage = ""sttLanguageExpanded = false})+ languagesList.forEach { lang ->+ DropdownMenuItem(+ text = { Text(lang) },+ onClick = {+ sttLanguage = lang+ sttLanguageExpanded = false+ }+ )+ }}}}+ Row(+ modifier = Modifier.fillMaxWidth(),+ horizontalArrangement = Arrangement.SpaceBetween,+ verticalAlignment = Alignment.CenterVertically+ ) {+ Text("Auto-read replies aloud", style = MaterialTheme.typography.bodyLarge)+ Switch(checked = autoReadReplies, onCheckedChange = { autoReadReplies = it })+ }+ Button(+ onClick = {+ onSave(currentSettings())+ overlay = SettingsOverlay("Saved.")+ status = null+ },+ modifier = Modifier.fillMaxWidth()+ ) { Text("Save Speech Settings") }}- Row(- modifier = Modifier.fillMaxWidth(),- horizontalArrangement = Arrangement.SpaceBetween,- verticalAlignment = Alignment.CenterVertically- ) {- Text("Auto-read replies aloud", style = MaterialTheme.typography.bodyLarge)- Switch(checked = autoReadReplies, onCheckedChange = { autoReadReplies = it })- }- Button(- onClick = {- onSave(currentSettings())- overlay = SettingsOverlay("Saved.")- status = null- },- modifier = Modifier.fillMaxWidth()- ) { Text("Save Speech Settings") }}- }- HorizontalDivider(thickness = 1.dp)+ HorizontalDivider(thickness = 1.dp)- // ---- Permissions ----- PermissionsSection(packageName = packageName)+ // ---- Permissions ----+ PermissionsSection(packageName = packageName)- HorizontalDivider(thickness = 1.dp)+ HorizontalDivider(thickness = 1.dp)- // ---- Skills (collapsible, collapsed by default) ----- SectionHeader(- title = "Skills / Plugins",- expanded = skillsExpanded,- onToggle = { skillsExpanded = !skillsExpanded }- )- AnimatedVisibility(visible = skillsExpanded) {- Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {- val allSkills = com.gotcha.agent.skills.SkillRegistry.getAllSkills()- if (allSkills.isEmpty()) {- Text("No skills loaded.", style = MaterialTheme.typography.bodyMedium)- } else {- allSkills.forEach { skill ->- Row(- modifier = Modifier.fillMaxWidth(),- horizontalArrangement = Arrangement.SpaceBetween,- verticalAlignment = Alignment.CenterVertically- ) {- Column(modifier = Modifier.weight(1f).padding(end = 8.dp)) {- Text(- skill.id,- style = MaterialTheme.typography.bodyLarge,- fontWeight = FontWeight.Bold- )- if (skill.description.isNotBlank()) {- Text(skill.description, style = MaterialTheme.typography.bodySmall)- }- }- Switch(- checked = !disabledSkills.contains(skill.id),- onCheckedChange = { enabled ->- disabledSkills = if (enabled) {- disabledSkills - skill.id- } else {- disabledSkills + skill.id+ // ---- Skills (collapsible, collapsed by default) ----+ SectionHeader(+ title = "Skills / Plugins",+ expanded = skillsExpanded,+ onToggle = { skillsExpanded = !skillsExpanded }+ )+ AnimatedVisibility(visible = skillsExpanded) {+ Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {+ val allSkills = com.gotcha.agent.skills.SkillRegistry.getAllSkills()+ if (allSkills.isEmpty()) {+ Text("No skills loaded.", style = MaterialTheme.typography.bodyMedium)+ } else {+ allSkills.forEach { skill ->+ Row(+ modifier = Modifier.fillMaxWidth(),+ horizontalArrangement = Arrangement.SpaceBetween,+ verticalAlignment = Alignment.CenterVertically+ ) {+ Column(modifier = Modifier.weight(1f).padding(end = 8.dp)) {+ Text(+ skill.id,+ style = MaterialTheme.typography.bodyLarge,+ fontWeight = FontWeight.Bold+ )+ if (skill.description.isNotBlank()) {+ Text(skill.description, style = MaterialTheme.typography.bodySmall)}- onSave(currentSettings())}- )+ Switch(+ checked = !disabledSkills.contains(skill.id),+ onCheckedChange = { enabled ->+ disabledSkills = if (enabled) {+ disabledSkills - skill.id+ } else {+ disabledSkills + skill.id+ }+ onSave(currentSettings())+ }+ )+ }}}}}- }- HorizontalDivider(thickness = 1.dp)+ HorizontalDivider(thickness = 1.dp)- // ---- Proactive Assistance ----- SectionHeader(- title = "Proactive Assistance",- expanded = proactiveExpanded,- onToggle = { proactiveExpanded = !proactiveExpanded }- )- AnimatedVisibility(visible = proactiveExpanded) {- Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {- SettingsToggleRow(- label = "Master Proactive Offers",- checked = proactiveEnabled,- onCheckedChange = { proactiveEnabled = it },- isLarge = true- )- if (proactiveEnabled) {- SettingsToggleRow(- label = "Scan Screen Content",- checked = proactiveScanScreen,- onCheckedChange = { proactiveScanScreen = it }- )- SettingsToggleRow(- label = "Scan Clipboard",- checked = proactiveScanClipboard,- onCheckedChange = { proactiveScanClipboard = it }- )- SettingsToggleRow(- label = "Scan Notifications",- checked = proactiveScanNotifications,- onCheckedChange = { proactiveScanNotifications = it }- )- SettingsToggleRow(- label = "Detect OTP / Codes",- checked = proactiveOtpEnabled,- onCheckedChange = { proactiveOtpEnabled = it }- )+ // ---- Proactive Assistance ----+ SectionHeader(+ title = "Proactive Assistance",+ expanded = proactiveExpanded,+ onToggle = { proactiveExpanded = !proactiveExpanded }+ )+ AnimatedVisibility(visible = proactiveExpanded) {+ Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {SettingsToggleRow(- label = "Auto-Copy OTP to Clipboard",- checked = proactiveAutoCopyOtp,- onCheckedChange = { proactiveAutoCopyOtp = it }+ label = "Master Proactive Offers",+ checked = proactiveEnabled,+ onCheckedChange = { proactiveEnabled = it },+ isLarge = true)+ if (proactiveEnabled) {+ SettingsToggleRow(+ label = "Scan Screen Content",+ checked = proactiveScanScreen,+ onCheckedChange = { proactiveScanScreen = it }+ )+ SettingsToggleRow(+ label = "Scan Clipboard",+ checked = proactiveScanClipboard,+ onCheckedChange = { proactiveScanClipboard = it }+ )+ SettingsToggleRow(+ label = "Scan Notifications",+ checked = proactiveScanNotifications,+ onCheckedChange = { proactiveScanNotifications = it }+ )+ SettingsToggleRow(+ label = "Detect OTP / Codes",+ checked = proactiveOtpEnabled,+ onCheckedChange = { proactiveOtpEnabled = it }+ )+ SettingsToggleRow(+ label = "Auto-Copy OTP to Clipboard",+ checked = proactiveAutoCopyOtp,+ onCheckedChange = { proactiveAutoCopyOtp = it }+ )- val languages = listOf(- "English", "Spanish", "French", "German", "Hindi",- "Japanese", "Chinese", "Italian", "Portuguese"- )- ExposedDropdownMenuBox(- expanded = languageExpanded,- onExpandedChange = { languageExpanded = it }- ) {- OutlinedTextField(- value = preferredLanguage,- onValueChange = {},- readOnly = true,- label = { Text("Preferred Language") },- trailingIcon = {- ExposedDropdownMenuDefaults.TrailingIcon(expanded = languageExpanded)- },- modifier = Modifier- .fillMaxWidth()- .menuAnchor()+ val languages = listOf(+ "English", "Spanish", "French", "German", "Hindi",+ "Japanese", "Chinese", "Italian", "Portuguese")- ExposedDropdownMenu(+ ExposedDropdownMenuBox(expanded = languageExpanded,- onDismissRequest = { languageExpanded = false }+ onExpandedChange = { languageExpanded = it }) {- languages.forEach { lang ->- DropdownMenuItem(- text = { Text(lang) },- onClick = {- preferredLanguage = lang- languageExpanded = false- }- )+ OutlinedTextField(+ value = preferredLanguage,+ onValueChange = {},+ readOnly = true,+ label = { Text("Preferred Language") },+ trailingIcon = {+ ExposedDropdownMenuDefaults.TrailingIcon(expanded = languageExpanded)+ },+ modifier = Modifier+ .fillMaxWidth()+ .menuAnchor()+ )+ ExposedDropdownMenu(+ expanded = languageExpanded,+ onDismissRequest = { languageExpanded = false }+ ) {+ languages.forEach { lang ->+ DropdownMenuItem(+ text = { Text(lang) },+ onClick = {+ preferredLanguage = lang+ languageExpanded = false+ }+ )+ }}}- }- val currencies = listOf("USD", "EUR", "GBP", "INR", "CAD", "AUD", "JPY", "CNY")- ExposedDropdownMenuBox(- expanded = currencyExpanded,- onExpandedChange = { currencyExpanded = it }- ) {- OutlinedTextField(- value = preferredCurrency,- onValueChange = {},- readOnly = true,- label = { Text("Preferred Currency") },- trailingIcon = {- ExposedDropdownMenuDefaults.TrailingIcon(expanded = currencyExpanded)- },- modifier = Modifier- .fillMaxWidth()- .menuAnchor()- )- ExposedDropdownMenu(+ val currencies = listOf("USD", "EUR", "GBP", "INR", "CAD", "AUD", "JPY", "CNY")+ ExposedDropdownMenuBox(expanded = currencyExpanded,- onDismissRequest = { currencyExpanded = false }+ onExpandedChange = { currencyExpanded = it }) {- currencies.forEach { curr ->- DropdownMenuItem(- text = { Text(curr) },- onClick = {- preferredCurrency = curr- currencyExpanded = false- }- )+ OutlinedTextField(+ value = preferredCurrency,+ onValueChange = {},+ readOnly = true,+ label = { Text("Preferred Currency") },+ trailingIcon = {+ ExposedDropdownMenuDefaults.TrailingIcon(expanded = currencyExpanded)+ },+ modifier = Modifier+ .fillMaxWidth()+ .menuAnchor()+ )+ ExposedDropdownMenu(+ expanded = currencyExpanded,+ onDismissRequest = { currencyExpanded = false }+ ) {+ currencies.forEach { curr ->+ DropdownMenuItem(+ text = { Text(curr) },+ onClick = {+ preferredCurrency = curr+ currencyExpanded = false+ }+ )+ }}}}+ Button(+ onClick = {+ onSave(currentSettings())+ overlay = SettingsOverlay("Saved Proactive Settings.")+ status = null+ },+ modifier = Modifier.fillMaxWidth()+ ) { Text("Save Proactive Settings") }}- Button(- onClick = {- onSave(currentSettings())- overlay = SettingsOverlay("Saved Proactive Settings.")- status = null- },- modifier = Modifier.fillMaxWidth()- ) { Text("Save Proactive Settings") }}- }- // Status text- status?.let {- Text(it, style = MaterialTheme.typography.bodyMedium)- }+ // Status text+ status?.let {+ Text(it, style = MaterialTheme.typography.bodyMedium)+ }- Text(- "The API key is stored encrypted on this device and never leaves it " +- "except in requests to the base URL above.",- style = MaterialTheme.typography.bodySmall- )- }+ Text(+ "The API key is stored encrypted on this device and never leaves it " ++ "except in requests to the base URL above.",+ style = MaterialTheme.typography.bodySmall+ )+ }- OverlayMessage(message = overlay, modifier = Modifier.align(Alignment.BottomCenter))+ OverlayMessage(message = overlay, modifier = Modifier.align(Alignment.BottomCenter))} // Box}}