pi-roundtable-web 0.23.1 → 0.23.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.md +9 -1
- package/dist/{chunk-character-creator-660d2t6p.js → chunk-character-creator-dwk6y4be.js} +1 -1
- package/dist/{chunk-connectors-d19v8cjc.js → chunk-connectors-pk0fh4y6.js} +1 -1
- package/dist/{chunk-conversations-4cmexmqq.js → chunk-conversations-sfsgmsdm.js} +1 -1
- package/dist/{chunk-entry-8xpx35ef.js → chunk-entry-x0j9g57j.js} +1 -1
- package/dist/{chunk-index-9tvf6es7.js → chunk-index-9k42hnam.js} +3 -3
- package/dist/{chunk-index-xw5hhmfq.js → chunk-index-k0z1ykph.js} +1 -1
- package/dist/{chunk-notes-fefwds14.js → chunk-notes-v60aswry.js} +1 -1
- package/dist/{chunk-overview-bxpwpmn6.js → chunk-overview-c1c0ccda.js} +1 -1
- package/dist/{chunk-skills-pce3zgxy.js → chunk-skills-r8rwbc5y.js} +1 -1
- package/dist/{chunk-table-zmpbrfvz.js → chunk-table-pmr7zrgm.js} +1 -1
- package/dist/{chunk-transcript-yhtjp3pd.js → chunk-transcript-wjqk37f5.js} +1 -1
- package/dist/{chunk-zh-tw-anqhqpaz.js → chunk-zh-tw-mtvm7sn7.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/sw.js +1 -1
- package/package.json +2 -2
- package/src/api-types.ts +9 -0
- package/src/app/app.ts +17 -0
- package/src/app/routes.ts +5 -0
- package/src/i18n/zh-tw.ts +2 -0
- package/src/options.ts +34 -0
- package/src/push/quiet-hours.ts +60 -0
- package/src/push/triggers.ts +14 -2
- package/src/web-plugin.ts +4 -0
package/src/push/triggers.ts
CHANGED
|
@@ -23,6 +23,11 @@ export interface PushServiceOptions {
|
|
|
23
23
|
logger: Logger;
|
|
24
24
|
/** The clock, in milliseconds; default `Date.now`. */
|
|
25
25
|
now?: () => number;
|
|
26
|
+
/**
|
|
27
|
+
* Whether a moment, in milliseconds, is in the quiet hours: an agent's post and a notice are
|
|
28
|
+
* not pushed then, while a card is. Default never.
|
|
29
|
+
*/
|
|
30
|
+
quiet?: (at: number) => boolean;
|
|
26
31
|
}
|
|
27
32
|
|
|
28
33
|
/** What a trigger says; the service shapes it into a notification. */
|
|
@@ -49,7 +54,8 @@ export function previewOf(text: string): string {
|
|
|
49
54
|
/**
|
|
50
55
|
* Decides when an owner's devices are pushed and what is said. Each trigger pushes only while no
|
|
51
56
|
* page of an owner is in view, and only to owners: a device whose person is no owner any more is
|
|
52
|
-
* skipped.
|
|
57
|
+
* skipped. In the quiet hours an agent's post and a notice wait for the owner to look; a card,
|
|
58
|
+
* which holds up work, is still pushed. Delivery never throws into the code that raised the trigger.
|
|
53
59
|
*/
|
|
54
60
|
export class PushService {
|
|
55
61
|
readonly #options: PushServiceOptions;
|
|
@@ -72,7 +78,8 @@ export class PushService {
|
|
|
72
78
|
|
|
73
79
|
/** An agent posted in a room, such as a finished job's report or an answer nobody was watching for. */
|
|
74
80
|
reply(room: string, author: string, text: string): Promise<void> {
|
|
75
|
-
const now =
|
|
81
|
+
const now = this.#now();
|
|
82
|
+
if (this.#options.quiet?.(now)) return Promise.resolve();
|
|
76
83
|
const last = this.#repliedAt.get(room);
|
|
77
84
|
if (last !== undefined && now - last < REPLY_QUIET_MS)
|
|
78
85
|
return Promise.resolve();
|
|
@@ -88,6 +95,7 @@ export class PushService {
|
|
|
88
95
|
|
|
89
96
|
/** A notice for one person, from the `notify` tool. */
|
|
90
97
|
notice(principalId: string, text: string, room?: string): Promise<void> {
|
|
98
|
+
if (this.#options.quiet?.(this.#now())) return Promise.resolve();
|
|
91
99
|
return this.#push({
|
|
92
100
|
kind: "notice",
|
|
93
101
|
title: "Notice",
|
|
@@ -98,6 +106,10 @@ export class PushService {
|
|
|
98
106
|
});
|
|
99
107
|
}
|
|
100
108
|
|
|
109
|
+
#now(): number {
|
|
110
|
+
return (this.#options.now ?? Date.now)();
|
|
111
|
+
}
|
|
112
|
+
|
|
101
113
|
async #push(event: Event): Promise<void> {
|
|
102
114
|
const { logger, preview } = this.#options;
|
|
103
115
|
try {
|
package/src/web-plugin.ts
CHANGED
|
@@ -153,6 +153,10 @@ async function build(settings: ResolvedOptions, context: Context) {
|
|
|
153
153
|
vapid,
|
|
154
154
|
subject: settings.push.subject,
|
|
155
155
|
preview: settings.push.preview,
|
|
156
|
+
...(settings.push.quietHours
|
|
157
|
+
? { quietHours: settings.push.quietHours }
|
|
158
|
+
: {}),
|
|
159
|
+
timeZone: env.timeZone,
|
|
156
160
|
endpointHosts: settings.push.endpointHosts,
|
|
157
161
|
...(settings.push.fetch ? { fetch: settings.push.fetch } : {}),
|
|
158
162
|
urlOf: (room) =>
|