Skip to content

feat(system): add the base for the redesigned home screen widgets - #346

Open
Tarquinen wants to merge 18 commits into
devfrom
widgets-redesign
Open

Tarquinen wants to merge 18 commits into
devfrom
widgets-redesign

Conversation

@Tarquinen

Copy link
Copy Markdown
Member

The base for the redesigned home screen widgets (part of #287). It adds no widget yet: the Ask, Needs You and Sessions widgets each come in their own PR on top of this one.

Widgets draw from one saved file and never use the network while drawing. The app's session list writes it while the app is open, a push writes it when a session needs an answer, finishes or fails, and a clear or an answer from a notification removes the request. The shared pieces (card, header, project badge, buttons, code box) follow the desktop look.

The new widgets stay out of the launcher's picker until the Home Screen Widgets experiment is on (off by default). A debug-only lab screen draws a widget at exact sizes from fixture data, which is what the pictures below show with a throwaway widget.

Light Dark
Shared widget pieces, light Shared widget pieces, dark

Adds one new test file, HomeWidgetDataTests.kt, for how pushes, clears and the app's list combine. Based on #337.

OpenCode now sends push messages itself (specs/v2/push.md in the opencode
repo): permission requests, questions, finished and failed turns, and clears.
The phone registers with PUT /api/experimental/push/device/<ref> instead of
pairing through the notify plugin, and shows each message as its own
notification:

- Permission: the commands or paths in a code block with Deny, Always Allow
  and Allow. A request that was cut only offers Open.
- Question: up to three option rows that answer on tap, plus Reply for a typed
  answer. Long questions, several questions and multi-selects only offer Open.
- Finished and failed: the end of the answer or the error, with Reply.
- Clears remove a notification, ordered by time as the spec asks.

Replaces OpenCodeClient.pairNotificationPreview with registerPushDevice and
drops the "previews need HTTPS" error. Boxes in the old payload format still
go through the old path.

Verified: scripts/check.sh on the Android VM (assemble, lint, unit tests),
translations.py all.
The debug-only lab-server-url extra saved the server with an empty password, so a
test server with a password answered 401. lab-server-password sets it.

Verified: a debug build launched with both extras connected to a password-protected
server on the emulator.
- A question answered by typing into the notification stayed in the shade:
  Android refuses an app's cancel of a notification that was replied to
  inline. It is now posted again with a short timeout, and later clears leave
  it alone while it goes.
- The launcher's badge count was the unread count times the number of
  notifications, because each one carried the whole count. Each push
  notification now counts as one.
- A finished turn shows the end of the answer as plain text (Markdown marks
  dropped), cut to the lines that fit, instead of the first lines of the last
  500 characters.
- A long question's collapsed line is its last line, which is the one that
  asks.
- "Wants to run a command" instead of "Wants to run 1 command".

Verified on the Android VM emulator (API 36) against an OpenCode dev server:
typed answer removes the question and the Finished notification replaces it;
scripts/check.sh :feature:system; translations.py all.
… is now

The parity doc still described the relay work FCM needed; the relay has it,
and OpenCode sends the pushes itself.

Verified: scripts/check.sh :feature:system on the Android VM.
…ation

PushNotificationTests reads messages in the server's format and checks what
each becomes: the permission's commands and buttons, question rows, the end of
a finished answer, failure text, unknown messages, and the ledger's ordering
of messages and clears.

firebase.xml holds the Firebase app's four string resources, which FCM needs
to give the app a token. Without it no push can arrive.

Verified: scripts/check.sh :feature:system on the Android VM (14 new tests pass).
…ixes

A permission request the server cut down to its ids has no action. It was
shown as a generic notification; it is now a permission notification that
only offers Open. A clear with a version this app doesn't know does nothing.
Typed replies ask for the phone to be unlocked, as Allow does.

Also drops an unused parameter, updates two comments and the parity rows
that still described the notify plugin's pairing call.

Verified: scripts/check.sh :server :feature:system on the VM (PushNotificationTests 14 passed).
The icon was orange, green or red by kind. It now has the system's own
colour, as the app's other notifications do.

Verified: scripts/check.sh :feature:system on the VM.
A long command, or many of them, was cut at four lines while Allow and
Always Allow stayed, so the part being approved could be hidden. The code
block now shows up to eight lines, and a request that doesn't fit in them
only offers Open, like one the server had to cut. Whether it fits is
estimated from the screen width and font size, erring towards Open.

Shell commands start with "$ " so a wrapped command reads as one.

Verified: scripts/check.sh :feature:system on the VM (PushNotificationTests
15 passed); on an API 36 emulator a 300-character pipeline, eight chained
commands and a heredoc script each showed Open only, and two short commands
kept Deny, Always Allow and Allow.
…fications

The line listed every saved pattern under the commands and ran to two
clipped lines for a request with several commands. A permission
notification is now the commands and the buttons; the patterns Always
Allow would save are no longer read from the message.

Verified: scripts/check.sh :feature:system on the VM (PushNotificationTests
15 passed); a two-command request on an API 36 emulator shows the commands
and Deny, Always Allow, Allow with nothing between.
A permission for a file such as README.md got a system "Open link" chip,
because the name looks like a web address.

Verified: scripts/check.sh :feature:system on the VM; an edit request for
README.md on an API 36 emulator shows only Deny, Always Allow and Allow.
Push notifications no longer post silently for an In-App Notices mode:
PushNotifications drops the silent flag, since presentation() is now only
None (the visible session) or Banner. docs/parity/system.md keeps this
branch's push rows and takes dev's wording that In-App Notices is not in
the app.

Verified: scripts/check.sh (all modules) on the Android VM.
The app still carried the old notification system next to the new one: the
notify plugin check and its setup prompt, the callback address sent with
every prompt and share, Always Notify, and the old payload format.

Now there is one path. The phone registers with the server's push API when
it connects, and Settings > Notifications controls only this phone:

- Notifications: on or off for this server. Off deletes the device on the
  server, and so does removing the server from the app.
- Notify About: Everything, or Only When It Needs Me.
- Sound and banners: rows that open Android's settings for each channel.
- A server without the push API shows the switch disabled.

Removed: OpenCodeClient.notifyPluginStatus and setAlwaysNotify,
PromptContext.notificationCallbackURL, the callback in ShareCredentials,
the Always Notify card, the old payload path in SessionPushNotifications,
NotificationContent and NotificationCrypto, and the What's New entries for
Always Notify, notify plugin setup and encrypted notification previews.
A server older than 2.4.2 no longer notifies this app.

Verified: scripts/check.sh (all modules) on the VM. On an API 36 emulator
against a server run from OpenCode dev: registration on connect, each
level, off and on, Android's permission never asked and denied, a real
push through the relay and FCM, removing a server (its device is deleted),
and a 2.4.1 server (switch disabled).
The line under the three rows ("Opens Android settings, where each kind can
pop up, make a sound or be turned off.") read oddly and the rows explain
themselves, so it is removed along with its string and translations.

Verified: scripts/check.sh :feature:settings on the VM, and the page on an
API 36 emulator in light and dark.
The page listed Needs You, Finished and Failed with a way into each
channel's Android settings. The app decides how each kind arrives instead
(permissions, questions and failures pop up with a sound; a finished
session only makes a sound), so the rows, the code that read the channels'
importance and their strings are removed.

Verified: scripts/check.sh (all modules) on the VM, and the page on an API
36 emulator in light and dark.
Android's notification prompt only appeared from the switch in Settings or
a first voice call, so most people would never be asked and never get a
notification.

Now an accepted send shows the prompt while Android has never asked. That
happens once per install: a refusal is remembered and the Settings page
then points at Android's settings. Allowing registers the phone.

Verified: scripts/check.sh (all modules) on the VM. On an API 36 emulator
with a fresh install: the first send shows the prompt, Allow registers the
device on the server, and after Don't allow a second send does not ask.
…ttings

- Opening the app removes this server's notifications for sessions that are
  read or archived and for requests already answered. The server's clear push
  normally does this, but it can be lost.
- Tapping a notification closes Settings and the drawer so the session shows.
- Removing a server from the app removes its notifications; a tap on one did
  nothing before.
- Notifications no longer carry CATEGORY_MESSAGE, which is for messages between
  people and can pass Do Not Disturb.

Verified with scripts/check.sh and on an API 36 emulator: stale notifications
removed on reopening after lost clears (unread ones kept), a tap with Settings
open, removing a server with a notification showing, and no category in
dumpsys notification.
Cleanup after review of the push rebuild.

- The app no longer keeps its own launcher count. AppIconBadge, AppBadgeLedger,
  Home's badge publishing, the ledger block in the push handler and the
  "Badge on the App Icon" What's New entry are gone: every push already counted
  as one, so the saved count was computed and never shown. The launcher badge
  is the notifications that are showing.
- Removed members nothing called: SessionNotifications.onOpen,
  pendingDestination, includeBadges, PushTokenProvider.inert; the
  NotificationPresentation enum is now isOnScreen(sessionID).
- A device id is no longer made up on read: the stale sweep, turning
  notifications off and removing a server use savedRef, and no DELETE is sent
  to a server this phone never registered with.
- A notification choice is saved only after the server accepts it, instead of
  saved first and rolled back.
- The three push requests are OpenCodeClient values with live and test
  implementations, like every other request.
- Every removal goes through PushNotifications.cancel, so a notification that
  was answered inline is removed the same way everywhere.
- HomeNotificationsFeature loads the settings in one helper.
- Stale comments, a test name and the parity rows updated.

Verified: vm.sh check (build, lint, unit tests) passes. On the emulator against
the push rig: Finished and question pushes arrive and group; answering a
question from the notification removes it; opening a session clears its
notification; the Notifications switch deletes and re-registers the device;
offline the switch stays on with "Couldn't change notifications. Try again.";
with the device deleted on the server, reopening the app removes a viewed
session's notification and keeps an unread one.
The new Ask, Needs You and Sessions widgets (issue #287) all draw from one
saved file, so they never touch the network while drawing. This adds that
file and what writes it, with no widget yet:

- HomeWidgetData / HomeWidgetStore: per server, the session list with each
  session's status and times, and the permissions and questions waiting for
  an answer.
- Writers: the app's session list while the app is open (throttled, and once
  more on entering the background), a push (permission, question, finished,
  failed), and a clear or an answer from a notification.
- HomeWidgetKit: the shared Glance pieces (card, header, project badge,
  button, code box, not-paired state) in the desktop look.
- The Home Screen Widgets experiment, off by default. Widget receivers in
  widgets.home are declared disabled and enabled while it is on, so the new
  widgets stay out of the launcher's picker until then.
- A debug-only lab activity that draws a widget at exact sizes from fixture
  data, for screenshots.

Verified: scripts/check.sh :core :feature:system :feature:drawer :app on the
dev VM (build, lint, unit tests, translations); the lab on the emulator in
light and dark with a throwaway widget, including a scrolling list.
Base automatically changed from push-core-notifications to dev November 29, 2026 23:23

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant