From 5e5e63353a175b8149da2f41cb10ec21dda25ed4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Bene=C5=A1?= Date: Tue, 24 Nov 2026 13:31:30 +0000 Subject: [PATCH] A file an agent shows is in the chat by its kind; an edit's diff is on its approval card A tool call's `media` with `shown` is drawn where generated media is: a picture with its name under it, audio and video with Play, a PDF with Open (its pages over the chat, by node id), and a 3D model, an archive, a text file, a binary and any kind the app does not know as a row with the name, the kind in words and the size. Every card keeps Open in Files, Download, Share and Open with. `audio` plays as `music` does. An approval item's `diffs` are worked out on the phone line by line (api/Diff.kt: shared head and tail, the longest shared run in between up to a bounded size, three lines of context) and drawn as one plain monospaced text per file in a sideways scroller of its own, folded past twelve lines and laid out to four hundred. The diff stands where the call's arguments did; Allow and Deny are unchanged. A picture in a chat now waits at the gate before it is fetched. Parsed and not drawn: a device's files, files_writable and files_that_run_code, and the editor's two models. Co-Authored-By: Claude Fable 5.2 --- CHANGELOG.md | 25 ++ .../main/java/eu/llembas/android/api/Diff.kt | 114 +++++++ .../main/java/eu/llembas/android/api/Media.kt | 27 +- .../java/eu/llembas/android/api/Models.kt | 38 +++ .../java/eu/llembas/android/ui/chat/Cards.kt | 4 +- .../eu/llembas/android/ui/chat/ChatScreen.kt | 8 + .../eu/llembas/android/ui/chat/DiffCard.kt | 144 +++++++++ .../android/ui/chat/GeneratedPicture.kt | 2 + .../eu/llembas/android/ui/chat/MediaCards.kt | 144 ++++++--- .../eu/llembas/android/ui/viewer/Media.kt | 58 +++- app/src/main/res/values-cs/strings.xml | 10 + app/src/main/res/values-de/strings.xml | 10 + app/src/main/res/values-es/strings.xml | 10 + app/src/main/res/values-fr/strings.xml | 10 + app/src/main/res/values-hu/strings.xml | 10 + app/src/main/res/values-it/strings.xml | 10 + app/src/main/res/values-pl/strings.xml | 10 + app/src/main/res/values-sk/strings.xml | 10 + app/src/main/res/values/strings.xml | 10 + .../java/eu/llembas/android/ShownMediaTest.kt | 293 ++++++++++++++++++ .../eu/llembas/android/shots/MediaShots.kt | 61 ++++ .../eu/llembas/android/shots/ScreenShots.kt | 39 +++ scripts/strings.py | 12 + scripts/strings_own.json | 80 ++++- 24 files changed, 1076 insertions(+), 63 deletions(-) create mode 100644 app/src/main/java/eu/llembas/android/api/Diff.kt create mode 100644 app/src/main/java/eu/llembas/android/ui/chat/DiffCard.kt create mode 100644 app/src/test/java/eu/llembas/android/ShownMediaTest.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index a1fa105..b86d2d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,33 @@ is in alpha and releases come off `main`. ## Unreleased +What is said here of shown files and of an edit's diff needs an instance newer than LLeMbas +2.0.0-beta.18. On an older one the app behaves as before. + +### Added + +- **A file an agent shows is in the chat, whatever it is.** When an agent puts a file in front + of you that is not text -- a screenshot it took, a recording, a report -- the reply holds it + where generated media is: a picture is drawn, with its name under it; sound and video have + Play and the app's own player; a PDF has Open, which lays its pages out over the chat. A 3D + model, an archive, a text file that came this way and any other file are a row with the + file's name, what it is in words and its size. A kind the app has not heard of is a "File", + never an empty place. Every one of them has Open in Files, Download, Share and Open with. + Whether a file is shown does not depend on what the model itself can read. +- **An edit's approval card shows what would change.** Where a linked computer asks before an + edit, the card lists each file with the lines that go and the lines that come, marked by a + sign and by colour, with a little unchanged text around them; a new file and a deleted one + say so. Long lines scroll sideways inside their own box; a long change is folded to its first + lines with "Show all". Both texts are drawn as plain text. Allow and Deny are as they were. + ### Changed +- **A picture in a chat is fetched only while the app is in front of an unlocked phone**, like + every other file of the account; one that comes into view behind the lock waits. +- Pinned to the server's `dev` at `809b87b`. A linked computer's files and the editor's two + models are read from the instance and not shown anywhere yet: this app has no browser for a + computer's files and no screen for the editor's settings. + - **The launcher icon is the app's own**: the LLeMbas leaf with a small phone beside it, so the app is told apart from the other LLeMbas products. The notification icon stays the leaf. diff --git a/app/src/main/java/eu/llembas/android/api/Diff.kt b/app/src/main/java/eu/llembas/android/api/Diff.kt new file mode 100644 index 0000000..3e48c41 --- /dev/null +++ b/app/src/main/java/eu/llembas/android/api/Diff.kt @@ -0,0 +1,114 @@ +package eu.llembas.android.api + +// An edit's diff on its approval card, worked out on the phone from the two texts the card +// carries (`contract/event_ask_edit.json`). Lines only: what is drawn is text with a sign, and +// every step is bounded, because both texts are a model's and a file's words of any size. + +/** What a line of a diff is: in both texts, only in the new one, only in the old one, or the mark of lines left out between two changes. */ +enum class DiffSign { Same, Added, Removed, Gap } + +data class DiffLine(val sign: DiffSign, val text: String) + +/** One file's change as the card draws it: the changed lines with a little around them, and how many were added and removed. */ +data class DiffView(val lines: List, val added: Int, val removed: Int) { + /** The lines drawn: the first [DIFF_FOLD] until the person opens it, and never more than [DIFF_MOST]. */ + fun shown(open: Boolean): List = lines.take(if (open) DIFF_MOST else DIFF_FOLD) + + /** Whether there is more than the folded card shows. */ + val folds: Boolean get() = lines.size > DIFF_FOLD + + /** The lines not drawn even when open. */ + val beyond: Int get() = (lines.size - DIFF_MOST).coerceAtLeast(0) +} + +/** How many lines of a file's diff the card shows before it is opened. */ +const val DIFF_FOLD = 12 + +/** The most lines of one file's diff the card lays out: a card is for deciding, not for reading a megabyte. */ +const val DIFF_MOST = 400 + +/** The lines kept around a change. */ +const val DIFF_CONTEXT = 3 + +/** Past this many pairs of lines the two middles are not compared: the old one is shown going and the new one coming. */ +private const val DIFF_CELLS = 1_000_000L + +/** A text's lines; the newline that ends the last one starts no empty line. */ +internal fun textLines(text: String): List { + if (text.isEmpty()) return emptyList() + val lines = text.split('\n') + return if (lines.last().isEmpty()) lines.dropLast(1) else lines +} + +/** + * [old] turned into [new], line by line: what both begin and end with is the same without being + * compared, and the middle is the longest run of lines the two share -- or, where the middles + * are too long to compare on a phone, the old middle removed and the new one added. + */ +fun diffLines(old: List, new: List): List { + var head = 0 + while (head < old.size && head < new.size && old[head] == new[head]) head++ + var tail = 0 + while (tail < old.size - head && tail < new.size - head && old[old.size - 1 - tail] == new[new.size - 1 - tail]) tail++ + val a = old.subList(head, old.size - tail) + val b = new.subList(head, new.size - tail) + val out = ArrayList(old.size + b.size) + for (i in 0 until head) out += DiffLine(DiffSign.Same, old[i]) + if (a.isEmpty() || b.isEmpty() || a.size.toLong() * b.size > DIFF_CELLS) { + a.forEach { out += DiffLine(DiffSign.Removed, it) } + b.forEach { out += DiffLine(DiffSign.Added, it) } + } else { + // shared[i][j]: how many lines the rest of a from i and the rest of b from j have in common, in order. + val shared = Array(a.size + 1) { IntArray(b.size + 1) } + for (i in a.size - 1 downTo 0) { + for (j in b.size - 1 downTo 0) { + shared[i][j] = if (a[i] == b[j]) shared[i + 1][j + 1] + 1 else maxOf(shared[i + 1][j], shared[i][j + 1]) + } + } + var i = 0 + var j = 0 + while (i < a.size && j < b.size) { + when { + a[i] == b[j] -> { + out += DiffLine(DiffSign.Same, a[i]) + i++ + j++ + } + + shared[i + 1][j] >= shared[i][j + 1] -> out += DiffLine(DiffSign.Removed, a[i++]) + + else -> out += DiffLine(DiffSign.Added, b[j++]) + } + } + while (i < a.size) out += DiffLine(DiffSign.Removed, a[i++]) + while (j < b.size) out += DiffLine(DiffSign.Added, b[j++]) + } + for (i in old.size - tail until old.size) out += DiffLine(DiffSign.Same, old[i]) + return out +} + +/** The changed lines of [lines] with [context] unchanged ones around each, and one [DiffSign.Gap] where lines between two changes are left out. */ +fun hunks(lines: List, context: Int = DIFF_CONTEXT): List { + val keep = BooleanArray(lines.size) + lines.forEachIndexed { at, line -> + if (line.sign != DiffSign.Same) for (k in maxOf(0, at - context)..minOf(lines.size - 1, at + context)) keep[k] = true + } + val out = ArrayList() + var left = false + lines.forEachIndexed { at, line -> + if (keep[at]) { + if (left && out.isNotEmpty()) out += DiffLine(DiffSign.Gap, "") + left = false + out += line + } else { + left = true + } + } + return out +} + +/** This file's change for the card: a file that is made is all added, one that goes is all removed. */ +fun FileDiff.view(): DiffView { + val all = diffLines(textLines(oldText.orEmpty()), textLines(if (deleted) "" else newText)) + return DiffView(hunks(all), added = all.count { it.sign == DiffSign.Added }, removed = all.count { it.sign == DiffSign.Removed }) +} diff --git a/app/src/main/java/eu/llembas/android/api/Media.kt b/app/src/main/java/eu/llembas/android/api/Media.kt index 22c9290..7063532 100644 --- a/app/src/main/java/eu/llembas/android/api/Media.kt +++ b/app/src/main/java/eu/llembas/android/api/Media.kt @@ -12,6 +12,11 @@ import kotlinx.serialization.Serializable * `model3d`), and the file is in the person's Files at [path] -- a moment's truth, since they may * move it; [nodeId] names it wherever it is. Its bytes are `GET /files/raw?node=`. [width], * [height] and [seconds] are 0 where the server did not know them. + * + * With [shown] it is a file an agent put in front of the person (`contract/tool_media_shown.json`) + * and [kind] is what the file is, read from its bytes: `image`, `audio`, `video`, `pdf`, + * `model3d`, `archive`, `binary`, `text`, or a word this app does not know yet. Whatever it is, + * its card names it and leads to the file; what the phone can draw is drawn as well. */ @Serializable data class GeneratedMedia( @@ -25,16 +30,22 @@ data class GeneratedMedia( val width: Int = 0, val height: Int = 0, val seconds: Double = 0.0, + /** An agent showed this file (the `show` tool on a file that is not text); it did not make it. */ + val shown: Boolean = false, ) { - /** How the card shows it, by what was asked for: an unknown kind is its details, never a player. */ + /** How the card shows it, by its kind: an unknown kind is its details, never a player. */ val view: MediaView get() = when (kind) { "image", "image_edit" -> MediaView.Picture "video" -> MediaView.Video - "music" -> MediaView.Sound + "music", "audio" -> MediaView.Sound + "pdf" -> MediaView.Document else -> MediaView.Details } + /** The kinds this app has a word for; anything else is said as "File" when shown, never as nothing. */ + val knownKind: Boolean get() = kind in KINDS + /** What to call it: its name, else the last name of its path. */ val title: String get() = name.ifBlank { FileKinds.name(path) } @@ -43,10 +54,18 @@ data class GeneratedMedia( /** The folder of the person's Files it was written to. */ val folder: String get() = FileKinds.parent(path) + + companion object { + val KINDS = setOf("image", "image_edit", "video", "music", "audio", "model3d", "pdf", "archive", "binary", "text") + } } -/** What a generated file's card is: a picture drawn, a player, or (a 3D model, anything unknown) the file's details. */ -enum class MediaView { Picture, Video, Sound, Details } +/** + * What a file's card is: a picture drawn, a player, a document with pages the phone can lay out + * (a PDF), or -- a 3D model, an archive, anything unknown -- the file's details. Every one of + * them names the file and has the ways to it. + */ +enum class MediaView { Picture, Video, Sound, Document, Details } /** The job a tool call started (`media_job`): [state] as it was when the call returned. */ @Serializable diff --git a/app/src/main/java/eu/llembas/android/api/Models.kt b/app/src/main/java/eu/llembas/android/api/Models.kt index 9733aa7..54fa672 100644 --- a/app/src/main/java/eu/llembas/android/api/Models.kt +++ b/app/src/main/java/eu/llembas/android/api/Models.kt @@ -385,6 +385,12 @@ data class LinkedDevice( @SerialName("max_mode") val maxMode: String = "", /** Whether the device remembers the model last used in a directory (spec 3.9.0). */ @SerialName("directory_model") val directoryModel: Boolean = false, + /** Whether the device hands its files over the link at all (spec 3.11.0, `fs`). Parsed; no screen reads it yet. */ + val files: Boolean = false, + /** False where its highest mode is plan: its files can be read and not changed. */ + @SerialName("files_writable") val filesWritable: Boolean = false, + /** Whether the device lets files that run code (git's own, an agent's configuration) be changed from here. */ + @SerialName("files_that_run_code") val filesThatRunCode: Boolean = false, ) { /** What to call it: its name, else its host. */ val label: String get() = name.ifBlank { host.ifBlank { id } } @@ -765,8 +771,40 @@ data class CardItem( * action's own fields, as the server checked them. Carried out by `actions/ActionRunner`. */ val phone: JsonObject? = null, + /** An edit's changes, one per file (`contract/event_ask_edit.json`); empty on a card without them. */ + val diffs: List = emptyList(), ) +/** + * What an edit would do to one file, on its approval card: [oldText] is null for a file that is + * made, [deleted] marks one that goes. Both texts are a model's and a file's words: drawn as + * text by the app's own diff view (`api/Diff.kt`), never rendered. + */ +@Serializable +data class FileDiff( + val path: String = "", + @SerialName("old_text") val oldText: String? = null, + @SerialName("new_text") val newText: String = "", + val deleted: Boolean = false, +) { + /** A file that does not exist yet. */ + val made: Boolean get() = oldText == null && !deleted +} + +/** + * A person's two models for an editor (`GET /editor`, `contract/editor.json`): parsed so the + * shape is pinned; this app has no screen for them. + */ +@Serializable +data class EditorModels(val autocomplete: Autocomplete = Autocomplete(), val main: Main = Main()) { + /** [source]: `person`, `instance` or null with no model. [allowed]: the refs an administrator allows, null for any. */ + @Serializable + data class Autocomplete(val model: String? = null, val source: String? = null, val allowed: List? = null) + + @Serializable + data class Main(val model: String? = null) +} + @Serializable data class CardSubagent(val id: String = "", val name: String = "", val position: String = "") diff --git a/app/src/main/java/eu/llembas/android/ui/chat/Cards.kt b/app/src/main/java/eu/llembas/android/ui/chat/Cards.kt index 6f017eb..556a79f 100644 --- a/app/src/main/java/eu/llembas/android/ui/chat/Cards.kt +++ b/app/src/main/java/eu/llembas/android/ui/chat/Cards.kt @@ -100,9 +100,11 @@ private fun Approval(card: Card, onAnswer: (CardAnswer) -> Unit) { 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()) { + } else if (item.detail.isNotBlank() && item.diffs.isEmpty()) { Text(item.detail, fontFamily = FontFamily.Monospace) } + // An edit says what it would change: the diff stands where the call's arguments would, as text. + if (item.diffs.isNotEmpty()) CardDiffs(item.diffs) 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, and only when it was corrected. diff --git a/app/src/main/java/eu/llembas/android/ui/chat/ChatScreen.kt b/app/src/main/java/eu/llembas/android/ui/chat/ChatScreen.kt index fee2d8b..023046e 100644 --- a/app/src/main/java/eu/llembas/android/ui/chat/ChatScreen.kt +++ b/app/src/main/java/eu/llembas/android/ui/chat/ChatScreen.kt @@ -111,9 +111,11 @@ import eu.llembas.android.ui.files.TransferHost import eu.llembas.android.ui.files.TransferViewModel import eu.llembas.android.ui.files.rememberSaver import eu.llembas.android.ui.theme.LocalPalette +import eu.llembas.android.ui.viewer.DocumentDialog import eu.llembas.android.ui.viewer.FileViewer import eu.llembas.android.ui.viewer.PlayerDialog import eu.llembas.android.ui.viewer.Playing +import eu.llembas.android.ui.viewer.Reading import kotlinx.coroutines.flow.drop import kotlinx.coroutines.launch @@ -175,6 +177,7 @@ fun ChatScreen( val transfers: TransferViewModel = viewModel(key = "chat-transfers") val saveTo = rememberSaver(transfers) var playing by remember { mutableStateOf(null) } + var reading by remember { mutableStateOf(null) } val media = remember(model, transfers) { object : MediaActions { override fun play(media: GeneratedMedia) { @@ -185,6 +188,10 @@ fun ChatScreen( playing = Playing(Raw.Attached(attachment.id), attachment.name, attachment.size, video = attachment.kind == "video") } + override fun view(media: GeneratedMedia) { + reading = Reading(media.raw, media.title, media.size) + } + // Where the file is now, by its id: it may have been renamed or moved since it was made. override fun openInFiles(media: GeneratedMedia) = model.whereIs(media, onFiles) @@ -238,6 +245,7 @@ fun ChatScreen( state.chat?.id?.let { id -> FileViewer(id, file, onClose = { showing = null }) } } playing?.let { PlayerDialog(it, onClose = { playing = null }, gone = stringResource(R.string.media_gone)) } + reading?.let { DocumentDialog(it, onClose = { reading = null }, gone = stringResource(R.string.media_gone)) } TransferHost(transfers) } diff --git a/app/src/main/java/eu/llembas/android/ui/chat/DiffCard.kt b/app/src/main/java/eu/llembas/android/ui/chat/DiffCard.kt new file mode 100644 index 0000000..1fd40bf --- /dev/null +++ b/app/src/main/java/eu/llembas/android/ui/chat/DiffCard.kt @@ -0,0 +1,144 @@ +package eu.llembas.android.ui.chat + +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.horizontalScroll +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.heightIn +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.material3.TextButton +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.key +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.semantics.clearAndSetSemantics +import androidx.compose.ui.semantics.contentDescription +import androidx.compose.ui.text.AnnotatedString +import androidx.compose.ui.text.SpanStyle +import androidx.compose.ui.text.buildAnnotatedString +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.withStyle +import androidx.compose.ui.unit.dp +import eu.llembas.android.R +import eu.llembas.android.api.DiffLine +import eu.llembas.android.api.DiffSign +import eu.llembas.android.api.FileDiff +import eu.llembas.android.api.view +import eu.llembas.android.ui.theme.LocalPalette +import eu.llembas.android.ui.theme.Palette + +// An edit's diff on its approval card: per file its path, how many lines come and go, and the +// changed lines as text -- a sign before each and the theme's colour behind it, in one width of +// letter. The lines scroll sideways in a box of their own, so the card never does. Both texts +// are a model's and a file's words: one plain Text draws them, and nothing in them is rendered. + +/** The most of one line that is drawn: a line of a megabyte is still one line of the card. */ +internal const val DIFF_LINE_MOST = 400 + +private val DiffShape = RoundedCornerShape(12.dp) + +/** A line as the card writes it: its sign, then its text with tabs as spaces and cut at [DIFF_LINE_MOST]. */ +internal fun diffRow(line: DiffLine): String { + val sign = when (line.sign) { + DiffSign.Added -> "+ " + DiffSign.Removed -> "- " + DiffSign.Same -> " " + DiffSign.Gap -> return "⋯" + } + val text = line.text.replace("\r", "").replace("\t", " ") + return sign + if (text.length > DIFF_LINE_MOST) text.take(DIFF_LINE_MOST) + "…" else text +} + +private fun diffText(lines: List, palette: Palette): AnnotatedString = buildAnnotatedString { + lines.forEachIndexed { at, line -> + val style = when (line.sign) { + DiffSign.Added -> SpanStyle(color = palette.success, background = palette.successSoft) + DiffSign.Removed -> SpanStyle(color = palette.danger, background = palette.dangerSoft) + DiffSign.Same -> SpanStyle(color = palette.ink) + DiffSign.Gap -> SpanStyle(color = palette.inkFaint) + } + withStyle(style) { append(diffRow(line)) } + if (at < lines.lastIndex) append('\n') + } +} + +/** The diffs of one item of an approval card, a block per file. */ +@Composable +fun CardDiffs(diffs: List, modifier: Modifier = Modifier) { + Column(modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(8.dp)) { + diffs.forEachIndexed { at, diff -> key(at, diff.path) { FileDiffBlock(diff) } } + } +} + +/** + * One file's change. The path gives (it wraps) and the two counts keep their width. The lines + * are folded to the first few; "Show all" opens them, up to what a card lays out. + */ +@Composable +private fun FileDiffBlock(diff: FileDiff) { + val palette = LocalPalette.current + val view = remember(diff) { diff.view() } + var open by rememberSaveable(diff.path) { mutableStateOf(false) } + Column(Modifier.fillMaxWidth().clip(DiffShape).background(palette.codeBg).border(1.dp, palette.codeBorder, DiffShape)) { + Row(Modifier.fillMaxWidth().padding(horizontal = 12.dp, vertical = 8.dp), verticalAlignment = Alignment.CenterVertically) { + Column(Modifier.weight(1f)) { + Text(diff.path, style = MaterialTheme.typography.bodySmall, fontFamily = FontFamily.Monospace, color = palette.ink) + val state = when { + diff.deleted -> stringResource(R.string.diff_deleted) + diff.made -> stringResource(R.string.files_new_file) + else -> null + } + if (state != null) Text(state, style = MaterialTheme.typography.labelSmall, color = palette.inkMuted) + } + Spacer(Modifier.width(12.dp)) + val counts = stringResource(R.string.diff_counts, view.added.toString(), view.removed.toString()) + Row(Modifier.clearAndSetSemantics { contentDescription = counts }, horizontalArrangement = Arrangement.spacedBy(8.dp)) { + Text("+${view.added}", style = MaterialTheme.typography.labelMedium, fontFamily = FontFamily.Monospace, color = palette.success) + Text("−${view.removed}", style = MaterialTheme.typography.labelMedium, fontFamily = FontFamily.Monospace, color = palette.danger) + } + } + val lines = view.shown(open) + if (lines.isNotEmpty()) { + val text = remember(lines, palette) { diffText(lines, palette) } + Box(Modifier.fillMaxWidth().horizontalScroll(rememberScrollState())) { + Text( + text, + style = MaterialTheme.typography.bodySmall, + fontFamily = FontFamily.Monospace, + softWrap = false, + modifier = Modifier.padding(start = 12.dp, end = 12.dp, bottom = 8.dp), + ) + } + } + if (open && view.beyond > 0) { + Text( + stringResource(R.string.diff_more, view.beyond.toString()), + style = MaterialTheme.typography.bodySmall, + color = palette.inkMuted, + modifier = Modifier.padding(horizontal = 12.dp), + ) + } + if (view.folds) { + TextButton(onClick = { open = !open }, modifier = Modifier.heightIn(min = 48.dp).padding(horizontal = 4.dp)) { + Text(if (open) stringResource(R.string.diff_show_less) else stringResource(R.string.diff_show_all, view.lines.size.toString())) + } + } + } +} diff --git a/app/src/main/java/eu/llembas/android/ui/chat/GeneratedPicture.kt b/app/src/main/java/eu/llembas/android/ui/chat/GeneratedPicture.kt index 7eb492f..b6aacab 100644 --- a/app/src/main/java/eu/llembas/android/ui/chat/GeneratedPicture.kt +++ b/app/src/main/java/eu/llembas/android/ui/chat/GeneratedPicture.kt @@ -75,6 +75,8 @@ private object Pictures { cache.get(key)?.let { return it } if (key in failed) return null val api = context.lembas.instances.client() ?: return null + // A picture that comes into view behind the lock, or with the app not in front, waits there. + context.lembas.gate.passLater() val bytes = try { fetch(api).takeIf { it.size <= MAX_BYTES } } catch (e: CancellationException) { diff --git a/app/src/main/java/eu/llembas/android/ui/chat/MediaCards.kt b/app/src/main/java/eu/llembas/android/ui/chat/MediaCards.kt index 9cafe03..947abcb 100644 --- a/app/src/main/java/eu/llembas/android/ui/chat/MediaCards.kt +++ b/app/src/main/java/eu/llembas/android/ui/chat/MediaCards.kt @@ -15,14 +15,18 @@ import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.widthIn import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.filled.InsertDriveFile import androidx.compose.material.icons.automirrored.filled.OpenInNew +import androidx.compose.material.icons.filled.Description import androidx.compose.material.icons.filled.Download import androidx.compose.material.icons.filled.ErrorOutline import androidx.compose.material.icons.filled.FolderOpen +import androidx.compose.material.icons.filled.FolderZip import androidx.compose.material.icons.filled.HourglassEmpty import androidx.compose.material.icons.filled.Image import androidx.compose.material.icons.filled.Movie import androidx.compose.material.icons.filled.MusicNote +import androidx.compose.material.icons.filled.PictureAsPdf import androidx.compose.material.icons.filled.PlayArrow import androidx.compose.material.icons.filled.Share import androidx.compose.material.icons.filled.ViewInAr @@ -59,8 +63,9 @@ import eu.llembas.android.ui.theme.LocalPalette import eu.llembas.android.ui.viewer.playTime import kotlinx.coroutines.delay -// What a model made, in the reply: a card for a file (a picture drawn, a video or a track with -// Play, a 3D model or anything else as what it is) and a card for a generation still under way. +// What a model made or an agent showed, in the reply: a card for a file (a picture drawn, a video +// or a track with Play, a PDF with Open, a 3D model or anything else as what it is) and a card for +// a generation still under way. // The file is one of the person's Files, so each card leads there, and out of the app the ways // a file leaves it: saved where the person chooses, shared, or opened with another app. The // cards are drawn only where a chat provides [LocalChatMedia] -- the chat's own screen, which @@ -74,6 +79,9 @@ interface MediaActions { /** Play sound or video the person attached. */ fun play(attachment: Attachment) {} + /** Lay a document's pages out over the chat (a PDF). */ + fun view(media: GeneratedMedia) {} + /** The folder of the person's Files the file is in. */ fun openInFiles(media: GeneratedMedia) {} @@ -96,21 +104,39 @@ val LocalChatMedia = compositionLocalOf { null } private val CardShape = RoundedCornerShape(16.dp) -/** The word for what was asked for: a picture, a video, music, a 3D model; the server's own word for anything else. */ -@Composable -internal fun mediaKind(kind: String): String = when (kind) { - "image", "image_edit" -> stringResource(R.string.media_image) - "video" -> stringResource(R.string.media_video) - "music" -> stringResource(R.string.media_music) - "model3d" -> stringResource(R.string.media_model) - else -> kind +/** The string for a kind this app has a word for; null for any other. */ +internal fun mediaKindWord(kind: String): Int? = when (kind) { + "image", "image_edit" -> R.string.media_image + "video" -> R.string.media_video + "music" -> R.string.media_music + "audio" -> R.string.media_audio + "model3d" -> R.string.media_model + "pdf" -> R.string.media_pdf + "archive" -> R.string.media_archive + "text" -> R.string.media_text + "binary" -> R.string.media_binary + else -> null } -private fun mediaIcon(kind: String): ImageVector = when (kind) { +/** + * The word for what a file is: a picture, a video, music, audio, a 3D model, a PDF, an archive, + * a text file, a file. A kind this app does not know is the server's own word for a generated + * file and "File" for one an agent showed ([shown]): a shown file always says what it is. + */ +@Composable +internal fun mediaKind(kind: String, shown: Boolean = false): String = + mediaKindWord(kind)?.let { stringResource(it) } ?: if (shown) stringResource(R.string.media_binary) else kind + +/** The mark of a kind; `binary` and a kind this app does not know are a file. */ +internal fun mediaIcon(kind: String): ImageVector = when (kind) { "image", "image_edit" -> Icons.Filled.Image "video" -> Icons.Filled.Movie - "music" -> Icons.Filled.MusicNote - else -> Icons.Filled.ViewInAr + "music", "audio" -> Icons.Filled.MusicNote + "model3d" -> Icons.Filled.ViewInAr + "pdf" -> Icons.Filled.PictureAsPdf + "archive" -> Icons.Filled.FolderZip + "text" -> Icons.Filled.Description + else -> Icons.AutoMirrored.Filled.InsertDriveFile } /** What is known of a file, in one line: what it is, how long, how large, its size in pixels. */ @@ -118,7 +144,7 @@ private fun mediaIcon(kind: String): ImageVector = when (kind) { internal fun mediaFacts(media: GeneratedMedia): String { val context = LocalContext.current return listOfNotNull( - mediaKind(media.kind).ifBlank { null }, + mediaKind(media.kind, media.shown).ifBlank { null }, media.seconds.takeIf { it > 0 }?.let { playTime((it * 1000).toInt()) }, media.size.takeIf { it > 0 }?.let { Formatter.formatShortFileSize(context, it) }, if (media.width > 0 && media.height > 0) "${media.width} × ${media.height}" else null, @@ -126,45 +152,33 @@ internal fun mediaFacts(media: GeneratedMedia): String { } /** - * A file a tool call made. A picture is drawn -- from its attachment where the call has one - * ([image]), else from the file itself; a video or a track is its name with Play (48 dp), which - * opens the player over the chat; a 3D model and anything this app does not know is what it is. - * Under each, four buttons of one size: Open in Files, Download, Share, Open with. + * A file a tool call made, or one an agent showed. A picture is drawn -- from its attachment + * where the call has one ([image]), else from the file itself; a video or a track is its name + * with Play (48 dp), which opens the player over the chat; a PDF is its name with Open, which + * lays its pages out over the chat; a 3D model, an archive and anything this app does not know + * is its name and what it is. Under each, four buttons of one size: Open in Files, Download, + * Share, Open with. + * + * A file that was shown is always named: its picture has its name and facts under it, so one + * that cannot be drawn on this phone (too large, a format the phone does not read) is still a + * name, a kind in words and the ways to the file. */ @Composable fun MediaCard(media: GeneratedMedia, image: GeneratedImage?, actions: MediaActions, modifier: Modifier = Modifier) { - val palette = LocalPalette.current Column(modifier.widthIn(max = 480.dp).fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(4.dp)) { when (media.view) { - MediaView.Picture -> if (image != null && image.id.isNotBlank()) GeneratedPicture(image) else GeneratedPicture(media) - - MediaView.Video, MediaView.Sound, MediaView.Details -> Row( - Modifier.fillMaxWidth().border(1.dp, palette.border, CardShape).padding(horizontal = 12.dp, vertical = 10.dp), - verticalAlignment = Alignment.CenterVertically, - ) { - if (media.view == MediaView.Details) { - Box(Modifier.size(48.dp), contentAlignment = Alignment.Center) { - Icon(mediaIcon(media.kind), contentDescription = null, tint = palette.inkMuted) - } - } else { - FilledIconButton( - onClick = { actions.play(media) }, - colors = IconButtonDefaults.filledIconButtonColors(containerColor = palette.accent, contentColor = palette.accentInk), - modifier = Modifier.size(48.dp), - ) { Icon(Icons.Filled.PlayArrow, contentDescription = stringResource(R.string.play)) } - } - Spacer(Modifier.width(12.dp)) - Column(Modifier.weight(1f)) { - Text(media.title, style = MaterialTheme.typography.bodyLarge, color = palette.ink, maxLines = 1, overflow = TextOverflow.MiddleEllipsis) - Text( - mediaFacts(media), - style = MaterialTheme.typography.bodySmall, - color = palette.inkMuted, - maxLines = 1, - overflow = TextOverflow.Ellipsis, - ) + MediaView.Picture -> { + // A result that names no node has no picture to ask for: its row stands in, so the card is never empty. + val drawable = (image != null && image.id.isNotBlank()) || media.nodeId.isNotBlank() + if (image != null && image.id.isNotBlank()) GeneratedPicture(image) else GeneratedPicture(media) + if (media.shown && drawable) { + Column(Modifier.fillMaxWidth().padding(horizontal = 4.dp)) { MediaWords(media) } + } else if (!drawable) { + MediaRow(media, actions) } } + + MediaView.Video, MediaView.Sound, MediaView.Document, MediaView.Details -> MediaRow(media, actions) } // Four buttons of 48 dp: nothing here depends on how long a word is in any language. Row { @@ -176,6 +190,44 @@ fun MediaCard(media: GeneratedMedia, image: GeneratedImage?, actions: MediaActio } } +/** The file's name on one line (its middle gives) and what is known of it on the next. */ +@Composable +private fun MediaWords(media: GeneratedMedia) { + val palette = LocalPalette.current + Text(media.title, style = MaterialTheme.typography.bodyLarge, color = palette.ink, maxLines = 1, overflow = TextOverflow.MiddleEllipsis) + Text(mediaFacts(media), style = MaterialTheme.typography.bodySmall, color = palette.inkMuted, maxLines = 1, overflow = TextOverflow.Ellipsis) +} + +/** + * A file as a row: a mark of 48 dp -- Play for sound and video, Open for a PDF, else the kind's + * icon -- and the file's words, which give. + */ +@Composable +private fun MediaRow(media: GeneratedMedia, actions: MediaActions) { + val palette = LocalPalette.current + Row( + Modifier.fillMaxWidth().border(1.dp, palette.border, CardShape).padding(horizontal = 12.dp, vertical = 10.dp), + verticalAlignment = Alignment.CenterVertically, + ) { + val filled = IconButtonDefaults.filledIconButtonColors(containerColor = palette.accent, contentColor = palette.accentInk) + when (media.view) { + MediaView.Video, MediaView.Sound -> FilledIconButton(onClick = { actions.play(media) }, colors = filled, modifier = Modifier.size(48.dp)) { + Icon(Icons.Filled.PlayArrow, contentDescription = stringResource(R.string.play)) + } + + MediaView.Document -> FilledIconButton(onClick = { actions.view(media) }, colors = filled, modifier = Modifier.size(48.dp)) { + Icon(mediaIcon(media.kind), contentDescription = stringResource(R.string.viewer_open)) + } + + MediaView.Picture, MediaView.Details -> Box(Modifier.size(48.dp), contentAlignment = Alignment.Center) { + Icon(mediaIcon(media.kind), contentDescription = null, tint = palette.inkMuted) + } + } + Spacer(Modifier.width(12.dp)) + Column(Modifier.weight(1f)) { MediaWords(media) } + } +} + @Composable private fun CardButton(icon: ImageVector, label: Int, onClick: () -> Unit) { IconButton(onClick = onClick) { Icon(icon, contentDescription = stringResource(label), tint = LocalPalette.current.inkMuted) } diff --git a/app/src/main/java/eu/llembas/android/ui/viewer/Media.kt b/app/src/main/java/eu/llembas/android/ui/viewer/Media.kt index 7bd0ca5..6e0d385 100644 --- a/app/src/main/java/eu/llembas/android/ui/viewer/Media.kt +++ b/app/src/main/java/eu/llembas/android/ui/viewer/Media.kt @@ -228,9 +228,19 @@ class PdfPages(private val copy: File) { } } -/** A PDF, page by page, as wide as the screen. */ +/** A PDF of the tree, page by page, as wide as the screen. */ @Composable -fun PdfBody(path: String, name: String, size: Long, fallback: @Composable (String?) -> Unit) { +fun PdfBody(path: String, name: String, size: Long, fallback: @Composable (String?) -> Unit) = + PdfBody(Raw.Path(path), name, size, gone = null, fallback = fallback) + +/** + * The same for any [Raw]: a file a chat names by its node id is copied and laid out as one of + * the tree is. [gone] is what to say of a file that is no longer there, where the instance's own + * refusal would name an id. + */ +@Composable +fun PdfBody(what: Raw, name: String, size: Long, gone: String? = null, fallback: @Composable (String?) -> Unit) { + val path = what val context = LocalContext.current var pages by remember(path) { mutableStateOf>(Fetched.Loading()) } DisposableEffect(path) { @@ -248,7 +258,7 @@ fun PdfBody(path: String, name: String, size: Long, fallback: @Composable (Strin pages = try { val api = context.lembas.instances.client() ?: throw ApiException(401, context.getString(R.string.assist_signed_out)) context.lembas.gate.pass() - api.copyInto(api.rawFile(path), copy, PDF_MAX_BYTES, stepped { done, total -> pages = Fetched.Loading(done, total) }) + api.copyInto(api.raw(what), copy, PDF_MAX_BYTES, stepped { done, total -> pages = Fetched.Loading(done, total) }) withContext(Dispatchers.IO) { made = PdfPages(copy) } Fetched.Ready(checkNotNull(made)) } catch (e: CancellationException) { @@ -259,7 +269,13 @@ fun PdfBody(path: String, name: String, size: Long, fallback: @Composable (Strin made?.closeLater() copy.delete() // A password, or not a PDF after all: the renderer's own words are for a developer. - Fetched.Failed(if (e is ApiException || unreachable(e)) viewerSays(context, e) else null) + Fetched.Failed( + when { + gone != null && e is ApiException && e.status == 404 -> gone + e is ApiException || unreachable(e) -> viewerSays(context, e) + else -> null + }, + ) } } when (val now = pages) { @@ -469,6 +485,40 @@ fun MediaBody(what: Raw, size: Long, video: Boolean, fallback: @Composable (Stri /** What a player opened over a chat plays: which bytes, what it is called, how large, and whether there is a picture. */ data class Playing(val what: Raw, val title: String, val size: Long, val video: Boolean) +/** A document a chat names, to be laid out over it: a PDF an agent showed. */ +data class Reading(val what: Raw, val title: String, val size: Long) + +/** + * A PDF over the whole screen, for a file a chat names by its node id: its pages as the tree's + * viewer lays them out, from a copy in the private cache. One that is no longer there says so + * ([gone]); one this phone cannot lay out says that it can still be downloaded. Back or the cross + * closes it. + */ +@OptIn(androidx.compose.material3.ExperimentalMaterial3Api::class) +@Composable +fun DocumentDialog(reading: Reading, onClose: () -> Unit, gone: String) { + val palette = LocalPalette.current + val unreadable: @Composable (String?) -> Unit = { note -> + Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { + Text(note ?: stringResource(R.string.files_not_shown), color = palette.inkMuted, modifier = Modifier.padding(32.dp)) + } + } + Dialog(onDismissRequest = onClose, properties = DialogProperties(usePlatformDefaultWidth = false, dismissOnClickOutside = false)) { + Scaffold( + topBar = { + TopAppBar( + navigationIcon = { IconButton(onClick = onClose) { Icon(Icons.Filled.Close, contentDescription = stringResource(R.string.close)) } }, + title = { Text(reading.title, maxLines = 1, overflow = TextOverflow.Ellipsis) }, + ) + }, + ) { padding -> + Box(Modifier.padding(padding).fillMaxSize()) { + PdfBody(reading.what, reading.title, reading.size, gone = gone, fallback = unreadable) + } + } + } +} + /** How a player's file was found before it was handed to the player. */ private sealed interface Probed { data object Asking : Probed diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 7ca4e47..d9e3100 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -415,6 +415,16 @@ Video Hudba 3D model + Zvuk + PDF + Archiv + Textový soubor + Soubor + Smazáno + Přidané řádky: %1$s, odebrané: %2$s + Zobrazit všechny řádky (%1$s) + Zobrazit méně + Další řádky, které se zde nezobrazují: %1$s. Tento soubor už neexistuje. Ve frontě Běží diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index a5c55e6..eb2cae6 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -415,6 +415,16 @@ Video Musik 3D-Modell + Audio + PDF + Archiv + Textdatei + Datei + Gelöscht + Zeilen hinzugefügt: %1$s, entfernt: %2$s + Alle %1$s Zeilen anzeigen + Weniger anzeigen + %1$s weitere Zeilen werden hier nicht angezeigt. Diese Datei gibt es nicht mehr. In der Warteschlange Läuft diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 8d648ac..b876ae0 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -415,6 +415,16 @@ Vídeo Música Modelo 3D + Audio + PDF + Archivo comprimido + Archivo de texto + Archivo + Eliminado + Líneas añadidas: %1$s, eliminadas: %2$s + Mostrar las %1$s líneas + Mostrar menos + Aquí no se muestran %1$s líneas más. Ese archivo ya no existe. En cola En ejecución diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 37487c0..5cec0c9 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -415,6 +415,16 @@ Vidéo Musique Modèle 3D + Audio + PDF + Archive + Fichier texte + Fichier + Supprimé + Lignes ajoutées : %1$s, supprimées : %2$s + Afficher les %1$s lignes + Afficher moins + %1$s lignes de plus ne sont pas affichées ici. Ce fichier n\'existe plus. En file d’attente En cours diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index 0f60d7d..6cf1d95 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -415,6 +415,16 @@ Videó Zene 3D-modell + Hang + PDF + Archívum + Szövegfájl + Fájl + Törölve + Hozzáadott sorok: %1$s, eltávolított: %2$s + Mind a(z) %1$s sor megjelenítése + Kevesebb megjelenítése + További %1$s sor itt nem látható. Ez a fájl már nem létezik. Sorban áll Fut diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 4c81d08..d8a394e 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -415,6 +415,16 @@ Video Musica Modello 3D + Audio + PDF + Archivio + File di testo + File + Eliminato + Righe aggiunte: %1$s, rimosse: %2$s + Mostra tutte le %1$s righe + Mostra meno + Altre %1$s righe non sono mostrate qui. Questo file non esiste più. In coda In esecuzione diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 8f0d154..af25f78 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -415,6 +415,16 @@ Wideo Muzyka Model 3D + Dźwięk + PDF + Archiwum + Plik tekstowy + Plik + Usunięto + Dodane wiersze: %1$s, usunięte: %2$s + Pokaż wszystkie wiersze (%1$s) + Pokaż mniej + Dalsze wiersze, których tu nie pokazano: %1$s. Ten plik już nie istnieje. W kolejce Działa diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml index 439733f..1091b8b 100644 --- a/app/src/main/res/values-sk/strings.xml +++ b/app/src/main/res/values-sk/strings.xml @@ -415,6 +415,16 @@ Video Hudba 3D model + Zvuk + PDF + Archív + Textový súbor + Súbor + Zmazané + Pridané riadky: %1$s, odobraté: %2$s + Zobraziť všetky riadky (%1$s) + Zobraziť menej + Ďalšie riadky, ktoré sa tu nezobrazujú: %1$s. Tento súbor už neexistuje. Vo fronte Beží diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 01610fc..7776803 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -417,6 +417,16 @@ Video Music 3D model + Audio + PDF + Archive + Text file + File + Deleted + Lines added: %1$s, removed: %2$s + Show all %1$s lines + Show less + %1$s more lines are not shown here. That file no longer exists. Queued Running diff --git a/app/src/test/java/eu/llembas/android/ShownMediaTest.kt b/app/src/test/java/eu/llembas/android/ShownMediaTest.kt new file mode 100644 index 0000000..9f5d4b7 --- /dev/null +++ b/app/src/test/java/eu/llembas/android/ShownMediaTest.kt @@ -0,0 +1,293 @@ +package eu.llembas.android + +import eu.llembas.android.api.AskFrame +import eu.llembas.android.api.DIFF_FOLD +import eu.llembas.android.api.DIFF_MOST +import eu.llembas.android.api.DeviceList +import eu.llembas.android.api.DiffLine +import eu.llembas.android.api.DiffSign +import eu.llembas.android.api.EditorModels +import eu.llembas.android.api.FileDiff +import eu.llembas.android.api.GeneratedMedia +import eu.llembas.android.api.LembasJson +import eu.llembas.android.api.MediaView +import eu.llembas.android.api.Raw +import eu.llembas.android.api.ToolCall +import eu.llembas.android.api.diffLines +import eu.llembas.android.api.hunks +import eu.llembas.android.api.view +import eu.llembas.android.ui.chat.DIFF_LINE_MOST +import eu.llembas.android.ui.chat.approvalTexts +import eu.llembas.android.ui.chat.diffRow +import eu.llembas.android.ui.chat.mediaKindWord +import eu.llembas.android.ui.chat.offersAlways +import kotlinx.serialization.builtins.ListSerializer +import kotlinx.serialization.json.jsonObject +import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse +import org.junit.Assert.assertNotNull +import org.junit.Assert.assertNull +import org.junit.Assert.assertTrue +import org.junit.Test + +/** + * What the pin after the editor round brought: a file an agent showed in the chat, an edit's + * diff on its approval card, and the shapes that are parsed and not drawn yet (a linked + * computer's files, an editor's two models). + */ +class ShownMediaTest { + private fun contract(name: String): String = requireNotNull(javaClass.classLoader!!.getResource("$name.json")) { + "contract/$name.json is missing" + }.readText() + + private fun shown(): List { + val calls = LembasJson.parseToJsonElement(contract("tool_media_shown")).jsonObject.getValue("calls") + return LembasJson.decodeFromJsonElement(ListSerializer(ToolCall.serializer()), calls) + } + + private fun media(kind: String, shown: Boolean = true) = GeneratedMedia(kind = kind, nodeId = "node1", name = "thing", shown = shown) + + // --- A file an agent showed --------------------------------------------------------------------- + + @Test + fun aShownFileIsTheCallsMediaAndNeverAnAttachment() { + val (picture, pdf, archive) = shown() + listOf(picture, pdf, archive).forEach { call -> + assertEquals("show", call.name) + assertTrue(call.media!!.shown) + // No `show` card and no attachment: the card is drawn from `media` alone. + assertNull(call.show) + assertNull(call.image) + assertNull(call.mediaJob) + } + val image = picture.media!! + assertEquals("image", image.kind) + assertEquals(MediaView.Picture, image.view) + assertEquals("chart.png", image.title) + assertEquals(1280, image.width) + assertEquals(720, image.height) + // Its bytes are asked for by its id, wherever the file is now. + assertEquals(Raw.Node("node8"), image.raw) + assertEquals("/home/frodo/oven", image.folder) + + assertEquals(MediaView.Document, pdf.media!!.view) + assertEquals("report-20260102-030405.pdf", pdf.media!!.title) + assertEquals(90_000L, pdf.media!!.size) + assertEquals("/home/frodo/Generated", pdf.media!!.folder) + + assertEquals(MediaView.Details, archive.media!!.view) + assertEquals(Raw.Node("node10"), archive.media!!.raw) + } + + @Test + fun aGeneratedFileIsNotAShownOne() { + val calls = LembasJson.parseToJsonElement(contract("tool_media")).jsonObject.getValue("calls") + val made = LembasJson.decodeFromJsonElement(ListSerializer(ToolCall.serializer()), calls).mapNotNull { it.media } + assertTrue(made.isNotEmpty()) + assertTrue(made.none { it.shown }) + } + + @Test + fun everyKindHasACardAndAudioPlaysAsMusicDoes() { + assertEquals(MediaView.Picture, media("image").view) + assertEquals(MediaView.Sound, media("audio").view) + assertEquals(media("music").view, media("audio").view) + assertEquals(MediaView.Video, media("video").view) + assertEquals(MediaView.Document, media("pdf").view) + // What the phone has no viewer for in a chat is its details: a name, a kind, the ways to the file. + listOf("model3d", "archive", "binary", "text", "hologram", "").forEach { assertEquals(it, MediaView.Details, media(it).view) } + } + + @Test + fun everyKindTheServerNamesHasAWordAndAnUnknownOneIsStillAFile() { + listOf("image", "audio", "video", "pdf", "model3d", "archive", "binary", "text").forEach { kind -> + assertNotNull(kind, mediaKindWord(kind)) + assertTrue(kind, media(kind).knownKind) + } + assertEquals(R.string.media_audio, mediaKindWord("audio")) + assertEquals(R.string.media_pdf, mediaKindWord("pdf")) + assertEquals(R.string.media_archive, mediaKindWord("archive")) + // No word of its own: the card says "File" for a shown one (`mediaKind`), never nothing. + assertNull(mediaKindWord("hologram")) + assertFalse(media("hologram").knownKind) + } + + @Test + fun aShownFileWithoutANameIsCalledByItsPath() { + val nameless = GeneratedMedia(kind = "binary", path = "/home/frodo/Generated/dump-20260102.bin", shown = true) + assertEquals("dump-20260102.bin", nameless.title) + // Without an id it is asked for by its path. + assertEquals(Raw.Path("/home/frodo/Generated/dump-20260102.bin"), nameless.raw) + } + + // --- An edit's diff on its card ----------------------------------------------------------------- + + private fun edit() = contractCard().items.single() + + private fun contractCard() = LembasJson.decodeFromString(AskFrame.serializer(), contract("event_ask_edit")).cards.single() + + @Test + fun anEditsCardCarriesADiffPerFile() { + val card = contractCard() + assertEquals("approval", card.kind) + val (changed, made, gone) = edit().diffs + assertEquals("src/oven.py", changed.path) + assertFalse(changed.made) + assertFalse(changed.deleted) + assertEquals("src/timer.py", made.path) + assertNull(made.oldText) + assertTrue(made.made) + assertEquals("src/old.py", gone.path) + assertTrue(gone.deleted) + assertFalse(gone.made) + // Allow and Deny are the card's usual ones: nothing of the diff goes back with the answer. + assertTrue(offersAlways(card)) + assertTrue(approvalTexts(card.items, emptyMap()).isEmpty()) + } + + @Test + fun aCardWithoutADiffHasNone() { + val cards = LembasJson.decodeFromString(AskFrame.serializer(), contract("event_ask")).cards + assertTrue(cards.flatMap { it.items }.all { it.diffs.isEmpty() }) + } + + @Test + fun aChangedFileShowsWhatGoesAndWhatComes() { + val view = edit().diffs[0].view() + assertEquals(2, view.added) + assertEquals(1, view.removed) + assertEquals( + listOf( + DiffLine(DiffSign.Same, "def bake(loaf):"), + DiffLine(DiffSign.Removed, " return loaf.heat(220)"), + DiffLine(DiffSign.Added, " # "), + DiffLine(DiffSign.Added, " return loaf.heat(240)"), + ), + view.lines, + ) + // A model's words stay words: the line is written as it is, with its sign before it. + assertEquals("+ # ", diffRow(view.lines[2])) + assertEquals("- return loaf.heat(220)", diffRow(view.lines[1])) + assertEquals(" def bake(loaf):", diffRow(view.lines[0])) + } + + @Test + fun aNewFileIsAllAddedAndADeletedOneAllRemoved() { + val (_, made, gone) = edit().diffs + assertEquals(listOf(DiffLine(DiffSign.Added, "MINUTES = 40")), made.view().lines) + assertEquals(1 to 0, made.view().let { it.added to it.removed }) + assertEquals(listOf(DiffLine(DiffSign.Removed, "x = 1")), gone.view().lines) + assertEquals(0 to 1, gone.view().let { it.added to it.removed }) + // A deleted file's new text is not read, whatever it says. + assertEquals(gone.view(), gone.copy(newText = "ignored\n").view()) + } + + @Test + fun aChangeKeepsALittleAroundItAndLeavesTheRestOut() { + val old = (1..40).map { "line $it" } + val new = old.toMutableList().also { + it[9] = "line ten" + it[29] = "line thirty" + } + val all = diffLines(old, new) + assertEquals(42, all.size) + val cut = hunks(all) + // Three lines before and after each change, and one mark for the lines between them. + assertEquals(1, cut.count { it.sign == DiffSign.Gap }) + assertEquals("line 7", cut.first().text) + assertEquals("line 33", cut.last().text) + assertEquals(listOf("line 10", "line 30"), cut.filter { it.sign == DiffSign.Removed }.map { it.text }) + assertEquals(listOf("line ten", "line thirty"), cut.filter { it.sign == DiffSign.Added }.map { it.text }) + assertEquals(17, cut.size) + assertEquals("⋯", diffRow(cut.first { it.sign == DiffSign.Gap })) + } + + @Test + fun linesThatMovedAreComparedAsTheLongestSharedRun() { + val lines = diffLines(listOf("a", "b", "c", "d"), listOf("a", "c", "d", "b")) + assertEquals( + listOf( + DiffLine(DiffSign.Same, "a"), + DiffLine(DiffSign.Removed, "b"), + DiffLine(DiffSign.Same, "c"), + DiffLine(DiffSign.Same, "d"), + DiffLine(DiffSign.Added, "b"), + ), + lines, + ) + // The same text is no change, and so no line on the card. + assertTrue(FileDiff(path = "same.txt", oldText = "a\nb\n", newText = "a\nb\n").view().lines.isEmpty()) + // An empty file that is made adds nothing; one without a last newline keeps its last line. + assertTrue(FileDiff(path = "empty", oldText = null, newText = "").view().lines.isEmpty()) + assertEquals(listOf("a", "b"), FileDiff(path = "p", oldText = null, newText = "a\nb").view().lines.map { it.text }) + } + + @Test + fun aLongDiffIsFoldedAndAHugeOneIsBounded() { + val long = FileDiff(path = "long.txt", oldText = null, newText = (1..1000).joinToString("\n") { "row $it" }) + val view = long.view() + assertEquals(1000, view.added) + assertTrue(view.folds) + assertEquals(DIFF_FOLD, view.shown(open = false).size) + assertEquals(DIFF_MOST, view.shown(open = true).size) + assertEquals(1000 - DIFF_MOST, view.beyond) + + val short = edit().diffs[0].view() + assertFalse(short.folds) + assertEquals(short.lines, short.shown(open = false)) + assertEquals(0, short.beyond) + + // Two texts too long to compare line against line are not compared: the old goes, the new comes. + val a = (1..1500).map { "old $it" } + val b = (1..1500).map { "new $it" } + val both = diffLines(a, b) + assertEquals(3000, both.size) + assertEquals(1500, both.count { it.sign == DiffSign.Removed }) + assertTrue(both.take(1500).all { it.sign == DiffSign.Removed }) + + // One line of any length is one bounded line of the card; a tab is spaces. + val row = diffRow(DiffLine(DiffSign.Added, "x".repeat(5000))) + assertEquals(2 + DIFF_LINE_MOST + 1, row.length) + assertEquals(" a", diffRow(DiffLine(DiffSign.Same, "\ta\r"))) + } + + // --- Parsed, and not drawn yet ------------------------------------------------------------------ + + @Test + fun aDeviceSaysWhetherItHandsItsFilesOver() { + val (workstation, laptop) = LembasJson.decodeFromString(DeviceList.serializer(), contract("devices")).devices + assertTrue(workstation.files) + assertTrue(workstation.filesWritable) + assertFalse(workstation.filesThatRunCode) + assertFalse(laptop.files) + assertFalse(laptop.filesWritable) + // An instance from before the files says nothing, and that is "no". + assertFalse(LembasJson.decodeFromString(DeviceList.serializer(), """{"devices":[{"id":"t1"}]}""").devices.single().files) + } + + @Test + fun anEditorsTwoModelsAreReadSetAndUnset() { + val set = LembasJson.decodeFromString(EditorModels.serializer(), contract("editor")) + assertEquals("local/qwen", set.autocomplete.model) + assertEquals("person", set.autocomplete.source) + assertEquals(listOf("local/qwen", "local/vision-small"), set.autocomplete.allowed) + assertEquals("local/gpt-oss", set.main.model) + + val unset = LembasJson.decodeFromString(EditorModels.serializer(), contract("editor_unset")) + assertNull(unset.autocomplete.model) + assertNull(unset.autocomplete.source) + assertNull(unset.autocomplete.allowed) + assertNull(unset.main.model) + } + + @Test + fun theShapesNothingUsesYetAreRead() { + // A linked computer's files and a message's editor context: no screen and no model of + // them here yet, and the app's reader takes each as the server wrote it. + listOf( + "device_fs_roots", "device_fs_listing", "device_fs_stat", "device_fs_content", "device_fs_content_withheld", "device_fs_written", + "device_fs_conflict", "device_fs_batch", "device_fs_deleted", "device_fs_no_trash", "device_fs_search", "device_fs_search_content", + "message_editor", + ).forEach { name -> assertTrue(name, LembasJson.parseToJsonElement(contract(name)).jsonObject.isNotEmpty()) } + } +} diff --git a/app/src/test/java/eu/llembas/android/shots/MediaShots.kt b/app/src/test/java/eu/llembas/android/shots/MediaShots.kt index 1a720d8..eaf4686 100644 --- a/app/src/test/java/eu/llembas/android/shots/MediaShots.kt +++ b/app/src/test/java/eu/llembas/android/shots/MediaShots.kt @@ -90,6 +90,67 @@ class MediaShots { shoot("60-media-cards", Phone.SmallScroll, fontScale = 1.5f, content = drawn) } + private fun shown(kind: String, name: String, size: Long, mime: String = "", width: Int = 0, height: Int = 0) = GeneratedMedia( + kind = kind, + path = "$made/$name", + nodeId = "node-$kind", + name = name, + mime = mime, + size = size, + width = width, + height = height, + shown = true, + ) + + /** Every kind a shown file can be, and one this app has never heard of: each is a name, a kind in words and the ways to the file. */ + private val shownFiles = listOf( + shown("image", "chart.png", 48_211, "image/png", 1280, 720), + shown("audio", "a-recording-of-the-meeting-about-the-ovens-20260102-030405.ogg", 3_300_000, "audio/ogg"), + shown("video", "screen-recording-20260102-030405.webm", 12_400_000, "video/webm", 1920, 1080), + shown("pdf", "report-20260102-030405.pdf", 90_000, "application/pdf"), + shown("model3d", "loaf-20260102.glb", 880_000), + shown("archive", "bundle-20260102-030405.zip", 1_200_000, "application/zip"), + shown("binary", "core-20260102.dump", 64_000_000), + shown("text", "notes-on-the-long-fermentation-of-waybread.txt", 2_048, "text/plain"), + shown("hologram", "something-new.holo", 512), + ) + + @Test + fun filesAnAgentShowed() { + val drawn: @Composable () -> Unit = { + Column(Modifier.fillMaxSize().verticalScroll(rememberScrollState()).padding(16.dp), verticalArrangement = Arrangement.spacedBy(12.dp)) { + shownFiles.forEach { MediaCard(it, null, actions) } + } + } + shoot("63-shown-files", Phone.Scroll, content = drawn) + shoot("63-shown-files", Phone.SmallScroll, content = drawn) + shoot("63-shown-files", Phone.SmallScroll, fontScale = 1.5f, content = drawn) + } + + @Test + fun aChatWithShownFiles() { + fun call(id: String, media: GeneratedMedia) = ToolCall( + id = id, + name = "show", + status = "ok", + path = media.path, + media = media, + block = ToolBlock(kind = "tool", title = media.path, state = "done", label = "Shown"), + ) + val reply = Message( + id = "m9", + role = "assistant", + steps = listOf( + Step(index = 0, kind = "tools", calls = listOf(call("c1", shownFiles[0]), call("c2", shownFiles[3]), call("c3", shownFiles[5]))), + Step(index = 1, kind = "text", markdown = "The chart, the report and everything else in one archive."), + ), + ) + val state = Fakes.transcript.copy(messages = listOf(Message(id = "m8", role = "user", text = "Show me what the run left."), reply), summary = null) + shoot("64-chat-shown") { ChatContent(state, object : ChatActions {}, agent = false, media = actions) } + shoot("64-chat-shown", Phone.Small) { ChatContent(state, object : ChatActions {}, agent = false, media = actions) } + shoot("64-chat-shown", Phone.Small, fontScale = 1.5f) { ChatContent(state, object : ChatActions {}, agent = false, media = actions) } + } + @Test fun aChatWithGeneratedMedia() { fun call(id: String, media: GeneratedMedia? = null, job: MediaJob? = null) = ToolCall( diff --git a/app/src/test/java/eu/llembas/android/shots/ScreenShots.kt b/app/src/test/java/eu/llembas/android/shots/ScreenShots.kt index 47fac1f..fa3244a 100644 --- a/app/src/test/java/eu/llembas/android/shots/ScreenShots.kt +++ b/app/src/test/java/eu/llembas/android/shots/ScreenShots.kt @@ -28,6 +28,9 @@ import com.github.takahirom.roborazzi.inspectionMode import com.github.takahirom.roborazzi.size import eu.llembas.android.R import eu.llembas.android.actions.NavApp +import eu.llembas.android.api.Card +import eu.llembas.android.api.CardItem +import eu.llembas.android.api.FileDiff import eu.llembas.android.assist.AssistActions import eu.llembas.android.assist.AssistSheetContent import eu.llembas.android.assist.AssistSheetFrame @@ -141,6 +144,42 @@ class ScreenShots { shoot("03-waiting", Phone.Small, fontScale = 1.5f) { ChatContent(Fakes.waiting, NoChatActions, agent = false) } } + @Test + fun editDiffCard() { + // An edit's approval card with its diff: a changed file with one line wider than the phone + // (it scrolls in its own box), a new file long enough to fold, and a file that goes. The + // card itself must not be wider than the phone, at a small one's width and large type too. + val long = " return loaf.heat(240, minutes=timer.MINUTES, rack=\"middle\", steam=True, turn_after=20) # hotter, as asked" + val card = Card( + id = "card9", + kind = "approval", + items = listOf( + CardItem( + key = "0", + kind = "approval", + tool = "edit", + title = "Edit a file", + detail = "{\"path\": \"src/oven.py\"}", + reason = "Manual mode asks before every edit.", + purpose = "Bake hotter", + freeText = false, + diffs = listOf( + FileDiff( + path = "src/bakery/ovens/oven.py", + oldText = "import timer\n\n\ndef bake(loaf):\n loaf.proof()\n return loaf.heat(220)\n", + newText = "import timer\n\n\ndef bake(loaf):\n loaf.proof()\n # 220 was cool for waybread.\n$long\n", + ), + FileDiff(path = "src/bakery/timer.py", oldText = null, newText = (1..30).joinToString("\n") { "STEP_$it = ${it * 5}" } + "\n"), + FileDiff(path = "src/bakery/old.py", oldText = "x = 1\ny = 2\n", newText = "", deleted = true), + ), + ), + ), + ) + shoot("09-edit-diff", Phone.Scroll) { SheetOver { CardSheet(card, onAnswer = {}) } } + shoot("09-edit-diff", Phone.SmallScroll) { SheetOver { CardSheet(card, onAnswer = {}) } } + shoot("09-edit-diff", Phone.SmallScroll, fontScale = 1.5f) { SheetOver { CardSheet(card, onAnswer = {}) } } + } + @Test fun writing() { // The 3.4.0 progress line under the reply: `{{text}} · {{elapsed}}`, the clock still. diff --git a/scripts/strings.py b/scripts/strings.py index 21d8241..6c56eed 100755 --- a/scripts/strings.py +++ b/scripts/strings.py @@ -447,6 +447,18 @@ STRINGS: dict[str, str] = { "media_video": "Video", "media_music": "Music", "media_model": "3D model", + # A file an agent showed: what it is, in words, for every kind + "media_audio": "Audio", + "media_pdf": "PDF", + "media_archive": "Archive", + "media_text": "Text file", + "media_binary": "File", + # An edit's diff on its approval card + "diff_deleted": "Deleted", + "diff_counts": "Lines added: %1$s, removed: %2$s", + "diff_show_all": "Show all %1$s lines", + "diff_show_less": "Show less", + "diff_more": "%1$s more lines are not shown here.", "media_gone": "That file no longer exists.", "job_queued": "Queued", "job_running": "Running", diff --git a/scripts/strings_own.json b/scripts/strings_own.json index 538aaf0..6d02aa2 100644 --- a/scripts/strings_own.json +++ b/scripts/strings_own.json @@ -424,7 +424,15 @@ "mcp_browser_note": "Přihlášení probíhá v prohlížeči, přímo na instanci. Pokud prohlížeč není k instanci přihlášen, nejprve si to vyžádá. Potom se vraťte sem.", "files_waiting": "Čeká se, až bude aplikace otevřená a telefon odemčený.", "share_refused": "Něco ze sdíleného odsud odeslat nelze a bylo vynecháno.", - "media_in_trash": "Tento soubor je v koši." + "media_in_trash": "Tento soubor je v koši.", + "media_pdf": "PDF", + "media_archive": "Archiv", + "media_text": "Textový soubor", + "diff_deleted": "Smazáno", + "diff_counts": "Přidané řádky: %1$s, odebrané: %2$s", + "diff_show_all": "Zobrazit všechny řádky (%1$s)", + "diff_show_less": "Zobrazit méně", + "diff_more": "Další řádky, které se zde nezobrazují: %1$s." }, "de": { "about_version": "LLeMbas für Android %1$s", @@ -852,7 +860,15 @@ "mcp_browser_note": "Die Anmeldung geschieht im Browser, auf der Instanz selbst. Ist der Browser dort nicht angemeldet, wird zuerst danach gefragt. Danach hierher zurückkehren.", "files_waiting": "Wartet, bis die App geöffnet und das Telefon entsperrt ist.", "share_refused": "Etwas vom Geteilten kann von hier nicht gesendet werden und wurde ausgelassen.", - "media_in_trash": "Diese Datei liegt im Papierkorb." + "media_in_trash": "Diese Datei liegt im Papierkorb.", + "media_pdf": "PDF", + "media_archive": "Archiv", + "media_text": "Textdatei", + "diff_deleted": "Gelöscht", + "diff_counts": "Zeilen hinzugefügt: %1$s, entfernt: %2$s", + "diff_show_all": "Alle %1$s Zeilen anzeigen", + "diff_show_less": "Weniger anzeigen", + "diff_more": "%1$s weitere Zeilen werden hier nicht angezeigt." }, "es": { "about_version": "LLeMbas para Android %1$s", @@ -1279,7 +1295,15 @@ "mcp_browser_note": "El inicio de sesión se hace en el navegador, en la propia instancia. Si el navegador no tiene la sesión iniciada en la instancia, primero la pide. Después, vuelva aquí.", "files_waiting": "Esperando a que la aplicación esté abierta y el teléfono desbloqueado.", "share_refused": "Algo de lo compartido no se puede enviar desde aquí y se ha omitido.", - "media_in_trash": "Ese archivo está en la papelera." + "media_in_trash": "Ese archivo está en la papelera.", + "media_pdf": "PDF", + "media_archive": "Archivo comprimido", + "media_text": "Archivo de texto", + "diff_deleted": "Eliminado", + "diff_counts": "Líneas añadidas: %1$s, eliminadas: %2$s", + "diff_show_all": "Mostrar las %1$s líneas", + "diff_show_less": "Mostrar menos", + "diff_more": "Aquí no se muestran %1$s líneas más." }, "fr": { "about_version": "LLeMbas pour Android %1$s", @@ -1707,7 +1731,15 @@ "mcp_browser_note": "La connexion se fait dans le navigateur, sur l’instance elle-même. Si le navigateur n’y est pas connecté, il le demande d’abord. Revenez ensuite ici.", "files_waiting": "En attente que l'application soit ouverte et le téléphone déverrouillé.", "share_refused": "Un élément partagé ne peut pas être envoyé d'ici et a été laissé de côté.", - "media_in_trash": "Ce fichier est dans la corbeille." + "media_in_trash": "Ce fichier est dans la corbeille.", + "media_pdf": "PDF", + "media_archive": "Archive", + "media_text": "Fichier texte", + "diff_deleted": "Supprimé", + "diff_counts": "Lignes ajoutées : %1$s, supprimées : %2$s", + "diff_show_all": "Afficher les %1$s lignes", + "diff_show_less": "Afficher moins", + "diff_more": "%1$s lignes de plus ne sont pas affichées ici." }, "hu": { "about_version": "LLeMbas Androidra %1$s", @@ -2135,7 +2167,15 @@ "mcp_browser_note": "A bejelentkezés a böngészőben történik, magán a példányon. Ha a böngésző nincs bejelentkezve a példányba, előbb azt kéri. Utána térjen vissza ide.", "files_waiting": "Várakozás, amíg az alkalmazás meg van nyitva és a telefon fel van oldva.", "share_refused": "A megosztottak közül valami innen nem küldhető el, ezért kimaradt.", - "media_in_trash": "Ez a fájl a lomtárban van." + "media_in_trash": "Ez a fájl a lomtárban van.", + "media_pdf": "PDF", + "media_archive": "Archívum", + "media_text": "Szövegfájl", + "diff_deleted": "Törölve", + "diff_counts": "Hozzáadott sorok: %1$s, eltávolított: %2$s", + "diff_show_all": "Mind a(z) %1$s sor megjelenítése", + "diff_show_less": "Kevesebb megjelenítése", + "diff_more": "További %1$s sor itt nem látható." }, "it": { "about_version": "LLeMbas per Android %1$s", @@ -2562,7 +2602,15 @@ "mcp_browser_note": "L’accesso avviene nel browser, sull’istanza stessa. Se il browser non ha effettuato l’accesso all’istanza, prima lo chiede. Poi torna qui.", "files_waiting": "In attesa che l'app sia aperta e il telefono sbloccato.", "share_refused": "Qualcosa di ciò che è stato condiviso non può essere inviato da qui ed è stato escluso.", - "media_in_trash": "Questo file è nel cestino." + "media_in_trash": "Questo file è nel cestino.", + "media_pdf": "PDF", + "media_archive": "Archivio", + "media_text": "File di testo", + "diff_deleted": "Eliminato", + "diff_counts": "Righe aggiunte: %1$s, rimosse: %2$s", + "diff_show_all": "Mostra tutte le %1$s righe", + "diff_show_less": "Mostra meno", + "diff_more": "Altre %1$s righe non sono mostrate qui." }, "pl": { "about_version": "LLeMbas na Androida %1$s", @@ -2989,7 +3037,15 @@ "mcp_browser_note": "Logowanie odbywa się w przeglądarce, na samej instancji. Jeśli przeglądarka nie jest zalogowana do instancji, najpierw o to poprosi. Potem wróć tutaj.", "files_waiting": "Oczekiwanie, aż aplikacja będzie otwarta, a telefon odblokowany.", "share_refused": "Czegoś z udostępnionych rzeczy nie można stąd wysłać i zostało pominięte.", - "media_in_trash": "Ten plik jest w koszu." + "media_in_trash": "Ten plik jest w koszu.", + "media_pdf": "PDF", + "media_archive": "Archiwum", + "media_text": "Plik tekstowy", + "diff_deleted": "Usunięto", + "diff_counts": "Dodane wiersze: %1$s, usunięte: %2$s", + "diff_show_all": "Pokaż wszystkie wiersze (%1$s)", + "diff_show_less": "Pokaż mniej", + "diff_more": "Dalsze wiersze, których tu nie pokazano: %1$s." }, "sk": { "about_version": "LLeMbas pre Android %1$s", @@ -3416,6 +3472,14 @@ "mcp_browser_note": "Prihlásenie prebieha v prehliadači, priamo na inštancii. Ak prehliadač nie je do inštancie prihlásený, najprv si to vyžiada. Potom sa vráťte sem.", "files_waiting": "Čaká sa, kým bude aplikácia otvorená a telefón odomknutý.", "share_refused": "Niečo zo zdieľaného sa odtiaľto nedá odoslať a bolo vynechané.", - "media_in_trash": "Tento súbor je v koši." + "media_in_trash": "Tento súbor je v koši.", + "media_pdf": "PDF", + "media_archive": "Archív", + "media_text": "Textový súbor", + "diff_deleted": "Zmazané", + "diff_counts": "Pridané riadky: %1$s, odobraté: %2$s", + "diff_show_all": "Zobraziť všetky riadky (%1$s)", + "diff_show_less": "Zobraziť menej", + "diff_more": "Ďalšie riadky, ktoré sa tu nezobrazujú: %1$s." } }