Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/MCP.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,9 @@ They use the same list and the same per-provider config as Settings.

Part 2 (`SKIP_REAL=1` runs it alone) imports from a sample `~/.codex/config.toml` and `~/.claude.json`.
- **Screenshots:** `scripts/desktop-mcp-shot.sh` (desktop, `THEME=dark|light`), `test/e2e/ios/mcp-shot.sh`, and the Android shot script.

## Project MCP discovery follow-up

The thread’s Context & Prompt inspector reviews project MCP commands and URLs before enabling their configuration. Approval applies to the file’s exact bytes at its reviewed checkout path. Changes take effect at the next provider launch.

Grok, Muse, and Antigravity can also discover project MCP files directly. Backplane refuses launches when it detects a conflicting native configuration in those runtimes. Standalone Antigravity also lacks a verified way to pass Backplane’s approved list. Follow-up work is to suppress native discovery per launch, pass the approved list explicitly, and verify both behaviors against each supported CLI with a harmless stand-in MCP server.
30 changes: 30 additions & 0 deletions i18n/en.msg
Original file line number Diff line number Diff line change
Expand Up @@ -4910,3 +4910,33 @@ web.composer.voice = Voice dictation
web.composer.unsupported = Unsupported image type: {type}
web.composer.maximages = At most {max} images per message.
web.logout.failed = Could not confirm sign-out. Try again.

# ---- thread-context: inspector ----
thread.context.title = Context & Prompt
thread.context.instructions = Instructions
thread.context.system = System Prompt
thread.context.skills = Skills
thread.context.mcp = Project MCPs
thread.context.mcp.short = MCPs
thread.context.reading = Reading thread context…
thread.context.none.instructions = No project instructions found.
thread.context.none.mcp = No project MCP configurations found.
thread.context.native.note = Backplane’s launch prompt. Native files are loaded by the provider.
thread.context.copy = Copy prompt
thread.context.copied = Prompt copied.
thread.context.base = Backplane
thread.context.injected.label = Injected project instructions
thread.context.index = Available skills index
thread.context.scope.user = User
thread.context.scope.bundled = Bundled
thread.context.native = Native
thread.context.injected = Injected
thread.context.cross = Cross-provider
thread.context.explicit = Explicit invocation
thread.context.untrusted = Untrusted
thread.context.invalid = Invalid
thread.context.trust = Trust and enable
thread.context.enable = Enable
thread.context.disable = Disable
thread.context.size = {bytes} B · ≈{tokens} tokens
thread.context.unreachable = Could not reach the hub.
30 changes: 30 additions & 0 deletions i18n/es.msg
Original file line number Diff line number Diff line change
Expand Up @@ -4910,3 +4910,33 @@ web.composer.voice = Dictado por voz
web.composer.unsupported = Tipo de imagen no compatible: {type}
web.composer.maximages = Como máximo {max} imágenes por mensaje.
web.logout.failed = No se pudo confirmar el cierre de sesión. Inténtalo de nuevo.

# ---- thread-context: inspector ----
thread.context.title = Contexto e instrucciones
thread.context.instructions = Instrucciones
thread.context.system = Instrucciones del sistema
thread.context.skills = Habilidades
thread.context.mcp = MCP del proyecto
thread.context.mcp.short = MCP
thread.context.reading = Leyendo el contexto del hilo…
thread.context.none.instructions = No se encontraron instrucciones del proyecto.
thread.context.none.mcp = No se encontraron configuraciones MCP del proyecto.
thread.context.native.note = Instrucciones de inicio de Backplane. El proveedor carga los archivos nativos.
thread.context.copy = Copiar instrucciones
thread.context.copied = Se copiaron las instrucciones.
thread.context.base = Backplane
thread.context.injected.label = Instrucciones del proyecto añadidas
thread.context.index = Índice de habilidades disponibles
thread.context.scope.user = Usuario
thread.context.scope.bundled = Incluidas
thread.context.native = Nativo
thread.context.injected = Añadido
thread.context.cross = Entre proveedores
thread.context.explicit = Invocación explícita
thread.context.untrusted = Sin aprobar
thread.context.invalid = No válido
thread.context.trust = Confiar y activar
thread.context.enable = Activar
thread.context.disable = Desactivar
thread.context.size = {bytes} B · ≈{tokens} tokens
thread.context.unreachable = No se pudo conectar con el hub.
30 changes: 30 additions & 0 deletions i18n/ja.msg
Original file line number Diff line number Diff line change
Expand Up @@ -4933,3 +4933,33 @@ web.composer.voice = 音声入力
web.composer.unsupported = 未対応の画像形式です: {type}
web.composer.maximages = 1 件のメッセージに添付できる画像は最大 {max} 枚です。
web.logout.failed = サインアウトを確認できませんでした。もう一度お試しください。

