ed96f6235dd3

feat: Complete entry detail browser parity pass (v2.3.4)

- Add inline title, primary URL, and additional URL editing on entry detail - Add browser-parity homograph and punycode URL warning - Surface passkey/passkey-only and canary metadata on detail - Cover domain, passkey, and detail helper behavior with tests

time
2026-06-25 23:40 UTC · 5 months ago
machine
koh2
parent
1541d408acb4
10 files app/build.gradle+2 −2app/src/main/java/com/peachpasswords/shared/DomainUtils.kt+15 −0app/src/main/java/com/peachpasswords/ui/vault/AdditionalUrlsDetail.kt+73 −9app/src/main/java/com/peachpasswords/ui/vault/EditableFieldRow.kt+5 −3app/src/main/java/com/peachpasswords/ui/vault/EntryDetailScreen.kt+178 −3app/src/main/java/com/peachpasswords/ui/vault/EntryDetailViewModel.kt+15 −0app/src/main/java/com/peachpasswords/vault/VaultEntry.kt+1 −0app/src/test/java/com/peachpasswords/shared/DomainUtilsTest.kt+22 −0app/src/test/java/com/peachpasswords/ui/vault/EntryDetailParityTest.kt+34 −0app/src/test/java/com/peachpasswords/vault/PasskeyEntryTest.kt+39 −0
app/build.gradle+2 −2
@@ -16,8 +16,8 @@1616         applicationId "com.peachpasswords"1717         minSdk 261818         targetSdk 3519-        versionCode 23030020-        versionName "2.3.3"19+        versionCode 23040020+        versionName "2.3.4"2121 2222         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"2323         vectorDrawables {

view file

app/src/main/java/com/peachpasswords/shared/DomainUtils.kt+15 −0
@@ -20,3 +20,18 @@2020         url2121     }2222 }23+24+/**25+ * Browser parity with `shared/domain.ts::detectHomograph`: true when the host26+ * contains non-ASCII characters or a punycode `xn--` label. This is warning-only;27+ * matching/keying remains handled by [extractDomain].28+ */29+fun detectHomograph(url: String): Boolean {30+    return try {31+        val normalized = if (url.contains("://")) url else "https://$url"32+        val host = java.net.URL(normalized).host33+        host.any { it.code > 0x7F } || host.split('.').any { it.startsWith("xn--", ignoreCase = true) }34+    } catch (_: Exception) {35+        false36+    }37+}

view file

