Contract at server dev 4b28b36: a device approval corrects its detail
CI / check (push) Canceled after 0s
CI / check (push) Canceled after 0s
The server's contract moved (2198eda, 94e5243): a device's approval has the heading "Run a command" in `title` and the command in `detail`, which is what an `editable` item corrects; it offers no free text and names the asking subagent in `job`. The agent chat carries its real subagent facts, and the chats list (`chats_listed.json`, new) says `subagents: null` -- read the chat. The approval card draws the asker, the heading, "It says:" for the model's purpose, the command in the box and the server's reason, with the page's own sentences (from the server's catalogue). `approvalTexts` sends a box only when its text differs from `detail`; an untouched or cleared box sends nothing. ContractTest covers both fixtures; a screenshot of the contract's approval and question cards. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
18 files changed
+176
-18
No files matched your search
@@ -72,21 +72,33 @@ private fun Approval(card: Card, onAnswer: (CardAnswer) -> Unit) {
|
||||
var refusing by remember { mutableStateOf(false) }
|
||||
Text(stringResource(R.string.card_approval), style = MaterialTheme.typography.titleMedium)
|
||||
card.items.forEach { item ->
|
||||
// A subagent asks, not the chat's own turn: said first, as the page says it.
|
||||
if (item.job.isNotBlank()) {
|
||||
Text(stringResource(R.string.card_asker, item.job), style = MaterialTheme.typography.labelLarge, color = palette.accent)
|
||||
}
|
||||
// `title` is the heading ("Run a command"); `detail` is the thing itself, the command.
|
||||
if (item.title.isNotBlank()) Text(item.title, style = MaterialTheme.typography.titleSmall)
|
||||
if (item.purpose.isNotBlank()) {
|
||||
Text(stringResource(R.string.card_it_says, item.purpose), style = MaterialTheme.typography.bodySmall, color = palette.inkMuted)
|
||||
}
|
||||
if (item.editable) {
|
||||
OutlinedTextField(
|
||||
value = edits[item.key] ?: item.title,
|
||||
value = edits[item.key] ?: item.detail,
|
||||
onValueChange = { edits[item.key] = it },
|
||||
textStyle = MaterialTheme.typography.bodyMedium.copy(fontFamily = FontFamily.Monospace),
|
||||
label = { Text(stringResource(R.string.card_change_before)) },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
)
|
||||
} else {
|
||||
Text(item.title, fontFamily = FontFamily.Monospace)
|
||||
if (approvalTexts(listOf(item), edits).isNotEmpty()) {
|
||||
Text(stringResource(R.string.card_edit_runs), style = MaterialTheme.typography.bodySmall, color = palette.inkMuted)
|
||||
}
|
||||
} else if (item.detail.isNotBlank()) {
|
||||
Text(item.detail, fontFamily = FontFamily.Monospace)
|
||||
}
|
||||
if (item.detail.isNotBlank()) Text(item.detail, style = MaterialTheme.typography.bodySmall, color = palette.inkMuted)
|
||||
if (item.purpose.isNotBlank()) Text(item.purpose, style = MaterialTheme.typography.bodySmall, color = palette.inkFaint)
|
||||
if (item.reason.isNotBlank()) Text(item.reason, style = MaterialTheme.typography.bodySmall, color = palette.inkFaint)
|
||||
}
|
||||
// A corrected command goes with an allow, never with a refusal.
|
||||
val texts = edits.filter { (key, value) -> card.items.firstOrNull { it.key == key }?.title != value }
|
||||
// A corrected command goes with an allow, never with a refusal, and only when it was corrected.
|
||||
val texts = approvalTexts(card.items, edits)
|
||||
if (refusing) {
|
||||
OutlinedTextField(
|
||||
value = reason,
|
||||
@@ -109,6 +121,19 @@ private fun Approval(card: Card, onAnswer: (CardAnswer) -> Unit) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* What an approval's allow sends in `texts`: the box of each `editable` item whose text differs
|
||||
* from the item's `detail` (the command it was offered with). An untouched box sends nothing, so
|
||||
* the server runs what the model asked for; a cleared box is no correction either.
|
||||
*/
|
||||
fun approvalTexts(items: List<CardItem>, edits: Map<String, String>): Map<String, String> = items
|
||||
.filter { it.editable }
|
||||
.mapNotNull { item ->
|
||||
val edited = edits[item.key]?.trim() ?: return@mapNotNull null
|
||||
if (edited.isEmpty() || edited == item.detail.trim()) null else item.key to edited
|
||||
}
|
||||
.toMap()
|
||||
|
||||
@Composable
|
||||
private fun Questions(card: Card, onAnswer: (CardAnswer) -> Unit) {
|
||||
val palette = LocalPalette.current
|
||||
|
||||
Reference in new issue
Block a user