Skip to content
Open
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
1 change: 1 addition & 0 deletions packages/omamobile-omarchy/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pkgdesc="Omarchy Mobile's Omarchy patches, re-applied after every Omarchy upgrad
arch=(any)
url="https://github.com/derekross/omarchy-mobile"
license=(MIT)
provides=('omamobile-notification-snapshot=1')
depends=('omarchy>=4.0.6' bash python patch libarchive gzip util-linux sudo pacman-contrib fakeroot systemd)
optdepends=('omamobile-shell: the update sheet')
checkdepends=(diffutils patch util-linux libarchive)
Expand Down
4 changes: 4 additions & 0 deletions packages/omamobile-omarchy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!-- SPDX-License-Identifier: MIT -->
# Notification snapshot capability

`omamobile-notification-snapshot=1` declares the packaged notification snapshot interface; `forgetAll` is available only with the 4.5 patch family, so consumers must still select their path from the notification store layout.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# SPDX-License-Identifier: MIT
# Notifications: wait for both keyed stores before deleting, and clear one
# daemon-owned snapshot with an acknowledged logical-key list. New arrivals
# survive, and sender actions/images and quiet/DND state remain untouched.
#
# Against genuine Omarchy 4.5.0-3 after the public #471 patch 0019.
# The 4.0.6 family keeps its existing serialized file-queue behavior.

--- a/shell/plugins/notifications/Service.qml
+++ b/shell/plugins/notifications/Service.qml
@@ -1195,6 +1195,7 @@
function forgetNotification(name) {
var key = String(name || "")
if (!Store.KEY.test(key)) return "none"
+ if (!liveLoaded || !historyLoaded) return "busy"
var exists = !!liveKeys[key] || !!Store.liveEntry(liveEntries, key)
|| historyEntries.some(function(entry) { return entry.key === key })
if (!exists) return "ok"
@@ -1203,6 +1204,20 @@
saveSoon("history")
closeToast(key, "forget", true)
return "ok"
+ }
+
+ // Forget one logical snapshot, not a sequence of external IPC clients.
+ // Arrivals after this call are not acknowledged and must remain visible.
+ function forgetAllNotifications() {
+ if (!liveLoaded || !historyLoaded)
+ return JSON.stringify({ version: 1, result: "busy", keys: [] })
+ var keys = Object.keys(liveKeys)
+ liveEntries.concat(historyEntries).forEach(function(entry) {
+ if (keys.indexOf(entry.key) < 0) keys.push(entry.key)
+ })
+ keys = keys.filter(function(key) { return Store.KEY.test(key) })
+ for (var i = 0; i < keys.length; i++) forgetNotification(keys[i])
+ return JSON.stringify({ version: 1, result: "ok", keys: keys })
}