app/src/main/java/com/peachpasswords/ui/vault/AdditionalUrlsDetail.kt+73 −9
@@ -21,6 +21,7 @@2121 import androidx.compose.foundation.layout.size2222 import androidx.compose.foundation.layout.width2323 import androidx.compose.foundation.shape.RoundedCornerShape24+import androidx.compose.foundation.text.BasicTextField2425 import androidx.compose.material.icons.Icons2526 import androidx.compose.material.icons.automirrored.rounded.OpenInNew2627 import androidx.compose.material.icons.rounded.Check@@ -29,6 +30,7 @@2930 import androidx.compose.material3.Text3031 import androidx.compose.runtime.Composable3132 import androidx.compose.runtime.getValue33+import androidx.compose.runtime.mutableStateOf3234 import androidx.compose.ui.Alignment3335 import androidx.compose.ui.Modifier3436 import androidx.compose.ui.draw.clip@@ -37,11 +39,14 @@3739 import androidx.compose.ui.geometry.Size3840 import androidx.compose.ui.graphics.Brush3941 import androidx.compose.ui.graphics.Color42+import androidx.compose.ui.graphics.SolidColor4043 import androidx.compose.ui.platform.LocalContext4144 import androidx.compose.ui.text.TextStyle4245 import androidx.compose.ui.unit.dp4346 import androidx.compose.ui.unit.em4447 import androidx.compose.ui.unit.sp48+import androidx.compose.runtime.remember49+import androidx.compose.runtime.setValue4550 import com.peachpasswords.ui.theme.LocalPeachAccent4651 import com.peachpasswords.ui.theme.LocalReduceMotion4752 import com.peachpasswords.ui.theme.peachColors@@ -61,23 +66,82 @@6166     urls: List<String>,6267     copiedField: String?,6368     onCopy: (key: String, value: String) -> Unit,69+    onSave: (index: Int, value: String) -> Unit = { _, _ -> },6470 ) {6571     val context = LocalContext.current6672     urls.forEachIndexed { index, url ->6773         if (url.isNotBlank()) {6874             val key = additionalUrlCopyKey(index)75+            var editing by remember(url) { mutableStateOf(false) }76+            var draft by remember(url) { mutableStateOf(url) }6977             AdditionalUrlFieldShell(label = "URL ${index + 2}") {70-                Text(71-                    url,72-                    color = peachColors.T0,73-                    style = PeachType.bodyMono,74-                    modifier = Modifier.weight(1f),75-                )76-                OpenInBrowserButton(onClick = { openUrlInBrowser(context, url) })77-                Spacer(Modifier.width(4.dp))78-                AdditionalUrlCopyButton(copied = copiedField == key, onCopy = { onCopy(key, url) })78+                if (editing) {79+                    Column(Modifier.weight(1f)) {80+                        AdditionalUrlInlineField(81+                            draft = draft,82+                            onDraftChange = { draft = it },83+                            modifier = Modifier.fillMaxWidth(),84+                        )85+                        Spacer(Modifier.height(8.dp))86+                        AdditionalUrlSaveCancelRow(87+                            onSave = { onSave(index, draft); editing = false },88+                            onCancel = { draft = url; editing = false },89+                        )90+                    }91+                } else {92+                    Text(93+                        url,94+                        color = peachColors.T0,95+                        style = PeachType.bodyMono,96+                        modifier = Modifier.weight(1f).clickable { draft = url; editing = true },97+                    )98+                    OpenInBrowserButton(onClick = { openUrlInBrowser(context, url) })99+                    Spacer(Modifier.width(4.dp))100+                    AdditionalUrlCopyButton(copied = copiedField == key, onCopy = { onCopy(key, url) })101+                }79102             }80103         }104+    }105+}106+107+@Composable108+private fun AdditionalUrlInlineField(109+    draft: String,110+    onDraftChange: (String) -> Unit,111+    modifier: Modifier = Modifier,112+) {113+    val accent = LocalPeachAccent.current114+    BasicTextField(115+        value = draft,116+        onValueChange = onDraftChange,117+        singleLine = true,118+        textStyle = PeachType.bodyMono.copy(color = peachColors.T0),119+        cursorBrush = SolidColor(accent),120+        modifier = modifier121+            .padding(bottom = 4.dp)122+            .drawBehind {123+                drawLine(124+                    color = accent,125+                    start = Offset(0f, size.height),126+                    end = Offset(size.width, size.height),127+                    strokeWidth = 1.dp.toPx(),128+                )129+            },130+    )131+}132+133+@Composable134+private fun AdditionalUrlSaveCancelRow(onSave: () -> Unit, onCancel: () -> Unit) {135+    val accent = LocalPeachAccent.current136+    Row(horizontalArrangement = Arrangement.spacedBy(16.dp), verticalAlignment = Alignment.CenterVertically) {137+        Text(138+            "✓ save", color = accent, style = PeachType.labelMono,139+            modifier = Modifier.clip(RoundedCornerShape(6.dp)).clickable(onClick = onSave).padding(vertical = 4.dp),140+        )141+        Text(142+            "✗", color = peachColors.T2, style = PeachType.labelMono,143+            modifier = Modifier.clip(RoundedCornerShape(6.dp)).clickable(onClick = onCancel).padding(horizontal = 6.dp, vertical = 4.dp),144+        )81145     }82146 }83147 

view file

