agent-loft 0.2.72 → 0.2.74
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/README.md +1 -0
- package/package.json +1 -1
- package/src/agents/codex/protocol.ts +11 -1
- package/src/agents/codex/session.ts +52 -1
- package/src/core/hub.ts +10 -0
- package/src/core/interactions.ts +12 -1
- package/src/core/task-runner.ts +2 -2
- package/src/core/types.ts +12 -1
- package/web/css/messages.css +2 -1
- package/web/css/mobile.css +104 -2
- package/web/css/topbar.css +12 -6
- package/web/index.html +2 -2
- package/web/views/layout.js +2 -0
- package/web/views/sidebar-gestures.js +84 -0
- package/web/views/topbar.js +10 -9
package/README.md
CHANGED
|
@@ -69,6 +69,7 @@ Logo 就是这个意思:一大两小几颗星(多个 agent)站在同一张
|
|
|
69
69
|
- 右上角「更多」最下面显示当前会话累计消耗的 token 分布(输入 / 缓存写入 / 缓存读取 / 输出,Claude 还有按 API 价格估算的费用)。设置也在「更多」里。
|
|
70
70
|
- 设置 → 用量:按日 / 月 / 年(默认按月)统计 token 和金额,有每天(每月)的柱状图,按 agent、模型、用户(管理员才有)分开看;成员只看到自己的。管理员还可查看服务端本机直接使用的 Claude Code、Codex 桌面端和 CLI 用量,和 Agent Loft 的用量分开显示、避免重复计算。金额都是按 API 价格算的参考值:Agent Loft 的 Claude 用它自己报的费用,Codex 和直接用的 Claude Code 按模型单价 × token 估算(OpenAI 单价来自 LiteLLM 公开价格表,内置快照、联网时每天更新)。Agent Loft 的账从 0.2.34 开始记录;本机直接使用的用量可回溯已有会话记录。
|
|
71
71
|
- 「添加到主屏幕」后当 App 用;切到后台再回来会自动重连,补上错过的内容。
|
|
72
|
+
- 手机顶栏采用实色圆形按钮和「专家+更多」胶囊按钮组;从左边缘右滑展开侧栏,在侧栏或遮罩上左滑收起,短滑会回弹。消息底部操作栏与下一条消息之间留 4px。
|
|
72
73
|
- **网页多服务器切换**:在 设置 → 服务器 添加其他 agent-loft,再点「授权」到对方页面确认,侧栏左上角就能切换;各台分别登录,切走后保持连接,列表显示待处理数和运行状态,刷新后保留选择。几台需使用同一主域名下的 HTTPS 地址(例如 `mac.example.com`、`nas.example.com`)。在外层页面开启系统通知后,各台的提醒都能推到同一个主屏幕 App,点通知自动切到对应服务器和对话。见[使用指南](docs/产品介绍.md#在网页和手机上切换多台服务器)。
|
|
73
74
|
- **系统通知**:Web 会话回复完成、出错、需要授权或提问时推送到手机 / 电脑(设置 → 通知 → 「在此设备开启通知」,可以发测试通知)。飞书会话由飞书提醒,正在前台看着的会话不推。需要 HTTPS 访问,iPhone 需 iOS 16.4+ 且从主屏幕图标打开。
|
|
74
75
|
- **跨渠道同步**:飞书里的会话在 Web 上也能打开接着聊。同一个授权请求同时出现在飞书卡片和网页上,哪边先点算哪边,另一边自动变成「已处理」。
|
package/package.json
CHANGED
|
@@ -209,9 +209,19 @@ export type ToolRequestUserInputResponse = {
|
|
|
209
209
|
|
|
210
210
|
// ---------- 服务端 → 客户端:通知 ----------
|
|
211
211
|
|
|
212
|
+
export type AsyncUserInputQuestion = { title: string; options: string[] | null };
|
|
213
|
+
|
|
212
214
|
export type ThreadItem =
|
|
213
215
|
| { type: "userMessage"; id: string }
|
|
214
|
-
| {
|
|
216
|
+
| {
|
|
217
|
+
type: "agentMessage";
|
|
218
|
+
id: string;
|
|
219
|
+
text: string;
|
|
220
|
+
phase?: string | null;
|
|
221
|
+
/** async + questions:模型调了 request_user_input_async,提问混在普通消息里发出,不走 item/tool/requestUserInput */
|
|
222
|
+
delivery?: string | null;
|
|
223
|
+
questions?: AsyncUserInputQuestion[] | null;
|
|
224
|
+
}
|
|
215
225
|
| { type: "reasoning"; id: string; summary?: string[]; content?: string[] }
|
|
216
226
|
| { type: "plan"; id: string; text: string }
|
|
217
227
|
| {
|
|
@@ -222,6 +222,38 @@ type TokenBreakdown = {
|
|
|
222
222
|
reasoningOutputTokens?: number;
|
|
223
223
|
};
|
|
224
224
|
|
|
225
|
+
/** request_user_input_async 的问题:只有标题和选项文字,且没有 id */
|
|
226
|
+
function parseAsyncQuestions(raw: unknown): QuestionSpec[] | null {
|
|
227
|
+
if (!Array.isArray(raw) || raw.length === 0) return null;
|
|
228
|
+
const specs: QuestionSpec[] = [];
|
|
229
|
+
for (const [i, item] of raw.entries()) {
|
|
230
|
+
const rec = (typeof item === "object" && item !== null ? item : {}) as { title?: unknown; options?: unknown };
|
|
231
|
+
const question = typeof rec.title === "string" ? rec.title.trim() : "";
|
|
232
|
+
if (!question) return null;
|
|
233
|
+
const labels = Array.isArray(rec.options) ? rec.options : [];
|
|
234
|
+
const options = labels.flatMap((o) => (typeof o === "string" && o.trim() ? [{ label: o.trim() }] : []));
|
|
235
|
+
specs.push({
|
|
236
|
+
id: `q${i}`,
|
|
237
|
+
header: options.length > 0 ? "选择" : "回答",
|
|
238
|
+
question,
|
|
239
|
+
options,
|
|
240
|
+
multiSelect: false,
|
|
241
|
+
allowOther: true,
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
return specs;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/** 提问卡的答案写成用户消息:一问就是答案本身,多问要带上问的是什么 */
|
|
248
|
+
function answersAsMessage(questions: QuestionSpec[], answers: Record<string, string[]>): string {
|
|
249
|
+
const answered = questions.flatMap((q) => {
|
|
250
|
+
const picked = answers[q.id];
|
|
251
|
+
return picked?.length ? [{ q, text: picked.join("、") }] : [];
|
|
252
|
+
});
|
|
253
|
+
if (questions.length === 1) return answered[0]?.text ?? "";
|
|
254
|
+
return answered.map(({ q, text }) => `${q.question}\n答:${text}`).join("\n\n");
|
|
255
|
+
}
|
|
256
|
+
|
|
225
257
|
function parseQuestions(raw: unknown): ParsedQuestion[] | null {
|
|
226
258
|
if (!Array.isArray(raw) || raw.length === 0) return null;
|
|
227
259
|
const specs: ParsedQuestion[] = [];
|
|
@@ -707,6 +739,17 @@ export class CodexSession implements AgentSession {
|
|
|
707
739
|
return outcome;
|
|
708
740
|
}
|
|
709
741
|
|
|
742
|
+
/** 不阻塞的提问:这一轮不等它(Codex 已经告诉模型 accepted),用户答了再作为下一条消息发出 */
|
|
743
|
+
private askDetached(questions: QuestionSpec[]): void {
|
|
744
|
+
void this.host({ kind: "question", title: "Codex 想确认一下", questions, detached: true })
|
|
745
|
+
.then((outcome) => {
|
|
746
|
+
if (outcome.settlement !== "answered" || this.disposed) return;
|
|
747
|
+
const text = answersAsMessage(questions, outcome.answers);
|
|
748
|
+
if (text) this.events.onFollowUp?.(text);
|
|
749
|
+
})
|
|
750
|
+
.catch((err) => console.warn("[codex] 不阻塞的提问没能弹出:", err));
|
|
751
|
+
}
|
|
752
|
+
|
|
710
753
|
/**
|
|
711
754
|
* 每一条都**必须**返回点什么 —— 漏回一次,Codex 那一轮就永远挂在等审批上。
|
|
712
755
|
* 未知方法也要按它自己的协议结构明确拒绝。
|
|
@@ -955,7 +998,15 @@ export class CodexSession implements AgentSession {
|
|
|
955
998
|
case "agentMessage": {
|
|
956
999
|
const message = item as Extract<ThreadItem, { type: "agentMessage" }>;
|
|
957
1000
|
if (message.phase === "commentary") this.commentaryItems.add(message.id);
|
|
958
|
-
if (phase !== "completed"
|
|
1001
|
+
if (phase !== "completed") return;
|
|
1002
|
+
if (message.delivery === "async") {
|
|
1003
|
+
const questions = parseAsyncQuestions(message.questions);
|
|
1004
|
+
if (questions) {
|
|
1005
|
+
this.askDetached(questions);
|
|
1006
|
+
return;
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
if (!message.text.trim()) return;
|
|
959
1010
|
// commentary 是 Codex 边干边说的旁白,属于过程;正文才是要给人看的回复
|
|
960
1011
|
if (message.phase === "commentary") {
|
|
961
1012
|
this.events.onStep("note", `💬 ${summarize(message.text)}`);
|
package/src/core/hub.ts
CHANGED
|
@@ -733,6 +733,14 @@ class Hub extends EventEmitter<{ event: [EventEnvelope]; task: [TaskTurnEnd] }>
|
|
|
733
733
|
onTodos: (todos) => alive() && this.emitEvent(key, { type: "todos", todos }),
|
|
734
734
|
onTextDelta: (text) => alive() && this.emitEvent(key, { type: "delta", text }),
|
|
735
735
|
onText: (text) => alive() && this.emitEvent(key, { type: "text", text }),
|
|
736
|
+
onFollowUp: (text) => {
|
|
737
|
+
if (!alive()) return;
|
|
738
|
+
try {
|
|
739
|
+
this.send(key, { text, attachments: [] }, { channel: "card", channelId: "card", name: "提问卡" });
|
|
740
|
+
} catch (err) {
|
|
741
|
+
this.emitEvent(key, { type: "notice", text: `你的回答没有发出(${err instanceof Error ? err.message : err}),请重新发送。` });
|
|
742
|
+
}
|
|
743
|
+
},
|
|
736
744
|
onResult: (result) => {
|
|
737
745
|
if (!alive()) return;
|
|
738
746
|
const parts = [`用时 ${formatDuration(result.durationMs)}`];
|
|
@@ -1017,6 +1025,8 @@ class Hub extends EventEmitter<{ event: [EventEnvelope]; task: [TaskTurnEnd] }>
|
|
|
1017
1025
|
};
|
|
1018
1026
|
input = { ...input, id: shown.id };
|
|
1019
1027
|
const by = `${origin.name ?? "用户"}以消息作答`;
|
|
1028
|
+
// 不阻塞的提问不等这条消息:用户另外说了话,卡就不用再答了(这条消息照常发给 agent)
|
|
1029
|
+
if (!task) interactions.dismissDetached(key, "已改为发消息");
|
|
1020
1030
|
|
|
1021
1031
|
/**
|
|
1022
1032
|
* 拿这条消息回答挂着的提问。条件:提问属于当前活着的会话进程、这条消息收到后
|
package/src/core/interactions.ts
CHANGED
|
@@ -177,12 +177,19 @@ class InteractionCenter extends EventEmitter<InteractionEvents> {
|
|
|
177
177
|
findQuestion(convKey: string): Interaction | undefined {
|
|
178
178
|
let oldest: Entry | undefined;
|
|
179
179
|
for (const entry of this.pending.values()) {
|
|
180
|
-
if (entry.spec.kind !== "question" || entry.convKey !== convKey) continue;
|
|
180
|
+
if (entry.spec.kind !== "question" || entry.spec.detached || entry.convKey !== convKey) continue;
|
|
181
181
|
if (!oldest || entry.createdAt < oldest.createdAt) oldest = entry;
|
|
182
182
|
}
|
|
183
183
|
return oldest ? publicView(oldest) : undefined;
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
+
/** 用户发了新消息:不阻塞的提问不再需要回答,撤掉。 */
|
|
187
|
+
dismissDetached(convKey: string, note: string): void {
|
|
188
|
+
for (const entry of [...this.pending.values()]) {
|
|
189
|
+
if (entry.convKey === convKey && isDetached(entry)) this.settle(entry.id, "skipped", note);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
186
193
|
/** 取消某会话上所有挂着的请求。中断、切目录、开新会话时必须调用。 */
|
|
187
194
|
cancelAll(convKey: string, note: string): Interaction[] {
|
|
188
195
|
const out: Interaction[] = [];
|
|
@@ -224,6 +231,10 @@ function publicView(entry: Entry | Interaction): Interaction {
|
|
|
224
231
|
};
|
|
225
232
|
}
|
|
226
233
|
|
|
234
|
+
export function isDetached(interaction: Interaction): boolean {
|
|
235
|
+
return interaction.spec.kind === "question" && !!interaction.spec.detached;
|
|
236
|
+
}
|
|
237
|
+
|
|
227
238
|
export function unansweredCount(entry: Interaction): number {
|
|
228
239
|
return entry.selections.filter((picked, i) => picked.length === 0 && !entry.freeText[i]).length;
|
|
229
240
|
}
|
package/src/core/task-runner.ts
CHANGED
|
@@ -9,7 +9,7 @@ import crypto from "node:crypto";
|
|
|
9
9
|
import { resolveWorkspacePath } from "./config.js";
|
|
10
10
|
import { canUseExpert, getExpert } from "./experts.js";
|
|
11
11
|
import { hub, type TaskTurnEnd } from "./hub.js";
|
|
12
|
-
import { interactions } from "./interactions.js";
|
|
12
|
+
import { interactions, isDetached } from "./interactions.js";
|
|
13
13
|
import { memoryOwnerOf } from "./personal.js";
|
|
14
14
|
import { getConversation, updateAgentBinding, updateConversation, type Conversation } from "./store.js";
|
|
15
15
|
import { formatDateTime } from "./task-schedule.js";
|
|
@@ -130,7 +130,7 @@ function fire(task: Task, manual: boolean, now = Date.now()): string | undefined
|
|
|
130
130
|
return `${hub.label(conv.agent)} 没有启用`;
|
|
131
131
|
}
|
|
132
132
|
// 刚点过停止的也当忙:被打断的那一轮可能还会晚到一个出错,别让它算到这次运行头上
|
|
133
|
-
if (hub.isBusy(key) || hub.recentlyStopped(key) || interactions.listPending(key).
|
|
133
|
+
if (hub.isBusy(key) || hub.recentlyStopped(key) || interactions.listPending(key).some((i) => !isDetached(i))) {
|
|
134
134
|
if (manual) return "这条对话正在回复或者在等你处理授权,等它结束再试";
|
|
135
135
|
const since = waiting.get(task.id)?.since ?? now;
|
|
136
136
|
if (now - since > WAIT_MAX_MS) {
|
package/src/core/types.ts
CHANGED
|
@@ -60,7 +60,16 @@ export type InteractionSpec =
|
|
|
60
60
|
/** 给了就显示「本会话全部允许」按钮。只有 agent 能真正兑现时才给 */
|
|
61
61
|
allowSession?: boolean;
|
|
62
62
|
}
|
|
63
|
-
| {
|
|
63
|
+
| {
|
|
64
|
+
kind: "question";
|
|
65
|
+
title: string;
|
|
66
|
+
questions: QuestionSpec[];
|
|
67
|
+
/**
|
|
68
|
+
* 发起方不等这张卡:那一轮照常结束,答案作为下一条用户消息发出(Codex 的 request_user_input_async)。
|
|
69
|
+
* 普通消息不算作答,而是撤掉这张卡、照常发给 agent。
|
|
70
|
+
*/
|
|
71
|
+
detached?: boolean;
|
|
72
|
+
};
|
|
64
73
|
|
|
65
74
|
export type InteractionOutcome = {
|
|
66
75
|
settlement: Settlement;
|
|
@@ -98,6 +107,8 @@ export type AgentEvents = {
|
|
|
98
107
|
onTextDelta: (delta: string) => void;
|
|
99
108
|
/** 一段完整的回复正文 */
|
|
100
109
|
onText: (text: string) => void;
|
|
110
|
+
/** 用户回答了不阻塞的提问(detached):把答案当下一条用户消息发出 */
|
|
111
|
+
onFollowUp?: (text: string) => void;
|
|
101
112
|
onResult: (result: TurnResult) => void;
|
|
102
113
|
onError: (err: unknown) => void;
|
|
103
114
|
/** 拿到 / 更新了 agent 侧的会话 id,持久化后用于 resume */
|
package/web/css/messages.css
CHANGED
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
padding: 16px 20px 40px;
|
|
54
54
|
display: flex;
|
|
55
55
|
flex-direction: column;
|
|
56
|
-
gap:
|
|
56
|
+
gap: 4px;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
.empty {
|
|
@@ -699,6 +699,7 @@ a.att-file:hover {
|
|
|
699
699
|
|
|
700
700
|
.ix-q .q-text {
|
|
701
701
|
font-size: 15px;
|
|
702
|
+
white-space: pre-wrap;
|
|
702
703
|
margin-top: -4px;
|
|
703
704
|
}
|
|
704
705
|
|
package/web/css/mobile.css
CHANGED
|
@@ -1,6 +1,80 @@
|
|
|
1
1
|
/* ---------- 手机 ---------- */
|
|
2
2
|
|
|
3
3
|
@media (max-width: 768px) {
|
|
4
|
+
/* 实色悬浮控件:左侧圆形,右侧共享胶囊底。 */
|
|
5
|
+
.topbar {
|
|
6
|
+
gap: 10px;
|
|
7
|
+
padding-left: 12px;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.topbar .menu-btn,
|
|
11
|
+
.top-actions {
|
|
12
|
+
border-radius: 999px;
|
|
13
|
+
background: var(--bg-input);
|
|
14
|
+
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08), 0 2px 5px rgba(0, 0, 0, 0.02);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@media (prefers-color-scheme: dark) {
|
|
18
|
+
.topbar .menu-btn,
|
|
19
|
+
.top-actions {
|
|
20
|
+
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24), 0 2px 5px rgba(0, 0, 0, 0.12);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.topbar .menu-btn {
|
|
25
|
+
width: 44px;
|
|
26
|
+
height: 44px;
|
|
27
|
+
color: var(--fg);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.top-actions {
|
|
31
|
+
display: flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
flex-shrink: 0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.top-actions .conv-expert-icon,
|
|
37
|
+
.top-actions .top-more {
|
|
38
|
+
order: 0;
|
|
39
|
+
margin: 0;
|
|
40
|
+
width: 44px;
|
|
41
|
+
height: 44px;
|
|
42
|
+
border-radius: 999px;
|
|
43
|
+
color: var(--fg);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.top-title .conv-name {
|
|
47
|
+
font-size: 16px;
|
|
48
|
+
font-weight: 600;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.topbar :is(.menu-btn, .top-more, .conv-expert-icon) {
|
|
52
|
+
transition: scale 120ms ease;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.topbar :is(.menu-btn, .top-more, .conv-expert-icon):active {
|
|
56
|
+
scale: 0.96;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.top-actions :is(.top-more, .conv-expert-icon):active {
|
|
60
|
+
background: var(--bg-hover);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.topbar :is(.menu-btn, .top-more, .conv-expert-icon):focus-visible {
|
|
64
|
+
outline: 2px solid var(--accent);
|
|
65
|
+
outline-offset: 3px;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@media (prefers-reduced-motion: reduce) {
|
|
69
|
+
.topbar :is(.menu-btn, .top-more, .conv-expert-icon) {
|
|
70
|
+
transition: none;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.topbar :is(.menu-btn, .top-more, .conv-expert-icon):active {
|
|
74
|
+
scale: none;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
4
78
|
/* 侧栏和遮罩用 absolute 而不是 fixed:iOS PWA 会拿贴着顶部的 fixed 元素给状态栏上色,
|
|
5
79
|
遮罩一出来状态栏就变暗,关掉后还不恢复 */
|
|
6
80
|
.sidebar {
|
|
@@ -11,18 +85,46 @@
|
|
|
11
85
|
transform: translateX(-100%);
|
|
12
86
|
transition: transform 0.2s ease;
|
|
13
87
|
width: min(84vw, 320px);
|
|
14
|
-
box-shadow:
|
|
88
|
+
box-shadow: none;
|
|
15
89
|
}
|
|
16
90
|
|
|
17
91
|
.layout.side-open .sidebar {
|
|
18
92
|
transform: none;
|
|
93
|
+
box-shadow: var(--shadow);
|
|
19
94
|
}
|
|
20
95
|
|
|
21
|
-
.
|
|
96
|
+
.scrim {
|
|
22
97
|
position: absolute;
|
|
23
98
|
inset: 0;
|
|
24
99
|
background: rgba(0, 0, 0, 0.35);
|
|
25
100
|
z-index: 25;
|
|
101
|
+
opacity: 0;
|
|
102
|
+
pointer-events: none;
|
|
103
|
+
transition: opacity 0.2s ease;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.layout.side-open .scrim {
|
|
107
|
+
opacity: 1;
|
|
108
|
+
pointer-events: auto;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.layout.side-dragging .sidebar {
|
|
112
|
+
transform: translateX(calc(var(--side-reveal, 0px) - 100%));
|
|
113
|
+
transition: none;
|
|
114
|
+
box-shadow: var(--shadow);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.layout.side-dragging .scrim {
|
|
118
|
+
opacity: var(--side-progress, 0);
|
|
119
|
+
pointer-events: auto;
|
|
120
|
+
transition: none;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
@media (prefers-reduced-motion: reduce) {
|
|
124
|
+
.sidebar,
|
|
125
|
+
.scrim {
|
|
126
|
+
transition: none;
|
|
127
|
+
}
|
|
26
128
|
}
|
|
27
129
|
|
|
28
130
|
.topbar .menu-btn {
|
package/web/css/topbar.css
CHANGED
|
@@ -155,8 +155,14 @@
|
|
|
155
155
|
gap: 2px;
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
/*
|
|
159
|
-
.top-
|
|
158
|
+
/* 桌面保留标题前的头像;移动端把头像和更多放进右侧按钮组。 */
|
|
159
|
+
.top-actions {
|
|
160
|
+
display: contents;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.topbar .conv-expert-icon {
|
|
164
|
+
order: -1;
|
|
165
|
+
margin-right: -4px;
|
|
160
166
|
display: inline-grid;
|
|
161
167
|
place-items: center;
|
|
162
168
|
flex-shrink: 0;
|
|
@@ -168,21 +174,21 @@
|
|
|
168
174
|
color: var(--fg-soft);
|
|
169
175
|
}
|
|
170
176
|
|
|
171
|
-
.
|
|
177
|
+
.topbar .conv-expert-icon .agent-icon {
|
|
172
178
|
display: inline-grid;
|
|
173
179
|
place-items: center;
|
|
174
180
|
width: 18px;
|
|
175
181
|
height: 18px;
|
|
176
182
|
}
|
|
177
183
|
|
|
178
|
-
.
|
|
179
|
-
.
|
|
184
|
+
.topbar .conv-expert-icon svg,
|
|
185
|
+
.topbar .conv-expert-icon img {
|
|
180
186
|
display: block;
|
|
181
187
|
width: 18px;
|
|
182
188
|
height: 18px;
|
|
183
189
|
}
|
|
184
190
|
|
|
185
|
-
.
|
|
191
|
+
.topbar .conv-expert-icon .expert-emoji {
|
|
186
192
|
font-size: 16px;
|
|
187
193
|
}
|
|
188
194
|
|
package/web/index.html
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
<link rel="stylesheet" href="/css/base.css?v=2" />
|
|
19
19
|
<link rel="stylesheet" href="/css/sidebar.css" />
|
|
20
20
|
<link rel="stylesheet" href="/css/topbar.css" />
|
|
21
|
-
<link rel="stylesheet" href="/css/messages.css" />
|
|
21
|
+
<link rel="stylesheet" href="/css/messages.css?v=3" />
|
|
22
22
|
<link rel="stylesheet" href="/css/albums.css" />
|
|
23
23
|
<link rel="stylesheet" href="/css/loader.css" />
|
|
24
24
|
<link rel="stylesheet" href="/css/composer.css" />
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
<link rel="stylesheet" href="/css/terminal.css" />
|
|
35
35
|
<link rel="stylesheet" href="/css/remote.css" />
|
|
36
36
|
<link rel="stylesheet" href="/css/servers.css" />
|
|
37
|
-
<link rel="stylesheet" href="/css/mobile.css?v=
|
|
37
|
+
<link rel="stylesheet" href="/css/mobile.css?v=6" />
|
|
38
38
|
</head>
|
|
39
39
|
<body>
|
|
40
40
|
<div id="app"><div class="boot"><span class="loft-loader xl" role="img" aria-label="加载中"><svg viewBox="96 56 320 388" aria-hidden="true"><defs><linearGradient id="boot-g" gradientUnits="userSpaceOnUse" x1="104" y1="104" x2="408" y2="408"><stop offset="0" stop-color="#3b82f6"/><stop offset="1" stop-color="#06b6d4"/></linearGradient></defs><path class="ll-shadow" d="M256 296L404 364L256 432L108 364Z" fill="url(#boot-g)"/><path class="ll-plate" d="M256 252L404 320L256 388L108 320Z" fill="url(#boot-g)"/><path class="ll-star ll-l" d="M152 186C158.46 217.54 158.46 217.54 190 224C158.46 230.46 158.46 230.46 152 262C145.54 230.46 145.54 230.46 114 224C145.54 217.54 145.54 217.54 152 186Z" fill="url(#boot-g)"/><path class="ll-star ll-c" d="M256 82C268.92 145.08 268.92 145.08 332 158C268.92 170.92 268.92 170.92 256 234C243.08 170.92 243.08 170.92 180 158C243.08 145.08 243.08 145.08 256 82Z" fill="url(#boot-g)"/><path class="ll-star ll-r" d="M360 186C366.46 217.54 366.46 217.54 398 224C366.46 230.46 366.46 230.46 360 262C353.54 230.46 353.54 230.46 322 224C353.54 217.54 353.54 217.54 360 186Z" fill="url(#boot-g)"/></svg></span></div></div>
|
package/web/views/layout.js
CHANGED
|
@@ -32,6 +32,7 @@ import { renameConv } from "./conv-actions.js";
|
|
|
32
32
|
import { clearCommandCache, preloadCommands } from "./slash.js";
|
|
33
33
|
import { releaseForeignPushSub } from "../lib/push.js";
|
|
34
34
|
import { createSidebarNav } from "./sidebar-nav.js";
|
|
35
|
+
import { bindSidebarGestures } from "./sidebar-gestures.js";
|
|
35
36
|
|
|
36
37
|
// ---------- 主界面 ----------
|
|
37
38
|
|
|
@@ -296,6 +297,7 @@ function renderLayout() {
|
|
|
296
297
|
ui.main = h("main", { class: "main" }, ui.topbar, ui.messages, createNav(), ui.composerWrap);
|
|
297
298
|
bindFileDrop(ui.main);
|
|
298
299
|
ui.layout = h("div", { class: "layout" }, ui.sidebar, h("div", { class: "scrim", onclick: closeSide }), ui.main);
|
|
300
|
+
bindSidebarGestures(ui.layout, ui.sidebar);
|
|
299
301
|
fill($app, ui.layout, h("div", { class: "edge-strip", "aria-hidden": "true" }));
|
|
300
302
|
renderComposer();
|
|
301
303
|
renderSidebar();
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { closeSide, openSide } from "./sidebar.js";
|
|
2
|
+
|
|
3
|
+
/** 只接管明确的单指横滑;上下滚动、输入、横向内容和远程控制保留自己的手势。 */
|
|
4
|
+
export function bindSidebarGestures(layout, sidebar) {
|
|
5
|
+
const mobile = matchMedia("(max-width: 768px)");
|
|
6
|
+
let gesture = null;
|
|
7
|
+
let suppressClickUntil = 0;
|
|
8
|
+
|
|
9
|
+
const reset = () => {
|
|
10
|
+
gesture = null;
|
|
11
|
+
layout.classList.remove("side-dragging");
|
|
12
|
+
layout.style.removeProperty("--side-reveal");
|
|
13
|
+
layout.style.removeProperty("--side-progress");
|
|
14
|
+
};
|
|
15
|
+
const ownsHorizontalScroll = (target) => {
|
|
16
|
+
for (let el = target; el && el !== layout; el = el.parentElement) {
|
|
17
|
+
if (el.scrollWidth > el.clientWidth + 1 && /auto|scroll/.test(getComputedStyle(el).overflowX)) return true;
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
layout.addEventListener("touchstart", (e) => {
|
|
23
|
+
reset();
|
|
24
|
+
suppressClickUntil = 0;
|
|
25
|
+
if (!mobile.matches || e.touches.length !== 1) return;
|
|
26
|
+
if (e.defaultPrevented || document.querySelector(".overlay, .popover")) return;
|
|
27
|
+
const target = e.target;
|
|
28
|
+
if (!(target instanceof Element) || target.closest("input, textarea, select, [contenteditable]:not([contenteditable='false']), .desk-viewport, .term-pane, .msg-nav") || ownsHorizontalScroll(target)) return;
|
|
29
|
+
if (window.getSelection()?.isCollapsed === false) return;
|
|
30
|
+
const touch = e.touches[0];
|
|
31
|
+
const open = layout.classList.contains("side-open");
|
|
32
|
+
if (open ? !sidebar.contains(target) && !target.closest(".scrim") : touch.clientX - layout.getBoundingClientRect().left > 32) return;
|
|
33
|
+
gesture = {
|
|
34
|
+
id: touch.identifier, x: touch.clientX, y: touch.clientY, open,
|
|
35
|
+
width: sidebar.getBoundingClientRect().width, viewport: innerWidth,
|
|
36
|
+
started: false, dx: 0, at: performance.now(),
|
|
37
|
+
};
|
|
38
|
+
}, { passive: true });
|
|
39
|
+
|
|
40
|
+
layout.addEventListener("touchmove", (e) => {
|
|
41
|
+
if (!gesture) return;
|
|
42
|
+
const g = gesture;
|
|
43
|
+
if (e.defaultPrevented || !mobile.matches || innerWidth !== g.viewport || e.touches.length !== 1 || layout.classList.contains("side-open") !== g.open) return reset();
|
|
44
|
+
const touch = [...e.touches].find((t) => t.identifier === g.id);
|
|
45
|
+
if (!touch) return reset();
|
|
46
|
+
const dx = touch.clientX - g.x;
|
|
47
|
+
const dy = touch.clientY - g.y;
|
|
48
|
+
if (!g.started) {
|
|
49
|
+
if (Math.abs(dy) > 10 && Math.abs(dy) >= Math.abs(dx)) return reset();
|
|
50
|
+
if (Math.abs(dx) < 10 || Math.abs(dx) < Math.abs(dy) * 1.25) return;
|
|
51
|
+
if (g.open ? dx > 0 : dx < 0) return reset();
|
|
52
|
+
g.started = true;
|
|
53
|
+
layout.classList.add("side-dragging");
|
|
54
|
+
}
|
|
55
|
+
if (!e.cancelable) return reset();
|
|
56
|
+
e.preventDefault();
|
|
57
|
+
g.dx = dx;
|
|
58
|
+
const reveal = Math.max(0, Math.min(g.width, (g.open ? g.width : 0) + dx));
|
|
59
|
+
layout.style.setProperty("--side-reveal", `${reveal}px`);
|
|
60
|
+
layout.style.setProperty("--side-progress", String(reveal / g.width));
|
|
61
|
+
}, { passive: false });
|
|
62
|
+
|
|
63
|
+
layout.addEventListener("touchend", (e) => {
|
|
64
|
+
if (!gesture || ![...e.changedTouches].some((t) => t.identifier === gesture.id)) return;
|
|
65
|
+
const g = gesture;
|
|
66
|
+
if (g.started) {
|
|
67
|
+
const distance = g.open ? -g.dx : g.dx;
|
|
68
|
+
const commit = distance >= Math.min(80, g.width * 0.25) || (distance >= 28 && performance.now() - g.at < 250);
|
|
69
|
+
suppressClickUntil = performance.now() + 400;
|
|
70
|
+
if (commit) (g.open ? closeSide : openSide)();
|
|
71
|
+
}
|
|
72
|
+
reset();
|
|
73
|
+
}, { passive: true });
|
|
74
|
+
|
|
75
|
+
layout.addEventListener("touchcancel", reset, { passive: true });
|
|
76
|
+
// 横滑从会话行或按钮开始时,松手不能再触发点击;下一次触摸会清除拦截。
|
|
77
|
+
layout.addEventListener("click", (e) => {
|
|
78
|
+
if (e.detail && performance.now() < suppressClickUntil) {
|
|
79
|
+
e.preventDefault();
|
|
80
|
+
e.stopImmediatePropagation();
|
|
81
|
+
suppressClickUntil = 0;
|
|
82
|
+
}
|
|
83
|
+
}, { capture: true });
|
|
84
|
+
}
|
package/web/views/topbar.js
CHANGED
|
@@ -16,6 +16,9 @@ export function renderTopbar() {
|
|
|
16
16
|
const tasks = S.view === "tasks";
|
|
17
17
|
const remote = S.view === "remote";
|
|
18
18
|
const library = S.view === "library";
|
|
19
|
+
const showExpert = c && !tasks && !remote && !library;
|
|
20
|
+
// 老版本桌面端把菜单放在窗口顶栏;菜单没有内容时也不放。
|
|
21
|
+
const showMore = !desktopMenu && (topMenuItems().length || usageSummary());
|
|
19
22
|
fill(ui.topbar,
|
|
20
23
|
h("button", { class: "icon-btn menu-btn", onclick: openSide, title: "会话列表" }, icon("menu")),
|
|
21
24
|
h(
|
|
@@ -24,17 +27,15 @@ export function renderTopbar() {
|
|
|
24
27
|
tasks || remote || library
|
|
25
28
|
? h("span", { class: "conv-name" }, tasks ? "定时任务" : library ? "资料库" : "远程控制")
|
|
26
29
|
: c
|
|
27
|
-
?
|
|
28
|
-
// 标题前面是专家的头像:点一下或鼠标停上去,看专家的信息和工作目录
|
|
29
|
-
expertAvatarButton(c),
|
|
30
|
-
h("span", { class: "conv-name", title: convTitle(c) }, convTitle(c)),
|
|
31
|
-
]
|
|
30
|
+
? h("span", { class: "conv-name", title: convTitle(c) }, convTitle(c))
|
|
32
31
|
: null,
|
|
33
32
|
),
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
showExpert || showMore
|
|
34
|
+
? h("div", { class: "top-actions", role: "group", "aria-label": "会话操作" },
|
|
35
|
+
showExpert ? expertAvatarButton(c) : null,
|
|
36
|
+
showMore ? h("button", { class: "icon-btn top-more", title: "更多", onclick: (e) => openTopMore(e.currentTarget) }, icon("more")) : null,
|
|
37
|
+
)
|
|
38
|
+
: null,
|
|
38
39
|
);
|
|
39
40
|
renderContext();
|
|
40
41
|
syncDesktopMenu();
|