feat(aiturk): hide what the paired IDE cannot serve, plain error sentences, reconnect on return
When paired with AITURK IDE: - an "unknown method" (-32601) answer and the proxy's 403/route-404 are shown as plain sentences, never as raw JsonRpcError text; a method the IDE does not have is not sent again on the same socket - Account connectors, Vault, Keys and Files are hidden (the IDE has no connectors.* / vault.* and its phone proxy refuses /api/env and /api/files) - an idle-closed chat socket is reopened when the app returns to the foreground; idle tunnel connections are dropped on a network change - an unsaved chat no longer polls /api/sessions/<id> - the pairing screen shows the app version A plain Hermes connection is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B8ppceaR5s6cvMnm7uGRnf
This commit is contained in:
1 parent
c2d828b90a
commit
827c74b3c3
18 files changed
+709
-22
No files matched your search
@@ -35,6 +35,8 @@ class HermesControlApp :
|
||||
}
|
||||
AuthManager.init(this)
|
||||
NetworkMonitor.init(this)
|
||||
com.m57.hermescontrol.data.aiturk.AiturkCompat
|
||||
.init(this)
|
||||
SessionListCacheStore.init(this)
|
||||
// Reply-notification turn boundaries survive process death (armed before
|
||||
// each mobile prompt, consumed by the matching completion).
|
||||
|
||||
@@ -52,7 +52,9 @@ import com.m57.hermescontrol.data.local.AuthManager
|
||||
import com.m57.hermescontrol.data.ws.ConnectionStatus
|
||||
import com.m57.hermescontrol.data.ws.HermesWsClient
|
||||
import com.m57.hermescontrol.theme.LocalHermesStatusColors
|
||||
import com.m57.hermescontrol.ui.aiturkpair.AiturkFeatureGate
|
||||
import com.m57.hermescontrol.ui.aiturkpair.AiturkPairDeepLinkEffect
|
||||
import com.m57.hermescontrol.ui.aiturkpair.AiturkUnavailableScreen
|
||||
import com.m57.hermescontrol.ui.common.DisableDrawerGestures
|
||||
import com.m57.hermescontrol.ui.common.DrawerGestureController
|
||||
import com.m57.hermescontrol.ui.common.LocalDrawerGestureController
|
||||
@@ -115,7 +117,11 @@ private fun appEntryProvider(
|
||||
|
||||
ScreenRegistry.ALL_SCREENS.forEach { screen ->
|
||||
addEntryProvider(clazz = screen.key::class) {
|
||||
screen.content(sessionId, openDrawer)
|
||||
if (AiturkFeatureGate.shows(screen.key)) {
|
||||
screen.content(sessionId, openDrawer)
|
||||
} else {
|
||||
AiturkUnavailableScreen(titleRes = screen.labelRes, onOpenDrawer = openDrawer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,6 +331,7 @@ fun MainNavigation(sessionId: String? = null) {
|
||||
)
|
||||
ScreenRegistry.ALL_SCREENS
|
||||
.filter { it.drawerSection == section }
|
||||
.filter { AiturkFeatureGate.shows(it.key) }
|
||||
.forEach { entry ->
|
||||
NavigationDrawerItem(
|
||||
icon = { Icon(entry.icon, contentDescription = null) },
|
||||
|
||||
@@ -0,0 +1,204 @@
|
||||
package com.m57.hermescontrol.data.aiturk
|
||||
|
||||
import android.content.Context
|
||||
import androidx.annotation.StringRes
|
||||
import com.m57.hermescontrol.BuildConfig
|
||||
import com.m57.hermescontrol.R
|
||||
import com.m57.hermescontrol.data.local.AuthManager
|
||||
import com.m57.hermescontrol.data.remote.NetworkMonitor
|
||||
import com.m57.hermescontrol.data.remote.OkHttpProvider
|
||||
import com.m57.hermescontrol.data.ws.ConnectionStatus
|
||||
import com.m57.hermescontrol.data.ws.HermesWsClient
|
||||
import com.m57.hermescontrol.data.ws.JsonRpcError
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import kotlinx.serialization.json.JsonPrimitive
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
|
||||
/**
|
||||
* What differs when the app talks to a paired AITURK IDE instead of a plain
|
||||
* Hermes dashboard, kept in one place so the upstream files only carry
|
||||
* one-line hooks.
|
||||
*
|
||||
* AITURK IDE's agent is an older/forked Hermes gateway: some JSON-RPC methods
|
||||
* this app knows (`connectors.*`, `vault.*`, `subagent.list` …) are not
|
||||
* registered there and answer `-32601 unknown method`, and the IDE's phone
|
||||
* proxy refuses secret and settings routes with `403 {"error":"forbidden"}`.
|
||||
* Neither is an error the user can act on, so:
|
||||
*
|
||||
* - an awaited call that hits `-32601` fails quietly (no chat banner) and the
|
||||
* method is remembered until the next socket, so it is not sent again;
|
||||
* - every text shown for such an answer is a plain sentence, never the raw
|
||||
* `JsonRpcError(code=-32601, …)` or `unknown method` wording;
|
||||
* - idle pooled tunnel connections are dropped when the phone changes network
|
||||
* and the chat socket is reopened when the app returns to the foreground.
|
||||
*
|
||||
* Nothing here runs for a connection that is not a paired AITURK IDE.
|
||||
*/
|
||||
object AiturkCompat {
|
||||
const val METHOD_NOT_FOUND = -32601
|
||||
|
||||
private const val FALLBACK_FEATURE_UNAVAILABLE = "This feature is not available in this version of AITURK IDE."
|
||||
private const val FALLBACK_PHONE_FORBIDDEN =
|
||||
"For security this cannot be done from the phone. Do it in AITURK IDE on your computer."
|
||||
|
||||
@Volatile
|
||||
private var appContext: Context? = null
|
||||
|
||||
/** Tests set this instead of pairing a real address. */
|
||||
@Volatile
|
||||
internal var linkedOverride: Boolean? = null
|
||||
|
||||
/** Tests replace the string lookup (no Android resources on the JVM). */
|
||||
@Volatile
|
||||
internal var stringLookup: ((Int) -> String?)? = null
|
||||
|
||||
private val missingMethods: MutableSet<String> = ConcurrentHashMap.newKeySet()
|
||||
private val started = AtomicBoolean(false)
|
||||
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
||||
|
||||
/** Called once from the Application: string lookup and the network-change hook. */
|
||||
fun init(context: Context) {
|
||||
appContext = context.applicationContext
|
||||
if (started.compareAndSet(false, true)) {
|
||||
scope.launch {
|
||||
NetworkMonitor.networkChanges.collect { available -> if (available) onNetworkChanged() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** True while the active connection is a paired AITURK IDE (LAN or tunnel). */
|
||||
fun isLinked(): Boolean =
|
||||
linkedOverride ?: runCatching { AiturkLanTrust.isPairedUrl(AuthManager.baseUrl()) }.getOrDefault(false)
|
||||
|
||||
// ── JSON-RPC ─────────────────────────────────────────────────────────
|
||||
|
||||
/** True when an awaited call's error must not also be shown as a chat banner. */
|
||||
fun quietRpcError(code: Int): Boolean = code == METHOD_NOT_FOUND && isLinked()
|
||||
|
||||
/** Remembers that the IDE on the other end does not have [method]. */
|
||||
fun noteRpcError(
|
||||
method: String?,
|
||||
code: Int,
|
||||
) {
|
||||
if (method != null && quietRpcError(code)) missingMethods.add(method)
|
||||
}
|
||||
|
||||
/** True when [method] already answered "unknown method" on this socket. */
|
||||
fun isKnownMissing(method: String): Boolean = method in missingMethods && isLinked()
|
||||
|
||||
/** A new socket may be a newer IDE: ask again. */
|
||||
fun onSocketOpened() {
|
||||
missingMethods.clear()
|
||||
}
|
||||
|
||||
/** The exception a locally refused call fails with (same code the IDE would send). */
|
||||
fun missingMethodError(): HermesWsClient.HermesRpcException =
|
||||
HermesWsClient.HermesRpcException(featureUnavailableText(), code = METHOD_NOT_FOUND)
|
||||
|
||||
/** Message of the exception an awaited call fails with. */
|
||||
fun rpcExceptionMessage(
|
||||
code: Int,
|
||||
message: String,
|
||||
): String = if (quietRpcError(code)) featureUnavailableText() else message
|
||||
|
||||
/**
|
||||
* Chat banner text for an RPC error event. [legacy] is the upstream text,
|
||||
* used unchanged for every connection that is not a paired AITURK IDE.
|
||||
*/
|
||||
fun rpcBannerText(
|
||||
error: Any?,
|
||||
legacy: String,
|
||||
): String {
|
||||
if (!isLinked()) return legacy
|
||||
val code = (error as? JsonRpcError)?.code ?: ((error as? Map<*, *>)?.get("code") as? Number)?.toInt()
|
||||
if (code == METHOD_NOT_FOUND) return featureUnavailableText()
|
||||
val message = (error as? JsonRpcError)?.message ?: (error as? Map<*, *>)?.get("message") as? String
|
||||
return message?.takeIf { it.isNotBlank() } ?: legacy
|
||||
}
|
||||
|
||||
// ── REST ─────────────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* A plain sentence for the two answers that mean "not from the phone" /
|
||||
* "not in this IDE": the proxy's `403 {"error":"forbidden"}` and a route
|
||||
* the IDE does not have (`404 {"detail":"Not Found"}`, the proxy's
|
||||
* `404 {"error":"not_found"}`). Null for everything else, including a 404
|
||||
* that names a real missing record ("Session not found").
|
||||
*/
|
||||
fun httpErrorMessage(
|
||||
code: Int,
|
||||
errorBody: String?,
|
||||
): String? {
|
||||
if (code != HTTP_FORBIDDEN && code != HTTP_NOT_FOUND) return null
|
||||
if (!isLinked()) return null
|
||||
val body = errorBody?.let { runCatching { Json.parseToJsonElement(it) as? JsonObject }.getOrNull() }
|
||||
val error = (body?.get("error") as? JsonPrimitive)?.content
|
||||
val detail = (body?.get("detail") as? JsonPrimitive)?.content
|
||||
return when {
|
||||
code == HTTP_FORBIDDEN && error == "forbidden" -> phoneForbiddenText()
|
||||
code == HTTP_NOT_FOUND && (error == "not_found" || detail == "Not Found") -> featureUnavailableText()
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A brand-new chat has no row in the IDE's session store until its first
|
||||
* message, so `GET /api/sessions/<id>` answers 404 on every poll.
|
||||
*/
|
||||
fun skipSessionDetail(transcriptEmpty: Boolean): Boolean = transcriptEmpty && isLinked()
|
||||
|
||||
// ── Network and lifecycle ────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* The default network changed (Wi-Fi ⇄ mobile data). Idle pooled
|
||||
* connections still ride the old network's tunnel stream; drop them so the
|
||||
* next REST call opens a fresh stream instead of waiting for a read timeout.
|
||||
*/
|
||||
internal fun onNetworkChanged(evictIdle: () -> Unit = { OkHttpProvider.base.connectionPool.evictAll() }) {
|
||||
if (isLinked()) runCatching(evictIdle)
|
||||
}
|
||||
|
||||
/**
|
||||
* The app came back to the foreground. An idle socket is closed on purpose
|
||||
* in the background; reopen it so the user does not have to tap "reconnect".
|
||||
* A socket that is open, opening, or signed out is left alone.
|
||||
*/
|
||||
fun onAppForeground(
|
||||
status: ConnectionStatus = HermesWsClient.connectionStatus.value,
|
||||
autoReconnect: () -> Boolean = { runCatching { AuthManager.isAutoReconnect() }.getOrDefault(false) },
|
||||
connect: () -> Unit = { HermesWsClient.connect() },
|
||||
) {
|
||||
if (status == ConnectionStatus.DISCONNECTED && isLinked() && autoReconnect()) connect()
|
||||
}
|
||||
|
||||
// ── Text ─────────────────────────────────────────────────────────────
|
||||
|
||||
/** "v1.2.3 (45)": what the pair screen and Settings → About show. */
|
||||
fun versionLabel(
|
||||
name: String = BuildConfig.VERSION_NAME,
|
||||
code: Int = BuildConfig.VERSION_CODE,
|
||||
): String = "v$name ($code)"
|
||||
|
||||
fun featureUnavailableText(): String = string(R.string.aiturk_feature_unavailable) ?: FALLBACK_FEATURE_UNAVAILABLE
|
||||
|
||||
fun phoneForbiddenText(): String = string(R.string.aiturk_phone_forbidden) ?: FALLBACK_PHONE_FORBIDDEN
|
||||
|
||||
private fun string(
|
||||
@StringRes id: Int,
|
||||
): String? = stringLookup?.invoke(id) ?: runCatching { appContext?.getString(id) }.getOrNull()
|
||||
|
||||
internal fun resetForTest() {
|
||||
linkedOverride = null
|
||||
stringLookup = null
|
||||
missingMethods.clear()
|
||||
}
|
||||
|
||||
private const val HTTP_FORBIDDEN = 403
|
||||
private const val HTTP_NOT_FOUND = 404
|
||||
}
|
||||
@@ -710,5 +710,6 @@ object AiturkRelayStatus {
|
||||
|
||||
fun onSocketOpened() {
|
||||
_hostOffline.value = false
|
||||
AiturkCompat.onSocketOpened()
|
||||
}
|
||||
}
|
||||
@@ -47,6 +47,10 @@ fun mapHttpError(
|
||||
if (code == 401) {
|
||||
return NetworkError.AuthExpired()
|
||||
}
|
||||
// AITURK: the IDE's phone proxy refusing a route, or the IDE not having it, gets a plain sentence.
|
||||
com.m57.hermescontrol.data.aiturk.AiturkCompat
|
||||
.httpErrorMessage(code, errorBody)
|
||||
?.let { return NetworkError.Http(code, it) }
|
||||
// Try to parse FastAPI-style error detail from response body
|
||||
val detail =
|
||||
if (errorBody != null) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.m57.hermescontrol.data.ws
|
||||
|
||||
import com.m57.hermescontrol.data.aiturk.AiturkCompat
|
||||
import com.m57.hermescontrol.data.ws.contract.RpcMethod
|
||||
import kotlinx.coroutines.CancellationException
|
||||
import kotlinx.coroutines.CompletableDeferred
|
||||
@@ -110,6 +111,11 @@ internal class RpcChannel(
|
||||
suppressErrorEvent: Boolean = false,
|
||||
): CompletableDeferred<Any?> {
|
||||
val deferred = CompletableDeferred<Any?>()
|
||||
// AITURK: a method the paired IDE already answered "unknown method" for is not sent again.
|
||||
if (AiturkCompat.isKnownMissing(method)) {
|
||||
deferred.completeExceptionally(AiturkCompat.missingMethodError())
|
||||
return deferred
|
||||
}
|
||||
val id =
|
||||
sendRequest(method, params) { reqId ->
|
||||
pendingCalls[reqId] = PendingCall(method, deferred, suppressErrorEvent = suppressErrorEvent)
|
||||
@@ -191,7 +197,7 @@ internal class RpcChannel(
|
||||
if (error != null) {
|
||||
call.deferred.completeExceptionally(
|
||||
HermesWsClient.HermesRpcException(
|
||||
message = error.message,
|
||||
message = AiturkCompat.rpcExceptionMessage(error.code, error.message),
|
||||
code = error.code,
|
||||
data = error.data,
|
||||
),
|
||||
@@ -332,7 +338,12 @@ internal class RpcChannel(
|
||||
|
||||
is WsEvent.RpcError -> {
|
||||
onError(event.id)
|
||||
if (pendingCalls[event.id]?.suppressErrorEvent == true) {
|
||||
// AITURK: an awaited call the paired IDE does not know fails through its
|
||||
// deferred only; the raw "unknown method" never reaches the chat banner.
|
||||
val pending = pendingCalls[event.id]
|
||||
AiturkCompat.noteRpcError(pending?.method, event.error.code)
|
||||
val quiet = pending != null && AiturkCompat.quietRpcError(event.error.code)
|
||||
if (quiet || pending?.suppressErrorEvent == true) {
|
||||
// Opt-in suppression: the caller already handles the
|
||||
// failure through the CompletableDeferred, so the event
|
||||
// copy would only surface a duplicate UI banner for
|
||||
|
||||
@@ -659,6 +659,8 @@ internal class WsTransport(
|
||||
outboundDrainJob?.cancel()
|
||||
outboundDrainJob = null
|
||||
Log.i(TAG, "WebSocket opened")
|
||||
com.m57.hermescontrol.data.aiturk.AiturkRelayStatus
|
||||
.onSocketOpened()
|
||||
connected.set(true)
|
||||
_connectionStatus.value = ConnectionStatus.CONNECTED
|
||||
reconnectPolicy.reset()
|
||||
|
||||
@@ -726,6 +726,11 @@ object NotificationHelper {
|
||||
) {
|
||||
ChatNotificationService.setAppForeground(foreground)
|
||||
HermesWsClient.setAppForeground(foreground)
|
||||
// AITURK: reopen the socket that was closed while idle in the background.
|
||||
if (foreground) {
|
||||
com.m57.hermescontrol.data.aiturk.AiturkCompat
|
||||
.onAppForeground()
|
||||
}
|
||||
if (!foreground) {
|
||||
BackgroundConnectionController.default.reconcileState()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.m57.hermescontrol.ui.aiturkpair
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Computer
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.testTag
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.navigation3.runtime.NavKey
|
||||
import com.m57.hermescontrol.AccountConnectorsScreen
|
||||
import com.m57.hermescontrol.FilesScreen
|
||||
import com.m57.hermescontrol.KeysScreen
|
||||
import com.m57.hermescontrol.R
|
||||
import com.m57.hermescontrol.SettingsVault
|
||||
import com.m57.hermescontrol.data.aiturk.AiturkCompat
|
||||
import com.m57.hermescontrol.ui.common.EmptyState
|
||||
import com.m57.hermescontrol.ui.common.HermesScaffold
|
||||
import com.m57.hermescontrol.ui.common.NavIcon
|
||||
|
||||
/**
|
||||
* Screens a paired AITURK IDE cannot serve, hidden from the drawer and the
|
||||
* settings list while that pairing is the active connection:
|
||||
*
|
||||
* - Account connectors, Credential vault: the IDE's agent has no
|
||||
* `connectors.*` / `vault.*` methods;
|
||||
* - Keys, Files: the IDE's phone proxy refuses `/api/env` and `/api/files`
|
||||
* on purpose (secrets and the computer's files stay on the computer).
|
||||
*
|
||||
* A plain Hermes dashboard connection shows everything, as upstream does.
|
||||
*/
|
||||
object AiturkFeatureGate {
|
||||
val HIDDEN_WHEN_LINKED: Set<NavKey> = setOf(AccountConnectorsScreen, KeysScreen, FilesScreen, SettingsVault)
|
||||
|
||||
fun shows(
|
||||
key: NavKey,
|
||||
linked: Boolean = AiturkCompat.isLinked(),
|
||||
): Boolean = !(linked && key in HIDDEN_WHEN_LINKED)
|
||||
}
|
||||
|
||||
/** Shown instead of a hidden screen that is still reached (restored back stack, shortcut). */
|
||||
@Composable
|
||||
fun AiturkUnavailableScreen(
|
||||
@StringRes titleRes: Int,
|
||||
onOpenDrawer: (() -> Unit)?,
|
||||
) {
|
||||
HermesScaffold(
|
||||
title = { Text(stringResource(titleRes)) },
|
||||
navigationIcon = onOpenDrawer?.let { NavIcon.Menu(it) },
|
||||
) { padding ->
|
||||
EmptyState(
|
||||
title = stringResource(R.string.aiturk_feature_unavailable),
|
||||
subtitle = stringResource(R.string.aiturk_feature_unavailable_hint),
|
||||
icon = Icons.Filled.Computer,
|
||||
modifier = Modifier.padding(padding).testTag("aiturk_unavailable"),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -43,6 +43,7 @@ import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.testTag
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
@@ -61,6 +62,7 @@ import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import com.journeyapps.barcodescanner.ScanContract
|
||||
import com.journeyapps.barcodescanner.ScanOptions
|
||||
import com.m57.hermescontrol.R
|
||||
import com.m57.hermescontrol.data.aiturk.AiturkCompat
|
||||
import com.m57.hermescontrol.data.aiturk.AiturkPairing
|
||||
import com.m57.hermescontrol.data.remote.requiresLocalNetworkPermission
|
||||
|
||||
@@ -286,6 +288,15 @@ fun AiturkPairScreen(
|
||||
TextButton(onClick = onBack, enabled = !state.busy) {
|
||||
Text(stringResource(R.string.aiturk_pair_back))
|
||||
}
|
||||
|
||||
// So the user can tell which build is installed when support asks.
|
||||
Text(
|
||||
text = stringResource(R.string.aiturk_app_version, AiturkCompat.versionLabel()),
|
||||
modifier = Modifier.testTag("aiturk_app_version"),
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
textAlign = TextAlign.Center,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,6 +79,7 @@ import androidx.lifecycle.compose.LocalLifecycleOwner
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import androidx.lifecycle.repeatOnLifecycle
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import com.m57.hermescontrol.AccountConnectorsScreen
|
||||
import com.m57.hermescontrol.BuildConfig
|
||||
import com.m57.hermescontrol.ExternalActivityLifecycleGuard
|
||||
import com.m57.hermescontrol.HistoryScreen
|
||||
@@ -94,6 +95,7 @@ import com.m57.hermescontrol.data.ws.ConnectionStatus
|
||||
import com.m57.hermescontrol.data.ws.HermesWsClient
|
||||
import com.m57.hermescontrol.notification.NotificationHelper
|
||||
import com.m57.hermescontrol.theme.LocalHermesStatusColors
|
||||
import com.m57.hermescontrol.ui.aiturkpair.AiturkFeatureGate
|
||||
import com.m57.hermescontrol.ui.chat.components.ChatAppUpdateSection
|
||||
import com.m57.hermescontrol.ui.chat.components.ChatConnectionBanner
|
||||
import com.m57.hermescontrol.ui.chat.components.ChatHistoryWindowBanner
|
||||
@@ -601,20 +603,23 @@ fun ChatScreen(
|
||||
modifier = Modifier.testTag("chat_menu_search"),
|
||||
)
|
||||
|
||||
DropdownMenuItem(
|
||||
text = { Text(stringResource(R.string.session_integrations_menu_item)) },
|
||||
leadingIcon = {
|
||||
Icon(
|
||||
imageVector = Icons.Filled.Extension,
|
||||
contentDescription = null,
|
||||
)
|
||||
},
|
||||
onClick = {
|
||||
showSessionMenu = false
|
||||
connectorsViewModel.show()
|
||||
},
|
||||
modifier = Modifier.testTag("chat_menu_session_integrations"),
|
||||
)
|
||||
// AITURK: the paired IDE has no connectors; the entry would only open an empty sheet.
|
||||
if (AiturkFeatureGate.shows(AccountConnectorsScreen)) {
|
||||
DropdownMenuItem(
|
||||
text = { Text(stringResource(R.string.session_integrations_menu_item)) },
|
||||
leadingIcon = {
|
||||
Icon(
|
||||
imageVector = Icons.Filled.Extension,
|
||||
contentDescription = null,
|
||||
)
|
||||
},
|
||||
onClick = {
|
||||
showSessionMenu = false
|
||||
connectorsViewModel.show()
|
||||
},
|
||||
modifier = Modifier.testTag("chat_menu_session_integrations"),
|
||||
)
|
||||
}
|
||||
ChatBackgroundConnectionMenuItem(
|
||||
checked = settingsState.keepConnectedInBackground,
|
||||
onToggle = settingsViewModel::onKeepConnectedInBackgroundChange,
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.net.Uri
|
||||
import android.util.Log
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.m57.hermescontrol.data.aiturk.AiturkCompat
|
||||
import com.m57.hermescontrol.data.local.AuthManager
|
||||
import com.m57.hermescontrol.data.local.DataScope
|
||||
import com.m57.hermescontrol.data.local.HermesDatabase
|
||||
@@ -2317,7 +2318,7 @@ class ChatViewModel(
|
||||
_uiState.update {
|
||||
it.copy(
|
||||
isLoading = false,
|
||||
errorMessage = "Error ($method): $errorMsg",
|
||||
errorMessage = AiturkCompat.rpcBannerText(error, legacy = "Error ($method): $errorMsg"),
|
||||
resumeError = if (method == WsMethods.SESSION_CREATE) errorMsg else it.resumeError,
|
||||
)
|
||||
}
|
||||
@@ -6038,6 +6039,8 @@ class ChatViewModel(
|
||||
) {
|
||||
return@launch
|
||||
}
|
||||
// AITURK: an unsaved (empty) chat has no session row yet; skip the 404 poll.
|
||||
if (AiturkCompat.skipSessionDetail(_uiState.value.messages.isEmpty())) return@launch
|
||||
val usedResult =
|
||||
safeApiCall { ApiClient.hermesApi.getSessionDetail(sessionId, profile) }
|
||||
coroutineContext.ensureActive()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.m57.hermescontrol.ui.chat
|
||||
|
||||
import com.m57.hermescontrol.data.aiturk.AiturkCompat
|
||||
import com.m57.hermescontrol.data.model.deltaFrom
|
||||
import com.m57.hermescontrol.data.model.mergeWith
|
||||
import com.m57.hermescontrol.data.model.parseUsageSnapshot
|
||||
@@ -997,7 +998,7 @@ object ChatWsEventReducer {
|
||||
state =
|
||||
state.copy(
|
||||
isLoading = false,
|
||||
errorMessage = "Error: ${event.error}",
|
||||
errorMessage = AiturkCompat.rpcBannerText(event.error, legacy = "Error: ${event.error}"),
|
||||
),
|
||||
streamingState = streamingState,
|
||||
)
|
||||
|
||||
@@ -46,6 +46,7 @@ import com.m57.hermescontrol.SettingsConnection
|
||||
import com.m57.hermescontrol.SettingsLanguage
|
||||
import com.m57.hermescontrol.SettingsVault
|
||||
import com.m57.hermescontrol.theme.ThemePreference
|
||||
import com.m57.hermescontrol.ui.aiturkpair.AiturkFeatureGate
|
||||
import com.m57.hermescontrol.ui.common.HermesScaffold
|
||||
import com.m57.hermescontrol.ui.common.NavIcon
|
||||
import com.m57.hermescontrol.ui.settings.components.SupportSection
|
||||
@@ -74,7 +75,7 @@ fun SettingsScreen(
|
||||
) {
|
||||
SettingsCategoryCard(
|
||||
items =
|
||||
listOf(
|
||||
listOfNotNull(
|
||||
SettingsRow(
|
||||
icon = Icons.AutoMirrored.Filled.ListAlt,
|
||||
label = stringResource(R.string.settings_sec_connection),
|
||||
@@ -94,7 +95,7 @@ fun SettingsScreen(
|
||||
label = stringResource(R.string.screen_account_connectors),
|
||||
summary = stringResource(R.string.account_connectors_summary),
|
||||
onClick = { NavigationController.navigateTo(AccountConnectorsScreen) },
|
||||
),
|
||||
).takeIf { AiturkFeatureGate.shows(AccountConnectorsScreen) },
|
||||
SettingsRow(
|
||||
icon = Icons.Filled.Palette,
|
||||
label = stringResource(R.string.settings_sec_appearance),
|
||||
@@ -136,7 +137,7 @@ fun SettingsScreen(
|
||||
label = stringResource(R.string.settings_sec_vault),
|
||||
summary = stringResource(R.string.settings_summary_vault),
|
||||
onClick = { NavigationController.navigateTo(SettingsVault) },
|
||||
),
|
||||
).takeIf { AiturkFeatureGate.shows(SettingsVault) },
|
||||
SettingsRow(
|
||||
icon = Icons.Filled.Info,
|
||||
label = stringResource(R.string.settings_sec_about),
|
||||
|
||||
Reference in new issue
Block a user