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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions i18n/en.msg
Original file line number Diff line number Diff line change
Expand Up @@ -4442,6 +4442,19 @@ ios.clone.signin.starting = Starting the sign-in…
ios.clone.signin.done = Signed in to GitHub.
ios.clone.signin.open = Open the page
ios.clone.loading = Reading your repositories…
mobile.tab.inbox = Inbox
mobile.tab.crew = Crew
mobile.tab.bench = Bench
mobile.inbox.clear = All clear
mobile.inbox.clear.note = Nothing needs you and nothing is running.
mobile.inbox.talk.bub = Talk to Bub
mobile.inbox.jump.in = Jump back in
mobile.inbox.open.bench = Open Bench
mobile.badge.pcb = PCB
mobile.pill.waiting = Waiting
mobile.snooze.wakes = Wakes in {time}
mobile.bench.all = All projects
mobile.snooze.for = Snooze for
# ---- end ----
# the sidebar's sections (docs/ALWAYS-ON.md section 8): the hub's words, and the window's
sidebar.sections.needs = Needs you
Expand Down
13 changes: 13 additions & 0 deletions i18n/es.msg
Original file line number Diff line number Diff line change
Expand Up @@ -4444,6 +4444,19 @@ ios.clone.signin.starting = Iniciando la sesión…
ios.clone.signin.done = Sesión iniciada en GitHub.
ios.clone.signin.open = Abrir la página
ios.clone.loading = Leyendo tus repositorios…
mobile.tab.inbox = Bandeja
mobile.tab.crew = Equipo
mobile.tab.bench = Banco
mobile.inbox.clear = Todo en orden
mobile.inbox.clear.note = Nada te necesita y nada está en marcha.
mobile.inbox.talk.bub = Hablar con Bub
mobile.inbox.jump.in = Volver a entrar
mobile.inbox.open.bench = Abrir el banco
mobile.badge.pcb = PCB
mobile.pill.waiting = En espera
mobile.snooze.wakes = Vuelve en {time}
mobile.bench.all = Todos los proyectos
mobile.snooze.for = Posponer
# ---- end ----
# the sidebar's sections (docs/ALWAYS-ON.md section 8): the hub's words, and the window's
sidebar.sections.needs = Te necesita
Expand Down
13 changes: 13 additions & 0 deletions i18n/ja.msg
Original file line number Diff line number Diff line change
Expand Up @@ -4465,6 +4465,19 @@ ios.clone.signin.starting = サインインを開始中…
ios.clone.signin.done = GitHub にサインインしました。
ios.clone.signin.open = ページを開く
ios.clone.loading = リポジトリを読み込み中…
mobile.tab.inbox = 受信トレイ
mobile.tab.crew = クルー
mobile.tab.bench = ベンチ
mobile.inbox.clear = 対応待ちなし
mobile.inbox.clear.note = 対応待ちも実行中のものもありません。
mobile.inbox.talk.bub = Bubと話す
mobile.inbox.jump.in = 最近開いたプロジェクト
mobile.inbox.open.bench = ベンチを開く
mobile.badge.pcb = PCB
mobile.pill.waiting = 待機中
mobile.snooze.wakes = {time}後に再開
mobile.bench.all = すべてのプロジェクト
mobile.snooze.for = スヌーズする期間
# ---- end ----
# the sidebar's sections (docs/ALWAYS-ON.md section 8): the hub's words, and the window's
sidebar.sections.needs = 対応が必要
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,10 @@ object DataClient {
}
fun toggleSection(t: String) { sectionsOpen = if (t in sectionsOpen) sectionsOpen - t else sectionsOpen + t; prefs().edit().putStringSet("sections.open", sectionsOpen).apply(); scope.launch { loadSections() } }
fun sidebarAct(action: String, value: String) { scope.launch { runCatching { call("sidebar.act", JSONObject().put("action", action).put("value", value)) }; loadSections() } }
/** Snooze or wake a thread row using the hub's own `snooze[].value` (`<id>|1h|tomorrow|1w`) or `wake` (`<id>|off`). */
fun snoozeRow(value: String) { if (value.isNotEmpty()) sidebarAct("row-snooze", value) }
/** Record a project visit on the hub so the Recent bench order follows this phone too. */
fun visitProject(key: String) { if (key.isNotEmpty()) sidebarAct("project-page", key) }
/** A section row's menu item for a thread of this hub (the hub's `menu`: pin, unpin, settle, unsettle, archive): `thread.act`, then the sections as the hub has them now. */
fun sectionThreadAct(tid: String, action: String) { scope.launch { runCatching { call("thread.act", JSONObject().put("thread", tid).put("action", action)).optJSONObject("thread")?.let { upsert(parseThread(it)) } }; loadSections() } }
suspend fun projectPage(key: String, done: Boolean, older: Boolean = false): List<DSection>? {
Expand Down
544 changes: 472 additions & 72 deletions mobile/android/app/src/main/java/dev/backplane/mobile/DataSections.kt

Large diffs are not rendered by default.

244 changes: 234 additions & 10 deletions mobile/android/app/src/main/java/dev/backplane/mobile/DataViews.kt

Large diffs are not rendered by default.

1,299 changes: 688 additions & 611 deletions mobile/android/app/src/main/java/dev/backplane/mobile/Msg.kt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
package dev.backplane.mobile

import org.json.JSONArray
import org.json.JSONObject
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Test

/** Unit tests for the mobile-native Crew/Inbox/Bench sections contract: status pills, snooze/wake/settle fields, hardware PCB badges, and tab partitioning. */
class MobileSectionsTest {
private fun row(j: String) = DSecRow.of(JSONObject(j))

@Test fun parsesNewHubFields() {
val r = row(
"""{
"id":"t1","title":"Route USB-C diff pair","word":"running","label":"Working","tone":"run",
"ago":"2m","project":"Mainboard","nav":"t1","settle":"",
"snooze":[{"label":"1 hour","value":"t1|1h"},{"label":"Tomorrow","value":"t1|tomorrow"},{"label":"1 week","value":"t1|1w"}]
}"""
)
assertEquals("Working", r.label)
assertEquals("run", r.tone)
assertEquals(3, r.snooze.size)
assertEquals("t1|1h", r.snooze[0].value)
assertEquals("Tomorrow", r.snooze[1].label)
assertEquals("", r.wake)
assertEquals("", r.settle)
}

@Test fun parsesHardwareBoardBadgeAndWake() {
val proj = row("""{"id":"p1","key":"k1","title":"SensorBoard","hasBoard":true,"hasSchematic":true,"pinned":true}""")
assertTrue(proj.hasBoard)
assertTrue(proj.hasSchematic)
assertTrue(proj.pinned)

val snz = row("""{"id":"t2","title":"Old build","word":"failed","label":"Failed","tone":"bad","wake":"t2|off","ago":"3h"}""")
assertEquals("t2|off", snz.wake)
val pill = statusPillOf(snz)!!
assertEquals(PillKind.FAILED, pill.kind)
assertEquals(PillTone.BAD_OUTLINE, pill.tone)

val idleSnz = row("""{"id":"t3","title":"Idle snooze","word":"idle","wake":"t3|off","ago":"1h"}""")
assertEquals(StatusPillModel(PillKind.SNOOZED, "Snoozed", PillTone.DIM), statusPillOf(idleSnz))
}

@Test fun resolvesHubLabelAndTonePills() {
assertEquals(StatusPillModel(PillKind.APPROVE, "Approve", PillTone.BAD), statusPillOf(row("""{"id":"1","label":"Approve","tone":"bad"}""")))
assertEquals(StatusPillModel(PillKind.SIGN_IN, "Sign in", PillTone.BAD), statusPillOf(row("""{"id":"2","label":"Sign in","tone":"bad"}""")))
assertEquals(StatusPillModel(PillKind.INPUT, "Input", PillTone.BAD), statusPillOf(row("""{"id":"3","label":"Input","tone":"bad"}""")))
assertEquals(StatusPillModel(PillKind.FAILED, "Failed", PillTone.BAD_OUTLINE), statusPillOf(row("""{"id":"4","label":"Failed","tone":"bad"}""")))
assertEquals(StatusPillModel(PillKind.STOPPED, "Stopped", PillTone.BAD_OUTLINE), statusPillOf(row("""{"id":"5","label":"Stopped","tone":"bad"}""")))
assertEquals(StatusPillModel(PillKind.WORKING, "Working", PillTone.RUN), statusPillOf(row("""{"id":"6","label":"Working","tone":"run"}""")))
assertEquals(StatusPillModel(PillKind.WAITING, "Waiting", PillTone.WAIT), statusPillOf(row("""{"id":"7","label":"Waiting","tone":"wait"}""")))
assertEquals(StatusPillModel(PillKind.DONE, "Done", PillTone.OK), statusPillOf(row("""{"id":"8","label":"Done","tone":"ok"}""")))
}

@Test fun fallsBackToLegacyWordAndWantWhenLabelAbsent() {
assertEquals(StatusPillModel(PillKind.APPROVE, "Approve", PillTone.BAD), statusPillOf(row("""{"id":"1","word":"needs","want":"approval"}""")))
assertEquals(StatusPillModel(PillKind.SIGN_IN, "Sign in", PillTone.BAD), statusPillOf(row("""{"id":"2","word":"needs","want":"sign-in"}""")))
assertEquals(StatusPillModel(PillKind.INPUT, "Input", PillTone.BAD), statusPillOf(row("""{"id":"3","word":"needs","want":"question"}""")))
assertEquals(StatusPillModel(PillKind.FAILED, "Failed", PillTone.BAD_OUTLINE), statusPillOf(row("""{"id":"4","word":"failed"}""")))
assertEquals(StatusPillModel(PillKind.STOPPED, "Stopped", PillTone.BAD_OUTLINE), statusPillOf(row("""{"id":"5","word":"cut"}""")))
assertEquals(StatusPillModel(PillKind.WORKING, "Working", PillTone.RUN), statusPillOf(row("""{"id":"6","word":"running"}""")))
assertEquals(StatusPillModel(PillKind.WAITING, "Waiting", PillTone.WAIT), statusPillOf(row("""{"id":"7","word":"limit"}""")))
assertEquals(StatusPillModel(PillKind.DONE, "Done", PillTone.OK), statusPillOf(row("""{"id":"8","word":"done"}""")))
assertNull(statusPillOf(row("""{"id":"9","word":"idle"}""")))
}

@Test fun partitionsInboxAndBenchAndComputesQuickJump() {
val raw = JSONArray(
"""[
{"id":"bub","kind":"bub","title":"","rows":[]},
{"id":"needs","kind":"threads","title":"Needs you","count":2,"rows":[{"id":"t1","title":"A"},{"id":"t2","title":"B"}]},
{"id":"running","kind":"threads","title":"Running","count":1,"rows":[{"id":"t3","title":"C"}]},
{"id":"snoozed","kind":"threads","title":"Snoozed","count":3,"fold":true,"open":false,"toggle":"sec:snoozed","rows":[]},
{"id":"pinned","kind":"projects","title":"Pinned","count":1,"rows":[{"id":"p1","key":"k1","title":"SensorBoard","hasBoard":true}]},
{"id":"active","kind":"projects","title":"Recent","count":3,"rows":[
{"id":"p1","key":"k1","title":"SensorBoard","hasBoard":true},
{"id":"p2","key":"k2","title":"Firmware"},
{"id":"p3","key":"k3","title":"PowerSupply","hasBoard":true},
{"id":"p4","key":"k4","title":"Enclosure"}
]},
{"id":"all","kind":"projects","title":"All projects","count":30,"fold":true,"open":false,"toggle":"sec:all","rows":[]},
{"id":"quiet","kind":"projects","title":"Quiet","count":9,"fold":true,"open":false,"toggle":"sec:quiet","hint":"Nothing for two weeks, or made quiet","rows":[]}
]"""
)
val sections = DSection.list(raw)
val p = partitionSections(sections)

assertEquals(listOf("needs", "running", "snoozed"), p.inbox.map { it.id })
assertEquals(listOf("pinned", "active", "all", "quiet"), p.bench.map { it.id })
assertEquals(2, p.needsCount)
assertEquals(1, p.runningCount)
assertEquals(3, p.snoozedCount)
assertFalse(p.inboxEmpty)
assertEquals("Nothing for two weeks, or made quiet", p.bench.last().hint)

val quick = p.quickJumpProjects(3)
assertEquals(listOf("k1", "k2", "k3"), quick.map { it.key })
}

@Test fun detectsAllClearInboxEvenWhenSnoozedPresent() {
val raw = JSONArray(
"""[
{"id":"snoozed","kind":"threads","title":"Snoozed","count":2,"fold":true,"open":false,"toggle":"sec:snoozed","rows":[]},
{"id":"active","kind":"projects","title":"Recent","count":1,"rows":[{"id":"p1","key":"k1","title":"BoardA","hasBoard":true}]}
]"""
)
val p = partitionSections(DSection.list(raw))
assertTrue(p.inboxEmpty)
assertEquals(0, p.needsCount)
assertEquals(2, p.snoozedCount)
assertEquals(1, p.quickJumpProjects(3).size)
}
}
5 changes: 5 additions & 0 deletions mobile/ios/Backplane/DataClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,11 @@ final class DataClient {
UserDefaults.standard.set(Array(sectionsOpen), forKey: "data.sections.open"); Task { await loadSections() }
}
func sidebarAct(_ action: String, _ value: String) async { _ = try? await call("sidebar.act", ["action": action, "value": value]) as DEmpty; await loadSections() }
/// A section row's snooze or wake by the hub's own value (the row's `snooze` option or `wake`: "<thread>|1h", "|tomorrow", "|1w", "|off").
func snoozeRow(_ value: String) async { await sidebarAct("row-snooze", value) }
/// A project's page opened here: a visit, so the bench (Recent) follows this phone too. The hub writes it at most once in ten minutes; an
/// older hub refuses the action, which changes nothing.
func visitProject(_ key: String) async { guard has("sections"), !key.isEmpty else { return }; _ = try? await call("sidebar.act", ["action": "project-page", "value": key]) as DEmpty }
/// A section row's menu item for a thread of this hub (the hub's `menu`: pin, unpin, settle, unsettle, archive): `thread.act`, then the sections as the hub has them now.
func sectionThreadAct(_ id: String, _ action: String) async { await threadAct(id, action); await loadSections() }
func projectPage(_ key: String, done: Bool, older: Bool = false) async -> DProjectPage? {
Expand Down
18 changes: 0 additions & 18 deletions mobile/ios/Backplane/DataModels.swift
Original file line number Diff line number Diff line change
Expand Up @@ -568,24 +568,6 @@ struct DHome: Decodable, Equatable {
}
}
}
struct DShellSyncReply: Decodable {
let sub: Int
let projects: [DProject]?
let threads: [DThread]?
let removed: [String]?
let sections: DSections?
let h: [String: String]?
enum CodingKeys: String, CodingKey { case sub, projects, threads, removed, sections, h }
init(from d: Decoder) throws {
let c = try d.container(keyedBy: CodingKeys.self)
sub = (try? c.decode(Int.self, forKey: .sub)) ?? 0
projects = try? c.decode([DProject].self, forKey: .projects)
threads = try? c.decode([DThread].self, forKey: .threads)
removed = try? c.decode([String].self, forKey: .removed)
sections = try? c.decode(DSections.self, forKey: .sections)
h = try? c.decode([String: String].self, forKey: .h)
}
}
struct DThreadOpenReply: Decodable {
let sub: Int
let thread: DThread?
Expand Down
Loading
Loading