diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 0c248d0..6fe1f0a 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -37,7 +37,7 @@ android:icon="@drawable/ic_rhema" android:label="@string/app_name" android:networkSecurityConfig="@xml/network_security_config" - android:theme="@android:style/Theme.Material.NoActionBar"> + android:theme="@style/Theme.Rhema"> Unit) Column(modifier = Modifier.fillMaxSize()) { ChatHeader(sessionKey, controller.connection, face, onBack) - HorizontalDivider(color = JadeiteBorder) + HorizontalDivider(color = TogetherBorder) // Reversed layout: index 0 is the newest turn, pinned to the // bottom edge. A streaming reply grows against that anchor, so @@ -216,9 +218,9 @@ fun ChatScreen(container: AppContainer, sessionKey: String, onBack: () -> Unit) item(key = "older") { Text( stringResource(R.string.chat_loading_earlier), - style = MaterialTheme.typography.labelSmall, - fontFamily = JadeiteMono, - color = JadeiteText3, + style = MaterialTheme.typography.bodySmall, + color = TogetherFaint, + textAlign = TextAlign.Center, modifier = Modifier.fillMaxWidth(), ) } @@ -228,7 +230,7 @@ fun ChatScreen(container: AppContainer, sessionKey: String, onBack: () -> Unit) controller.sendError?.let { err -> Text( stringResource(R.string.chat_send_failed, err), - color = JadeiteError, + color = TogetherDanger, style = MaterialTheme.typography.bodySmall, modifier = Modifier.padding(horizontal = 16.dp, vertical = 4.dp), ) @@ -269,7 +271,7 @@ fun ChatScreen(container: AppContainer, sessionKey: String, onBack: () -> Unit) Icon( Icons.Filled.Add, contentDescription = stringResource(R.string.chat_attach), - tint = JadeiteText3, + tint = TogetherMuted, ) } OutlinedTextField( @@ -280,13 +282,13 @@ fun ChatScreen(container: AppContainer, sessionKey: String, onBack: () -> Unit) maxLines = 4, shape = MaterialTheme.shapes.small, colors = OutlinedTextFieldDefaults.colors( - focusedBorderColor = JadeiteAccent, - unfocusedBorderColor = JadeiteBorder, - focusedContainerColor = JadeiteSunken, - unfocusedContainerColor = JadeiteSunken, - cursorColor = JadeiteAccentText, - focusedTextColor = JadeiteText, - unfocusedTextColor = JadeiteText, + focusedBorderColor = TogetherAccent, + unfocusedBorderColor = TogetherBorderStrong, + focusedContainerColor = TogetherSurface, + unfocusedContainerColor = TogetherSurface, + cursorColor = TogetherAccent, + focusedTextColor = TogetherText, + unfocusedTextColor = TogetherText, ), ) SendButton( @@ -365,10 +367,10 @@ private fun ChatHeader( Icon( Icons.AutoMirrored.Filled.ArrowBack, contentDescription = stringResource(R.string.chat_back), - tint = JadeiteText2, + tint = TogetherMuted, ) } - AppAvatar(face.glyph, accent = face.image == null, size = 34.dp, image = face.image) + AppAvatar(face.glyph, size = 34.dp, image = face.image) Column(modifier = Modifier.weight(1f)) { Text( sessionKey.removePrefix("interactive:"), @@ -377,23 +379,25 @@ private fun ChatHeader( maxLines = 1, overflow = TextOverflow.Ellipsis, ) - Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(6.dp)) { - StatusDot(tone = connTone(conn)) - Text( - connText(conn), - style = MaterialTheme.typography.labelSmall, - color = if (connTone(conn) == DotTone.Error) JadeiteError else JadeiteText3, - ) - } + Text( + connText(conn), + style = MaterialTheme.typography.bodySmall, + color = when (connTone(conn)) { + StatusTone.Ok -> TogetherAccent + StatusTone.Warn -> TogetherWarn + StatusTone.Error -> TogetherDanger + StatusTone.Idle -> TogetherMuted + }, + ) } } } -private fun connTone(conn: ChatController.Conn): DotTone = when (conn) { - ChatController.Conn.Connecting -> DotTone.Warn - ChatController.Conn.Live -> DotTone.Ok - ChatController.Conn.Reconnecting -> DotTone.Error - is ChatController.Conn.Failed -> DotTone.Error +private fun connTone(conn: ChatController.Conn): StatusTone = when (conn) { + ChatController.Conn.Connecting -> StatusTone.Warn + ChatController.Conn.Live -> StatusTone.Ok + ChatController.Conn.Reconnecting -> StatusTone.Error + is ChatController.Conn.Failed -> StatusTone.Error } @Composable @@ -413,7 +417,7 @@ private fun connText(conn: ChatController.Conn): String = when (conn) { private fun SendButton(enabled: Boolean, onClick: () -> Unit) { Surface( shape = CircleShape, - color = if (enabled) JadeiteAccent else JadeiteElevated, + color = if (enabled) TogetherAccent else TogetherSurface2, modifier = Modifier .size(44.dp) .clickable(enabled = enabled, onClick = onClick), @@ -422,7 +426,7 @@ private fun SendButton(enabled: Boolean, onClick: () -> Unit) { Icon( Icons.AutoMirrored.Filled.Send, contentDescription = stringResource(R.string.chat_send), - tint = if (enabled) JadeiteOnAccent else JadeiteText3, + tint = if (enabled) TogetherOnAccent else TogetherMuted, modifier = Modifier.size(20.dp), ) } @@ -470,87 +474,129 @@ private fun TurnGroupRow( controller: ChatController, face: AgentFace, ) { + // The reader's rows say who they are the way the web surface does: + // "you" on the conversable keys, "dispatch" on the others, and the + // matching initial in the round avatar. + val you = controller.sessionKey.startsWith("interactive:") || + controller.sessionKey.startsWith("phone:") + val author = stringResource(if (you) R.string.chat_user_you else R.string.chat_user_dispatch) + when (group) { is TurnGroup.User -> Row( - horizontalArrangement = Arrangement.End, - modifier = Modifier.fillMaxWidth(), - ) { - // The reader's own words: a right-anchored bubble, elevated - // one step and marked on its trailing edge — no label or - // avatar, the side says whose it is. - Row( - modifier = Modifier - .weight(1f, fill = false) - .height(IntrinsicSize.Min) - .background(JadeiteElevated, MaterialTheme.shapes.small), - ) { - Column( - modifier = Modifier - .padding(horizontal = 10.dp, vertical = 8.dp) - .weight(1f, fill = false), - verticalArrangement = Arrangement.spacedBy(4.dp), - ) { - // The message's images sit above its text, the web - // sent row's layout: a locally sent row previews its - // own staged files, a replayed one fetches by id. - if (group.images.isNotEmpty()) { - Row( - horizontalArrangement = Arrangement.spacedBy(6.dp), - modifier = Modifier.horizontalScroll(rememberScrollState()), - ) { - group.images.forEach { image -> - SentImageThumb(image, container) - } - } - } - // Chips render as chips, not payloads; the text - // around them stays verbatim. The row's chip record - // slices them out of the plain text; a row from - // before the record rode the stream carries none - // and still scans the mark form in the text. - var chip = 0 - messageParts(group.text, group.pastes).forEach { part -> - when (part) { - is PastePart.Text -> Text(part.text, style = MaterialTheme.typography.bodyLarge) - is PastePart.Paste -> { - chip += 1 - PasteChip(chipLabel(part.payload, chip)) - } - } - } - } - AccentBar(JadeiteAccent) - } - } - is TurnGroup.Agent -> Row( horizontalArrangement = Arrangement.spacedBy(10.dp), modifier = Modifier.fillMaxWidth(), ) { - AppAvatar(face.glyph, accent = face.image == null, image = face.image) - Column(modifier = Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(8.dp)) { + Box( + modifier = Modifier + .size(24.dp) + .clip(CircleShape) + .background(TogetherSurface2) + .border(1.dp, TogetherBorderStrong, CircleShape), + contentAlignment = Alignment.Center, + ) { + Text( + author.take(1).uppercase(), + style = MaterialTheme.typography.labelSmall, + fontWeight = FontWeight.SemiBold, + color = TogetherMuted, + ) + } + Column(modifier = Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(4.dp)) { + Text( + author, + style = MaterialTheme.typography.bodySmall, + fontWeight = FontWeight.SemiBold, + ) + // The message's images sit above its text, the web + // sent row's layout: a locally sent row previews its + // own staged files, a replayed one fetches by id. + if (group.images.isNotEmpty()) { + Row( + horizontalArrangement = Arrangement.spacedBy(6.dp), + modifier = Modifier.horizontalScroll(rememberScrollState()), + ) { + group.images.forEach { image -> + SentImageThumb(image, container) + } + } + } + // Chips render as chips, not payloads; the text + // around them stays verbatim. The row's chip record + // slices them out of the plain text; a row from + // before the record rode the stream carries none + // and still scans the mark form in the text. + var chip = 0 + messageParts(group.text, group.pastes).forEach { part -> + when (part) { + is PastePart.Text -> Text(part.text, style = MaterialTheme.typography.bodyMedium) + is PastePart.Paste -> { + chip += 1 + PasteChip(chipLabel(part.payload, chip)) + } + } + } + } + } + is TurnGroup.Agent -> Row( + modifier = Modifier + .fillMaxWidth() + .height(IntrinsicSize.Min) + .background( + TogetherSurface, + RoundedCornerShape( + topStart = 0.dp, + topEnd = 10.dp, + bottomEnd = 10.dp, + bottomStart = 0.dp, + ), + ), + ) { + AccentBar(TogetherAccent, width = 2.dp) + Column( + modifier = Modifier + .padding(12.dp) + .weight(1f), + verticalArrangement = Arrangement.spacedBy(8.dp), + ) { Text( face.name ?: stringResource(R.string.chat_agent), - style = MaterialTheme.typography.labelMedium, - fontWeight = FontWeight.Bold, - color = if (group.items.any { it is ChatController.Reply && it.streaming }) { - JadeiteAccentText - } else { - JadeiteText2 - }, + style = MaterialTheme.typography.bodySmall, + fontWeight = FontWeight.SemiBold, + color = TogetherAccent, ) - // The design stacks a turn as thinking, tool cards, then the - // reply and its outcome — stream order interleaves them, the - // rendering does not. + // The design's turn surface shows the cards the reader must + // act on or can open, the reply, and the outcome word; the + // thinking trace and the tool calls stay off it — the same + // surface the web draws. group.items.sortedBy { turnPriority(it) }.forEach { item -> when (item) { - is ChatController.Thinking -> ThinkingBlock(item) - is ChatController.ToolCall -> - if (isShellTool(item.name)) ShellRow(item) else ToolCard(item) is ChatController.Attachment -> AttachmentCard(item, container) is ChatController.Consent -> ConsentCard(item, controller) is ChatController.Reply -> ReplyBlock(item) is ChatController.Outcome -> OutcomeTag(item.outcome) - is ChatController.UserMessage -> Unit // never grouped here + else -> Unit // thinking and tool calls never render + } + } + // A live turn with nothing to read yet — no reply, no + // outcome — says so: the spinner row the web surface + // shows, and the only honest feedback the phone gets. + if ( + group.items.none { it is ChatController.Outcome } && + group.items.none { it is ChatController.Reply && it.text.isNotBlank() } + ) { + Row( + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(8.dp), + ) { + CircularProgressIndicator(modifier = Modifier.size(12.dp), strokeWidth = 2.dp) + Text( + stringResource( + R.string.chat_working_fmt, + face.name ?: stringResource(R.string.chat_agent), + ), + style = MaterialTheme.typography.bodySmall, + color = TogetherMuted, + ) } } } @@ -558,152 +604,15 @@ private fun TurnGroupRow( } } -// Render order inside one agent turn: thinking, tools, attachments, -// questions, reply, outcome. +// Render order inside one agent turn: cards, reply, outcome. The +// thinking trace and the tool calls never render, so their order is +// whatever falls out of the fold. private fun turnPriority(item: ChatController.Item): Int = when (item) { - is ChatController.Thinking -> 0 - is ChatController.ToolCall -> 1 - is ChatController.Attachment -> 2 - is ChatController.Consent -> 3 - is ChatController.Reply -> 4 - is ChatController.Outcome -> 5 - is ChatController.UserMessage -> 6 -} - -@Composable -private fun ThinkingBlock(item: ChatController.Thinking) { - // Dim and collapsible: it is the agent's scratch, not its answer. - var expanded by remember(item.id) { mutableStateOf(false) } - val text = if (expanded || item.text.length <= 120) item.text else "${item.text.take(120)}…" - Column( - modifier = Modifier - .fillMaxWidth() - .clickable { expanded = !expanded } - .background(JadeiteSurface, MaterialTheme.shapes.extraSmall) - .padding(8.dp), - ) { - Text( - "thinking", - style = MaterialTheme.typography.labelSmall, - color = JadeiteText3, - ) - Text( - text, - style = MaterialTheme.typography.bodySmall, - fontStyle = FontStyle.Italic, - color = JadeiteText3, - ) - } -} - -@Composable -private fun ToolCard(item: ChatController.ToolCall) { - val tint = when { - item.running -> JadeiteText3 - item.isError -> JadeiteError - else -> JadeiteOk - } - Row( - modifier = Modifier - .fillMaxWidth() - .heightIn(min = 32.dp) - .height(IntrinsicSize.Min) - .background(JadeiteSurface, MaterialTheme.shapes.extraSmall), - ) { - AccentBar(tint) - Row( - modifier = Modifier - .padding(horizontal = 10.dp, vertical = 6.dp) - .weight(1f), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(8.dp), - ) { - Text( - if (item.running) "…" else if (item.isError) "✗" else "✓", - style = MaterialTheme.typography.labelMedium, - color = tint, - ) - Text( - item.name, - style = MaterialTheme.typography.labelMedium, - fontFamily = JadeiteMono, - color = JadeiteText, - maxLines = 1, - overflow = TextOverflow.Ellipsis, - ) - item.summary?.takeIf { it.isNotBlank() }?.let { summary -> - Text( - summary, - style = MaterialTheme.typography.bodySmall, - fontFamily = JadeiteMono, - color = JadeiteText3, - maxLines = 1, - overflow = TextOverflow.Ellipsis, - ) - } - } - } -} - -/** Command rows render as shell lines, not glyph rows (the desktop's - * shell_line); run_command is the bash tool's other name. */ -private fun isShellTool(name: String): Boolean = name == "bash" || name == "run_command" - -@Composable -private fun ShellRow(item: ChatController.ToolCall) { - val tint = when { - item.running -> JadeiteText3 - item.exitCode == 0L && !item.isError -> JadeiteOk - else -> JadeiteError - } - Row( - modifier = Modifier - .fillMaxWidth() - .heightIn(min = 32.dp) - .height(IntrinsicSize.Min) - .background(JadeiteSurface, MaterialTheme.shapes.extraSmall), - ) { - AccentBar(tint) - Row( - modifier = Modifier - .padding(horizontal = 10.dp, vertical = 6.dp) - .weight(1f), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(8.dp), - ) { - // A shell line reads as the command it ran: dim $ prefix, the - // command, the exit code at its end. - Text( - "$", - style = MaterialTheme.typography.labelMedium, - fontFamily = JadeiteMono, - color = JadeiteText3, - ) - Text( - item.command ?: "…", - style = MaterialTheme.typography.labelMedium, - fontFamily = JadeiteMono, - color = JadeiteText, - maxLines = 1, - overflow = TextOverflow.Ellipsis, - modifier = Modifier.weight(1f, fill = false), - ) - when { - item.running -> Unit - item.exitCode != null -> Text( - "[${item.exitCode}]", - style = MaterialTheme.typography.labelMedium, - fontFamily = JadeiteMono, - color = if (item.exitCode == 0L) JadeiteOk else JadeiteError, - ) - item.isError -> Text( - "✗", - style = MaterialTheme.typography.labelMedium, - color = JadeiteError, - ) - } - } - } + is ChatController.Attachment -> 0 + is ChatController.Consent -> 1 + is ChatController.Reply -> 2 + is ChatController.Outcome -> 3 + else -> 4 } @Composable @@ -717,32 +626,36 @@ private fun ReplyBlock(item: ChatController.Reply) { @Composable private fun OutcomeTag(outcome: String) { // A steered turn was cut short by the next message, not failed: the - // reply that replaced it streams right below, so the tag reads as an - // accent, not an error — the same distinction the web UI draws. + // reply that replaced it streams right below, so the word reads as + // an accent, not an error — the same distinction the web UI draws. val color = when { - outcome.equals("Failed", ignoreCase = true) -> JadeiteError - outcome.equals("Steered", ignoreCase = true) -> JadeiteAccentText - else -> JadeiteText3 + outcome.equals("Failed", ignoreCase = true) -> TogetherDanger + outcome.equals("Steered", ignoreCase = true) -> TogetherAccent + outcome.equals("Aborted", ignoreCase = true) -> TogetherWarn + else -> TogetherMuted } Text( outcome, - style = MaterialTheme.typography.labelSmall, - fontFamily = JadeiteMono, + style = MaterialTheme.typography.bodySmall, color = color, ) } @Composable private fun PasteChip(label: String) { - Text( - label, - style = MaterialTheme.typography.labelSmall, - fontFamily = JadeiteMono, - color = JadeiteText3, - modifier = Modifier - .background(JadeiteSunken, MaterialTheme.shapes.extraSmall) - .padding(horizontal = 8.dp, vertical = 2.dp), - ) + Surface( + shape = RoundedCornerShape(6.dp), + color = TogetherSurface2, + border = BorderStroke(1.dp, TogetherBorderStrong), + ) { + Text( + label, + style = MaterialTheme.typography.labelSmall, + fontFamily = TogetherMono, + color = TogetherMuted, + modifier = Modifier.padding(horizontal = 8.dp, vertical = 1.dp), + ) + } } // --- paste chips ------------------------------------------------------ @@ -992,9 +905,9 @@ private fun formatSize(size: Long): String = when { @Composable private fun StagedChipView(chip: StagedChip, number: Int, onRemove: () -> Unit) { Surface( - shape = MaterialTheme.shapes.extraSmall, - color = JadeiteSunken, - border = BorderStroke(1.dp, JadeiteBorder), + shape = RoundedCornerShape(6.dp), + color = TogetherSurface2, + border = BorderStroke(1.dp, TogetherBorderStrong), ) { Row( verticalAlignment = Alignment.CenterVertically, @@ -1014,13 +927,13 @@ private fun StagedChipView(chip: StagedChip, number: Int, onRemove: () -> Unit) Text( "▣$number ${chip.name} ${formatSize(chip.image.sizeBytes)}", style = MaterialTheme.typography.labelSmall, - fontFamily = JadeiteMono, - color = JadeiteText3, + fontFamily = TogetherMono, + color = TogetherMuted, ) Icon( Icons.Filled.Close, contentDescription = stringResource(R.string.chat_image_drop, chip.name), - tint = JadeiteText3, + tint = TogetherMuted, modifier = Modifier .size(14.dp) .clickable(onClick = onRemove), @@ -1051,14 +964,14 @@ private fun ImageErrorRow(error: ImageStageError, onDismiss: () -> Unit) { is ImageStageError.ReadFailed -> stringResource(R.string.chat_image_read_failed, error.name) }, - color = JadeiteError, + color = TogetherDanger, style = MaterialTheme.typography.bodySmall, modifier = Modifier.weight(1f), ) Icon( Icons.Filled.Close, contentDescription = stringResource(R.string.chat_image_dismiss), - tint = JadeiteText3, + tint = TogetherMuted, modifier = Modifier .size(16.dp) .clickable(onClick = onDismiss), @@ -1097,7 +1010,7 @@ private fun SentImageThumb(image: ChatController.SentImage, container: AppContai .widthIn(max = 240.dp) .heightIn(max = 240.dp) .clip(MaterialTheme.shapes.small) - .border(1.dp, JadeiteBorder, MaterialTheme.shapes.small), + .border(1.dp, TogetherBorder, MaterialTheme.shapes.small), ) } } @@ -1170,24 +1083,16 @@ private fun AttachmentCard(item: ChatController.Attachment, container: AppContai } val current = state - Row( - modifier = Modifier - .fillMaxWidth() - .heightIn(min = 32.dp) - .height(IntrinsicSize.Min) - .background(JadeiteSurface, MaterialTheme.shapes.extraSmall), + Surface( + modifier = Modifier.fillMaxWidth(), + shape = RoundedCornerShape(8.dp), + color = TogetherSurface2, + border = BorderStroke(1.dp, TogetherBorder), ) { - AccentBar( - when (current) { - AttachState.Loading -> JadeiteText3 - is AttachState.Failed -> JadeiteError - else -> JadeiteOk - }, - ) Column( modifier = Modifier - .padding(horizontal = 10.dp, vertical = 6.dp) - .weight(1f), + .padding(horizontal = 12.dp, vertical = 8.dp) + .fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(4.dp), ) { Row( @@ -1196,9 +1101,9 @@ private fun AttachmentCard(item: ChatController.Attachment, container: AppContai ) { Text( item.name, - style = MaterialTheme.typography.labelMedium, - fontFamily = JadeiteMono, - color = JadeiteText, + style = MaterialTheme.typography.bodySmall, + fontFamily = TogetherMono, + color = TogetherText, maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f, fill = false), @@ -1206,12 +1111,12 @@ private fun AttachmentCard(item: ChatController.Attachment, container: AppContai Text( formatBytes(item.size), style = MaterialTheme.typography.labelSmall, - fontFamily = JadeiteMono, - color = JadeiteText3, + fontFamily = TogetherMono, + color = TogetherFaint, ) } item.caption?.takeIf { it.isNotBlank() }?.let { caption -> - Text(caption, style = MaterialTheme.typography.bodySmall, color = JadeiteText2) + Text(caption, style = MaterialTheme.typography.bodySmall, color = TogetherMuted) } if (current is AttachState.Ready) { current.preview?.let { preview -> @@ -1221,21 +1126,23 @@ private fun AttachmentCard(item: ChatController.Attachment, container: AppContai contentScale = ContentScale.Fit, modifier = Modifier .fillMaxWidth() - .heightIn(max = 240.dp), + .heightIn(max = 240.dp) + .clip(RoundedCornerShape(8.dp)) + .border(1.dp, TogetherBorder, RoundedCornerShape(8.dp)), ) } current.note?.let { note -> - Text(note, style = MaterialTheme.typography.bodySmall, color = JadeiteError) + Text(note, style = MaterialTheme.typography.bodySmall, color = TogetherDanger) } } if (current is AttachState.Failed) { - Text(current.message, style = MaterialTheme.typography.bodySmall, color = JadeiteError) + Text(current.message, style = MaterialTheme.typography.bodySmall, color = TogetherDanger) } if (current is AttachState.Loading) { Text( stringResource(R.string.chat_attachment_downloading), - style = MaterialTheme.typography.labelMedium, - color = JadeiteText3, + style = MaterialTheme.typography.bodySmall, + color = TogetherMuted, ) } else { Text( @@ -1243,8 +1150,9 @@ private fun AttachmentCard(item: ChatController.Attachment, container: AppContai is AttachState.Ready -> stringResource(R.string.chat_attachment_open) else -> stringResource(R.string.chat_attachment_download) }, - style = MaterialTheme.typography.labelMedium, - color = JadeiteAccentText, + style = MaterialTheme.typography.bodySmall, + color = TogetherAccent, + fontWeight = FontWeight.Medium, modifier = Modifier.clickable { when (val s = state) { is AttachState.Ready -> { @@ -1306,12 +1214,18 @@ private fun ConsentCard(item: ChatController.Consent, controller: ChatController var busy by remember(item.id) { mutableStateOf(false) } var failure by remember(item.id) { mutableStateOf(null) } - // An open question glows warn; a settled card keeps only its tone. + // An open question keeps the warn edge; a settled one carries the + // answer's tone. val tint = when (item.granted) { - null -> JadeiteWarn - true -> JadeiteOk - false -> JadeiteText3 + null -> TogetherWarn + true -> TogetherOk + false -> TogetherDanger } + // The kind is the card's small label, spelled the way the web + // surface spells it. + val kindLabel = stringResource( + if (item.kind == "secret") R.string.consent_kind_secret else R.string.consent_kind_phone, + ) fun answer(call: suspend () -> ClawResult) { busy = true @@ -1325,43 +1239,47 @@ private fun ConsentCard(item: ChatController.Consent, controller: ChatController } } - Row( - modifier = Modifier - .fillMaxWidth() - .height(IntrinsicSize.Min) - .background(JadeiteSurface, MaterialTheme.shapes.extraSmall), + Surface( + modifier = Modifier.fillMaxWidth(), + shape = RoundedCornerShape(8.dp), + color = TogetherSurface2, + border = BorderStroke(1.dp, TogetherBorder), ) { - AccentBar(tint) - Column( - modifier = Modifier - .padding(horizontal = 10.dp, vertical = 6.dp) - .weight(1f), - verticalArrangement = Arrangement.spacedBy(6.dp), - ) { - Row( - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(8.dp), + Row(modifier = Modifier.height(IntrinsicSize.Min)) { + AccentBar(tint) + Column( + modifier = Modifier + .padding(12.dp) + .weight(1f), + verticalArrangement = Arrangement.spacedBy(6.dp), ) { - AppBadge(item.kind, tint = tint) - Text( - item.summary, - style = MaterialTheme.typography.titleSmall, - fontWeight = FontWeight.SemiBold, - modifier = Modifier.weight(1f, fill = false), - ) - } - Text(item.detail, style = MaterialTheme.typography.bodySmall, color = JadeiteText2) - when (item.granted) { - true -> Text( - "✓ " + stringResource(R.string.consent_granted), - style = MaterialTheme.typography.labelMedium, - color = JadeiteOk, - ) - false -> Text( - "✗ " + stringResource(R.string.consent_denied), - style = MaterialTheme.typography.labelMedium, - color = JadeiteText3, - ) + Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) { + Text( + kindLabel, + style = MaterialTheme.typography.bodySmall, + color = TogetherFaint, + ) + Text( + item.summary, + style = MaterialTheme.typography.titleSmall, + fontWeight = if (item.granted == false) FontWeight.Normal else FontWeight.SemiBold, + color = if (item.granted == false) TogetherMuted else TogetherText, + modifier = Modifier.weight(1f, fill = false), + ) + if (item.granted != null) { + Text( + stringResource( + if (item.granted == true) R.string.consent_granted else R.string.consent_denied, + ), + style = MaterialTheme.typography.bodySmall, + color = if (item.granted == true) TogetherAccent else TogetherDanger, + ) + } + } + Text(item.detail, style = MaterialTheme.typography.bodySmall, color = TogetherMuted) + when (item.granted) { + true -> Unit // the state word in the head says it + false -> Unit // the state word in the head says it null -> { if (item.kind == "secret") { OutlinedTextField( @@ -1374,13 +1292,13 @@ private fun ConsentCard(item: ChatController.Consent, controller: ChatController enabled = !busy, shape = MaterialTheme.shapes.small, colors = OutlinedTextFieldDefaults.colors( - focusedBorderColor = JadeiteAccent, - unfocusedBorderColor = JadeiteBorder, - focusedContainerColor = JadeiteSunken, - unfocusedContainerColor = JadeiteSunken, - cursorColor = JadeiteAccentText, - focusedTextColor = JadeiteText, - unfocusedTextColor = JadeiteText, + focusedBorderColor = TogetherAccent, + unfocusedBorderColor = TogetherBorderStrong, + focusedContainerColor = TogetherSurface, + unfocusedContainerColor = TogetherSurface, + cursorColor = TogetherAccent, + focusedTextColor = TogetherText, + unfocusedTextColor = TogetherText, ), ) } @@ -1413,9 +1331,10 @@ private fun ConsentCard(item: ChatController.Consent, controller: ChatController Text( stringResource(R.string.consent_answer_failed, fail), style = MaterialTheme.typography.bodySmall, - color = JadeiteError, + color = TogetherDanger, ) } + } } } } diff --git a/android/app/src/main/java/rs/rhema/phone/ui/Components.kt b/android/app/src/main/java/rs/rhema/phone/ui/Components.kt index fca00c4..c49b627 100644 --- a/android/app/src/main/java/rs/rhema/phone/ui/Components.kt +++ b/android/app/src/main/java/rs/rhema/phone/ui/Components.kt @@ -3,20 +3,28 @@ package rs.rhema.phone.ui import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.Image import androidx.compose.foundation.background -import androidx.compose.foundation.border import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.ColumnScope +import androidx.compose.foundation.layout.IntrinsicSize import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.RowScope import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width +import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.ArrowDropDown +import androidx.compose.material.icons.outlined.CheckCircle +import androidx.compose.material.icons.outlined.Info +import androidx.compose.material.icons.outlined.Refresh +import androidx.compose.material.icons.outlined.Warning import androidx.compose.material3.DropdownMenu import androidx.compose.material3.DropdownMenuItem import androidx.compose.material3.HorizontalDivider @@ -35,90 +43,110 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.ImageBitmap +import androidx.compose.ui.graphics.lerp import androidx.compose.ui.graphics.vector.ImageVector +import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextOverflow -import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp // The design language's shared pieces, mirroring the web components: -// one card voice, one label voice, one badge/dot/callout vocabulary. +// one card voice, one label voice, one badge/word/callout vocabulary. // Screens compose these; nothing here knows about the claw API. -/** The uppercase letterspaced section label — the repeated typographic voice. */ +/** The quiet section label — the repeated typographic voice, 11sp + * medium in the faint color (main.css's `.label`). */ @Composable fun SectionLabel(text: String, modifier: Modifier = Modifier) { Text( text, modifier = modifier, style = MaterialTheme.typography.labelMedium, - fontWeight = FontWeight.Bold, - color = JadeiteText3, - letterSpacing = MaterialTheme.typography.labelMedium.letterSpacing * 1.4f, + fontSize = 11.sp, + fontWeight = FontWeight.Medium, + color = TogetherFaint, ) } -enum class DotTone { Ok, Warn, Error, Idle } +/** The tones a status word can carry. */ +enum class StatusTone { Ok, Warn, Error, Idle } -/** One honest state dot: ok, warn, error, or idle gray. */ +/** Status is a word: plain text carrying its tone's color — no + * container, no dot (main.css's `.state`). */ @Composable -fun StatusDot(tone: DotTone, modifier: Modifier = Modifier) { +fun StatusWord(text: String, tone: StatusTone, modifier: Modifier = Modifier) { val color = when (tone) { - DotTone.Ok -> JadeiteOk - DotTone.Warn -> JadeiteWarn - DotTone.Error -> JadeiteError - DotTone.Idle -> JadeiteText3 + StatusTone.Ok -> TogetherAccent + StatusTone.Warn -> TogetherWarn + StatusTone.Error -> TogetherDanger + StatusTone.Idle -> TogetherFaint } - Box(modifier = modifier.size(8.dp).clip(RoundedCornerShape(50)).background(color)) + Text( + text, + modifier = modifier, + style = MaterialTheme.typography.bodySmall, + color = color, + ) } -/** The pill: one small status or tag word, outlined in its tone. */ +/** The badge variants, main.css's `.badge` classes. */ +enum class BadgeVariant { Dim, Accent, Ok, Warn, Error } + +/** + * One small tag: a machine spelling or a count — surface-2 ground, + * hairline border, mono (main.css's `.badge`). A toned variant colors + * the border and text; a status that a word alone can carry belongs in + * [StatusWord] instead. + */ @Composable -fun AppBadge(text: String, modifier: Modifier = Modifier, tint: Color = JadeiteText3) { +fun AppBadge(text: String, modifier: Modifier = Modifier, variant: BadgeVariant = BadgeVariant.Dim) { + val tone = when (variant) { + BadgeVariant.Dim -> null + BadgeVariant.Accent -> TogetherAccent + BadgeVariant.Ok -> TogetherOk + BadgeVariant.Warn -> TogetherWarn + BadgeVariant.Error -> TogetherDanger + } Surface( modifier = modifier, - shape = RoundedCornerShape(50), - color = Color.Transparent, - border = BorderStroke(1.dp, tint), + shape = RoundedCornerShape(6.dp), + color = if (variant == BadgeVariant.Accent) TogetherAccentSoft else TogetherSurface2, + border = BorderStroke( + 1.dp, + if (tone == null) TogetherBorderStrong else lerp(TogetherBorder, tone, 0.4f), + ), ) { Text( text, modifier = Modifier.padding(horizontal = 8.dp, vertical = 1.dp), style = MaterialTheme.typography.labelSmall, - fontFamily = JadeiteMono, - color = tint, + fontFamily = TogetherMono, + color = tone ?: TogetherMuted, ) } } /** - * The avatar square: the agent's picture when the claw has one, the - * accent mark (or a neutral one) otherwise — the same precedence as the - * web's `AgentAvatar`. + * The avatar circle: the agent's picture when the claw has one, the + * accent mark with the name's initial otherwise — the web `AgentAvatar`'s + * precedence, now round (main.css's `--r-avatar`). */ @Composable fun AppAvatar( - mark: String, - accent: Boolean, + glyph: String, modifier: Modifier = Modifier, size: Dp = 32.dp, image: ImageBitmap? = null, ) { - val shape = RoundedCornerShape(size / 4) Box( modifier = modifier .size(size) - .clip(shape) + .clip(CircleShape) .then( if (image == null) { - Modifier - .background(if (accent) JadeiteAccent else JadeiteElevated) - .border( - if (accent) 0.dp else 1.dp, - if (accent) Color.Transparent else JadeiteBorderStrong, - shape, - ) + Modifier.background(TogetherAccent) } else { Modifier }, @@ -134,10 +162,10 @@ fun AppAvatar( ) } else { Text( - mark, + glyph, style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.Bold, - color = if (accent) JadeiteOnAccent else JadeiteText2, + color = TogetherOnAccent, ) } } @@ -158,9 +186,14 @@ fun PageHeader( verticalAlignment = Alignment.CenterVertically, ) { Column(modifier = Modifier.weight(1f)) { - Text(title, style = MaterialTheme.typography.headlineSmall, fontWeight = FontWeight.Bold) + Text( + title, + style = MaterialTheme.typography.titleLarge, + fontSize = 20.sp, + fontWeight = FontWeight.SemiBold, + ) subtitle?.let { - Text(it, style = MaterialTheme.typography.bodySmall, color = JadeiteText3) + Text(it, style = MaterialTheme.typography.bodySmall, color = TogetherMuted) } } actions?.invoke(this) @@ -182,8 +215,8 @@ fun RhemaCard( Surface( modifier = modifier.fillMaxWidth(), shape = MaterialTheme.shapes.medium, - color = JadeiteSurface, - border = BorderStroke(1.dp, JadeiteBorder), + color = TogetherSurface, + border = BorderStroke(1.dp, TogetherBorder), ) { Column { Row( @@ -195,7 +228,7 @@ fun RhemaCard( Text( title, style = MaterialTheme.typography.titleMedium, - fontWeight = FontWeight.Bold, + fontWeight = FontWeight.SemiBold, modifier = Modifier.weight(1f, fill = false), ) meta?.let { @@ -203,11 +236,11 @@ fun RhemaCard( it, modifier = Modifier.padding(start = 12.dp), style = MaterialTheme.typography.bodySmall, - color = JadeiteText3, + color = TogetherMuted, ) } } - HorizontalDivider(color = JadeiteBorder) + HorizontalDivider(color = TogetherBorder) Column(content = content) } } @@ -226,7 +259,7 @@ fun CardRow( first: Boolean = false, control: (@Composable () -> Unit)? = null, ) { - if (!first) HorizontalDivider(color = JadeiteBorder) + if (!first) HorizontalDivider(color = TogetherBorder) Row( modifier = modifier .fillMaxWidth() @@ -237,7 +270,7 @@ fun CardRow( Column(modifier = Modifier.weight(1f)) { Text(title, style = MaterialTheme.typography.titleSmall, fontWeight = FontWeight.SemiBold) description?.let { - Text(it, style = MaterialTheme.typography.bodySmall, color = JadeiteText3) + Text(it, style = MaterialTheme.typography.bodySmall, color = TogetherMuted) } } control?.invoke() @@ -247,7 +280,9 @@ fun CardRow( /** Tones of [AppCallout]: the inline note vocabulary. */ enum class CalloutTone { Info, Ok, Warn, Error } -/** The toned inline callout — the "changes not applied" voice. */ +/** The toned inline callout — the "changes not applied" voice: surface-2 + * ground, a hairline border, and the tone on a one-sided border + * (main.css's `.callout`). */ @Composable fun AppCallout( tone: CalloutTone, @@ -256,45 +291,52 @@ fun AppCallout( title: String? = null, ) { val tint = when (tone) { - CalloutTone.Info -> JadeiteInfo - CalloutTone.Ok -> JadeiteOk - CalloutTone.Warn -> JadeiteWarn - CalloutTone.Error -> JadeiteError + CalloutTone.Info -> TogetherInfo + CalloutTone.Ok -> TogetherOk + CalloutTone.Warn -> TogetherWarn + CalloutTone.Error -> TogetherDanger } - val mark = when (tone) { - CalloutTone.Info -> "i" - CalloutTone.Ok -> "✓" - CalloutTone.Warn -> "↺" - CalloutTone.Error -> "✗" + val icon = when (tone) { + CalloutTone.Info -> Icons.Outlined.Info + CalloutTone.Ok -> Icons.Outlined.CheckCircle + CalloutTone.Warn -> Icons.Outlined.Refresh + CalloutTone.Error -> Icons.Outlined.Warning } Surface( modifier = modifier.fillMaxWidth(), shape = RoundedCornerShape(8.dp), - color = tint.copy(alpha = 0.08f), - border = BorderStroke(1.dp, JadeiteBorder), + color = TogetherSurface2, + border = BorderStroke(1.dp, TogetherBorder), ) { - Row( - modifier = Modifier.padding(12.dp), - horizontalArrangement = Arrangement.spacedBy(10.dp), - ) { - Text( - mark, - style = MaterialTheme.typography.titleSmall, - fontWeight = FontWeight.Bold, - color = tint, - ) - Column { - title?.let { - Text(it, style = MaterialTheme.typography.titleSmall, fontWeight = FontWeight.Bold) + Row(modifier = Modifier.height(IntrinsicSize.Min)) { + AccentBar(tint) + Row( + modifier = Modifier.padding(12.dp), + horizontalArrangement = Arrangement.spacedBy(10.dp), + ) { + Icon( + icon, + contentDescription = null, + tint = tint, + modifier = Modifier.size(16.dp), + ) + Column { + title?.let { + Text( + it, + style = MaterialTheme.typography.titleSmall, + fontWeight = FontWeight.SemiBold, + ) + } + Text(text, style = MaterialTheme.typography.bodySmall, color = TogetherMuted) } - Text(text, style = MaterialTheme.typography.bodySmall, color = JadeiteText2) } } } } /** - * The design's select: a sunken field that opens a menu. Options are + * The design's select: a field that opens a menu. Options are * (value, label) pairs; an empty-string value is a legitimate option * ("(provider default)"), which is why selection is by value. */ @@ -311,8 +353,8 @@ fun RhemaSelect( Box(modifier) { Surface( shape = RoundedCornerShape(8.dp), - color = JadeiteSunken, - border = BorderStroke(1.dp, JadeiteBorder), + color = TogetherSurface, + border = BorderStroke(1.dp, TogetherBorderStrong), modifier = Modifier .fillMaxWidth() .clip(RoundedCornerShape(8.dp)) @@ -328,15 +370,21 @@ fun RhemaSelect( style = MaterialTheme.typography.bodyMedium, maxLines = 1, overflow = TextOverflow.Ellipsis, - color = if (selected == null) JadeiteText3 else JadeiteText, + color = if (selected == null) TogetherFaint else TogetherText, + ) + Icon( + Icons.Filled.ArrowDropDown, + contentDescription = null, + tint = TogetherMuted, + modifier = Modifier.size(18.dp), ) - Text("▾", style = MaterialTheme.typography.bodySmall, color = JadeiteText3) } } DropdownMenu( expanded = open, onDismissRequest = { open = false }, - containerColor = JadeiteElevated, + containerColor = TogetherSurface, + shape = RoundedCornerShape(8.dp), ) { options.forEach { (value, optionLabel) -> DropdownMenuItem( @@ -344,8 +392,8 @@ fun RhemaSelect( Text( optionLabel, style = MaterialTheme.typography.bodyMedium, - fontFamily = if (value.isEmpty()) null else JadeiteMono, - color = if (value == selected) JadeiteAccentText else JadeiteText2, + fontFamily = if (value.isEmpty()) null else TogetherMono, + color = if (value == selected) TogetherAccent else TogetherText, ) }, onClick = { @@ -358,10 +406,12 @@ fun RhemaSelect( } } -/** The tool-card accent bar: the design's one-sided border. The parent row must size itself (IntrinsicSize.Min) for the bar to span it. */ +/** The one-sided border: a callout's tone, a turn card's accent. The + * parent row must size itself (IntrinsicSize.Min) for the bar to span + * it. */ @Composable -fun AccentBar(color: Color, modifier: Modifier = Modifier) { - Box(modifier = modifier.width(3.dp).fillMaxHeight().background(color)) +fun AccentBar(color: Color, modifier: Modifier = Modifier, width: Dp = 3.dp) { + Box(modifier = modifier.width(width).fillMaxHeight().background(color)) } /** A quiet icon action: transparent, dim, brightening on press. */ @@ -374,6 +424,6 @@ fun GhostIcon( onClick: () -> Unit, ) { IconButton(onClick = onClick, enabled = enabled, modifier = modifier) { - Icon(icon, contentDescription = contentDescription, tint = JadeiteText3) + Icon(icon, contentDescription = contentDescription, tint = TogetherMuted) } } diff --git a/android/app/src/main/java/rs/rhema/phone/ui/DiagnosticsScreen.kt b/android/app/src/main/java/rs/rhema/phone/ui/DiagnosticsScreen.kt index 55e7c94..76fe537 100644 --- a/android/app/src/main/java/rs/rhema/phone/ui/DiagnosticsScreen.kt +++ b/android/app/src/main/java/rs/rhema/phone/ui/DiagnosticsScreen.kt @@ -151,14 +151,14 @@ private fun WorkRow( WorkInfo.State.CANCELLED -> stringResource(R.string.diag_state_cancelled) } } - val tint = when { - infos == null -> JadeiteWarn - info == null && absentLabel == null -> JadeiteError + val tone = when { + infos == null -> StatusTone.Warn + info == null && absentLabel == null -> StatusTone.Error else -> when (info?.state) { - WorkInfo.State.RUNNING -> JadeiteOk - WorkInfo.State.FAILED, WorkInfo.State.CANCELLED -> JadeiteError - WorkInfo.State.BLOCKED -> JadeiteWarn - else -> JadeiteText3 + WorkInfo.State.RUNNING -> StatusTone.Ok + WorkInfo.State.FAILED, WorkInfo.State.CANCELLED -> StatusTone.Error + WorkInfo.State.BLOCKED -> StatusTone.Warn + else -> StatusTone.Idle } } val detail = when { @@ -174,7 +174,7 @@ private fun WorkRow( ).joinToString(" · ").ifEmpty { null } } CardRow(title = label, description = detail, first = first) { - AppBadge(stateLabel, tint = tint) + StatusWord(stateLabel, tone) } } @@ -214,21 +214,23 @@ private fun ClocksCard(container: AppContainer, resumeKey: Int) { description = stringResource(R.string.diag_clock_phone_desc), first = true, ) { - AppBadge(if (lastReportAt > 0) clock(lastReportAt) else stringResource(R.string.diag_clock_never)) + if (lastReportAt > 0) { + AppBadge(clock(lastReportAt)) + } else { + StatusWord(stringResource(R.string.diag_clock_never), StatusTone.Idle) + } } CardRow( title = stringResource(R.string.diag_clock_claw), description = stringResource(R.string.diag_clock_claw_desc), ) { val seen = clawSeen - AppBadge( - when { - clawError != null -> stringResource(R.string.diag_clock_unreachable) - seen == null -> stringResource(R.string.diag_state_checking) - seen < 0 -> stringResource(R.string.diag_clock_never) - else -> clock(seen) - }, - ) + when { + clawError != null -> StatusWord(stringResource(R.string.diag_clock_unreachable), StatusTone.Error) + seen == null -> StatusWord(stringResource(R.string.diag_state_checking), StatusTone.Warn) + seen < 0 -> StatusWord(stringResource(R.string.diag_clock_never), StatusTone.Idle) + else -> AppBadge(clock(seen)) + } } val currentError = clawError @@ -289,7 +291,7 @@ private fun ChecksCard(resumeKey: Int) { first = true, ) { if (powerOk) { - AppBadge(stringResource(R.string.diag_check_ok), tint = JadeiteOk) + StatusWord(stringResource(R.string.diag_check_ok), StatusTone.Ok) } else { OutlinedButton(onClick = { context.startActivity(Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS)) @@ -303,7 +305,7 @@ private fun ChecksCard(resumeKey: Int) { description = stringResource(R.string.diag_check_background_desc), ) { if (backgroundOk) { - AppBadge(stringResource(R.string.diag_check_ok), tint = JadeiteOk) + StatusWord(stringResource(R.string.diag_check_ok), StatusTone.Ok) } else { OutlinedButton(onClick = { openAppDetails(context) }) { Text(stringResource(R.string.diag_check_background_fix)) @@ -315,7 +317,7 @@ private fun ChecksCard(resumeKey: Int) { description = stringResource(R.string.diag_check_notifications_desc), ) { if (notificationsOk) { - AppBadge(stringResource(R.string.diag_check_ok), tint = JadeiteOk) + StatusWord(stringResource(R.string.diag_check_ok), StatusTone.Ok) } else { OutlinedButton(onClick = { context.startActivity( @@ -357,15 +359,15 @@ private fun LogCard(container: AppContainer) { Text( stringResource(R.string.diag_log_empty), style = MaterialTheme.typography.bodySmall, - color = JadeiteText3, + color = TogetherMuted, ) } else { entries.reversed().take(60).forEach { entry -> Text( clock(entry.at) + " " + entry.line, style = MaterialTheme.typography.bodySmall, - fontFamily = JadeiteMono, - color = JadeiteText2, + fontFamily = TogetherMono, + color = TogetherText, ) } } diff --git a/android/app/src/main/java/rs/rhema/phone/ui/Markdown.kt b/android/app/src/main/java/rs/rhema/phone/ui/Markdown.kt index 330ff05..61020d8 100644 --- a/android/app/src/main/java/rs/rhema/phone/ui/Markdown.kt +++ b/android/app/src/main/java/rs/rhema/phone/ui/Markdown.kt @@ -19,7 +19,7 @@ import com.mikepenz.markdown.model.markdownDimens // Agent replies are markdown; this renders them the way the web UI's // AppMarkdown does. The parser runs the GFM flavour: raw HTML in the // source stays literal, so model output cannot mount markup here. -// Code and links pin Jadeite tokens; everything else follows the theme. +// Code and links pin Together tokens; everything else follows the theme. // Headings step down from the Material display sizes: a chat reply is // not a document (the web styles ride the same scale). @Composable @@ -30,10 +30,10 @@ internal fun AgentMarkdown(text: String, modifier: Modifier = Modifier, streamin Markdown( if (streaming) text + "▊" else text, colors = markdownColor( - codeBackground = JadeiteSunken, - inlineCodeBackground = JadeiteSunken, - dividerColor = JadeiteBorder, - tableBackground = JadeiteSurface, + codeBackground = TogetherSurface2, + inlineCodeBackground = TogetherSurface2, + dividerColor = TogetherBorder, + tableBackground = TogetherSurface, ), typography = markdownTypography( h1 = base.copy(fontWeight = FontWeight.Bold), @@ -43,13 +43,13 @@ internal fun AgentMarkdown(text: String, modifier: Modifier = Modifier, streamin h5 = base.copy(fontSize = 13.sp, fontWeight = FontWeight.Bold), h6 = base.copy(fontSize = 13.sp, fontWeight = FontWeight.Bold), code = MaterialTheme.typography.bodySmall.copy( - fontFamily = JadeiteMono, - color = JadeiteText, + fontFamily = TogetherMono, + color = TogetherText, ), - inlineCode = base.copy(fontFamily = JadeiteMono, color = JadeiteText), + inlineCode = base.copy(fontFamily = TogetherMono, color = TogetherText), textLink = TextLinkStyles( style = SpanStyle( - color = JadeiteAccentText, + color = TogetherAccent, textDecoration = TextDecoration.Underline, ), ), diff --git a/android/app/src/main/java/rs/rhema/phone/ui/PhonesScreen.kt b/android/app/src/main/java/rs/rhema/phone/ui/PhonesScreen.kt index 82e02ce..0cddca5 100644 --- a/android/app/src/main/java/rs/rhema/phone/ui/PhonesScreen.kt +++ b/android/app/src/main/java/rs/rhema/phone/ui/PhonesScreen.kt @@ -99,12 +99,12 @@ fun PhonesCard(container: AppContainer) { list == null -> Text( stringResource(R.string.phones_loading), style = MaterialTheme.typography.bodySmall, - color = JadeiteText3, + color = TogetherMuted, ) list.isEmpty() -> Text( stringResource(R.string.phones_empty), style = MaterialTheme.typography.bodySmall, - color = JadeiteText3, + color = TogetherMuted, ) else -> { forgotName?.let { name -> @@ -221,11 +221,12 @@ fun ReportingCard() { } } -/** On reads as a quiet badge; off as a button into the system settings. */ +/** On reads as a word in the ok tone; off as a button into the system + * settings. */ @Composable private fun GrantControl(on: Boolean, onAllow: () -> Unit) { if (on) { - AppBadge(stringResource(R.string.reporting_on), tint = JadeiteOk) + StatusWord(stringResource(R.string.reporting_on), StatusTone.Ok) } else { OutlinedButton(onClick = onAllow) { Text(stringResource(R.string.reporting_allow)) diff --git a/android/app/src/main/java/rs/rhema/phone/ui/SessionsScreen.kt b/android/app/src/main/java/rs/rhema/phone/ui/SessionsScreen.kt index 6cb0243..6031d4e 100644 --- a/android/app/src/main/java/rs/rhema/phone/ui/SessionsScreen.kt +++ b/android/app/src/main/java/rs/rhema/phone/ui/SessionsScreen.kt @@ -35,9 +35,9 @@ import rs.rhema.phone.net.SessionInfo import kotlinx.coroutines.launch // The session inventory, the design's sidebar as a screen: grouped -// interactive-first rows with an honest state dot and the inbox depth. -// Displayed names drop the `interactive:` prefix; the full key is what -// gets opened. +// interactive-first rows whose meta line speaks in state words and the +// inbox depth. Displayed names drop the `interactive:` prefix; the full +// key is what gets opened. @Composable fun SessionsScreen( container: AppContainer, @@ -110,7 +110,7 @@ fun SessionsScreen( stringResource(R.string.sessions_empty), modifier = Modifier.padding(horizontal = 16.dp), style = MaterialTheme.typography.bodyMedium, - color = JadeiteText3, + color = TogetherMuted, ) visible != null -> SessionsList( sessions = visible, @@ -181,7 +181,6 @@ private fun SessionRow(session: SessionInfo, onClick: () -> Unit) { verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp), ) { - StatusDot(tone = stateTone(session.state)) Column(modifier = Modifier.weight(1f)) { Text( session.key.removePrefix("interactive:"), @@ -189,26 +188,27 @@ private fun SessionRow(session: SessionInfo, onClick: () -> Unit) { maxLines = 1, overflow = androidx.compose.ui.text.style.TextOverflow.Ellipsis, ) - Text( - listOfNotNull( - session.state, - session.revision?.let { "rev $it" }, - ).joinToString(" · "), - style = MaterialTheme.typography.bodySmall, - fontFamily = JadeiteMono, - color = JadeiteText3, - ) - } - val depth = session.inboxDepth - if (depth != null && depth > 0) { - AppBadge(depth.toString(), tint = JadeiteInfo) + // Status is a word: the state in its tone, the inbox depth + // queued beside it — the web sidebar's meta line. + val depth = session.inboxDepth ?: 0 + if (session.state != null || depth > 0) { + Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) { + when (session.state) { + "leased" -> StatusWord( + stringResource(R.string.sessions_state_running), + StatusTone.Ok, + ) + "reacquire" -> StatusWord( + stringResource(R.string.sessions_state_waiting), + StatusTone.Warn, + ) + else -> session.state?.let { StatusWord(it, StatusTone.Idle) } + } + if (depth > 0) { + StatusWord(stringResource(R.string.sessions_queued_fmt, depth), StatusTone.Idle) + } + } + } } } } - -/** Leased keys are alive, reacquiring ones are troubled, the rest idle. */ -private fun stateTone(state: String?): DotTone = when (state) { - "leased" -> DotTone.Ok - "reacquire" -> DotTone.Warn - else -> DotTone.Idle -} diff --git a/android/app/src/main/java/rs/rhema/phone/ui/SettingsScreen.kt b/android/app/src/main/java/rs/rhema/phone/ui/SettingsScreen.kt index d43c657..a9d5d4e 100644 --- a/android/app/src/main/java/rs/rhema/phone/ui/SettingsScreen.kt +++ b/android/app/src/main/java/rs/rhema/phone/ui/SettingsScreen.kt @@ -14,6 +14,7 @@ import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.ArrowBack +import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight import androidx.compose.material3.Button import androidx.compose.material3.Icon import androidx.compose.material3.IconButton @@ -164,10 +165,14 @@ private fun SettingsNav(onSelect: (String) -> Unit) { Text( stringResource(entry.descRes), style = MaterialTheme.typography.bodySmall, - color = JadeiteText3, + color = TogetherMuted, ) } - Text("›", style = MaterialTheme.typography.titleMedium, color = JadeiteText3) + Icon( + Icons.AutoMirrored.Filled.KeyboardArrowRight, + contentDescription = null, + tint = TogetherFaint, + ) } } } @@ -187,7 +192,7 @@ private fun SettingsPage(title: String, onBack: () -> Unit, content: @Composable Icon( Icons.AutoMirrored.Filled.ArrowBack, contentDescription = stringResource(R.string.settings_back), - tint = JadeiteText2, + tint = TogetherMuted, ) } Text(title, style = MaterialTheme.typography.headlineSmall, fontWeight = FontWeight.Bold) @@ -227,7 +232,7 @@ private fun ConnectionPage(container: AppContainer, onConnected: () -> Unit, onB Icon( Icons.AutoMirrored.Filled.ArrowBack, contentDescription = stringResource(R.string.settings_back), - tint = JadeiteText2, + tint = TogetherMuted, ) } Text( @@ -290,7 +295,7 @@ private fun ConnectionCard( enabled = !busy, modifier = Modifier.fillMaxWidth(), shape = MaterialTheme.shapes.small, - colors = sunkenFieldColors(), + colors = surfaceFieldColors(), ) OutlinedTextField( value = token, @@ -301,7 +306,7 @@ private fun ConnectionCard( enabled = !busy, modifier = Modifier.fillMaxWidth(), shape = MaterialTheme.shapes.small, - colors = sunkenFieldColors(), + colors = surfaceFieldColors(), ) Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) { Button(enabled = !busy && baseUrl.isNotBlank(), onClick = onConnect) { @@ -320,13 +325,13 @@ private fun ConnectionCard( Text( stringResource(R.string.device_id_fmt, deviceId), style = MaterialTheme.typography.bodySmall, - fontFamily = JadeiteMono, - color = JadeiteText3, + fontFamily = TogetherMono, + color = TogetherMuted, ) Text( stringResource(R.string.settings_hint), style = MaterialTheme.typography.bodySmall, - color = JadeiteText3, + color = TogetherMuted, ) } } @@ -405,13 +410,13 @@ private fun ProvidersCard(container: AppContainer) { currentState == null -> Text( stringResource(R.string.providers_loading), style = MaterialTheme.typography.bodySmall, - color = JadeiteText3, + color = TogetherMuted, ) else -> { Text( stringResource(R.string.providers_field_provider), style = MaterialTheme.typography.labelMedium, - color = JadeiteText3, + color = TogetherMuted, ) RhemaSelect( selected = draftProvider, @@ -427,7 +432,7 @@ private fun ProvidersCard(container: AppContainer) { Text( stringResource(R.string.providers_field_model), style = MaterialTheme.typography.labelMedium, - color = JadeiteText3, + color = TogetherMuted, ) RhemaSelect( selected = draftModel, @@ -444,7 +449,7 @@ private fun ProvidersCard(container: AppContainer) { Text( stringResource(R.string.providers_none), style = MaterialTheme.typography.bodySmall, - color = JadeiteText3, + color = TogetherMuted, ) } @@ -553,14 +558,15 @@ private sealed interface ListingState { private const val DEFAULT_MODEL = "" -/** The design's input voice: sunken ground, hairline border, accent focus. */ +/** The design's input voice: surface ground, strong hairline, accent + * focus — main.css's `input`. */ @Composable -private fun sunkenFieldColors() = OutlinedTextFieldDefaults.colors( - focusedBorderColor = JadeiteAccent, - unfocusedBorderColor = JadeiteBorder, - focusedContainerColor = JadeiteSunken, - unfocusedContainerColor = JadeiteSunken, - cursorColor = JadeiteAccentText, - focusedTextColor = JadeiteText, - unfocusedTextColor = JadeiteText, +private fun surfaceFieldColors() = OutlinedTextFieldDefaults.colors( + focusedBorderColor = TogetherAccent, + unfocusedBorderColor = TogetherBorderStrong, + focusedContainerColor = TogetherSurface, + unfocusedContainerColor = TogetherSurface, + cursorColor = TogetherAccent, + focusedTextColor = TogetherText, + unfocusedTextColor = TogetherText, ) diff --git a/android/app/src/main/java/rs/rhema/phone/ui/Theme.kt b/android/app/src/main/java/rs/rhema/phone/ui/Theme.kt index fc70f9b..4684010 100644 --- a/android/app/src/main/java/rs/rhema/phone/ui/Theme.kt +++ b/android/app/src/main/java/rs/rhema/phone/ui/Theme.kt @@ -1,78 +1,169 @@ package rs.rhema.phone.ui +import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.ColorScheme import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Shapes import androidx.compose.material3.darkColorScheme +import androidx.compose.material3.lightColorScheme +import androidx.compose.material3.Shapes import androidx.compose.runtime.Composable +import androidx.compose.runtime.CompositionLocalProvider +import androidx.compose.runtime.staticCompositionLocalOf import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.unit.dp -// The Jadeite dark tokens, lifted from crates/rhema-code/src/palette.rs -// DARK: one design system across the TUI, the web UI, and this app. -// Dark is the design's primary; there is deliberately no light scheme -// and no dynamic color — the palette is the brand. -/** The design's dark ground; also the system-bar scrim. */ -internal val JadeiteGround = Color(0xFF0F1413) -internal val JadeiteSurface = Color(0xFF171D1B) -internal val JadeiteElevated = Color(0xFF1F2624) -internal val JadeiteSunken = Color(0xFF0A0F0E) -internal val JadeiteBorder = Color(0xFF28312E) -internal val JadeiteBorderStrong = Color(0xFF3D4844) -internal val JadeiteText = Color(0xFFEEF3F1) -internal val JadeiteText2 = Color(0xFFB9C6C1) -internal val JadeiteText3 = Color(0xFF87948F) -internal val JadeiteAccent = Color(0xFF35A882) -internal val JadeiteAccentText = Color(0xFF64C9A3) -internal val JadeiteOnAccent = Color(0xFF07110D) -internal val JadeiteOk = Color(0xFF4FBF94) -internal val JadeiteWarn = Color(0xFFD9A643) -internal val JadeiteError = Color(0xFFE4687A) -internal val JadeiteInfo = Color(0xFF8FA6B8) +// The Rhema Together tokens, lifted from web/claw/app/assets/css/main.css: +// a warm paper ground, white cards, one jade accent, and status color only +// where a state needs it — one design system across the web UI and this +// app. Light is the design's default; the dark values follow the operating +// system, as the web's `prefers-color-scheme` does. There is no dynamic +// color: the palette is the brand. -/** Machine spellings — keys, model ids, outcomes — render mono. */ -internal val JadeiteMono: FontFamily = FontFamily.Monospace +/** The light ground; also the light system-bar scrim. */ +internal val TogetherGroundLight = Color(0xFFF7F6F3) -private val JadeiteDark = darkColorScheme( - primary = JadeiteAccent, - onPrimary = JadeiteOnAccent, - primaryContainer = JadeiteElevated, - onPrimaryContainer = JadeiteAccentText, - secondary = JadeiteAccentText, - onSecondary = JadeiteOnAccent, - tertiary = JadeiteInfo, - background = JadeiteGround, - onBackground = JadeiteText, - surface = JadeiteSurface, - onSurface = JadeiteText, - surfaceVariant = JadeiteElevated, - onSurfaceVariant = JadeiteText2, - surfaceContainerLowest = JadeiteGround, - surfaceContainerLow = JadeiteSurface, - surfaceContainer = JadeiteSurface, - surfaceContainerHigh = JadeiteElevated, - surfaceContainerHighest = JadeiteElevated, - outline = JadeiteBorder, - outlineVariant = JadeiteBorderStrong, - error = JadeiteError, +/** The dark ground; also the dark system-bar scrim. */ +internal val TogetherGroundDark = Color(0xFF12110F) + +/** One palette's values, spelled the way main.css names them. */ +private data class TogetherColors( + val ground: Color, + val surface: Color, + val surface2: Color, + val border: Color, + val borderStrong: Color, + val text: Color, + val muted: Color, + val faint: Color, + val accent: Color, + val accentSoft: Color, + val onAccent: Color, + val ok: Color, + val warn: Color, + val danger: Color, + val info: Color, ) -// The design's shape language: soft cards on a hairline grid, controls a -// step softer. Default Material radii read as someone else's app. -private val JadeiteShapes = Shapes( +private val LightColors = TogetherColors( + ground = Color(0xFFF7F6F3), + surface = Color(0xFFFFFFFF), + surface2 = Color(0xFFF1EFE9), + border = Color(0xFFE4E0D8), + borderStrong = Color(0xFFD3CEC3), + text = Color(0xFF1F1D1A), + muted = Color(0xFF736D63), + faint = Color(0xFF9A9388), + accent = Color(0xFF2F6F5E), + accentSoft = Color(0xFFE7F1ED), + onAccent = Color(0xFFFFFFFF), + ok = Color(0xFF2F6F5E), + warn = Color(0xFF8A6519), + danger = Color(0xFFA33A2F), + info = Color(0xFF4F5F8F), +) + +private val DarkColors = TogetherColors( + ground = Color(0xFF12110F), + surface = Color(0xFF1A1917), + surface2 = Color(0xFF22201D), + border = Color(0xFF272521), + borderStrong = Color(0xFF3A3733), + text = Color(0xFFF2F0EC), + muted = Color(0xFFA49D92), + faint = Color(0xFF7D766C), + accent = Color(0xFF58A58C), + accentSoft = Color(0xFF1E2F2A), + onAccent = Color(0xFF12110F), + ok = Color(0xFF58A58C), + warn = Color(0xFFC9A45C), + danger = Color(0xFFD07366), + info = Color(0xFF8B9BD0), +) + +private val LocalTogetherColors = staticCompositionLocalOf { LightColors } + +/** Machine spellings — keys, model ids, outcomes — render mono. The web + * bundles FiraCode Nerd Font Mono; the phone keeps the platform mono, + * which its small utility text reads fine in. */ +internal val TogetherMono: FontFamily = FontFamily.Monospace + +// The tokens. Reads resolve to the scheme the OS asked for. +internal val TogetherGround: Color @Composable get() = LocalTogetherColors.current.ground +internal val TogetherSurface: Color @Composable get() = LocalTogetherColors.current.surface +internal val TogetherSurface2: Color @Composable get() = LocalTogetherColors.current.surface2 +internal val TogetherBorder: Color @Composable get() = LocalTogetherColors.current.border +internal val TogetherBorderStrong: Color @Composable get() = LocalTogetherColors.current.borderStrong +internal val TogetherText: Color @Composable get() = LocalTogetherColors.current.text +internal val TogetherMuted: Color @Composable get() = LocalTogetherColors.current.muted +internal val TogetherFaint: Color @Composable get() = LocalTogetherColors.current.faint +internal val TogetherAccent: Color @Composable get() = LocalTogetherColors.current.accent +internal val TogetherAccentSoft: Color @Composable get() = LocalTogetherColors.current.accentSoft +internal val TogetherOnAccent: Color @Composable get() = LocalTogetherColors.current.onAccent +internal val TogetherOk: Color @Composable get() = LocalTogetherColors.current.ok +internal val TogetherWarn: Color @Composable get() = LocalTogetherColors.current.warn +internal val TogetherDanger: Color @Composable get() = LocalTogetherColors.current.danger +internal val TogetherInfo: Color @Composable get() = LocalTogetherColors.current.info + +/** Material slots filled from the palette, so the stock components (menus, + * dialogs, text fields, the spinner) speak the same colors. */ +private fun TogetherColors.toColorScheme(dark: Boolean): ColorScheme { + val base = if (dark) darkColorScheme() else lightColorScheme() + return base.copy( + primary = accent, + onPrimary = onAccent, + primaryContainer = accentSoft, + onPrimaryContainer = accent, + secondary = accent, + onSecondary = onAccent, + tertiary = info, + onTertiary = onAccent, + background = ground, + onBackground = text, + surface = surface, + onSurface = text, + surfaceVariant = surface2, + onSurfaceVariant = muted, + surfaceContainerLowest = ground, + surfaceContainerLow = surface, + surfaceContainer = surface, + surfaceContainerHigh = surface2, + surfaceContainerHighest = surface2, + surfaceTint = surface, + outline = borderStrong, + outlineVariant = border, + error = danger, + onError = onAccent, + errorContainer = surface2, + onErrorContainer = danger, + inverseSurface = text, + inverseOnSurface = ground, + inversePrimary = accent, + scrim = Color.Black, + ) +} + +// The design's shape language: cards a 10, controls an 8, badges a 6 — +// main.css's --r-card, --r-control, and the badge radius. +private val TogetherShapes = Shapes( extraSmall = RoundedCornerShape(6.dp), small = RoundedCornerShape(8.dp), medium = RoundedCornerShape(10.dp), large = RoundedCornerShape(14.dp), ) -/** The app's theme: Jadeite dark, always — matching the TUI and the web UI. */ +/** The app's theme: Together's light scheme, the dark one while the OS + * asks for dark — matching the web UI. */ @Composable fun RhemaTheme(content: @Composable () -> Unit) { - MaterialTheme( - colorScheme = JadeiteDark, - shapes = JadeiteShapes, - content = content, - ) + val dark = isSystemInDarkTheme() + val colors = if (dark) DarkColors else LightColors + CompositionLocalProvider(LocalTogetherColors provides colors) { + MaterialTheme( + colorScheme = colors.toColorScheme(dark), + shapes = TogetherShapes, + content = content, + ) + } } diff --git a/android/app/src/main/res/values-night/colors.xml b/android/app/src/main/res/values-night/colors.xml new file mode 100644 index 0000000..0d9c97e --- /dev/null +++ b/android/app/src/main/res/values-night/colors.xml @@ -0,0 +1,5 @@ + + + + #FF12110F + diff --git a/android/app/src/main/res/values-night/themes.xml b/android/app/src/main/res/values-night/themes.xml new file mode 100644 index 0000000..c404bab --- /dev/null +++ b/android/app/src/main/res/values-night/themes.xml @@ -0,0 +1,10 @@ + + + + + diff --git a/android/app/src/main/res/values/colors.xml b/android/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..e2c1c57 --- /dev/null +++ b/android/app/src/main/res/values/colors.xml @@ -0,0 +1,6 @@ + + + + #FFF7F6F3 + diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index 4e85894..e2607d6 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -22,6 +22,9 @@ The claw returned HTTP %1$d Cannot reach the claw: %1$s HTTP 401 means the bearer token is wrong or missing. Update it in Settings. + running + waiting + %1$d queued Back Send @@ -32,8 +35,9 @@ disconnected: %1$s unauthorized; check the token in Settings Send failed: %1$s - tool running: %1$s - tool: %1$s + you + dispatch + %1$s is working Download and open loading earlier turns downloading… @@ -51,6 +55,8 @@ %1$s: not a png, jpeg, gif, or webp image %1$s: could not be read Attached image + Secret + Phone control The secret the agent asked for Send secret Approve diff --git a/android/app/src/main/res/values/themes.xml b/android/app/src/main/res/values/themes.xml new file mode 100644 index 0000000..f258cad --- /dev/null +++ b/android/app/src/main/res/values/themes.xml @@ -0,0 +1,11 @@ + + + + +