agent-loft 0.2.55 → 0.2.57
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/package.json +1 -1
- package/src/agents/codex/driver.ts +44 -1
- package/src/channels/web/push.ts +3 -3
- package/src/channels/web/server.ts +20 -5
- package/src/core/config.ts +6 -0
- package/web/css/topbar.css +0 -4
- package/web/lib/diagrams.js +2 -1
- package/web/lib/shell.js +2 -0
- package/web/lib/ws.js +37 -8
- package/web/settings/agents.js +10 -0
- package/web/settings/notify.js +3 -1
- package/web/views/layout.js +3 -3
- package/web/views/messages.js +2 -2
package/package.json
CHANGED
|
@@ -107,7 +107,50 @@ export class CodexDriver implements AgentDriver {
|
|
|
107
107
|
|
|
108
108
|
async sessionTitle(id: string): Promise<string | undefined> {
|
|
109
109
|
const res = await appServer.call<{ thread: Thread }>("thread/read", { threadId: id, includeTurns: false });
|
|
110
|
-
|
|
110
|
+
const name = res.thread.name?.replace(/\s+/g, " ").trim();
|
|
111
|
+
if (name) return name;
|
|
112
|
+
// app-server 不会自动起名(Codex App / TUI 是在客户端自己生成的),开了设置就由这边生成一次
|
|
113
|
+
const c = config().agents.codex;
|
|
114
|
+
if (!c.autoTitle || this.titled.has(id)) return undefined;
|
|
115
|
+
this.titled.add(id);
|
|
116
|
+
return this.generateTitle(id, c.titleModel).catch((err) => {
|
|
117
|
+
console.error("[codex] 生成会话名称失败:", err instanceof Error ? err.message : err);
|
|
118
|
+
return undefined;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** 本进程里已经生成过(或试过)名称的线程:失败了也不反复重试,每轮结束都会来问 */
|
|
123
|
+
private titled = new Set<string>();
|
|
124
|
+
|
|
125
|
+
/** 按第一轮的问答起个短标题,写回线程(thread/name/set),Codex App 里也能看到 */
|
|
126
|
+
private async generateTitle(id: string, model: string): Promise<string | undefined> {
|
|
127
|
+
const res = await appServer.call<{ thread: { turns?: { items?: HistoryItem[] }[] } }>("thread/read", { threadId: id, includeTurns: true });
|
|
128
|
+
const items = res.thread.turns?.[0]?.items ?? [];
|
|
129
|
+
const user = items
|
|
130
|
+
.filter((i) => i.type === "userMessage")
|
|
131
|
+
.flatMap((i) => (i.content ?? []).map((c) => (c.type === "text" ? (c.text ?? "") : "")))
|
|
132
|
+
.join("\n");
|
|
133
|
+
const question = splitAttachmentNote(stripContext(user)).text.trim();
|
|
134
|
+
if (!question) return undefined;
|
|
135
|
+
const answer = items
|
|
136
|
+
.filter((i) => i.type === "agentMessage" && i.phase !== "commentary" && i.text)
|
|
137
|
+
.map((i) => i.text)
|
|
138
|
+
.join("\n\n");
|
|
139
|
+
const out = (await this.complete({
|
|
140
|
+
system: "你给对话起标题。根据用户的第一条消息(和助手的回复)概括这次对话在做什么,输出一个简短的标题:和用户用同一种语言,中文不超过 15 个字,不加引号、句号和表情。",
|
|
141
|
+
prompt: `用户:\n${question.slice(0, 2000)}${answer ? `\n\n助手:\n${answer.slice(0, 1500)}` : ""}`,
|
|
142
|
+
schema: { type: "object", properties: { title: { type: "string" } }, required: ["title"], additionalProperties: false },
|
|
143
|
+
...(model ? { model } : {}),
|
|
144
|
+
timeoutMs: 60_000,
|
|
145
|
+
})) as { title?: unknown };
|
|
146
|
+
const title = String(out?.title ?? "")
|
|
147
|
+
.replace(/\s+/g, " ")
|
|
148
|
+
.replace(/^["'“”‘’「」《》]+|["'“”‘’「」《》。.]+$/g, "")
|
|
149
|
+
.trim()
|
|
150
|
+
.slice(0, 80);
|
|
151
|
+
if (!title) return undefined;
|
|
152
|
+
await appServer.call("thread/name/set", { threadId: id, name: title });
|
|
153
|
+
return title;
|
|
111
154
|
}
|
|
112
155
|
|
|
113
156
|
async readHistory(id: string): Promise<HistoryMessage[]> {
|
package/src/channels/web/push.ts
CHANGED
|
@@ -347,9 +347,9 @@ export function removeSubscriptionsOf(mine: OwnerFilter): void {
|
|
|
347
347
|
if (s.subscriptions.length !== before) persist();
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
-
/**
|
|
351
|
-
export async function pushToAll(payload: PushPayload, to?: OwnerFilter): Promise<number> {
|
|
352
|
-
const subs = load().subscriptions.filter((x) => !to || to(x.userId));
|
|
350
|
+
/** 按主人和设备筛选订阅,返回成功的数量。单个设备失败不影响别的。 */
|
|
351
|
+
export async function pushToAll(payload: PushPayload, to?: OwnerFilter, device?: (endpoint: string, userId: string | undefined) => boolean): Promise<number> {
|
|
352
|
+
const subs = load().subscriptions.filter((x) => (!to || to(x.userId)) && (!device || device(x.endpoint, x.userId)));
|
|
353
353
|
if (subs.length === 0) return 0;
|
|
354
354
|
const results = await Promise.all(
|
|
355
355
|
subs.map((sub) =>
|
|
@@ -182,6 +182,9 @@ type Client = {
|
|
|
182
182
|
/** 页面在前台,且正看着哪条会话(前端在切会话、切前后台时上报) */
|
|
183
183
|
visible: boolean;
|
|
184
184
|
viewing: string | null;
|
|
185
|
+
/** 本设备应用是否在前台、它的推送订阅(与当前会话及空闲计时无关)。 */
|
|
186
|
+
foreground: boolean;
|
|
187
|
+
pushEndpoint: string | null;
|
|
185
188
|
/** 最后一次收到这个页面的消息(含 ping) */
|
|
186
189
|
seen: number;
|
|
187
190
|
};
|
|
@@ -246,14 +249,24 @@ function broadcastSkills(): void {
|
|
|
246
249
|
// ---------- 系统通知(Web Push) ----------
|
|
247
250
|
|
|
248
251
|
/**
|
|
249
|
-
*
|
|
252
|
+
* 桌面端或旧页面正在前台看着这条会话:人就在眼前,不用推。
|
|
253
|
+
* 能上报订阅的新页面按设备过滤,避免手机在前台时连带屏蔽其它设备。
|
|
250
254
|
* 页面每 25 秒发一次 ping;40 秒没收到它的任何消息就不算(手机切走后网络断了,连接还没被心跳清掉,
|
|
251
255
|
* 最后报的还是「在看」)
|
|
252
256
|
*/
|
|
253
257
|
const SEEN_MS = 40_000;
|
|
254
258
|
function watching(key: string): boolean {
|
|
255
259
|
const now = Date.now();
|
|
256
|
-
for (const client of clients) if (client.visible && client.viewing === key && now - client.seen < SEEN_MS) return true;
|
|
260
|
+
for (const client of clients) if (!client.pushEndpoint && client.visible && client.viewing === key && now - client.seen < SEEN_MS) return true;
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** 只暂停前台设备自己的推送,不影响同账号的其它设备或其它用户。 */
|
|
265
|
+
function foregroundDevice(endpoint: string, owner: string | undefined): boolean {
|
|
266
|
+
const now = Date.now();
|
|
267
|
+
for (const client of clients) {
|
|
268
|
+
if (client.foreground && client.pushEndpoint === endpoint && client.user.id === owner && now - client.seen < SEEN_MS && checkClient(client)) return true;
|
|
269
|
+
}
|
|
257
270
|
return false;
|
|
258
271
|
}
|
|
259
272
|
|
|
@@ -286,7 +299,7 @@ type Notice = { title: string; body: string; tag: string };
|
|
|
286
299
|
* 一条要提醒的动静,走两条路:
|
|
287
300
|
* - 广播给所有连着的页面(t: "notice"):桌面端据此弹系统通知,要不要弹由它自己判断
|
|
288
301
|
* (它知道自己是不是正看着这条会话)。普通网页忽略。
|
|
289
|
-
* - Web Push
|
|
302
|
+
* - Web Push:只在没有页面正看着这条会话时推,并跳过应用正在前台的设备。
|
|
290
303
|
*/
|
|
291
304
|
function notify(key: string, notice: Notice): void {
|
|
292
305
|
if (!isWebConv(key)) return;
|
|
@@ -297,7 +310,7 @@ function notify(key: string, notice: Notice): void {
|
|
|
297
310
|
void pushToAll({ ...notice, url: `/#${encodeURIComponent(key)}` }, (owner) => {
|
|
298
311
|
const u = getUser(owner ?? legacy);
|
|
299
312
|
return !!u && !u.disabled && canSeeKey(u, key);
|
|
300
|
-
});
|
|
313
|
+
}, (endpoint, owner) => !foregroundDevice(endpoint, owner ?? legacy));
|
|
301
314
|
}
|
|
302
315
|
|
|
303
316
|
function pushEvent(env: EventEnvelope): void {
|
|
@@ -376,6 +389,8 @@ function handleClientMessage(client: Client, raw: string): void {
|
|
|
376
389
|
case "presence":
|
|
377
390
|
client.visible = msg.visible === true;
|
|
378
391
|
client.viewing = typeof msg.key === "string" && msg.key ? msg.key : null;
|
|
392
|
+
client.foreground = msg.foreground === true;
|
|
393
|
+
client.pushEndpoint = typeof msg.pushEndpoint === "string" && msg.pushEndpoint.length <= 4096 ? msg.pushEndpoint : null;
|
|
379
394
|
return;
|
|
380
395
|
|
|
381
396
|
case "unsub":
|
|
@@ -509,7 +524,7 @@ export async function startWeb(): Promise<void> {
|
|
|
509
524
|
if (url.pathname === "/ws/term") return upgradeTerminal(wss!, req, socket, head, user, token, url);
|
|
510
525
|
if (url.pathname === "/ws/desktop") return upgradeDesktop(wss!, req, socket, head, user, token, url);
|
|
511
526
|
wss!.handleUpgrade(req, socket, head, (ws) => {
|
|
512
|
-
const client: Client = { ws, subs: new Set(), alive: true, token, user, visible: false, viewing: null, seen: Date.now() };
|
|
527
|
+
const client: Client = { ws, subs: new Set(), alive: true, token, user, visible: false, viewing: null, foreground: false, pushEndpoint: null, seen: Date.now() };
|
|
513
528
|
clients.add(client);
|
|
514
529
|
ws.on("pong", () => (client.alive = true));
|
|
515
530
|
ws.on("message", (data) => {
|
package/src/core/config.ts
CHANGED
|
@@ -52,6 +52,10 @@ export type AppConfig = {
|
|
|
52
52
|
defaultEffort: string;
|
|
53
53
|
/** 同 claude.models */
|
|
54
54
|
models: string[];
|
|
55
|
+
/** app-server 不会给线程起名(那是 Codex App / TUI 自己做的),开了就由这边在第一轮后生成 */
|
|
56
|
+
autoTitle: boolean;
|
|
57
|
+
/** 生成会话名称用的模型,空 = Codex 默认模型 */
|
|
58
|
+
titleModel: string;
|
|
55
59
|
};
|
|
56
60
|
};
|
|
57
61
|
web: {
|
|
@@ -126,6 +130,8 @@ export function defaultConfig(): AppConfig {
|
|
|
126
130
|
defaultModel: "",
|
|
127
131
|
defaultEffort: "",
|
|
128
132
|
models: [],
|
|
133
|
+
autoTitle: false,
|
|
134
|
+
titleModel: "",
|
|
129
135
|
},
|
|
130
136
|
},
|
|
131
137
|
web: { enabled: true, host: "0.0.0.0", port: 8800, passwordHash: "", trustedProxies: ["127.0.0.1", "::1"], quotaRefreshMin: 10, quotaEnabled: true },
|
package/web/css/topbar.css
CHANGED
package/web/lib/diagrams.js
CHANGED
|
@@ -244,7 +244,8 @@ function chartOption(spec) {
|
|
|
244
244
|
axisTick: { show: false },
|
|
245
245
|
axisLabel: { color: c.muted },
|
|
246
246
|
splitLine: { show: type === "value", lineStyle: { color: c.grid } },
|
|
247
|
-
|
|
247
|
+
// 普通折线和散点按数据范围缩放;柱形、面积及堆叠图保留 0 基线。
|
|
248
|
+
scale: type === "value" && (spec.type === "scatter" || (spec.type === "line" && !spec.stack)),
|
|
248
249
|
});
|
|
249
250
|
const category = axis("category", spec.xName);
|
|
250
251
|
category.data = spec.x;
|
package/web/lib/shell.js
CHANGED
|
@@ -575,10 +575,12 @@ function onHostMessage(origin, m) {
|
|
|
575
575
|
return;
|
|
576
576
|
case "push":
|
|
577
577
|
SH.push = m.push ?? null;
|
|
578
|
+
emit("aim:shell-active");
|
|
578
579
|
applyRelayPush();
|
|
579
580
|
return;
|
|
580
581
|
case "push-off":
|
|
581
582
|
SH.push = null;
|
|
583
|
+
emit("aim:shell-active");
|
|
582
584
|
void dropRelayPush(m.endpoint, false).then(() => {
|
|
583
585
|
toHost({ t: "push-off-done", request: m.request });
|
|
584
586
|
}).catch((err) => console.warn("[多服务器] 通知订阅没有撤销:", err.message));
|
package/web/lib/ws.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { h } from "./dom.js";
|
|
2
2
|
import { api } from "./api.js";
|
|
3
|
-
import { desktop, S, ui } from "../state.js";
|
|
3
|
+
import { desktop, framed, S, ui } from "../state.js";
|
|
4
4
|
import { showAuth } from "../views/auth.js";
|
|
5
5
|
import { applyBootstrap, bootstrapQuery, renderSidebar, scheduleSidebar } from "../views/sidebar.js";
|
|
6
6
|
import { scheduleQuota } from "../views/quota.js";
|
|
@@ -8,7 +8,8 @@ import { renderTopbar } from "../views/topbar.js";
|
|
|
8
8
|
import { applyEvent, openConversation } from "../views/messages.js";
|
|
9
9
|
import { upsertInteraction } from "../views/interaction.js";
|
|
10
10
|
import { setBusy } from "../views/composer.js";
|
|
11
|
-
import { shownHere } from "./shell.js";
|
|
11
|
+
import { SH, shownHere } from "./shell.js";
|
|
12
|
+
import { currentPushSub } from "./push.js";
|
|
12
13
|
import { renderScheduled } from "../views/schedule.js";
|
|
13
14
|
|
|
14
15
|
// ---------- WebSocket ----------
|
|
@@ -20,6 +21,7 @@ export const WS = {
|
|
|
20
21
|
backoff: 500,
|
|
21
22
|
connected: false,
|
|
22
23
|
pingTimer: null,
|
|
24
|
+
pushEndpoint: null,
|
|
23
25
|
|
|
24
26
|
stopped: false,
|
|
25
27
|
epoch: null,
|
|
@@ -101,12 +103,27 @@ export const WS = {
|
|
|
101
103
|
// 多服务器:外壳切到了别的服务器、或者这台被嵌着但没在显示,也算没在看
|
|
102
104
|
const visible = document.visibilityState === "visible" && document.hasFocus() && Date.now() - lastInput < IDLE_MS && shownHere();
|
|
103
105
|
// 在定时任务、远程控制页上:没在看哪条对话(远程控制页不清 S.current,回来时对话还在)
|
|
104
|
-
this.raw({
|
|
106
|
+
this.raw({
|
|
107
|
+
t: "presence", visible, key: S.view ? "" : (S.current ?? ""),
|
|
108
|
+
// 前台免打扰按设备判断,不受正在看哪条会话、是否空闲的影响。
|
|
109
|
+
foreground: document.visibilityState === "visible",
|
|
110
|
+
pushEndpoint: framed ? (SH.push?.subscription.endpoint ?? null) : this.pushEndpoint,
|
|
111
|
+
});
|
|
112
|
+
},
|
|
113
|
+
|
|
114
|
+
async refreshPushPresence() {
|
|
115
|
+
if (!framed) this.pushEndpoint = (await currentPushSub())?.endpoint ?? null;
|
|
116
|
+
this.presence();
|
|
105
117
|
},
|
|
106
118
|
};
|
|
107
119
|
|
|
108
120
|
// 切回窗口本身就算动了一下
|
|
109
|
-
window.addEventListener("focus", () =>
|
|
121
|
+
window.addEventListener("focus", () => {
|
|
122
|
+
markActive();
|
|
123
|
+
WS.presence();
|
|
124
|
+
clearAppNotifications();
|
|
125
|
+
void WS.refreshPushPresence();
|
|
126
|
+
});
|
|
110
127
|
document.addEventListener("aim:shell-active", () => {
|
|
111
128
|
if (shownHere()) markActive();
|
|
112
129
|
WS.presence();
|
|
@@ -146,17 +163,28 @@ function onInput() {
|
|
|
146
163
|
for (const ev of ["pointerdown", "keydown", "wheel", "touchstart", "scroll"]) window.addEventListener(ev, onInput, { capture: true, passive: true });
|
|
147
164
|
armIdle();
|
|
148
165
|
|
|
149
|
-
/** 打开 /
|
|
150
|
-
export function
|
|
151
|
-
if (document.visibilityState !== "visible") return;
|
|
166
|
+
/** 打开 / 切回页面:清掉本应用已显示的通知、桌面图标角标和计数。 */
|
|
167
|
+
export function clearAppNotifications() {
|
|
168
|
+
if (framed || document.visibilityState !== "visible") return;
|
|
152
169
|
navigator.clearAppBadge?.().catch(() => {});
|
|
153
170
|
if ("caches" in window) caches.delete("aim-badge").catch(() => {});
|
|
171
|
+
navigator.serviceWorker?.getRegistration().then(async (reg) => {
|
|
172
|
+
const notifications = await reg?.getNotifications();
|
|
173
|
+
// 异步读取期间可能已经切走,后台到达的新通知留着提醒。
|
|
174
|
+
if (document.visibilityState === "visible") for (const n of notifications ?? []) n.close();
|
|
175
|
+
}).catch(() => {});
|
|
154
176
|
}
|
|
155
177
|
|
|
178
|
+
window.addEventListener("pageshow", () => {
|
|
179
|
+
clearAppNotifications();
|
|
180
|
+
void WS.refreshPushPresence();
|
|
181
|
+
});
|
|
182
|
+
|
|
156
183
|
document.addEventListener("visibilitychange", () => {
|
|
157
184
|
if (document.visibilityState === "visible") markActive();
|
|
158
185
|
WS.presence();
|
|
159
|
-
|
|
186
|
+
clearAppNotifications();
|
|
187
|
+
if (document.visibilityState === "visible") void WS.refreshPushPresence();
|
|
160
188
|
// 手机切回前台:连接多半已经被系统掐了,立刻重连而不是等退避
|
|
161
189
|
if (document.visibilityState === "visible" && WS.sock?.readyState !== 1) {
|
|
162
190
|
WS.backoff = 300;
|
|
@@ -194,6 +222,7 @@ function onWsMessage(msg) {
|
|
|
194
222
|
WS.epoch = msg.epoch;
|
|
195
223
|
WS.hellos += 1;
|
|
196
224
|
WS.presence();
|
|
225
|
+
void WS.refreshPushPresence();
|
|
197
226
|
if (restarted) {
|
|
198
227
|
// 服务重启过:seq 从头计数了,旧游标全部作废,当前会话整页重拉
|
|
199
228
|
S.seq.clear();
|
package/web/settings/agents.js
CHANGED
|
@@ -149,6 +149,13 @@ export function agentsTab(cfg, page) {
|
|
|
149
149
|
);
|
|
150
150
|
const codexPick = modelPicker("codex", a.codex.defaultModel, a.codex.defaultEffort, "跟随 config.toml");
|
|
151
151
|
const codexModels = modelChecklist("codex", a.codex.models ?? []);
|
|
152
|
+
// 自动生成会话名称:一行,勾上才显示后面的模型选择
|
|
153
|
+
const titleOn = h("input", { type: "checkbox", checked: !!a.codex.autoTitle });
|
|
154
|
+
const titlePick = modelPicker("codex", a.codex.titleModel ?? "", "", "跟随 config.toml");
|
|
155
|
+
const titleModelEl = h("div", { class: "grow" }, titlePick.modelEl);
|
|
156
|
+
const syncTitle = () => (titleModelEl.hidden = !titleOn.checked);
|
|
157
|
+
titleOn.addEventListener("change", syncTitle);
|
|
158
|
+
syncTitle();
|
|
152
159
|
// 一组勾选框不能放进 <label>(点哪都会切到第一个),所以不用 field()
|
|
153
160
|
const checksField = (list) => h("div", { class: "field" }, h("span", {}, "输入框可选模型"), list.el);
|
|
154
161
|
// 两个 agent 一起保存:整组算一张表单
|
|
@@ -174,6 +181,7 @@ export function agentsTab(cfg, page) {
|
|
|
174
181
|
field("默认模型", codexPick.modelEl),
|
|
175
182
|
field("默认思考程度", codexPick.effortEl),
|
|
176
183
|
checksField(codexModels),
|
|
184
|
+
h("div", { class: "row title-row" }, h("label", { class: "check" }, titleOn, "自动生成会话名称"), titleModelEl),
|
|
177
185
|
),
|
|
178
186
|
h(
|
|
179
187
|
"div",
|
|
@@ -201,6 +209,8 @@ export function agentsTab(cfg, page) {
|
|
|
201
209
|
defaultModel: codexPick.model(),
|
|
202
210
|
defaultEffort: codexPick.effort(),
|
|
203
211
|
models: codexList,
|
|
212
|
+
autoTitle: titleOn.checked,
|
|
213
|
+
titleModel: titlePick.model(),
|
|
204
214
|
},
|
|
205
215
|
},
|
|
206
216
|
});
|
package/web/settings/notify.js
CHANGED
|
@@ -3,6 +3,7 @@ import { api } from "../lib/api.js";
|
|
|
3
3
|
import { relTime } from "../lib/time.js";
|
|
4
4
|
import { currentPushSub, enablePush, pushSupport } from "../lib/push.js";
|
|
5
5
|
import { refreshShellPush } from "../lib/shell.js";
|
|
6
|
+
import { WS } from "../lib/ws.js";
|
|
6
7
|
|
|
7
8
|
export async function notifyTab(panel) {
|
|
8
9
|
const support = pushSupport();
|
|
@@ -27,6 +28,7 @@ export async function notifyTab(panel) {
|
|
|
27
28
|
}
|
|
28
29
|
btn.disabled = false;
|
|
29
30
|
// 多服务器的外壳:开关通知后,转给各台的订阅跟着变
|
|
31
|
+
void WS.refreshPushPresence();
|
|
30
32
|
void refreshShellPush();
|
|
31
33
|
await render();
|
|
32
34
|
};
|
|
@@ -49,7 +51,7 @@ export async function notifyTab(panel) {
|
|
|
49
51
|
fill(
|
|
50
52
|
box,
|
|
51
53
|
h("h4", {}, "系统通知"),
|
|
52
|
-
h("div", { class: "muted" }, "Web 对话里 agent
|
|
54
|
+
h("div", { class: "muted" }, "Web 对话里 agent 回复完成、出错、需要授权或向你提问时,推送到开启了通知的设备。本设备的应用在前台时不推送,打开或切回应用会清除本应用的历史通知和角标。飞书对话由飞书自己提醒。"),
|
|
53
55
|
support.ok
|
|
54
56
|
? h("div", { class: "row" }, here ? offBtn : onBtn, data.subscriptions.length ? testBtn : null)
|
|
55
57
|
: support.framed
|
package/web/views/layout.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { $app, fill, h, icon, toast } from "../lib/dom.js";
|
|
2
2
|
import { api } from "../lib/api.js";
|
|
3
3
|
import { desktop, desktopMenu, desktopQuota, desktopSettings, framed, remoteTabs, S, ui } from "../state.js";
|
|
4
|
-
import {
|
|
4
|
+
import { clearAppNotifications, WS } from "../lib/ws.js";
|
|
5
5
|
import { showAuth } from "./auth.js";
|
|
6
6
|
import {
|
|
7
7
|
applyBootstrap,
|
|
@@ -184,10 +184,10 @@ export async function boot() {
|
|
|
184
184
|
}
|
|
185
185
|
// 被嵌在别的服务器的页面里时,通知、角标都归外壳管
|
|
186
186
|
if ("serviceWorker" in navigator && !framed) {
|
|
187
|
-
navigator.serviceWorker.register("/sw.js").catch(() => {});
|
|
188
|
-
clearAppBadge();
|
|
187
|
+
navigator.serviceWorker.register("/sw.js").then(() => clearAppNotifications()).catch(() => {});
|
|
189
188
|
void releaseForeignPushSub()
|
|
190
189
|
.catch(() => {})
|
|
190
|
+
.then(() => WS.refreshPushPresence())
|
|
191
191
|
.then(() => refreshShellPush());
|
|
192
192
|
// 点了系统通知、页面本来就开着:跳到通知对应的会话
|
|
193
193
|
navigator.serviceWorker.addEventListener("message", (e) => {
|
package/web/views/messages.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { fill, h, icon, starsLoader, toast } from "../lib/dom.js";
|
|
1
|
+
import { fill, h, icon, isTouch, starsLoader, toast } from "../lib/dom.js";
|
|
2
2
|
import { api } from "../lib/api.js";
|
|
3
3
|
import { clockTime, liveDuration, serverNow, setServerTime, tidyFooter } from "../lib/time.js";
|
|
4
4
|
import { copyText, patchMarkdown, renderMarkdown } from "../lib/markdown.js";
|
|
@@ -48,7 +48,7 @@ export function newDraft() {
|
|
|
48
48
|
renderChips();
|
|
49
49
|
renderSidebar();
|
|
50
50
|
scheduleNav();
|
|
51
|
-
ui.input?.focus();
|
|
51
|
+
if (!isTouch) ui.input?.focus();
|
|
52
52
|
preloadCommands();
|
|
53
53
|
}
|
|
54
54
|
|