app/src/main/java/com/peachpasswords/ui/vault/EditableFieldRow.kt+5 −3
@@ -82,21 +82,23 @@8282     suggestions: List<String> = emptyList(),8383     mono: Boolean = true,8484     singleLine: Boolean = true,85+    placeholder: String = "",8586 ) {8687     var editing by remember(value) { mutableStateOf(false) }8788     var draft by remember(value) { mutableStateOf(value) }8889 8990     FieldShell(label) {9091         if (!editing) {92+            val isEmpty = value.isBlank()9193             Text(92-                value,93-                color = peachColors.T0,94+                if (isEmpty) placeholder else value,95+                color = if (isEmpty) peachColors.T2 else peachColors.T0,9496                 style = if (mono) PeachType.bodyMono else PeachType.body,9597                 modifier = Modifier9698                     .weight(1f)9799                     .clickable { draft = value; editing = true },98100             )99-            CopyButton(copied, onCopy)101+            if (!isEmpty) CopyButton(copied, onCopy)100102         } else {101103             InlineEditor(102104                 draft = draft,

view file

app/src/main/java/com/peachpasswords/ui/vault/EntryDetailScreen.kt+178 −3
@@ -31,6 +31,7 @@3131 import androidx.compose.foundation.rememberScrollState3232 import androidx.compose.foundation.shape.CircleShape3333 import androidx.compose.foundation.shape.RoundedCornerShape34+import androidx.compose.foundation.text.BasicTextField3435 import androidx.compose.material.icons.rounded.Check3536 import androidx.compose.material.icons.rounded.ContentCopy3637 import androidx.compose.material.icons.rounded.Search@@ -57,6 +58,7 @@5758 import androidx.compose.ui.geometry.Size5859 import androidx.compose.ui.graphics.Brush5960 import androidx.compose.ui.graphics.Color61+import androidx.compose.ui.graphics.SolidColor6062 import androidx.compose.ui.graphics.graphicsLayer6163 import androidx.compose.ui.platform.LocalContext6264 import androidx.compose.ui.input.pointer.pointerInput@@ -69,6 +71,7 @@6971 import androidx.compose.runtime.collectAsState7072 import androidx.fragment.app.FragmentActivity7173 import androidx.hilt.navigation.compose.hiltViewModel74+import com.peachpasswords.shared.detectHomograph7275 import com.peachpasswords.ui.PeachNav7376 import com.peachpasswords.ui.components.CharEnterText7477 import com.peachpasswords.ui.components.CopyButton@@ -82,8 +85,11 @@8285 import com.peachpasswords.ui.theme.ShellBackground8386 import com.peachpasswords.vault.TOTPGenerator8487 import com.peachpasswords.vault.hasTOTP88+import com.peachpasswords.vault.hasPasskey8589 import com.peachpasswords.vault.isBreach8690 import com.peachpasswords.vault.isCard91+import com.peachpasswords.vault.isNote92+import com.peachpasswords.vault.isPasskeyOnly8793 8894 @Composable8995 fun EntryDetailScreen(@@ -191,6 +197,9 @@191197                         )192198                     }193199                 }200+                if (entryHasHomographWarning(e)) {201+                    HomographWarning()202+                }194203 195204                 // Hero — ghost PeachScript watermark behind the entry name. The full196205                 // title is drawn (not just its first letter); a long title overflows@@ -206,9 +215,9 @@206215                         modifier = Modifier.align(Alignment.TopCenter).offset(y = (-16).dp),207216                     )208217                     Column(Modifier.fillMaxWidth().padding(top = 18.dp)) {209-                        CharEnterText(210-                            text = e.title,211-                            style = PeachType.entryNameHero.copy(color = peachColors.T0),218+                        EditableTitleHero(219+                            title = e.title,220+                            onSave = { vm.updateField("title", it) },212221                         )213222                         Spacer(Modifier.height(8.dp))214223                         Text(@@ -241,6 +250,15 @@241250                         copyButton = { copied, onCopy -> CopyButton(copied, onCopy) },242251                     )243252                 } else {253+                    if (!e.isNote()) {254+                        EditableFieldRow(255+                            label = "url", field = "url", value = e.url.orEmpty(),256+                            copied = copiedField == "url",257+                            onCopy = { vm.copy("url", e.url) },258+                            onSave = { vm.updateField("url", it) },259+                            placeholder = "add url",260+                        )261+                    }244262                     e.username?.takeIf { it.isNotBlank() }?.let { v ->245263                         EditableFieldRow(246264                             label = "username", field = "username", value = v,@@ -264,8 +282,12 @@264282                             urls = urls,265283                             copiedField = copiedField,266284                             onCopy = { key, value -> vm.copy(key, value) },285+                            onSave = { index, value -> vm.updateAdditionalUrl(index, value) },267286                         )268287                     }288+                    if (e.hasPasskey()) {289+                        PasskeyDetailSection(e)290+                    }269291                     e.password?.takeIf { it.isNotBlank() }?.let { pw ->270292                         EditablePasswordRow(271293                             value = pw,@@ -318,6 +340,14 @@318340                         onEditTags = { onNavigate(PeachNav.EntryEdit(e.id)) },319341                     )320342                 }343+                e.canary?.let { canary ->344+                    CanaryDetailSection(345+                        label = canary.label,346+                        webhookUrl = canary.webhookUrl,347+                        lastPinged = canary.lastPinged,348+                        pingCount = canary.pingCount,349+                    )350+                }321351 322352                 Spacer(Modifier.height(24.dp))323353             }@@ -346,6 +376,134 @@346376 }347377 348378 @Composable379+private fun EditableTitleHero(title: String, onSave: (String) -> Unit) {380+    val accent = LocalPeachAccent.current381+    var editing by remember(title) { mutableStateOf(false) }382+    var draft by remember(title) { mutableStateOf(title) }383+    if (!editing) {384+        Box(Modifier.fillMaxWidth().clickable { draft = title; editing = true }) {385+            CharEnterText(386+                text = title,387+                style = PeachType.entryNameHero.copy(color = peachColors.T0),388+            )389+        }390+        return391+    }392+    Column(Modifier.fillMaxWidth()) {393+        BasicTextField(394+            value = draft,395+            onValueChange = { draft = it },396+            singleLine = true,397+            textStyle = PeachType.entryNameHero.copy(color = peachColors.T0),398+            cursorBrush = SolidColor(accent),399+            modifier = Modifier.fillMaxWidth().drawBehind {400+                drawLine(401+                    color = accent,402+                    start = Offset(0f, size.height),403+                    end = Offset(size.width, size.height),404+                    strokeWidth = 1.dp.toPx(),405+                )406+            },407+        )408+        Spacer(Modifier.height(8.dp))409+        Row(horizontalArrangement = Arrangement.spacedBy(16.dp), verticalAlignment = Alignment.CenterVertically) {410+            Text(411+                "✓ save", color = accent, style = PeachType.labelMono,412+                modifier = Modifier.clip(RoundedCornerShape(6.dp)).clickable {413+                    onSave(draft)414+                    editing = false415+                }.padding(vertical = 4.dp),416+            )417+            Text(418+                "✗", color = peachColors.T2, style = PeachType.labelMono,419+                modifier = Modifier.clip(RoundedCornerShape(6.dp)).clickable {420+                    draft = title421+                    editing = false422+                }.padding(horizontal = 6.dp, vertical = 4.dp),423+            )424+        }425+    }426+}427+428+@Composable429+private fun HomographWarning() {430+    Row(431+        Modifier.fillMaxWidth()432+            .padding(top = 8.dp)433+            .clip(RoundedCornerShape(8.dp))434+            .background(peachColors.BreachBg)435+            .border(1.dp, peachColors.BreachBorder, RoundedCornerShape(8.dp))436+            .padding(horizontal = 12.dp, vertical = 9.dp),437+        verticalAlignment = Alignment.CenterVertically,438+    ) {439+        Text("!", color = peachColors.Breach, style = PeachType.labelMono)440+        Spacer(Modifier.width(10.dp))441+        Text(442+            "This URL contains non-ASCII or punycode characters.",443+            color = peachColors.Breach,444+            style = PeachType.labelMono,445+            modifier = Modifier.weight(1f),446+        )447+    }448+}449+450+@Composable451+private fun PasskeyDetailSection(entry: com.peachpasswords.vault.VaultEntry) {452+    val passkey = entry.passkey ?: return453+    FieldShell(if (entry.isPasskeyOnly()) "passkey only" else "passkey") {454+        Column(Modifier.weight(1f)) {455+            Text(456+                passkey.rpName?.takeIf { it.isNotBlank() } ?: passkey.rpId,457+                color = peachColors.T0,458+                style = PeachType.body,459+            )460+            Text(461+                listOfNotNull(462+                    passkey.rpId,463+                    passkey.userDisplayName?.takeIf { it.isNotBlank() } ?: passkey.userName,464+                ).joinToString(" · "),465+                color = peachColors.T2,466+                style = PeachType.labelMono,467+            )468+            Text(469+                "credential ${shortCredential(passkey.credentialId)} · sign count ${passkey.signCount}",470+                color = peachColors.T2,471+                style = PeachType.labelMono,472+                modifier = Modifier.padding(top = 3.dp),473+            )474+        }475+    }476+}477+478+@Composable479+private fun CanaryDetailSection(label: String?, webhookUrl: String, lastPinged: Long?, pingCount: Int?) {480+    FieldShell("canary alert") {481+        Column(Modifier.weight(1f)) {482+            Text(483+                label?.takeIf { it.isNotBlank() } ?: "Enabled",484+                color = peachColors.T0,485+                style = PeachType.body,486+            )487+            Text(488+                webhookUrl,489+                color = peachColors.T2,490+                style = PeachType.labelMono,491+                maxLines = 1,492+                overflow = TextOverflow.Ellipsis,493+            )494+            if (lastPinged != null || pingCount != null) {495+                Text(496+                    canaryStatusLabel(lastPinged, pingCount),497+                    color = peachColors.T2,498+                    style = PeachType.labelMono,499+                    modifier = Modifier.padding(top = 3.dp),500+                )501+            }502+        }503+    }504+}505+506+@Composable349507 private fun EntryDetailSearchStrip(350508     currentIndex: Int,351509     totalEntries: Int,@@ -464,6 +622,23 @@464622  * falling back to "P" for a blank title so the hero never renders empty.465623  */466624 internal fun ghostWatermarkText(title: String): String = title.ifBlank { "P" }625+626+internal fun entryHasHomographWarning(entry: com.peachpasswords.vault.VaultEntry): Boolean =627+    (listOfNotNull(entry.url) + entry.additionalUrls.orEmpty()).any(::detectHomograph)628+629+internal fun shortCredential(credentialId: String): String {630+    if (credentialId.length <= 12) return credentialId631+    return credentialId.take(6) + "..." + credentialId.takeLast(4)632+}633+634+internal fun canaryStatusLabel(lastPinged: Long?, pingCount: Int?): String {635+    val count = pingCount ?: 0636+    val countLabel = "$count total alert" + if (count == 1) "" else "s"637+    if (lastPinged == null) return countLabel638+    val date = java.text.DateFormat.getDateInstance(java.text.DateFormat.MEDIUM)639+        .format(java.util.Date(lastPinged))640+    return "Last triggered: $date · $countLabel"641+}467642 468643 private fun com.peachpasswords.vault.VaultEntry.displayDomain(): String {469644     val raw = url

view file

app/src/main/java/com/peachpasswords/ui/vault/EntryDetailViewModel.kt+15 −0
@@ -126,6 +126,8 @@126126     fun updateField(field: String, value: String) {127127         val current = entry.value ?: return128128         val patch = when (field) {129+            "title" -> current.copy(title = value.trim().ifBlank { current.title })130+            "url" -> current.copy(url = value.ifBlank { null })129131             "username" -> current.copy(username = value.ifBlank { null })130132             "email" -> current.copy(email = value.ifBlank { null })131133             "password" -> current.copy(password = value.ifBlank { null })@@ -133,6 +135,19 @@133135             "totp" -> current.copy(totp = value.ifBlank { null })134136             else -> return135137         }138+        viewModelScope.launch {139+            runCatching { vault.updateEntry(patch) }140+        }141+    }142+143+    fun updateAdditionalUrl(index: Int, value: String) {144+        val current = entry.value ?: return145+        val urls = current.additionalUrls.orEmpty().toMutableList()146+        if (index !in urls.indices) return147+        urls[index] = value148+        val patch = current.copy(149+            additionalUrls = urls.map { it.trim() }.filter { it.isNotBlank() }.ifEmpty { null },150+        )136151         viewModelScope.launch {137152             runCatching { vault.updateEntry(patch) }138153         }

view file

app/src/main/java/com/peachpasswords/vault/VaultEntry.kt+1 −0
@@ -78,6 +78,7 @@7878 fun VaultEntry.isDeleted() = deletedAt != null7979 fun VaultEntry.hasTOTP() = !totp.isNullOrBlank()8080 fun VaultEntry.hasPasskey() = passkey != null81+fun VaultEntry.isPasskeyOnly() = hasPasskey() && password.isNullOrBlank() && totp.isNullOrBlank() && email.isNullOrBlank()8182 fun VaultEntry.isBreach() = (breach ?: 0) > 08283 8384 fun VaultEntry.domainKey(): String? {

view file

app/src/test/java/com/peachpasswords/shared/DomainUtilsTest.kt+22 −0
@@ -0,0 +1,22 @@1+package com.peachpasswords.shared2+3+import org.junit.Assert.assertFalse4+import org.junit.Assert.assertTrue5+import org.junit.Test6+7+class DomainUtilsTest {8+    @Test fun detect_homograph_flags_unicode_hosts() {9+        assertTrue(detectHomograph("https://аpple.com"))10+    }11+12+    @Test fun detect_homograph_flags_punycode_hosts() {13+        assertTrue(detectHomograph("https://xn--pple-43d.com"))14+        assertTrue(detectHomograph("xn--pple-43d.com"))15+    }16+17+    @Test fun detect_homograph_ignores_plain_ascii_and_invalid_urls() {18+        assertFalse(detectHomograph("https://apple.com"))19+        assertFalse(detectHomograph(""))20+        assertFalse(detectHomograph("http://"))21+    }22+}

view file

app/src/test/java/com/peachpasswords/ui/vault/EntryDetailParityTest.kt+34 −0
@@ -0,0 +1,34 @@1+package com.peachpasswords.ui.vault2+3+import com.peachpasswords.vault.VaultEntry4+import org.junit.Assert.assertEquals5+import org.junit.Assert.assertFalse6+import org.junit.Assert.assertTrue7+import org.junit.Test8+9+class EntryDetailParityTest {10+    @Test fun entry_homograph_warning_checks_primary_and_additional_urls() {11+        val safe = VaultEntry(12+            id = "1",13+            title = "Safe",14+            url = "https://example.com",15+            additionalUrls = listOf("https://accounts.example.com"),16+            createdAt = 1,17+            modifiedAt = 1,18+        )19+        val risky = safe.copy(additionalUrls = listOf("https://xn--pple-43d.com"))20+21+        assertFalse(entryHasHomographWarning(safe))22+        assertTrue(entryHasHomographWarning(risky))23+    }24+25+    @Test fun short_credential_preserves_readable_edges() {26+        assertEquals("short", shortCredential("short"))27+        assertEquals("abcdef...7890", shortCredential("abcdefghijklmnopqrstuvwxyz7890"))28+    }29+30+    @Test fun canary_status_label_handles_count_without_date() {31+        assertEquals("0 total alerts", canaryStatusLabel(null, null))32+        assertEquals("1 total alert", canaryStatusLabel(null, 1))33+    }34+}

view file

app/src/test/java/com/peachpasswords/vault/PasskeyEntryTest.kt+39 −0
@@ -0,0 +1,39 @@1+package com.peachpasswords.vault2+3+import org.junit.Assert.assertFalse4+import org.junit.Assert.assertTrue5+import org.junit.Test6+7+class PasskeyEntryTest {8+    private fun passkeyEntry(9+        password: String? = null,10+        email: String? = null,11+        totp: String? = null,12+    ) = VaultEntry(13+        id = "id",14+        type = "login",15+        title = "Passkey",16+        password = password,17+        email = email,18+        totp = totp,19+        passkey = PasskeyData(20+            credentialId = "credential",21+            publicKeyCose = "cose",22+            rpId = "example.com",23+            userHandle = "handle",24+            userName = "june",25+        ),26+        createdAt = 1,27+        modifiedAt = 1,28+    )29+30+    @Test fun passkey_only_allows_username_but_no_password_totp_or_email() {31+        assertTrue(passkeyEntry().isPasskeyOnly())32+    }33+34+    @Test fun passkey_with_fillable_secret_is_not_passkey_only() {35+        assertFalse(passkeyEntry(password = "secret").isPasskeyOnly())36+        assertFalse(passkeyEntry(email = "[email protected]").isPasskeyOnly())37+        assertFalse(passkeyEntry(totp = "GEZDGNBVGY3TQOJQ").isPasskeyOnly())38+    }39+}

view file