# ---- thread-context: inspector ----
thread.context.title = コンテキストとプロンプト
thread.context.instructions = 指示
thread.context.system = システムプロンプト
thread.context.skills = スキル
thread.context.mcp = プロジェクトの MCP
thread.context.mcp.short = MCP
thread.context.reading = スレッドのコンテキストを読み込み中…
thread.context.none.instructions = プロジェクトの指示が見つかりません。
thread.context.none.mcp = プロジェクトの MCP 設定が見つかりません。
thread.context.native.note = Backplane が起動時に渡すプロンプトです。ネイティブファイルはプロバイダーが読み込みます。
thread.context.copy = プロンプトをコピー
thread.context.copied = プロンプトをコピーしました。
thread.context.base = Backplane
thread.context.injected.label = 追加されたプロジェクトの指示
thread.context.index = 利用可能なスキルの一覧
thread.context.scope.user = ユーザー
thread.context.scope.bundled = 同梱
thread.context.native = ネイティブ
thread.context.injected = 追加済み
thread.context.cross = プロバイダー共通
thread.context.explicit = 明示的な呼び出し
thread.context.untrusted = 未承認
thread.context.invalid = 無効
thread.context.trust = 承認して有効にする
thread.context.enable = 有効にする
thread.context.disable = 無効にする
thread.context.size = {bytes} B・約{tokens}トークン
thread.context.unreachable = ハブに接続できませんでした。
1 change: 1 addition & 0 deletions i18n/native.keys
Original file line number Diff line number Diff line change
Expand Up @@ -373,3 +373,4 @@ reply.action
reply.cancel
reply.replying
reply.to
thread.context.size
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ fun threadActions(t: DThread, rename: () -> Unit, confirmDelete: () -> Unit, sea
fun ThreadMenus(t: DThread, shown: Boolean, close: () -> Unit, deleted: () -> Unit = {}, search: (() -> Unit)? = null, buy: Pair<String, () -> Unit>? = null) {
var renaming by remember(t.id) { mutableStateOf(false) }
var deleting by remember(t.id) { mutableStateOf(false) }
if (shown) ActionSheet(t.title, threadActions(t, { renaming = true }, { deleting = true }, search, buy), close)
var contextOpen by remember(t.id) { mutableStateOf(false) }
val contextAction: List<Pair<String, () -> Unit>> =
if (DataClient.has("threadContext")) listOf("Context & Prompt" to { contextOpen = true }) else emptyList()
if (shown) ActionSheet(t.title, contextAction + threadActions(t, { renaming = true }, { deleting = true }, search, buy), close)
if (contextOpen) ThreadContextSheet(t.id) { contextOpen = false }
if (renaming) TextPrompt(Msg.android_thread_rename, t.title, Msg.menu_rename, { renaming = false }) { DataClient.threadAct(t.id, "rename", it) }
if (deleting) ActionSheet(Msg.android_thread_delete_ask(t.title), listOf("Delete thread" to { DataClient.threadAct(t.id, "delete"); deleted() }, "Keep it" to {}), { deleting = false })
}
Expand Down
173 changes: 170 additions & 3 deletions mobile/android/app/src/main/java/dev/backplane/mobile/Msg.kt

Large diffs are not rendered by default.

155 changes: 155 additions & 0 deletions mobile/android/app/src/main/java/dev/backplane/mobile/ThreadContext.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
package dev.backplane.mobile

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import kotlinx.coroutines.launch
import org.json.JSONObject

private fun JSONObject.rows(key: String): List<JSONObject> =
optJSONArray(key)?.let { a -> (0 until a.length()).mapNotNull(a::optJSONObject) }.orEmpty()

@Composable
internal fun ThreadContextSheet(thread: String, close: () -> Unit) {
val scope = rememberCoroutineScope()
val context = LocalContext.current
var snapshot by remember(thread) { mutableStateOf<JSONObject?>(null) }
var tab by remember(thread) { mutableIntStateOf(0) }
var expanded by remember(thread) { mutableStateOf("") }
var busy by remember(thread) { mutableStateOf(false) }
var error by remember(thread) { mutableStateOf("") }
suspend fun load(action: String = "", config: JSONObject? = null) {
if (busy) return
busy = true
error = ""
try {
val params = JSONObject().put("thread", thread)
if (config != null) params.put("path", config.optString("path")).put("sha256", config.optString("sha256")).put("action", action)
snapshot = DataClient.call(if (config == null) "thread.context" else "thread.context.mcp", params)
} catch (e: kotlinx.coroutines.CancellationException) {
throw e
} catch (e: Exception) {
error = e.message.orEmpty()
} finally {
busy = false
}
}
LaunchedEffect(thread) { load() }
Dialog(onDismissRequest = close, properties = DialogProperties(usePlatformDefaultWidth = false)) {
Column(Modifier.fillMaxWidth(.95f).fillMaxHeight(.9f).background(dcs.surface).padding(12.dp)) {
Row(Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) {
Text(Tr.t("Context & Prompt"), Modifier.weight(1f), color = dcs.onSurface)
TextButton(onClick = { scope.launch { load() } }, enabled = !busy) { Text(Tr.t("Refresh")) }
TextButton(onClick = close) { Text(Tr.t("Close")) }
}
snapshot?.optString("cwd")?.let { DMono(it, dcs.onSurfaceVariant, 11) }
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween) {
listOf("Instructions", "Prompt", "Skills", "MCPs").forEachIndexed { index, title ->
TextButton(onClick = { tab = index }, modifier = Modifier.weight(1f)) {
Text(Tr.t(title), color = if (tab == index) dcs.primary else dcs.onSurfaceVariant)
}
}
}
DLine()
if (busy) DMono(Tr.t("Reading thread context…"), dcs.onSurfaceVariant, 11)
if (error.isNotEmpty()) Text(error, color = dcs.error)
val data = snapshot
if (data != null) key(tab) {
LazyColumn(Modifier.weight(1f).fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(8.dp)) {
when (tab) {
0 -> {
val files = data.rows("instructions")
if (files.isEmpty()) item { Text(Tr.t("No project instructions found.")) }
files.forEach { row -> item {
val path = row.optString("path")
Column(Modifier.fillMaxWidth().clickable { expanded = if (expanded == path) "" else path }.padding(6.dp)) {
ContextStatus(path, row.optString("status"))
DMono(Msg.thread_context_size(row.optLong("bytes"), row.optLong("estimated_tokens")), dcs.onSurfaceVariant, 11)
if (expanded == path) {
ContextCode(row.optString("preview"))
if (row.optString("note").isNotEmpty()) Text(row.optString("note"))
}
}
DLine()
} }
}
1 -> {
item {
Text(Tr.t("Backplane’s launch prompt. Native files are loaded by the provider."))
TextButton(onClick = {
val clipboard = context.getSystemService(android.content.Context.CLIPBOARD_SERVICE) as android.content.ClipboardManager
clipboard.setPrimaryClip(android.content.ClipData.newPlainText("Backplane", data.optString("prompt")))
}) { Text(Tr.t("Copy prompt")) }
}
val sections = data.optJSONObject("sections")
listOf("base" to "Backplane", "instructions" to "Injected project instructions", "skills" to "Available skills index").forEach { (key, label) ->
val text = sections?.optString(key).orEmpty()
if (text.isNotEmpty()) item { Text(Tr.t(label), color = dcs.primary); ContextCode(text) }
}
}
2 -> listOf("Project", "User", "Bundled").forEach { group ->
val skills = data.rows("skills").filter { it.optString("scope") == group }
if (skills.isNotEmpty()) item { Text(Tr.t(group), color = dcs.primary) }
skills.forEach { row -> item {
ContextStatus(row.optString("name"), row.optString("status"))
Text(row.optString("description"))
DMono(listOf("source", "provider", "model").map { row.optString(it) }.filter { it.isNotEmpty() }.joinToString(" · "), dcs.onSurfaceVariant, 11)
DMono(row.optString("path"), dcs.onSurfaceVariant, 10)
DLine()
} }
}
else -> {
val configs = data.rows("mcp")
if (configs.isEmpty()) item { Text(Tr.t("No project MCP configurations found.")) }
configs.forEach { config -> item {
val state = config.optString("state")
ContextStatus(config.optString("path"), state)
config.rows("servers").forEach { server ->
ContextStatus(server.optString("name"), server.optString("status"))
val args = server.optJSONArray("args")
val argv = listOf(server.optString("command")) + (0 until (args?.length() ?: 0)).map { args!!.optString(it) }
ContextCode(server.optString("url").ifEmpty { argv.joinToString(" ") { JSONObject.quote(it) } })
}
if (config.optString("error").isNotEmpty()) Text(config.optString("error"), color = dcs.error)
val action = when (state) {
"Untrusted" -> "trust" to "Trust and enable"
"Enabled" -> "disable" to "Disable"
"Disabled" -> "enable" to "Enable"
else -> null
}
if (action != null) TextButton(onClick = { scope.launch { load(action.first, config) } }, enabled = !busy) { Text(Tr.t(action.second)) }
DLine()
} }
}
}
}
}
}
}
}

@Composable
private fun ContextStatus(title: String, status: String) {
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(8.dp), verticalAlignment = Alignment.CenterVertically) {
Text(title, Modifier.weight(1f), color = dcs.onSurface)
DMono(Tr.t(status), if (status == "Native" || status == "Enabled") dcs.primary else dcs.onSurfaceVariant, 11)
}
}

@Composable
private fun ContextCode(text: String) {
SelectionContainer {
DMono(text, dcs.onSurface, 12, Modifier.fillMaxWidth().background(dcs.surfaceVariant).padding(8.dp))
}
}
Loading
Loading