From 0eb4007b05a15749051d26c1cdf70c7094b421a1 Mon Sep 17 00:00:00 2001 From: Fledgewing <8509633+Fledgewing@users.noreply.github.com> Date: Thu, 26 Nov 2026 13:37:25 -0800 Subject: [PATCH 1/3] F12 G: install local Word, Reading buddy and Light widgets Extend the existing Home registration and companion read model with one-row local projections, both approved picker sizes, explicit states and native actions. Highlight and A year ago remain staged because their design sources require saved authorized server snapshots. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01BLYjLJzEkmBRpMx6vsJ4xw --- AGENTS.md | 3 + README.md | 8 +- ROADMAP.md | 1 + .../orbitcompanion/LibraryReadModel.kt | 7 +- .../fledgewing/orbitcompanion/LocalWidgets.kt | 46 +++++++++++ .../orbitcompanion/LocalWidgetsTest.kt | 70 ++++++++++++++++ .../koreader/orbit.koplugin/ko/home_host.lua | 3 + .../orbit.koplugin/ko/local_widgets.lua | 66 +++++++++++++++ .../koreader/orbit.koplugin/logic/budgets.lua | 2 +- .../orbit.koplugin/logic/local_widgets.lua | 14 ++++ .../orbit.koplugin/logic/widget_registry.lua | 7 ++ android/koreader/orbit.koplugin/main.lua | 4 +- android/koreader/test/home_host_flows.lua | 1 + android/koreader/test/koreader_compat.lua | 2 + android/koreader/test/local_widget_flows.lua | 80 +++++++++++++++++++ android/koreader/test/test_local_widgets.lua | 21 +++++ android/koreader/test/test_logic.lua | 2 + docs/FEATURES.md | 9 ++- docs/design/booksync-home/DESIGN-NOTES.md | 16 ++++ .../booksync-home/F12-G-LOCAL-WIDGETS.md | 40 ++++++++++ docs/design/booksync-home/REVIEW-PASS-4.md | 2 +- shared/features.json | 51 ++++++++++++ 22 files changed, 442 insertions(+), 13 deletions(-) create mode 100644 android/companion/app/src/main/java/net/fledgewing/orbitcompanion/LocalWidgets.kt create mode 100644 android/companion/app/src/test/java/net/fledgewing/orbitcompanion/LocalWidgetsTest.kt create mode 100644 android/koreader/orbit.koplugin/ko/local_widgets.lua create mode 100644 android/koreader/orbit.koplugin/logic/local_widgets.lua create mode 100644 android/koreader/test/local_widget_flows.lua create mode 100644 android/koreader/test/test_local_widgets.lua create mode 100644 docs/design/booksync-home/F12-G-LOCAL-WIDGETS.md diff --git a/AGENTS.md b/AGENTS.md index ab803a51..e84654d1 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -79,6 +79,9 @@ CrossInk 2.x bridge and the later stable BookSync releases become available (`xt ## Screen and widget performance budgets +Local optional widgets inherit one-row/16 KiB budgets too: companion-owned vocabulary selection +and reading messages; native frontlight scalars only in Library. Paint never scans local history. + Nested group covers and Series next-book previews count as rows in the caller budget; never hide multiple display records behind a single summary row. Companion materialization owns their ordering, counts and status labels. diff --git a/README.md b/README.md index 1e633720..546f3bc4 100644 --- a/README.md +++ b/README.md @@ -18,10 +18,10 @@ Generated support counts (settings included): ✅ supported, 🟡 partial, ❌ m | Platform | ✅ | 🟡 | ❌ | ➖ | |---|---:|---:|---:|---:| -| Android (M8C / Boox) | 75 | 12 | 1 | 3 | -| X4 Pro | 55 | 12 | 12 | 12 | -| X4 classic | 54 | 12 | 12 | 13 | -| X3 | 20 | 16 | 42 | 13 | +| Android (M8C / Boox) | 75 | 13 | 1 | 3 | +| X4 Pro | 55 | 12 | 13 | 12 | +| X4 classic | 54 | 12 | 13 | 13 | +| X3 | 20 | 16 | 43 | 13 | ## Releases diff --git a/ROADMAP.md b/ROADMAP.md index 2398068c..fbc1d567 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -17,6 +17,7 @@ CrossInk 2.x only; 1.6 is retired). | Outcome | Platforms | Status | |---|---|---| +| Word of the day, local Reading buddy and hardware Light picker widgets; Highlight and A year ago await authorized server snapshots. | Android; X4 Pro/X4/X3 deferred to firmware | building (device acceptance pending) | | Server-free Android catalog operations: companion-owned covers, refresh, copies, recommendations and end-of-book snapshots and commands. | Android; X4 Pro, X4, X3 later under Android-first ruling | building (F12-Q2 covers migrated; remaining catalog callers pending) | | Independent optional account, sync and OPDS logins, encrypted credentials, origin-aware sign-out and account-wide reading statistics through the library interface. | Android; X4 Pro, X4, X3 later | building (Android F12-K foundation and F12-N plugin screens implemented; device acceptance and firmware follow) | | Configure one Book list widget with presets, paged counted sources and local Custom filters in the Home editor. | Android building; X4 Pro, X4, X3 follow Android | building (approved design rev 16; device acceptance pending) | diff --git a/android/companion/app/src/main/java/net/fledgewing/orbitcompanion/LibraryReadModel.kt b/android/companion/app/src/main/java/net/fledgewing/orbitcompanion/LibraryReadModel.kt index 6263dce3..df974ed8 100644 --- a/android/companion/app/src/main/java/net/fledgewing/orbitcompanion/LibraryReadModel.kt +++ b/android/companion/app/src/main/java/net/fledgewing/orbitcompanion/LibraryReadModel.kt @@ -13,6 +13,7 @@ class LibraryReadModel( private val fallbackReadingStats: ((String) -> RemoteReadingStats?)? = null, private val accountState: () -> Map = { mapOf("signedIn" to false) }, private val accountStats: (String) -> Map<*, *>? = { null }, + private val vocabulary: () -> java.io.File = { java.io.File(SleepScreen.dir().parentFile, "vocabulary_builder.sqlite3") }, private val adapter: ServerAdapter = ServerAdapters.forStore(store, clock = clock, fallbackReadingStats = fallbackReadingStats, accountState = accountState, accountStats = accountStats), ) { @@ -28,9 +29,10 @@ class LibraryReadModel( require(requests.size <= MAX_BATCH) // Never take ownership from a read command, nor expose a prior account's data. if (store.meta("owner") != owner) return false + val localStats by lazy { readingStats() } val power by lazy { battery() } val account by lazy { accountStats(owner) } - val stats by lazy { ReadingStats.display(AccountStats.combine(readingStats(), adapter.cachedReadingStats(owner), account, clock()), clock(), AccountStats.zone(account)) } + val stats by lazy { ReadingStats.display(AccountStats.combine(localStats, adapter.cachedReadingStats(owner), account, clock()), clock(), AccountStats.zone(account)) } for (encoded in requests) { val start = System.nanoTime() val request = encoded as? String ?: continue @@ -41,6 +43,9 @@ class LibraryReadModel( val result = try { when (args["op"]) { "reader.controls" -> ReaderControls.project(args["native"] as? Map<*, *> ?: emptyMap()) "reading.stats" -> stats + "local.word" -> LocalWidgets.word(vocabulary(), clock()) + "local.buddy" -> LocalWidgets.buddy(localStats) + "local.light" -> LocalWidgets.light(args["native"] as? Map<*, *> ?: emptyMap()) "device.clock" -> ClockWidget.snapshot(clock(), power, twelve = args["twelve_hour"] == true) "mode-estimates" -> BatteryEstimate.modeRows(power, (args["limit"] as? Number)?.toInt() ?: 3) "battery" -> power diff --git a/android/companion/app/src/main/java/net/fledgewing/orbitcompanion/LocalWidgets.kt b/android/companion/app/src/main/java/net/fledgewing/orbitcompanion/LocalWidgets.kt new file mode 100644 index 00000000..f633af18 --- /dev/null +++ b/android/companion/app/src/main/java/net/fledgewing/orbitcompanion/LocalWidgets.kt @@ -0,0 +1,46 @@ +// SPDX-License-Identifier: MIT +package net.fledgewing.orbitcompanion + +import java.io.File +import java.time.Instant +import java.time.ZoneId + +/** Local projections only. Borrowed vocabulary is read-only, on the existing worker. */ +object LocalWidgets { + private fun row(state: String, message: String) = mapOf( + "state" to state, "message" to LuaValue.str(message), "row_count" to 1, + "freshness" to mapOf("saved" to true, "origin" to "local-reader")) + + fun word(file: File, now: Long): Map { + if (!file.isFile) return row("empty", "Look up a word while reading.") + return try { AndroidSql(file, readOnly = true).use { word(it, now) } } + catch (e: Exception) { if (e is InterruptedException) throw e; row("error", "Vocabulary unavailable") } + } + fun word(db: Sql, now: Long, zone: ZoneId = ZoneId.systemDefault()): Map { + val day = Instant.ofEpochSecond(now).atZone(zone).toLocalDate().toEpochDay() + // One SELECT uses one read snapshot, with at most one decoded record. + return db.query("SELECT substr(v.word,1,96),substr(v.prev_context,1,120),substr(v.next_context,1,120),substr(t.name,1,100) FROM vocabulary v LEFT JOIN title t ON t.id=v.title_id ORDER BY v.word LIMIT 1 OFFSET (SELECT ((? % max(count(*),1)) + max(count(*),1)) % max(count(*),1) FROM vocabulary)", day) { + row("ready", "On this reader") + mapOf( + "word" to LuaValue.str(it.text(0).orEmpty()), + "context" to LuaValue.str(listOfNotNull(it.text(1),it.text(0),it.text(2)).joinToString(" ").replace('\n',' ')), + "source" to LuaValue.str(it.text(3) ?: "Source unavailable")) + }.firstOrNull() ?: row("empty", "Look up a word while reading.") + } + + fun buddy(stats: Map): Map { + val records = stats["records"] as? Map<*, *> + val streak = (records?.get("streak") as? Number)?.toLong() + val pages = (records?.get("recorded_pages") as? Number)?.toLong() + return when { + stats["state"] == "error" -> row("error", "Reading activity unavailable") + pages == null || pages == 0L -> row("empty", "Your next chapter is waiting.") + streak != null && streak > 0 -> row("ready", "$streak day reading streak · On this reader") + else -> row("ready", "Welcome back. Your next chapter is waiting.") + } + } + fun light(native: Map<*, *>): Map { + val level = (native["level"] as? Number)?.toInt()?.takeIf { it in 0..100 } + return if (native["supported"] != true || level == null) row("unavailable", "Frontlight unavailable on this reader") + else row("ready", "Light · $level%") + mapOf("level" to level) + } +} diff --git a/android/companion/app/src/test/java/net/fledgewing/orbitcompanion/LocalWidgetsTest.kt b/android/companion/app/src/test/java/net/fledgewing/orbitcompanion/LocalWidgetsTest.kt new file mode 100644 index 00000000..24a9596a --- /dev/null +++ b/android/companion/app/src/test/java/net/fledgewing/orbitcompanion/LocalWidgetsTest.kt @@ -0,0 +1,70 @@ +// SPDX-License-Identifier: MIT +package net.fledgewing.orbitcompanion + +import org.junit.Assert.* +import org.junit.Test +import java.nio.file.Files +import java.time.ZoneOffset + +class LocalWidgetsTest { + @Test fun oneBatchPublishesOnlyLocalRowsWithoutServerProjection() { + val dir=Files.createTempDirectory("local-widget-batch").toFile() + try { JdbcSql(java.io.File(dir,"views.sqlite3")).use { sql -> + LibraryReadModel.initialize(sql) + val store=object: ProjectionStore { + override fun db()=sql + override fun meta(k:String)=if(k=="owner") "fixture" else null + override fun transaction(block:()->T):T=sql.transaction(block) + override fun close()=Unit + } + val adapter=object:ServerAdapter { + override val id="fixture" + override fun project(owner:String,request:Map<*,*>):Map = error("no server projection") + } + var reads=0 + val model=LibraryReadModel(store,{86400},{},readingStats={reads++; mapOf("state" to "empty")}, + vocabulary={java.io.File(dir,"missing.sqlite3")},adapter=adapter) + val requests=listOf("local.word","local.buddy","local.light").map { op -> + String(LuaValue.encode(mapOf("op" to op,"limit" to 1,"bytes" to 16384)),Charsets.ISO_8859_1) + } + assertTrue(model.publish("fixture",requests)); assertEquals(1,reads) + val rows=sql.query("SELECT body FROM library_views") { it.bytes(0)!! } + assertEquals(3,rows.size) + for(body in rows) { + assertTrue(body.size<=16384) + val result=LuaValue.parse(body) as Map<*,*> + assertEquals(1L,result["row_count"]) + } + assertFalse(model.publish("another-owner",requests)) + } } finally { dir.deleteRecursively() } + } + @Test fun vocabularyIsOneBoundedDailyRecordWithContextAndSource() { + val dir=Files.createTempDirectory("local-widget").toFile() + try { JdbcSql(java.io.File(dir,"vocabulary.sqlite3")).use { db -> + db.exec("CREATE TABLE title(id INTEGER PRIMARY KEY,name TEXT)") + db.exec("CREATE TABLE vocabulary(word TEXT PRIMARY KEY,title_id INTEGER,prev_context TEXT,next_context TEXT)") + assertEquals("empty",LocalWidgets.word(db,86400,ZoneOffset.UTC)["state"]) + db.exec("INSERT INTO title VALUES(1,'The Moon')") + db.exec("INSERT INTO vocabulary VALUES('lantern',1,'the','room')") + val a=LocalWidgets.word(db,86400,ZoneOffset.UTC) + assertEquals("lantern",a["word"]); assertEquals("the lantern room",a["context"]); assertEquals("The Moon",a["source"]) + assertEquals(a,LocalWidgets.word(db,86401,ZoneOffset.UTC)) + db.exec("INSERT INTO vocabulary VALUES('anchor',NULL,?,?)","x".repeat(10000),"y".repeat(10000)) + val b=LocalWidgets.word(db,2*86400,ZoneOffset.UTC) + assertEquals("anchor",b["word"]); assertEquals("Source unavailable",b["source"]) + assertTrue(LuaValue.encode(b).size<16384); assertEquals(1,b["row_count"]) + assertEquals(2L,db.query("SELECT count(*) FROM vocabulary") { it.long(0) }.first()) + } } finally { dir.deleteRecursively() } + } + @Test fun missingVocabularyLightCapabilityAndLocalBuddyStates() { + assertEquals("empty",LocalWidgets.word(java.io.File("missing-widget-vocabulary"),1)["state"]) + assertEquals("unavailable",LocalWidgets.light(emptyMap())["state"]) + assertEquals("unavailable",LocalWidgets.light(mapOf("supported" to true,"level" to 101))["state"]) + assertEquals(LuaValue.str("Light · 40%"),LocalWidgets.light(mapOf("supported" to true,"level" to 40))["message"]) + assertEquals("empty",LocalWidgets.buddy(emptyMap())["state"]) + assertEquals("error",LocalWidgets.buddy(mapOf("state" to "error"))["state"]) + val buddy=LocalWidgets.buddy(mapOf("records" to mapOf("streak" to 3,"recorded_pages" to 20))) + assertEquals(LuaValue.str("3 day reading streak · On this reader"),buddy["message"]) + assertEquals("ready",buddy["state"]) + } +} diff --git a/android/koreader/orbit.koplugin/ko/home_host.lua b/android/koreader/orbit.koplugin/ko/home_host.lua index 69c9415f..07fa09f2 100644 --- a/android/koreader/orbit.koplugin/ko/home_host.lua +++ b/android/koreader/orbit.koplugin/ko/home_host.lua @@ -197,6 +197,9 @@ function HomeHost.create() end function Host:dispatch(action,row,p) if action == "retry" then Library.retry(); self:rebuild(); UIManager:setDirty(self,"ui") + elseif action == "word-lookup" or action == "light-down" or action == "light-up" then + Library.localWidgetAction(action,row) + if action~="word-lookup" then self:rebuild(); UIManager:setDirty(self,"ui") end elseif action == "battery" then BatteryUI.show() elseif action == "book" then if self.caps.account and not row.local_path and not AccountPlan.login(self.account or {},"opds").available then diff --git a/android/koreader/orbit.koplugin/ko/local_widgets.lua b/android/koreader/orbit.koplugin/ko/local_widgets.lua new file mode 100644 index 00000000..5e63f8b9 --- /dev/null +++ b/android/koreader/orbit.koplugin/ko/local_widgets.lua @@ -0,0 +1,66 @@ +-- SPDX-License-Identifier: AGPL-3.0-or-later +-- Local native access stays behind Library; the host alone requests projections. +function Library.localWidgetNeed(id) + local need={op="local."..id,limit=1} + if id=="light" then + local device=require("device") + local supported=device.hasFrontlight and device:hasFrontlight() or false + local power=supported and device:getPowerDevice() + need.native={supported=supported,level=power and power:frontlightIntensity()} + end + return need +end +function Library.localWidgetAction(action,value) + if action=="word-lookup" then + if type(value)~="string" or #value>384 or value=="" then return false end + local ui=liveUI() or require("apps/filemanager/filemanager").instance + if ui and ui.dictionary then ui.dictionary:onLookupWord(value,true); return true end + return false + end + if action=="light-down" or action=="light-up" then + local need=Library.localWidgetNeed("light") + if not need.native.supported or not need.native.level then return false end + return Library.readerControl({},"light",math.max(0,math.min(100,need.native.level+(action=="light-up" and 10 or -10)))) + end + return false +end +LocalWidgets = {} +function LocalWidgets.render(p,snapshot,dispatch,rect) + local finish=Budgets.span("local-widget."..p.widget,now_s,log) + assert(Budgets.check(Budgets.get("widgets",p.widget),{rows=1,bytes=snapshot.bytes,snapshotBytes=snapshot.bytes,spawns=0,network=0,roundTrips=0})) + local plan=LocalWidgetPlan.build(p.widget,snapshot) + local scale=function(n) return Device.screen:scaleBySize(n) end + local w,h=rect.w-2,rect.h-2 + local pad=scale(10) + local c=HomeWidgets.canvas(w,h) + HomeWidgets.text(c,p.widget=="light" and plan.ready and plan.message or _(plan.title),pad,pad,w-2*pad,18,false,true) + if p.widget=="word" and plan.word then + if p.h==1 then + HomeWidgets.button(c,plan.word.." ›",pad,h-pad-scale(50),w-2*pad,scale(50),function() dispatch("word-lookup",plan.word) end) + else + HomeWidgets.text(c,plan.word,pad,pad+scale(30),w-2*pad,22,false,true) + HomeWidgets.text(c,plan.context or "",pad,pad+scale(60),w-2*pad,14) + HomeWidgets.text(c,plan.source or "Source unavailable",pad,pad+scale(83),w-2*pad,13) + HomeWidgets.button(c,_("Look up ›"),pad,h-pad-scale(50),w-2*pad,scale(50),function() dispatch("word-lookup",plan.word) end) + end + elseif p.widget=="light" and plan.ready then + local bw=math.floor((w-3*pad)/2) + if p.h>1 then HomeWidgets.text(c,plan.message,pad,pad+scale(36),w-2*pad,22,false,true) end + HomeWidgets.button(c,"−",pad,h-pad-scale(50),bw,scale(50),function() dispatch("light-down") end) + HomeWidgets.button(c,"+",2*pad+bw,h-pad-scale(50),bw,scale(50),function() dispatch("light-up") end) + else + -- A single bounded line in compact cards; no hidden history or render reads. + HomeWidgets.text(c,_(plan.message),pad,pad+scale(32),w-2*pad,14) + if plan.retry then + if p.h==1 then table.remove(c) end -- compact message is itself the retry target + HomeWidgets.button(c,_(p.h==1 and plan.message or "Retry"),pad,h-pad-scale(50),w-2*pad,scale(50),function() dispatch("retry") end) + end + end + finish() + return HomeWidgets.ui().Frame:new{padding=0,margin=0,bordersize=1,c} +end +for _,id in ipairs({"word","light","buddy"}) do + local name=id + HomeWidgets.register(name,LocalWidgets.render,function() return Library.localWidgetNeed(name) end) + WidgetRegistry[name].renderers={['android-tablet']=LocalWidgets.render} +end diff --git a/android/koreader/orbit.koplugin/logic/budgets.lua b/android/koreader/orbit.koplugin/logic/budgets.lua index f14d283c..97873b88 100644 --- a/android/koreader/orbit.koplugin/logic/budgets.lua +++ b/android/koreader/orbit.koplugin/logic/budgets.lua @@ -25,7 +25,7 @@ Budgets.screens["editor-picker"].drawNodes = 24 Budgets.screens["filter-picker"] = budget(24, 16384, 50) Budgets.libraryWindow = budget(32, 32768, 30) for _, id in ipairs({"continue-reading", "booklist", "lists", "library", "battery", "this-week", - "year-in-reading", "when-you-read", "reading-records", "clock"}) do + "year-in-reading", "when-you-read", "reading-records", "clock", "word", "light", "buddy"}) do Budgets.widgets[id] = budget(id == "booklist" and 12 or id == "lists" and 8 or 1, 16384, 50) end -- Library summary + local storage summary are two materialized rows in one batch. diff --git a/android/koreader/orbit.koplugin/logic/local_widgets.lua b/android/koreader/orbit.koplugin/logic/local_widgets.lua new file mode 100644 index 00000000..ac268e19 --- /dev/null +++ b/android/koreader/orbit.koplugin/logic/local_widgets.lua @@ -0,0 +1,14 @@ +-- SPDX-License-Identifier: AGPL-3.0-or-later +-- Bounded presentation only; selection and reading messages belong to the companion. +LocalWidgetPlan = {} +function LocalWidgetPlan.build(id,snapshot) + local d=snapshot.data or {} + local state=d.state or snapshot.state + local ready=state=="ready" or state=="offline-with-data" + local fallback={loading="Loading…",error="Couldn't load this widget",empty=id=="word" and "Look up a word while reading." or "Your next chapter is waiting.", + ["offline-without-data"]="Not saved yet",["not-saved"]="Not saved yet",unavailable="Frontlight unavailable on this reader"} + return {title=WidgetRegistry[id].name,state=state,ready=ready, + message=ready and (d.message or "On this reader") or (fallback[state] or "Unavailable"), + word=ready and d.word,context=ready and d.context,source=ready and d.source, + retry=state=="error" or state=="loading" or state=="offline-without-data" or state=="not-saved"} +end diff --git a/android/koreader/orbit.koplugin/logic/widget_registry.lua b/android/koreader/orbit.koplugin/logic/widget_registry.lua index 2bfac2fe..ab7ef0ec 100644 --- a/android/koreader/orbit.koplugin/logic/widget_registry.lua +++ b/android/koreader/orbit.koplugin/logic/widget_registry.lua @@ -18,6 +18,10 @@ widget("year-in-reading", "reading.stats", {{4,3},{4,2}}, {{2,4},{2,3}}) widget("when-you-read", "reading.stats", {{2,2},{2,3},{2,1},{4,1}}, {{2,1},{2,2},{1,2}}) widget("reading-records", "reading.stats", {{3,2},{2,3},{2,2},{4,1}}, {{2,2},{2,3}}) widget("clock", "device.clock", {{1,2},{2,1},{2,2}}, {{2,2},{1,1},{2,1}}) +for _,id in ipairs({"word","light","buddy"}) do + widget(id, "local."..id, {{2,1},{2,2}}, {{2,1}}) +end +WidgetRegistry.word.refreshSeconds = 60 -- daily selection is companion-owned WidgetRegistry.clock.refreshSeconds = 60 -- host-owned refresh, only while visible -- The Library tile also displays local storage; both small needs share its budget and -- are part of the host's single batched snapshot, never separate render-time round trips. @@ -36,6 +40,9 @@ local descriptions={ ["year-in-reading"]={"Year in reading","A calendar of your reading days."}, ["when-you-read"]={"When you read","Your reading by hour of day."}, ["reading-records"]={"Reading records","Your reading streaks and records."}, + word={"Word of the day","A daily word from your KOReader vocabulary."}, + light={"Light","Control this reader's frontlight."}, + buddy={"Reading buddy","A reading message from activity on this reader."}, clock={"Clock","The time on your Home page."}, } for id,copy in pairs(descriptions) do WidgetRegistry[id].name=copy[1]; WidgetRegistry[id].description=copy[2] end diff --git a/android/koreader/orbit.koplugin/main.lua b/android/koreader/orbit.koplugin/main.lua index 63451283..acaa0f6b 100644 --- a/android/koreader/orbit.koplugin/main.lua +++ b/android/koreader/orbit.koplugin/main.lua @@ -34,7 +34,7 @@ local LOGIC = { "logic/prompts.lua", "logic/server/bookorbit/group.lua", "logic/server/bookorbit/finish.lua", "logic/server/bookorbit/localfirst.lua", "logic/sheet_layout.lua", "logic/cache.lua", "logic/server/bookorbit/cache.lua", "logic/server/bookorbit/recommended.lua", "logic/caps.lua", "logic/copies.lua", "logic/sleep_pool.lua", "logic/settings_sync.lua", "logic/orbismart.lua", "logic/status_layout.lua", - "logic/reading_style.lua", "logic/account.lua", "logic/settings_ui.lua", "logic/reader_panel.lua", "logic/budgets.lua", "logic/widget_registry.lua", "logic/layout.lua", "logic/filter_sheet.lua", "logic/reading_stats.lua", "logic/battery_widget.lua", "logic/home_host.lua", "logic/home_editor.lua", "logic/booklist.lua", "logic/series.lua", + "logic/reading_style.lua", "logic/account.lua", "logic/settings_ui.lua", "logic/reader_panel.lua", "logic/budgets.lua", "logic/widget_registry.lua", "logic/layout.lua", "logic/filter_sheet.lua", "logic/reading_stats.lua", "logic/local_widgets.lua", "logic/battery_widget.lua", "logic/home_host.lua", "logic/home_editor.lua", "logic/booklist.lua", "logic/series.lua", } local KO = { "ko/base.lua", "ko/settings.lua", "ko/jni.lua", "ko/companion.lua", "ko/shared.lua", @@ -44,7 +44,7 @@ local KO = { "ko/test_sync_path.lua", "ko/companion_ui.lua", "ko/server/bookorbit/recommended.lua", "ko/menu.lua", "ko/wifi_backend.lua", "ko/server/bookorbit/grouping.lua", "ko/endsheet.lua", "ko/server/bookorbit/endofbook.lua", "ko/server/bookorbit/localfirst.lua", "ko/db.lua", "ko/store.lua", "ko/server/bookorbit/store.lua", "ko/badge.lua", "ko/server/bookorbit/mirror.lua", "ko/server/bookorbit/copies.lua", "ko/sleepscreen.lua", - "ko/sqlite_stress.lua", "ko/server/bookorbit/library_bookorbit.lua", "ko/library.lua", "ko/covers.lua", "ko/account.lua", "ko/reading_style.lua", "ko/custom_reading.lua", "ko/reader_panel.lua", "ko/filter_sheet.lua", "ko/reading_stats.lua", "ko/home_widgets.lua", "ko/clock.lua", "ko/battery.lua", "ko/home_host.lua", "ko/series.lua", "ko/home_editor.lua", "ko/booklist_config.lua", "ko/settings_view.lua", + "ko/sqlite_stress.lua", "ko/server/bookorbit/library_bookorbit.lua", "ko/library.lua", "ko/covers.lua", "ko/account.lua", "ko/reading_style.lua", "ko/custom_reading.lua", "ko/reader_panel.lua", "ko/filter_sheet.lua", "ko/reading_stats.lua", "ko/home_widgets.lua", "ko/clock.lua", "ko/local_widgets.lua", "ko/battery.lua", "ko/home_host.lua", "ko/series.lua", "ko/home_editor.lua", "ko/booklist_config.lua", "ko/settings_view.lua", "ko/server/bookorbit/orbismart.lua", "ko/status_layout.lua", "ko/notices.lua", "ko/main_loop.lua", } diff --git a/android/koreader/test/home_host_flows.lua b/android/koreader/test/home_host_flows.lua index 920b453f..d159b5d0 100644 --- a/android/koreader/test/home_host_flows.lua +++ b/android/koreader/test/home_host_flows.lua @@ -73,6 +73,7 @@ return function(test,eq,ok,E,W,Widget) dofile((arg[0]:match("^(.*)/") or ".").."/booklist_flows.lua")(test,eq,ok,E,W,Widget,withHost) dofile((arg[0]:match("^(.*)/") or ".").."/home_editor_flows.lua")(test,eq,ok,E,W,Widget,withHost) dofile((arg[0]:match("^(.*)/") or ".").."/battery_flows.lua")(test,eq,ok,E,W,withHost) + dofile((arg[0]:match("^(.*)/") or ".").."/local_widget_flows.lua")(test,eq,ok,E,W,withHost) test("Home host: paint batches only installed visible widgets and page swipe",function() withHost(function(batches,reads) E.S.home_layout=E.Layout.default() diff --git a/android/koreader/test/koreader_compat.lua b/android/koreader/test/koreader_compat.lua index a24209e0..36159333 100644 --- a/android/koreader/test/koreader_compat.lua +++ b/android/koreader/test/koreader_compat.lua @@ -56,6 +56,7 @@ local NEEDS = { { "frontend/apps/reader/modules/readerfont.lua", { "onSetFontSize" } }, { "frontend/apps/reader/modules/readerfooter.lua", { "applyFooterMode", "onUpdateFooter" } }, { "frontend/device/generic/device.lua", { "hasFrontlight", "hasNaturalLight", "getPowerDevice" } }, + { "frontend/apps/reader/modules/readerdictionary.lua", { "onLookupWord" } }, { "frontend/device/generic/powerd.lua", { "frontlightIntensity", "frontlightWarmth", "setIntensity", "setWarmth" } }, { "frontend/ui/widget/buttontable.lua", { {"buttons_layout", F} } }, { "frontend/ui/widget/button.lua", { "onFocus", "onUnfocus" } }, @@ -140,6 +141,7 @@ local NEEDS = { { "frontend/ui/widget/widget.lua", { "getSize" } }, { "frontend/ui/widget/textwidget.lua", { "getSize", "paintTo", "free" } }, { "frontend/device/generic/device.lua", { "getPowerDevice" } }, + { "frontend/apps/reader/modules/readerdictionary.lua", { "onLookupWord" } }, { "frontend/device/generic/powerd.lua", { "getCapacity", "isCharging" } }, -- OrbiSmart (ko/orbismart.lua): places in this layout's pages, and the Yes / No popup (its -- Back / tap outside runs cancel_callback). diff --git a/android/koreader/test/local_widget_flows.lua b/android/koreader/test/local_widget_flows.lua new file mode 100644 index 00000000..ff4b297e --- /dev/null +++ b/android/koreader/test/local_widget_flows.lua @@ -0,0 +1,80 @@ +-- SPDX-License-Identifier: AGPL-3.0-or-later +return function(test,eq,ok,E,W,withHost) + test('local widgets: Home owns one batch for all three local projections and Back',function() + withHost(function(batches) + local ops={} + E.LibraryAdapter.read=function(raw) + local args=E.Cache.decode(raw); ops[#ops+1]=args.op + if args.op=='capabilities' then return {},2 end + eq(args.limit,1); ok(args.bytes<=16384) + if args.op=='local.light' then ok(type(args.native)=='table') end + return {state='empty',row_count=1,freshness={saved=true}},100 + end + E.S.home_layout=E.Layout.default() + E.S.home_layout.pages={{id='local',tab='Home',name='Local',placements={}}} + for i,id in ipairs({'word','light','buddy'}) do + table.insert(E.S.home_layout.pages[1].placements,{instance=id,widget=id,version=1,x=0,y=(i-1)*2,w=2,h=2,settings={}}) + end + local host=E.HomeHost.create(); E.HomeHost.active=host; W.shown={host} + eq(#ops,4); eq(#batches,1); eq(#batches[1],4) + eq(host.metrics.roundTrips,1); eq(host.metrics.spawns,0); eq(host.metrics.network,0); eq(host.metrics.rows,4) + host:onClose(); host:onCloseWidget(); eq(E.Library.listener,nil) + end) + end) + test('local widgets: every size/state paints immutable data without reads; 50px actions',function() + withHost(function() + for _,id in ipairs({'word','light','buddy'}) do + ok(E.HomeWidgets.renderers[id]) + local offered=false + for _,name in ipairs(E.HomeEditor.available({})) do if name==id then offered=true end end + ok(offered,id..' offered by installed picker') + for _,size in ipairs(E.WidgetRegistry[id].sizes['android-tablet']) do + for _,state in ipairs({'ready','empty','loading','error','offline-with-data','offline-without-data','unavailable'}) do + local result={state=state,word='lantern',context='the lantern room',source='The Moon',message='Light · 40%',level=40, + freshness={saved=state~='offline-without-data'}} + if state=='loading' then result.pending=true end + if state=='error' then result.error='unavailable' end + local snapshot=E.HomeHostPlan.snapshot(result) + local before=E.Cache.encode(result) + local p={widget=id,w=size[1],h=size[2],settings={}} + local actions={} + local height=size[2]==1 and 110 or 220 + local card=E.HomeWidgets.renderers[id](p,snapshot,function(a,value) actions[#actions+1]={a,value} end,{w=340,h=height}) + for _,node in ipairs(card[1]) do + if node.callback then + ok(node.height>=50); ok(node.width>=50) + local x,y=unpack(node.overlap_offset) + ok(x>=0 and y>=0 and x+node.width<=338 and y+node.height<=height-2) + node.callback() + end + end + eq(E.Cache.encode(result),before) + if state=='ready' or state=='offline-with-data' then + if id=='word' then eq(actions[1][1],'word-lookup'); eq(actions[1][2],'lantern') end + if id=='light' then eq(actions[1][1],'light-down'); eq(actions[2][1],'light-up') end + end + end + end + end + end) + end) + test('local widgets: native light actions use Library and clamp; dictionary dispatch returns to host',function() + withHost(function() + local oldRequire,oldControl,oldLive=E.require,E.Library.readerControl,E.liveUI + local level,received=95 + E.require=function(name) + if name=='device' then return {hasFrontlight=function() return true end,getPowerDevice=function() + return {frontlightIntensity=function() return level end} + end} end + return oldRequire(name) + end + E.Library.readerControl=function(_,action,value) eq(action,'light'); received=value; return true end + ok(E.Library.localWidgetAction('light-up')); eq(received,100) + level=5; ok(E.Library.localWidgetAction('light-down')); eq(received,0) + E.liveUI=function() return {dictionary={onLookupWord=function(_,word,sane) eq(word,'lantern'); eq(sane,true); received=word end}} end + ok(E.Library.localWidgetAction('word-lookup','lantern')); eq(received,'lantern') + ok(not E.Library.localWidgetAction('word-lookup',string.rep('x',385))) + E.require,E.Library.readerControl,E.liveUI=oldRequire,oldControl,oldLive + end) + end) +end diff --git a/android/koreader/test/test_local_widgets.lua b/android/koreader/test/test_local_widgets.lua new file mode 100644 index 00000000..2a4d27c6 --- /dev/null +++ b/android/koreader/test/test_local_widgets.lua @@ -0,0 +1,21 @@ +-- SPDX-License-Identifier: AGPL-3.0-or-later +return function(test,eq,ok,here,Cache) + local e=setmetatable({Cache=Cache},{__index=_G}) + for _,file in ipairs({'logic/budgets.lua','logic/widget_registry.lua','logic/local_widgets.lua'}) do + setfenv(assert(loadfile(here..'/../orbit.koplugin/'..file)),e)() + end + for _,id in ipairs({'word','light','buddy'}) do + test('local widget: '..id..' state and contract',function() + eq(#e.WidgetRegistry[id].sizes['android-tablet'],2) + for _,state in ipairs({'ready','empty','loading','error','offline-with-data','offline-without-data','unavailable'}) do + local p=e.LocalWidgetPlan.build(id,{state=state,data={state=state,word='lantern',message='Local message'}}) + eq(p.ready,state=='ready' or state=='offline-with-data'); ok(#p.message>0) + eq(p.word,p.ready and 'lantern' or false) + end + local b=e.Budgets.get('widgets',id) + ok(e.Budgets.check(b,{rows=1,bytes=16384,snapshotBytes=16384,network=0,spawns=0,roundTrips=0})) + ok(not e.Budgets.check(b,{rows=2,bytes=1,snapshotBytes=1,network=0,spawns=0,roundTrips=0})) + ok(not e.Budgets.check(b,{rows=1,bytes=16385,snapshotBytes=16385,network=0,spawns=0,roundTrips=0})) + end) + end +end diff --git a/android/koreader/test/test_logic.lua b/android/koreader/test/test_logic.lua index 07555599..54330b85 100644 --- a/android/koreader/test/test_logic.lua +++ b/android/koreader/test/test_logic.lua @@ -1782,5 +1782,7 @@ dofile(here .. "/test_reading_style.lua")(test, eq, ok, here, M) dofile(here .. "/test_reader_panel.lua")(test, eq, ok, here) +dofile(here .. "/test_local_widgets.lua")(test, eq, ok, here, M.Cache) + print(string.format("%d passed, %d failed", passed, failed)) if failed > 0 then os.exit(1) end diff --git a/docs/FEATURES.md b/docs/FEATURES.md index 012342ff..3553dccf 100644 --- a/docs/FEATURES.md +++ b/docs/FEATURES.md @@ -20,10 +20,10 @@ Counts include settings exposure as separate rows; they are not feature quality | Platform | ✅ | 🟡 | ❌ | ➖ | |---|---:|---:|---:|---:| -| Android (M8C / Boox) | 75 | 12 | 1 | 3 | -| X4 Pro | 55 | 12 | 12 | 12 | -| X4 classic | 54 | 12 | 12 | 13 | -| X3 | 20 | 16 | 42 | 13 | +| Android (M8C / Boox) | 75 | 13 | 1 | 3 | +| X4 Pro | 55 | 12 | 13 | 12 | +| X4 classic | 54 | 12 | 13 | 13 | +| X3 | 20 | 16 | 43 | 13 | ## Behaviour @@ -87,6 +87,7 @@ Counts include settings exposure as separate rows; they are not feature quality | Clear, editable Custom reading styles and apply-then-edit quick choices | 🟡 Font and weight, device-local margins, line spacing and contrast; editors, native-style copy with Undo, and clear sync labels. Device acceptance pending.; **deliberately deferred: unreleased Android implementation awaits device visual and performance acceptance; firmware follows separately**. [android/koreader/orbit.koplugin/ko/custom_reading.lua:1](../android/koreader/orbit.koplugin/ko/custom_reading.lua#L1), [android/koreader/test/reader_panel_flows.lua:170](../android/koreader/test/reader_panel_flows.lua#L170) | ❌ Custom style editors await the firmware slice; KOReader copy does not apply.; **deliberately deferred: maintainer authorized Android first on 2026-11-25; firmware follows with device-specific margin ranges.**. [docs/design/booksync-home/DESIGN-NOTES.md:715](../docs/design/booksync-home/DESIGN-NOTES.md#L715) | ❌ Custom style editors await the firmware slice; KOReader copy does not apply.; **deliberately deferred: maintainer authorized Android first on 2026-11-25; firmware follows with device-specific margin ranges.**. [docs/design/booksync-home/DESIGN-NOTES.md:715](../docs/design/booksync-home/DESIGN-NOTES.md#L715) | ❌ Custom style editors await the firmware slice; KOReader copy does not apply.; **deliberately deferred: maintainer authorized Android first on 2026-11-25; firmware follows with device-specific margin ranges.**. [docs/design/booksync-home/DESIGN-NOTES.md:715](../docs/design/booksync-home/DESIGN-NOTES.md#L715) | | BookSync Home battery widget and snapshot Battery page | 🟡 Six widget sizes, Overview/Rates/Daily/Charges and Settings link; **deliberately deferred: 0.12 Android source implementation is building, unreleased and awaiting device validation. Grouped rates, page/refresh efficiency and export/compare actions remain later work; missing evidence is labelled explicitly.**. [docs/design/booksync-home/F12-O-NOTES.md:1](../docs/design/booksync-home/F12-O-NOTES.md#L1) | ❌ Owned battery widget and page follow Android; **deliberately deferred: maintainer authorised Android first on 2026-11-25; implement the snapshot widget and page in the later Xteink slice.**. [docs/design/booksync-home/F12-O-NOTES.md:1](../docs/design/booksync-home/F12-O-NOTES.md#L1) | ❌ Owned battery widget and page follow Android; **deliberately deferred: maintainer authorised Android first on 2026-11-25; implement the snapshot widget and page in the later Xteink slice.**. [docs/design/booksync-home/F12-O-NOTES.md:1](../docs/design/booksync-home/F12-O-NOTES.md#L1) | ❌ Owned battery widget and page follow Android; **deliberately deferred: maintainer authorised Android first on 2026-11-25; implement the snapshot widget and page in the later Xteink slice. X3 also requires measured flash fit.**. [docs/design/booksync-home/F12-O-NOTES.md:1](../docs/design/booksync-home/F12-O-NOTES.md#L1) | | Home editor Book list configuration (0.12 foundation; unreleased) | 🟡 One Book list renderer with friendly presets, settings, paged counted sources and local Custom filters; **deliberately deferred: real-device acceptance and release follow the Android 0.12 foundation**. [android/koreader/orbit.koplugin/ko/booklist_config.lua:3](../android/koreader/orbit.koplugin/ko/booklist_config.lua#L3) | ❌ Book list settings and sources follow Android; shared cfg and focus logic are ready for firmware integration; **deliberately deferred: maintainer authorised Android first on 2026-11-25; firmware implementation follows**. [docs/design/booksync-home/DESIGN-NOTES.md:809](../docs/design/booksync-home/DESIGN-NOTES.md#L809) | ❌ Book list settings and sources follow Android; shared cfg and focus logic are ready for firmware integration; **deliberately deferred: maintainer authorised Android first on 2026-11-25; firmware implementation follows**. [docs/design/booksync-home/DESIGN-NOTES.md:809](../docs/design/booksync-home/DESIGN-NOTES.md#L809) | ❌ Book list settings and sources follow Android; shared cfg and focus logic are ready for firmware integration; **deliberately deferred: maintainer authorised Android first on 2026-11-25; firmware implementation follows**. [docs/design/booksync-home/DESIGN-NOTES.md:809](../docs/design/booksync-home/DESIGN-NOTES.md#L809) | +| Word of the day, Reading buddy and Light picker widgets (0.12; unreleased) | 🟡 Installed 2×1 and 2×2 widgets: companion daily vocabulary/context/source, local reading message and native frontlight controls; explicit loading/empty/offline/error states.; **deliberately deferred: device appearance and latency acceptance pending; Highlight and A year ago need authorized server snapshots.**. [android/koreader/orbit.koplugin/ko/local_widgets.lua:1](../android/koreader/orbit.koplugin/ko/local_widgets.lua#L1) | ❌ Local optional widgets follow Android.; **deliberately deferred: maintainer authorised Android first on 2026-11-25; firmware local vocabulary and controls follow.**. [docs/design/booksync-home/F12-G-LOCAL-WIDGETS.md:1](../docs/design/booksync-home/F12-G-LOCAL-WIDGETS.md#L1) | ❌ Local optional widgets follow Android.; **deliberately deferred: maintainer authorised Android first on 2026-11-25; firmware local vocabulary and controls follow.**. [docs/design/booksync-home/F12-G-LOCAL-WIDGETS.md:1](../docs/design/booksync-home/F12-G-LOCAL-WIDGETS.md#L1) | ❌ Local optional widgets follow Android.; **deliberately deferred: maintainer authorised Android first on 2026-11-25; firmware local vocabulary and controls follow; X3 also requires measured flash fit.**. [docs/design/booksync-home/F12-G-LOCAL-WIDGETS.md:1](../docs/design/booksync-home/F12-G-LOCAL-WIDGETS.md#L1) | ## Settings exposure diff --git a/docs/design/booksync-home/DESIGN-NOTES.md b/docs/design/booksync-home/DESIGN-NOTES.md index 729052cd..637e7b6b 100644 --- a/docs/design/booksync-home/DESIGN-NOTES.md +++ b/docs/design/booksync-home/DESIGN-NOTES.md @@ -934,3 +934,19 @@ keeps a declared budget inherited by Library: six sleep choices and 16 KiB per page, zero render network/subprocesses; device settings are a lifecycle-cached row. Counts and choice decoding stay in the companion; paints/calls log info timing spans. Device latency and Android power-policy acceptance remain pending. + +### Android local picker widgets (2026-11-26) + +The authorised Android-first build installs Word of the day, Reading buddy and Light +in both prototype picker sizes (2×1 and 2×2); defaults are unchanged. Word is a daily +KOReader vocabulary snapshot with context/source and native lookup. Buddy uses only +local statistics, labelled On this reader; it does not imply account completion or +achievements. Light uses native frontlight capability and cached intensity, with +50 px decrease/increase actions; unsupported hardware has an explicit explanation. +Highlight needs an authorized saved passage and A year ago a cached server snapshot +(DESIGN §3.1–3.2); both remain staged with Recommended and Discover. + +Each widget inherits one row, 16 KiB, zero subprocesses/render network and one shared +Home batch from budgets.lua. Selection, count and messages stay in the companion; +Lua draws immutable windows. Timing spans remain device evidence, not host acceptance. +See [local widget implementation](F12-G-LOCAL-WIDGETS.md) for pinned source evidence. diff --git a/docs/design/booksync-home/F12-G-LOCAL-WIDGETS.md b/docs/design/booksync-home/F12-G-LOCAL-WIDGETS.md new file mode 100644 index 00000000..3447bdfd --- /dev/null +++ b/docs/design/booksync-home/F12-G-LOCAL-WIDGETS.md @@ -0,0 +1,40 @@ +# Android local optional widgets + +Android-only, under the maintainer's 2026-11-25 build authorization. Word, Reading +buddy and Light retain the prototype picker names and 2×1/2×2 sizes. The prototype +still draws placeholders for these; meaningful copy follows DESIGN §3.1/§3.4. +Highlight's authorized passage and A year ago's server snapshot remain staged, +alongside Recommended and Discover, under this slice's server-data exclusion. + +Reuse: `ko/home_widgets.lua:4` registers isolated renderers; `ko/home_host.lua:89` +reads through `ko/library.lua:29` into `LibraryReadModel.kt:25`. The same Home owner +owns invalidation, batching, Back and editor placement; no alternate store/cache or +transport. `logic/local_widgets.lua` contains presentation state only; the existing +`ko/reading_style.lua:228` owner applies Light changes behind Library. + +KOReader evidence at pinned commit `9192014d8bd82a91dc1012473be0f238dedfdb54`: + +- `plugins/vocabbuilder.koplugin/db.lua:8` names the borrowed settings database; + `:12` and `:25` define vocabulary/context and title. The companion uses one + read-only SELECT, selecting one daily row and bounding SQL text columns. Missing + DB/history shows “Look up a word while reading.” Missing title is explicit. +- `frontend/apps/reader/modules/readerdictionary.lua:838` is the native lookup; + `frontend/apps/filemanager/filemanager.lua:411` also installs that module. Lookup + is an explicit tap, retains KOReader's dictionary dialogs, and returns to Home. +- `frontend/device/generic/powerd.lua:126` returns the already-cached frontlight + scalar; `:216` owns mutations. The existing Library reader-control action wraps + this owner; no sysfs access, vendor command or render-time hardware query. +- `plugins/statistics.koplugin/main.lua:406` defines `page_stat_data`; the existing + `ReadingStats.kt:34` aggregation owns reading history and streaks. Buddy uses + only its local output, never account totals or fabricated completion state. + +Each widget has a one-row/16 KiB budget, a timing span, and no render network, +subprocess, history scan or separate companion round-trip. Home keeps one batch. +Word's host-owned minute heartbeat permits daily rollover without widget timers. +Light unsupported/error/loading and Word/Buddy missing/empty/loading/error/offline +states keep the named card. Compact retry messages are 50 px targets. The picker +uses installed registrations; cancelling preserves the existing editor draft rule. + +Logic, native-tree flows, companion projection and pinned native-symbol checks +cover states and boundaries. No device was used: framebuffer wrapping, supported +vendor frontlight behavior and <50 ms/<500 ms targets await device acceptance. diff --git a/docs/design/booksync-home/REVIEW-PASS-4.md b/docs/design/booksync-home/REVIEW-PASS-4.md index 7b9b4518..101e94d8 100644 --- a/docs/design/booksync-home/REVIEW-PASS-4.md +++ b/docs/design/booksync-home/REVIEW-PASS-4.md @@ -44,7 +44,7 @@ The latter remains on ROADMAP; this review does not label it shipped. | Library widget / Storage | Group and device links tested. Compact Library uses one combined count/link band so its targets fit. `ko/home_widgets.lua:126` still lacks storage figures/bar and Collections. There is no owned Storage page/removal workflow; do not draw fabricated capacity figures. | | Battery widget and four tabs | Existing learning/missing/error labels, bounded daily windows, actual-level glyphs and charges retained (`test/battery_flows.lua`). Targets fixed. Grouped rates, export/compare and efficiency metrics remain explicitly deferred in `shared/features.json`. No replacement battery model. | | This week / Year / When you read / Records | Existing native paint paths and one shared materialization exercised in `test/test_reading_stats.lua` and Home flows. Retain explicit per-field provenance and separate possibly overlapping local-today minutes: more truthful than demo totals. `logic/reading_stats.lua:29` still has simplified calendar/legend, peak and records typography compared with the prototype. | -| Clock and later picker widgets | Clock has a registry contract (`logic/widget_registry.lua:20`) but no installed renderer. Recommended, Highlight, Buddy, Discover, Year ago, Word and Light are not offered as installed widgets. Staged catalog retained; no dead picker choices added. | +| Clock and later picker widgets | Clock now has a snapshot renderer. Word, Reading buddy and Light are installed in both Android picker sizes with local companion projections; see [local widget evidence](F12-G-LOCAL-WIDGETS.md). Highlight and Year ago require authorized server snapshots and remain staged with Recommended/Discover. | | Home editor / Rename / picker / Book list configuration | Existing geometry-only moves, draft cancellation, atomic Done, keyboard Rename and paged source windows retained; Configure touch target fixed. `ko/home_editor.lua:113` draws geometry cards rather than dimmed live previews, preserving the maintainer's zero-read move budget. Tags/toolbar/next-size copy remain visually different from the HTML. | | Owned Library / Search / filter sheet / pickers | Existing neutral filters, companion counts, exclusion context, paging and removable chips retained; check `test/booklist_flows.lua` and `test/test_filter_sheet.lua`. Chips enlarged without replacing the settled sheet. The g-series slice adds companion-materialized grouped cover rows, full-Series progress dots and an owned Series destination; cached covers and bulk transfer jobs remain staged. | | Reader top / Book info / Details | Bounded progress, missing-data states, native menu escape, async visibility guard and plain bar tested in `test/reader_panel_flows.lua`. Battery and Settings destinations fixed. The reader slice extends the same owner with the header icons, separate bottom scrubber/quick settings panel and native Contents/annotations/Go to/search/bookmark dispatch. See [reader implementation and limits](G-READER-NOTES.md); framebuffer/font fit and device latency remain unverified. | diff --git a/shared/features.json b/shared/features.json index 0344fd19..484acfe3 100644 --- a/shared/features.json +++ b/shared/features.json @@ -5836,6 +5836,57 @@ } }, "deferred": "Device acceptance, firmware renderers and configuration pages." + }, + { + "id": "home-local-widgets", + "feature": "Word of the day, Reading buddy and Light picker widgets (0.12; unreleased)", + "category": "Behaviour", + "platforms": { + "android": { + "status": "partial", + "note": "Installed 2×1 and 2×2 widgets: companion daily vocabulary/context/source, local reading message and native frontlight controls; explicit loading/empty/offline/error states.", + "reason": "deliberately deferred: device appearance and latency acceptance pending; Highlight and A year ago need authorized server snapshots.", + "evidence": [ + { + "path": "android/koreader/orbit.koplugin/ko/local_widgets.lua", + "line": 1 + } + ] + }, + "x4_pro": { + "status": "missing", + "note": "Local optional widgets follow Android.", + "reason": "deliberately deferred: maintainer authorised Android first on 2026-11-25; firmware local vocabulary and controls follow.", + "evidence": [ + { + "path": "docs/design/booksync-home/F12-G-LOCAL-WIDGETS.md", + "line": 1 + } + ] + }, + "x4": { + "status": "missing", + "note": "Local optional widgets follow Android.", + "reason": "deliberately deferred: maintainer authorised Android first on 2026-11-25; firmware local vocabulary and controls follow.", + "evidence": [ + { + "path": "docs/design/booksync-home/F12-G-LOCAL-WIDGETS.md", + "line": 1 + } + ] + }, + "x3": { + "status": "missing", + "note": "Local optional widgets follow Android.", + "reason": "deliberately deferred: maintainer authorised Android first on 2026-11-25; firmware local vocabulary and controls follow; X3 also requires measured flash fit.", + "evidence": [ + { + "path": "docs/design/booksync-home/F12-G-LOCAL-WIDGETS.md", + "line": 1 + } + ] + } + } } ], "release_evidence": { From 4d9e3f93b8a27960a53ed983179e690a3fc2c86a Mon Sep 17 00:00:00 2001 From: Fledgewing <8509633+Fledgewing@users.noreply.github.com> Date: Thu, 26 Nov 2026 13:37:48 -0800 Subject: [PATCH 2/3] F12 G: install local Word, Reading buddy and Light widgets Extend the existing Home registration and companion read model with one-row local projections, both approved picker sizes, explicit states and native actions. Highlight and A year ago remain staged because their design sources require saved authorized server snapshots. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01BLYjLJzEkmBRpMx6vsJ4xw --- android/koreader/orbit.koplugin/logic/local_widgets.lua | 2 +- android/koreader/test/test_local_widgets.lua | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/android/koreader/orbit.koplugin/logic/local_widgets.lua b/android/koreader/orbit.koplugin/logic/local_widgets.lua index ac268e19..7069ef94 100644 --- a/android/koreader/orbit.koplugin/logic/local_widgets.lua +++ b/android/koreader/orbit.koplugin/logic/local_widgets.lua @@ -5,7 +5,7 @@ function LocalWidgetPlan.build(id,snapshot) local d=snapshot.data or {} local state=d.state or snapshot.state local ready=state=="ready" or state=="offline-with-data" - local fallback={loading="Loading…",error="Couldn't load this widget",empty=id=="word" and "Look up a word while reading." or "Your next chapter is waiting.", + local fallback={loading="Loading…",error="Couldn't load this widget",empty=id=="word" and "Look up a word while reading." or id=="light" and "Frontlight unavailable on this reader" or "Your next chapter is waiting.", ["offline-without-data"]="Not saved yet",["not-saved"]="Not saved yet",unavailable="Frontlight unavailable on this reader"} return {title=WidgetRegistry[id].name,state=state,ready=ready, message=ready and (d.message or "On this reader") or (fallback[state] or "Unavailable"), diff --git a/android/koreader/test/test_local_widgets.lua b/android/koreader/test/test_local_widgets.lua index 2a4d27c6..9f6c5fec 100644 --- a/android/koreader/test/test_local_widgets.lua +++ b/android/koreader/test/test_local_widgets.lua @@ -12,6 +12,9 @@ return function(test,eq,ok,here,Cache) eq(p.ready,state=='ready' or state=='offline-with-data'); ok(#p.message>0) eq(p.word,p.ready and 'lantern' or false) end + if id=='light' then + eq(e.LocalWidgetPlan.build(id,{state='empty'}).message,'Frontlight unavailable on this reader') + end local b=e.Budgets.get('widgets',id) ok(e.Budgets.check(b,{rows=1,bytes=16384,snapshotBytes=16384,network=0,spawns=0,roundTrips=0})) ok(not e.Budgets.check(b,{rows=2,bytes=1,snapshotBytes=1,network=0,spawns=0,roundTrips=0})) From 18692fba7313ac7446fa96470f074941ca25d495 Mon Sep 17 00:00:00 2001 From: Fledgewing <8509633+Fledgewing@users.noreply.github.com> Date: Thu, 26 Nov 2026 14:56:37 -0800 Subject: [PATCH 3/3] Update local widget fixture for the shared projection root Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01BLYjLJzEkmBRpMx6vsJ4xw --- .../test/java/net/fledgewing/orbitcompanion/LocalWidgetsTest.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/android/companion/app/src/test/java/net/fledgewing/orbitcompanion/LocalWidgetsTest.kt b/android/companion/app/src/test/java/net/fledgewing/orbitcompanion/LocalWidgetsTest.kt index 24a9596a..effc1968 100644 --- a/android/companion/app/src/test/java/net/fledgewing/orbitcompanion/LocalWidgetsTest.kt +++ b/android/companion/app/src/test/java/net/fledgewing/orbitcompanion/LocalWidgetsTest.kt @@ -13,6 +13,7 @@ class LocalWidgetsTest { LibraryReadModel.initialize(sql) val store=object: ProjectionStore { override fun db()=sql + override val root=dir override fun meta(k:String)=if(k=="owner") "fixture" else null override fun transaction(block:()->T):T=sql.transaction(block) override fun close()=Unit