function storeClose(key, reason) {
@@ -1415,6 +1430,8 @@
function ping(): string { return "ok" }

function forget(name: string): string { return service.forgetNotification(name) }
+
+ function forgetAll(): string { return service.forgetAllNotifications() }

function isDnd(): string { return service.doNotDisturb ? "on" : "off" }

215 changes: 215 additions & 0 deletions packages/omamobile-omarchy/test/notification-snapshot.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
// SPDX-License-Identifier: MIT
const fs = require('fs'), vm = require('vm'), path = require('path'), assert = require('assert'),
os = require('os');
const root = path.resolve(process.argv[3]);
const source = fs.readFileSync(process.argv[2], 'utf8');
function fn(s, n) {
const a = s.indexOf(' function ' + n + '(');
assert(a >= 0, n);
let i = s.indexOf('{', a) + 1, depth = 1;
while (depth) {
if (s[i] === '{')
depth++;
if (s[i] === '}')
depth--;
i++
}
return s.slice(a, i)
}
function lib(name) {
let s = fs.readFileSync(path.join(root, name + '.js'), 'utf8');
let c = {console};
s = s.replace(/^\.import "([^"]+)" as (\w+)\s*$/gm, (_, f, a) => {
c[a] = lib(f.replace('.js', ''));
return ''
}).replace(/^\.pragma.*$/gm, '');
vm.createContext(c);
vm.runInContext(s, c);
return c
}
const Store = lib('Store');
let tests = 0;
function test(name, f) {
f();
tests++;
console.log('PASS', name)
}
function service(ready = true) {
let files = {live : '', history : ''}, later = [], dismissed = 0;
let c = {
Object,
JSON,
Date,
Math,
Store,
liveLoaded : ready,
historyLoaded : ready,
liveKeys : Object.create(null),
refs : Object.create(null),
refsRevision : 0,
liveEntries : [],
historyEntries : [],
held : [],
leaving : {},
departures : {},
bannerHidden : {},
replyKey : '',
heights : {},
fresh : {},
layoutRevision : 0,
unsaved : {},
quietLoaded : true,
doNotDisturb : true,
jumping : false,
saveTimer : {running : false, start() { this.running = true }},
land() {},
Qt : {callLater : f => later.push(f)}
};
c.service = c;
c.rows = [];
c.toasts = {get : i => c.rows[i], remove : i => c.rows.splice(i, 1)};
Object.defineProperty(c.toasts, 'count', {get : () => c.rows.length});
c.rowIndexFor = k => c.rows.findIndex(x => x.key === k);
c.setBannerHidden = (k, v) => {
if (v)
c.bannerHidden[k] = true;
else
delete c.bannerHidden[k]
};
c.liveFile = {setText : t => files.live = t};
c.historyFile = {setText : t => files.history = t};
c.quietFile = {setText : () => { throw Error('DND must not be written') }};
vm.createContext(c);
vm.runInContext(
[
'releaseLive', 'release', 'closeToast', 'closeToasts', 'unmarkLeaving', 'finishClose',
'finishLeaving', 'forgetNotification', 'forgetAllNotifications', 'storeDrop', 'storeClose',
'storeRecord', 'saveSoon', 'flushStore'
].map(n => fn(source, n))
.join('\n'),
c);
c.add = (k, kind = 'visible') => {
const row = {
key : k,
ts : Date.now() / 1000,
app : 'Fixture',
summary : 'Owned notification',
body : 'body',
urgency : 1
};
if (kind === 'history') {
c.historyEntries.push({...row, closed_ts : Date.now() / 1000});
return
}
c.liveKeys[k] = {row : null};
c.liveEntries.push(row);
if (kind !== 'pending') {
c.rows.push(row);
if (kind === 'hidden')
c.bannerHidden[k] = true
}
c.refs[k] = {
dismiss() { dismissed++ },
expire() { throw Error('must not expire') },
invokeAction() { throw Error('must not invoke sender action') }
}
};
c.settle = () => {
while (later.length)
later.shift()();
c.flushStore()
};
return {c, files, dismissed : () => dismissed};
}
test('clear snapshot removes visible, hidden, pending and history without rearchive', () => {
const s = service();
s.c.add('visible');
s.c.add('hidden', 'hidden');
s.c.add('pending', 'pending');
s.c.add('old', 'history');
const r = JSON.parse(s.c.forgetAllNotifications());
assert.equal(r.result, 'ok');
assert.equal(r.version, 1);
assert.deepEqual([...r.keys ].sort(), [ 'hidden', 'old', 'pending', 'visible' ]);
s.c.settle();
assert.equal(s.c.rows.length, 0);
assert.equal(s.c.liveEntries.length, 0);
assert.equal(s.c.historyEntries.length, 0);
assert.deepEqual(JSON.parse(s.files.live), []);
assert.deepEqual(JSON.parse(s.files.history), []);
assert.equal(s.dismissed(), 3);
assert.equal(s.c.doNotDisturb, true)
});
test('history-only deletion is persisted and cannot return on reload', () => {
const s = service();
s.c.add('one', 'history');
s.c.add('two', 'history');
assert.equal(s.c.forgetNotification('one'), 'ok');
s.c.settle();
assert.deepEqual(Store.parseHistory(s.files.history).map(x => x.key), [ 'two' ]);
assert.equal(s.dismissed(), 0)
});
test('one hidden live row is dropped from both store and sender reference', () => {
const s = service();
s.c.add('one', 'hidden');
assert.equal(s.c.forgetNotification('one'), 'ok');
s.c.settle();
assert.equal(s.c.liveEntries.length, 0);
assert(!s.c.refs.one);
assert.equal(s.c.historyEntries.length, 0)
});
test('unloaded stores refuse before mutation instead of resurrecting later load', () => {
const s = service(false);
s.c.add('one', 'history');
assert.equal(s.c.forgetNotification('one'), 'busy');
assert.equal(JSON.parse(s.c.forgetAllNotifications()).result, 'busy');
assert.equal(s.c.historyEntries.length, 1);
assert.equal(Object.keys(s.c.unsaved).length, 0)
});
test('either partially loaded store refuses before mutation', () => {
for (const partial of ['liveLoaded', 'historyLoaded']) {
const s = service(false);
s.c[partial] = true;
s.c.add('old', 'history');
assert.equal(s.c.forgetNotification('old'), 'busy');
const reply = JSON.parse(s.c.forgetAllNotifications());
assert.equal(reply.version, 1);
assert.equal(reply.result, 'busy');
assert.equal(s.c.historyEntries.length, 1);
assert.equal(Object.keys(s.c.unsaved).length, 0);
}
});
test('new arrival after clear is retained and not included in acknowledgment', () => {
const s = service();
s.c.add('old');
let r = JSON.parse(s.c.forgetAllNotifications());
s.c.add('new');
s.c.settle();
assert.deepEqual(r.keys, [ 'old' ]);
assert.deepEqual(s.c.liveEntries.map(x => x.key), [ 'new' ]);
assert.equal(s.c.historyEntries.length, 0)
});
test('repeated clear is idempotent after deferred closures settle', () => {
const s = service();
s.c.add('old');
s.c.forgetAllNotifications();
s.c.settle();
assert.deepEqual(JSON.parse(s.c.forgetAllNotifications()).keys, []);
s.c.settle();
assert.equal(s.dismissed(), 1)
});
test('invalid keyed delete performs no arbitrary file operation', () => {
const s = service();
s.c.add('old');
for (const key of ['../quiet.json', '/etc/passwd', 'a/b', ''])
assert.equal(s.c.forgetNotification(key), 'none');
assert.equal(s.c.liveEntries.length, 1);
assert.equal(Object.keys(s.c.unsaved).length, 0)
});
test('already absent key stays idempotent after stores load', () => {
const s = service();
assert.equal(s.c.forgetNotification('gone'), 'ok');
s.c.settle();
assert.equal(s.dismissed(), 0)
});
console.log('PASS total', tests, 'genuine-source provider cases');
4 changes: 4 additions & 0 deletions packages/omamobile-omarchy/test/port45.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ def actual(t, ex, version, make_root, run, ok, read, series, package, parse_qml)
node_tests = [
('upstream45/notifications/logic.cjs', [], 'actual notification functions'),
('notification-store45.cjs', [env['OMARCHY_SHELL_DIR']], 'keyed store and lock-glance compatibility'),
('notification-snapshot.cjs', [
os.path.join(env['OMARCHY_SHELL_DIR'], 'plugins/notifications/Service.qml'),
os.path.join(env['OMARCHY_SHELL_DIR'], 'plugins/notifications'),
], 'startup-safe snapshot notification deletion'),
]
for script, arguments, label in node_tests:
if not node:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ function newCapacityScope() {
maxLiveNotifications: 100, heights: {}, fresh: {}, leaving: {}, departures: {}, layoutRevision: 0,
arriving: '', jumping: false, travel: 24, arriveDuration: 250, leaveDuration: 200, placements: {},
held: [], doNotDisturb: false,
liveEntries: [], historyEntries: [], unsaved: {}, liveLoaded: false,
liveEntries: [], historyEntries: [], unsaved: {}, liveLoaded: false, historyLoaded: false,
saveTimer: { running: false, start() {} },
deckDisplayName: '',
hyprRevision: 0,
Expand Down Expand Up @@ -1079,6 +1079,9 @@ console.log('notification logic: passed')
}
{
const s = newCapacityScope()
// Idempotent deletion is a post-startup contract.
s.liveLoaded = true
s.historyLoaded = true
const n = s.fakeNotification(8, 'Synthetic forgotten')
s.admit(n)
const key = s.toasts.get(0).key
Expand Down Expand Up @@ -1110,4 +1113,20 @@ console.log('notification logic: passed')
s.drainCallLater()
assert.equal(retainedState(), afterFirstForget, 'second forget leaves state unchanged')
}
{
const s = newCapacityScope()
const n = s.fakeNotification(9, 'Synthetic startup notification')
s.admit(n)
const key = s.toasts.get(0).key
const snapshot = () => JSON.stringify({
live: s.liveEntries, history: s.historyEntries, keys: s.liveKeys,
rows: s.toasts.rows, unsaved: s.unsaved,
})
const before = snapshot()
assert.equal(s.forgetNotification(key), 'busy', 'startup deletion waits for both stores')
assert.equal(snapshot(), before, 'unloaded deletion leaves all logical state untouched')
s.liveLoaded = true
assert.equal(s.forgetNotification(key), 'busy', 'history still loading cannot authorize deletion')
assert.equal(snapshot(), before)
}
console.log('mobile 4.5 reply/forget: passed')
2 changes: 1 addition & 1 deletion packages/omamobile-omarchy/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.39
0.1.40