agent-yes 1.303.1 → 1.304.0
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 +54 -0
- package/default.config.yaml +5 -5
- package/dist/{JsonlStore-BpYZZTap.js → JsonlStore-CB_0sfdT.js} +5 -4
- package/dist/{SUPPORTED_CLIS-Dq9Lq9WJ.js → SUPPORTED_CLIS-C_1IiOj3.js} +2 -2
- package/dist/SUPPORTED_CLIS-Do3GHAY1.js +12 -0
- package/dist/{agentShare-suB6yPgO.js → agentShare-BvpEm-Fr.js} +10 -9
- package/dist/{askCli-BU3CNCLU.js → askCli-KmMf-3wA.js} +6 -6
- package/dist/{browser-BmxN1Ur9.js → browser-BAFPmEvN.js} +2 -2
- package/dist/{callback-Ctj3_Wxp.js → callback-BiSUhjw7.js} +6 -6
- package/dist/callback-SqLD2mMX.js +17 -0
- package/dist/{callbackCore-DSJWhqAe.js → callbackCore-BZ_10zyc.js} +1 -1
- package/dist/{callbackCore-BesbQ6-Z.js → callbackCore-Deve5pv3.js} +1 -1
- package/dist/{channels-j5nWuzlQ.js → channels-Y36S0ccW.js} +2 -2
- package/dist/cli.js +118 -13
- package/dist/{cmdDsh-2LP0grim.js → cmdDsh-DZ8bLsH7.js} +1 -1
- package/dist/cmdKill-CzSBfWmx.js +116 -0
- package/dist/{cmdPs-wc1j85fi.js → cmdPs-DBt23Qz0.js} +11 -10
- package/dist/{cwdConflictWarn-skQSMwEh.js → cwdConflictWarn-y-epQyOj.js} +21 -5
- package/dist/{cwdPassthroughHint-BUbWMoz0.js → cwdPassthroughHint-CzWh0hrw.js} +1 -1
- package/dist/{expose-Dawq1LxC.js → expose-Bhsn5yUz.js} +2 -2
- package/dist/forceKill-BDqxx4uQ.js +44 -0
- package/dist/{forkNested-CavHyWzA.js → forkNested-3heLs5XC.js} +45 -5
- package/dist/{globalPidIndex-CRB5KtyL.js → globalPidIndex-BsjlId-h.js} +6 -5
- package/dist/{globalPidIndex-BftWlg2V.js → globalPidIndex-uoz8Esqz.js} +2 -2
- package/dist/{hist-Cs0KFSUW.js → hist-DY16wm7g.js} +1 -1
- package/dist/{identity-DA7YI9km.js → identity-C0MxfwI2.js} +1 -1
- package/dist/{identity-Bk-aG_xl.js → identity-Ckav3-Up.js} +1 -1
- package/dist/index.js +7 -7
- package/dist/{initMsg-CcTqFtsp.js → initMsg-BEVDWYnv.js} +1 -1
- package/dist/{initMsg-D9KJnfgC.js → initMsg-GPU52N-j.js} +1 -1
- package/dist/liagent/box-BSIrRRc_.js +2320 -0
- package/dist/liagent/box-DloywR57.d.ts +409 -0
- package/dist/liagent/box.d.ts +3 -0
- package/dist/liagent/box.js +3 -0
- package/dist/liagent/cli.d.ts +1 -0
- package/dist/liagent/cli.js +908 -0
- package/dist/liagent/client.d.ts +28 -0
- package/dist/liagent/client.js +240 -0
- package/dist/liagent/echo-BvzPSI0x.js +86 -0
- package/dist/liagent/echo-W2RcMEny.d.ts +38 -0
- package/dist/liagent/hub.d.ts +405 -0
- package/dist/liagent/hub.js +1831 -0
- package/dist/liagent/index.d.ts +14 -0
- package/dist/liagent/index.js +10 -0
- package/dist/liagent/liagent.js +339 -0
- package/dist/liagent/mic-audio-C3Shud_F.js +754 -0
- package/dist/liagent/mic-audio-DMCWtEI-.d.ts +317 -0
- package/dist/liagent/mic-button-CtZHFBSG.js +651 -0
- package/dist/liagent/mic-button-Y0ioPetQ.d.ts +248 -0
- package/dist/liagent/mic.d.ts +3 -0
- package/dist/liagent/mic.js +4 -0
- package/dist/liagent/progress-CJs08bXb.js +473 -0
- package/dist/liagent/progress-CfE-meHr.d.ts +205 -0
- package/dist/liagent/progress.d.ts +2 -0
- package/dist/liagent/progress.js +3 -0
- package/dist/liagent/protocol.d.ts +324 -0
- package/dist/liagent/protocol.js +504 -0
- package/dist/liagent/speech-rate-DXeJjRTc.js +42 -0
- package/dist/liagent/state-tree-BZCmAknI.js +353 -0
- package/dist/liagent/tree-BrR7NwMf.js +710 -0
- package/dist/liagent/tree-HB9RhX_H.d.ts +295 -0
- package/dist/liagent/tree.d.ts +2 -0
- package/dist/liagent/tree.js +4 -0
- package/dist/liagent/ui-strings-B03le3fh.d.ts +27 -0
- package/dist/liagent/ui-strings-CJIwW5Gf.js +794 -0
- package/dist/liagent/ui.d.ts +394 -0
- package/dist/liagent/ui.js +5 -0
- package/dist/liagent/voice-D7yeS9VM.js +802 -0
- package/dist/liagent/voice-Qo7SCgi8.d.ts +308 -0
- package/dist/liagent/voice.d.ts +3 -0
- package/dist/liagent/voice.js +4 -0
- package/dist/{notifyDaemon-C7GlfJ1E.js → notifyDaemon-DkUB7GV2.js} +10 -9
- package/dist/{openBrowser-1cIo4dJL.js → openBrowser-CQAOIrD6.js} +1 -1
- package/dist/oxmgrService-DlYHmqyI.js +37 -0
- package/dist/oxmgrService-o9L3I6FX.js +3 -0
- package/dist/{parentLink-DoEWVGld.js → parentLink-BcAYcO9L.js} +2 -2
- package/dist/{parentLink-B58V1RVd.js → parentLink-MBUD3oY2.js} +2 -2
- package/dist/{parentPingLoop-C73bbmCE.js → parentPingLoop-DDO592Wh.js} +5 -5
- package/dist/{pidStore-433kvh9D.js → pidStore-C50VPk3E.js} +3 -3
- package/dist/pidStore-COkPjpW8.js +6 -0
- package/dist/{procStats-BvmrBrOs.js → procStats-DwTxj3rs.js} +1 -1
- package/dist/{remotes-MfdV9M8u.js → remotes-BqLoB5GR.js} +2 -2
- package/dist/{remotes-DevcBeLl.js → remotes-BsMGvAay.js} +3 -3
- package/dist/{roomReplyAlias-DFqg_6IU.js → roomReplyAlias-B-v76TA8.js} +3 -3
- package/dist/roomReplyAlias-BzWUBkQy.js +6 -0
- package/dist/{rustBinary-7VK7oLlW.js → rustBinary-BrJ2p8wy.js} +2 -2
- package/dist/{rustBinary-BV4LxMMn.js → rustBinary-vpfpWj1q.js} +2 -2
- package/dist/{schedule-Dp0qkNO1.js → schedule-Bzjhl6-h.js} +15 -44
- package/dist/schedulesCli-CLqieyQZ.js +784 -0
- package/dist/senderAncestry-CVHeKk1Y.js +173 -0
- package/dist/senderAncestry-KhAUPCQs.js +3 -0
- package/dist/{serve-BpOIIOVc.js → serve-XwFYE0cE.js} +67 -69
- package/dist/{serveRust-CbBrcUrg.js → serveRust-BfWkeL6T.js} +31 -4
- package/dist/{setup-DdIBk6Iv.js → setup-D4-s2VZw.js} +5 -5
- package/dist/{share-w5oRbvlj.js → share-CbFetL5H.js} +1 -1
- package/dist/{share-DrS3LYqf.js → share-_TPYAGWC.js} +1 -1
- package/dist/{shareCmd-DDENkBW2.js → shareCmd-DUBsVI3e.js} +10 -10
- package/dist/spawnGate-Dfj9V76w.js +5 -0
- package/dist/{spawnGate-lr3tvA6U.js → spawnGate-Dj_WaS29.js} +3 -3
- package/dist/{subcommands-DxgvDmZX.js → subcommands-B7YZJL8n.js} +471 -307
- package/dist/subcommands-BZPxFgkT.js +15 -0
- package/dist/{systemPathLink-SjUzgSiq.js → systemPathLink-Y3iC7bYV.js} +1 -1
- package/dist/{terminal-C2h7tpe0.js → terminal-13cGj3h6.js} +2 -2
- package/dist/terminal.js +1 -1
- package/dist/{todoAutomation-TTp_Qz9G.js → todoAutomation-CKlrxuZv.js} +2 -2
- package/dist/{todoCli-BWm5nZE0.js → todoCli-CU9vSJSJ.js} +6 -6
- package/dist/{todoIdentity-BvXZKWJI.js → todoIdentity-CzS1e7VL.js} +2 -2
- package/dist/{todoStore-C9RTz0Vs.js → todoStore-msRCEUi1.js} +2 -2
- package/dist/{tray-BeRSozJz.js → tray-CLktEN3G.js} +1 -1
- package/dist/{trayApp-QQjqhDv1.js → trayApp-5_OlvQcz.js} +2 -2
- package/dist/trayApp-DkAPo0m6.js +5 -0
- package/dist/{ts-6LF7f4fx.js → ts-njuddXQz.js} +126 -57
- package/dist/{versionChecker-Bc62HNf6.js → versionChecker-BJycAanp.js} +2 -2
- package/dist/{webrtcLink-va_gAR77.js → webrtcLink-DcvacEci.js} +1 -1
- package/dist/{webrtcLink-SsInrVHU.js → webrtcLink-WxS1nTIs.js} +1 -1
- package/dist/{webrtcRemote-BlGyNZDC.js → webrtcRemote-C3xQyf3u.js} +2 -2
- package/dist/{widget-Crb5zeHL.js → widget-DmRwOlco.js} +3 -3
- package/dist/widgets.js +1 -1
- package/dist/{workspaceConfig-BLWB5Wu9.js → workspaceConfig-DBgsu81B.js} +1 -1
- package/dist/{ws-DIbwNz8Z.js → ws-ByO6JO6m.js} +3 -3
- package/dist/{ws-BRhPG1Vy.js → ws-D0-Jg88z.js} +9 -8
- package/lab/ui/index.html +1 -1
- package/lab/ui/lab/posts/2026-08-11-slack-term-safe-writes.md +1 -1
- package/package.json +73 -8
- package/ts/JsonlStore.ts +10 -3
- package/ts/cli-idle.bun.spec.ts +1 -1
- package/ts/cli-idle.spec.ts +1 -1
- package/ts/cli.ts +35 -0
- package/ts/cmdKill.bun.spec.ts +155 -0
- package/ts/cmdKill.spec.ts +155 -0
- package/ts/cmdKill.ts +183 -0
- package/ts/composerGuard.edges.spec.ts +91 -0
- package/ts/composerGuard.spec.ts +53 -6
- package/ts/composerGuard.ts +42 -13
- package/ts/conptyModeFilter.spec.ts +30 -0
- package/ts/conptyModeFilter.ts +53 -0
- package/ts/copyLiagent.ts +42 -0
- package/ts/cwdConflictWarn.io.spec.ts +50 -0
- package/ts/cwdConflictWarn.spec.ts +34 -1
- package/ts/cwdConflictWarn.ts +43 -5
- package/ts/cwdGuard.spec.ts +110 -0
- package/ts/cwdGuard.ts +118 -0
- package/ts/forceKill.ts +52 -0
- package/ts/forkNested.bun.spec.ts +41 -0
- package/ts/forkNested.spec.ts +41 -0
- package/ts/forkNested.ts +48 -1
- package/ts/globalPidIndex.edges.spec.ts +125 -0
- package/ts/globalPidIndex.ts +6 -2
- package/ts/index.ts +13 -1
- package/ts/interruptSend.bun.spec.ts +99 -0
- package/ts/interruptSend.spec.ts +99 -0
- package/ts/interruptSend.ts +51 -0
- package/ts/lockRegistry.spec.ts +49 -0
- package/ts/lsRenderCache.spec.ts +58 -0
- package/ts/needsInput.edges.spec.ts +23 -0
- package/ts/parseCliArgs.ts +7 -0
- package/ts/pushGatePlan.spec.ts +147 -0
- package/ts/roomReplyAlias.io.spec.ts +81 -0
- package/ts/schedule.ts +5 -1
- package/ts/schedules.bun.spec.ts +397 -0
- package/ts/schedules.spec.ts +397 -0
- package/ts/schedules.ts +517 -0
- package/ts/schedulesCli.ts +386 -0
- package/ts/sendControl.bun.spec.ts +12 -0
- package/ts/senderAncestry.ts +1 -3
- package/ts/serve.ts +22 -33
- package/ts/serveRust.spec.ts +29 -2
- package/ts/serveRust.ts +27 -2
- package/ts/sizeNego.bun.spec.ts +9 -2
- package/ts/sizeNego.spec.ts +9 -2
- package/ts/sizeNego.ts +10 -5
- package/ts/subcommands.spec.ts +348 -9
- package/ts/subcommands.ts +513 -93
- package/ts/suggestAgents.spec.ts +33 -0
- package/ts/terminal/browser.ts +1 -1
- package/ts/todoParse.spec.ts +22 -1
- package/ts/todoParse.ts +19 -0
- package/dist/SUPPORTED_CLIS-ByO5twge.js +0 -12
- package/dist/callback-D7qfh_7p.js +0 -16
- package/dist/pidStore-BRlKRHXY.js +0 -6
- package/dist/roomReplyAlias-DuEkSSDI.js +0 -6
- package/dist/spawnGate-DeQBTX-o.js +0 -5
- package/dist/subcommands-DmiswRy4.js +0 -14
- package/dist/trayApp-C4TAvRvU.js +0 -5
|
@@ -0,0 +1,794 @@
|
|
|
1
|
+
import { i as crumbs } from "./state-tree-BZCmAknI.js";
|
|
2
|
+
|
|
3
|
+
//#region src/detent.ts
|
|
4
|
+
/** The thing's position for a finger travel: the snapping staircase, then the rubber band. */
|
|
5
|
+
function snapDetent(finger, o) {
|
|
6
|
+
const max = finger >= 0 ? o.max : -(o.min ?? -o.max);
|
|
7
|
+
const f = Math.abs(finger);
|
|
8
|
+
const top = max * o.cell;
|
|
9
|
+
const x = f <= top ? o.unit * (f / o.cell - o.snap * Math.sin(2 * Math.PI * f / o.cell) / (2 * Math.PI)) : Math.min(o.stop, max * o.unit + (f - top) * o.stretch);
|
|
10
|
+
return Math.sign(finger) * x;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The level after `t` cells of travel, from level `from`, with hysteresis
|
|
14
|
+
* both ways: it moves on only `hysteresis` past a midpoint, so a finger
|
|
15
|
+
* resting on a boundary never flickers.
|
|
16
|
+
*/
|
|
17
|
+
function detentLevel(t, from, o) {
|
|
18
|
+
let k = from;
|
|
19
|
+
while (k < o.max && t > k + .5 + o.hysteresis) k++;
|
|
20
|
+
while (k > o.min && t < k - .5 - o.hysteresis) k--;
|
|
21
|
+
return k;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/tree-nav.ts
|
|
26
|
+
/**
|
|
27
|
+
* Navigating a tree by detents: a pure reducer, `treeNav(state, event)`.
|
|
28
|
+
* Generic: any tree (the chat box's tree view uses it).
|
|
29
|
+
*
|
|
30
|
+
* The view: at each level the collapsed siblings sit in a row of chips; one
|
|
31
|
+
* node is expanded at a time along one branch (an accordion), its subtree
|
|
32
|
+
* shown `expanded[id]` levels deep. A focused node takes the gestures.
|
|
33
|
+
*
|
|
34
|
+
* - Dragging right by k cells expands the focused node one level per cell,
|
|
35
|
+
* up to `maxDetent` (min(3, its subtree's height)); a leaf can't expand.
|
|
36
|
+
* - Dragging left collapses one level per cell: first the focused node's own
|
|
37
|
+
* depth, deepest level first; past its own level the focus moves to its
|
|
38
|
+
* parent, whose depth then drops by one; at a top-level chip with nothing
|
|
39
|
+
* expanded there is nothing left to collapse.
|
|
40
|
+
* - At either limit the reducer stops: no wrap-around, the SAME state object
|
|
41
|
+
* back (or once, the state with `atLimit` set), so the view can rubber-band.
|
|
42
|
+
* - A drag previews (`preview`) and commits only on `dragEnd`.
|
|
43
|
+
*
|
|
44
|
+
* It is not a counter: the result depends on the path (the focus moves, and
|
|
45
|
+
* each node has its own depth), so "expand 2 then collapse 1" and "collapse 1
|
|
46
|
+
* then expand 2" can differ.
|
|
47
|
+
*/
|
|
48
|
+
/** Build a NavIndex from any tree. */
|
|
49
|
+
function indexTree(roots, childrenOf, idOf) {
|
|
50
|
+
const ix = {
|
|
51
|
+
roots: [],
|
|
52
|
+
parent: /* @__PURE__ */ new Map(),
|
|
53
|
+
children: /* @__PURE__ */ new Map()
|
|
54
|
+
};
|
|
55
|
+
const go = (n, parent, i) => {
|
|
56
|
+
const id = idOf(n, parent, i);
|
|
57
|
+
ix.parent.set(id, parent);
|
|
58
|
+
ix.children.set(id, childrenOf(n).map((c, j) => go(c, id, j)));
|
|
59
|
+
return id;
|
|
60
|
+
};
|
|
61
|
+
ix.roots = roots.map((r, i) => go(r, null, i));
|
|
62
|
+
return ix;
|
|
63
|
+
}
|
|
64
|
+
/** Levels below a node: 0 for a leaf. */
|
|
65
|
+
function height(ix, id) {
|
|
66
|
+
const kids = ix.children.get(id) ?? [];
|
|
67
|
+
return kids.length ? 1 + Math.max(...kids.map((k) => height(ix, k))) : 0;
|
|
68
|
+
}
|
|
69
|
+
/** How deep a node can open: min(3, its subtree's height); 0 for a leaf. */
|
|
70
|
+
const MAX_DETENT = 3;
|
|
71
|
+
function maxDetent(ix, id) {
|
|
72
|
+
return Math.min(MAX_DETENT, height(ix, id));
|
|
73
|
+
}
|
|
74
|
+
const initialNav = (ix) => ({
|
|
75
|
+
focusId: ix.roots[0] ?? null,
|
|
76
|
+
expanded: {},
|
|
77
|
+
detent: 0
|
|
78
|
+
});
|
|
79
|
+
/** The ancestors of a node, nearest first. */
|
|
80
|
+
function ancestors(ix, id) {
|
|
81
|
+
const out = [];
|
|
82
|
+
for (let p = ix.parent.get(id) ?? null; p !== null; p = ix.parent.get(p) ?? null) out.push(p);
|
|
83
|
+
return out;
|
|
84
|
+
}
|
|
85
|
+
const topOf = (ix, id) => ancestors(ix, id).at(-1) ?? id;
|
|
86
|
+
/** Is a node on screen: a top-level chip, or within an expanded ancestor's depth. */
|
|
87
|
+
function isVisible(ix, s, id) {
|
|
88
|
+
const up = ancestors(ix, id);
|
|
89
|
+
if (!up.length) return true;
|
|
90
|
+
if (!isVisible(ix, s, up[0])) return false;
|
|
91
|
+
return up.some((a, i) => (s.expanded[a] ?? 0) >= i + 1);
|
|
92
|
+
}
|
|
93
|
+
/** Drop depths of nodes no longer on screen, and anything outside `top`'s branch. */
|
|
94
|
+
function prune(ix, e, top) {
|
|
95
|
+
const out = {};
|
|
96
|
+
for (const [id, d] of Object.entries(e)) if (d > 0 && (top === null || topOf(ix, id) === top)) out[id] = d;
|
|
97
|
+
for (let changed = true; changed;) {
|
|
98
|
+
changed = false;
|
|
99
|
+
for (const id of Object.keys(out)) if (!isVisible(ix, { expanded: out }, id)) {
|
|
100
|
+
delete out[id];
|
|
101
|
+
changed = true;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return out;
|
|
105
|
+
}
|
|
106
|
+
function expandStep(ix, s) {
|
|
107
|
+
const f = s.focusId;
|
|
108
|
+
if (f === null) return {
|
|
109
|
+
s,
|
|
110
|
+
limit: "max"
|
|
111
|
+
};
|
|
112
|
+
const d = s.expanded[f] ?? 0;
|
|
113
|
+
if (d >= maxDetent(ix, f)) return {
|
|
114
|
+
s,
|
|
115
|
+
limit: "max"
|
|
116
|
+
};
|
|
117
|
+
const e = prune(ix, {
|
|
118
|
+
...s.expanded,
|
|
119
|
+
[f]: d + 1
|
|
120
|
+
}, topOf(ix, f));
|
|
121
|
+
return { s: {
|
|
122
|
+
...s,
|
|
123
|
+
expanded: e
|
|
124
|
+
} };
|
|
125
|
+
}
|
|
126
|
+
function collapseStep(ix, s) {
|
|
127
|
+
const f = s.focusId;
|
|
128
|
+
if (f === null) return {
|
|
129
|
+
s,
|
|
130
|
+
limit: "min"
|
|
131
|
+
};
|
|
132
|
+
const d = s.expanded[f] ?? 0;
|
|
133
|
+
if (d > 0) {
|
|
134
|
+
const e = {
|
|
135
|
+
...s.expanded,
|
|
136
|
+
[f]: d - 1
|
|
137
|
+
};
|
|
138
|
+
return { s: {
|
|
139
|
+
...s,
|
|
140
|
+
expanded: prune(ix, e, topOf(ix, f))
|
|
141
|
+
} };
|
|
142
|
+
}
|
|
143
|
+
const p = ix.parent.get(f) ?? null;
|
|
144
|
+
if (p === null) return {
|
|
145
|
+
s,
|
|
146
|
+
limit: "min"
|
|
147
|
+
};
|
|
148
|
+
const pd = s.expanded[p] ?? 1;
|
|
149
|
+
const e = {
|
|
150
|
+
...s.expanded,
|
|
151
|
+
[p]: Math.max(0, pd - 1)
|
|
152
|
+
};
|
|
153
|
+
return { s: {
|
|
154
|
+
...s,
|
|
155
|
+
focusId: p,
|
|
156
|
+
expanded: prune(ix, e, topOf(ix, p))
|
|
157
|
+
} };
|
|
158
|
+
}
|
|
159
|
+
/** `n` steps (signed) from `s`, stopping at a limit. */
|
|
160
|
+
function steps(ix, s, n) {
|
|
161
|
+
let cur = { s };
|
|
162
|
+
for (let i = 0; i < Math.abs(n); i++) {
|
|
163
|
+
const next = n > 0 ? expandStep(ix, cur.s) : collapseStep(ix, cur.s);
|
|
164
|
+
if (next.limit) return {
|
|
165
|
+
s: cur.s,
|
|
166
|
+
limit: next.limit
|
|
167
|
+
};
|
|
168
|
+
cur = next;
|
|
169
|
+
}
|
|
170
|
+
return cur;
|
|
171
|
+
}
|
|
172
|
+
/** The same object when nothing changes; else the new one. */
|
|
173
|
+
function settle(prev, next, limit) {
|
|
174
|
+
const out = limit ? {
|
|
175
|
+
...next,
|
|
176
|
+
atLimit: limit
|
|
177
|
+
} : next.atLimit ? {
|
|
178
|
+
...next,
|
|
179
|
+
atLimit: void 0
|
|
180
|
+
} : next;
|
|
181
|
+
if (out.focusId === prev.focusId && out.detent === prev.detent && out.atLimit === prev.atLimit && out.base === prev.base && sameDepths(out.expanded, prev.expanded)) return prev;
|
|
182
|
+
return out;
|
|
183
|
+
}
|
|
184
|
+
const sameDepths = (a, b) => {
|
|
185
|
+
const ka = Object.keys(a);
|
|
186
|
+
return ka.length === Object.keys(b).length && ka.every((k) => a[k] === b[k]);
|
|
187
|
+
};
|
|
188
|
+
/** Siblings of a node, in order. */
|
|
189
|
+
const siblings = (ix, id) => {
|
|
190
|
+
const p = ix.parent.get(id) ?? null;
|
|
191
|
+
return p === null ? ix.roots : ix.children.get(p) ?? [];
|
|
192
|
+
};
|
|
193
|
+
function treeNav(ix, s, ev) {
|
|
194
|
+
switch (ev.type) {
|
|
195
|
+
case "dragStart": return {
|
|
196
|
+
...s,
|
|
197
|
+
base: s.base ?? {
|
|
198
|
+
...s,
|
|
199
|
+
base: void 0
|
|
200
|
+
},
|
|
201
|
+
detent: 0,
|
|
202
|
+
atLimit: void 0
|
|
203
|
+
};
|
|
204
|
+
case "dragMove": {
|
|
205
|
+
const base = s.base ?? s;
|
|
206
|
+
const r = steps(ix, base, ev.cells);
|
|
207
|
+
return settle(s, {
|
|
208
|
+
...r.s,
|
|
209
|
+
base,
|
|
210
|
+
detent: ev.cells
|
|
211
|
+
}, r.limit);
|
|
212
|
+
}
|
|
213
|
+
case "dragEnd":
|
|
214
|
+
if (!s.base) return s;
|
|
215
|
+
return {
|
|
216
|
+
...s,
|
|
217
|
+
base: void 0,
|
|
218
|
+
detent: 0,
|
|
219
|
+
atLimit: void 0
|
|
220
|
+
};
|
|
221
|
+
case "dragCancel": return s.base ? {
|
|
222
|
+
...s.base,
|
|
223
|
+
base: void 0,
|
|
224
|
+
detent: 0,
|
|
225
|
+
atLimit: void 0
|
|
226
|
+
} : s;
|
|
227
|
+
case "tapChip": {
|
|
228
|
+
if (!ix.parent.has(ev.id)) return s;
|
|
229
|
+
const top = topOf(ix, ev.id);
|
|
230
|
+
const d = s.expanded[ev.id] ?? 0;
|
|
231
|
+
const want = d === 0 && maxDetent(ix, ev.id) > 0 ? 1 : d;
|
|
232
|
+
const e = prune(ix, {
|
|
233
|
+
...s.expanded,
|
|
234
|
+
[ev.id]: want
|
|
235
|
+
}, top);
|
|
236
|
+
return settle(s, {
|
|
237
|
+
...s,
|
|
238
|
+
focusId: ev.id,
|
|
239
|
+
expanded: e,
|
|
240
|
+
base: void 0,
|
|
241
|
+
detent: 0
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
case "collapseAll": return settle(s, {
|
|
245
|
+
focusId: s.focusId === null ? null : topOf(ix, s.focusId),
|
|
246
|
+
expanded: {},
|
|
247
|
+
detent: 0
|
|
248
|
+
});
|
|
249
|
+
case "key": {
|
|
250
|
+
const f = s.focusId;
|
|
251
|
+
if (f === null) return s;
|
|
252
|
+
const sib = siblings(ix, f);
|
|
253
|
+
const i = sib.indexOf(f);
|
|
254
|
+
const step = (n) => {
|
|
255
|
+
const r = steps(ix, s, n);
|
|
256
|
+
return settle(s, r.s, r.limit);
|
|
257
|
+
};
|
|
258
|
+
switch (ev.key) {
|
|
259
|
+
case "ArrowRight": return i < sib.length - 1 ? settle(s, {
|
|
260
|
+
...s,
|
|
261
|
+
focusId: sib[i + 1]
|
|
262
|
+
}) : step(1);
|
|
263
|
+
case "ArrowLeft": return i > 0 ? settle(s, {
|
|
264
|
+
...s,
|
|
265
|
+
focusId: sib[i - 1]
|
|
266
|
+
}) : step(-1);
|
|
267
|
+
case "Enter": return step(1);
|
|
268
|
+
case "Escape": return step(-1);
|
|
269
|
+
case "ArrowDown": {
|
|
270
|
+
const kid = (ix.children.get(f) ?? [])[0];
|
|
271
|
+
return kid && (s.expanded[f] ?? 0) > 0 ? settle(s, {
|
|
272
|
+
...s,
|
|
273
|
+
focusId: kid
|
|
274
|
+
}) : s;
|
|
275
|
+
}
|
|
276
|
+
case "ArrowUp": {
|
|
277
|
+
const p = ix.parent.get(f) ?? null;
|
|
278
|
+
return p === null ? s : settle(s, {
|
|
279
|
+
...s,
|
|
280
|
+
focusId: p
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
default: return s;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
/** One detent of the tree button's drag: about the button's width. */
|
|
289
|
+
const TREE_DETENT_PX = 40;
|
|
290
|
+
/** How many cells a single drag can reach each way. */
|
|
291
|
+
const TREE_DRAG_CELLS = 6;
|
|
292
|
+
/** The tree drag's feel: the card swipe's snap and hysteresis (detent.ts). */
|
|
293
|
+
const TREE_HYSTERESIS = .1;
|
|
294
|
+
const TREE_SNAP = .6;
|
|
295
|
+
const TREE_STRETCH = .3;
|
|
296
|
+
/** Cells of a horizontal drag `dx`, from the cells it was at (hysteresis). */
|
|
297
|
+
function dragCells(dx, from) {
|
|
298
|
+
return detentLevel(dx / TREE_DETENT_PX, from, {
|
|
299
|
+
min: -TREE_DRAG_CELLS,
|
|
300
|
+
max: TREE_DRAG_CELLS,
|
|
301
|
+
hysteresis: TREE_HYSTERESIS
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Where the tree button's preview sits for a drag `dx`: snapping to the
|
|
306
|
+
* detents, and past a limit only rubber-banding (STRETCH of the travel
|
|
307
|
+
* beyond `limitCells`), released back to the detent.
|
|
308
|
+
*/
|
|
309
|
+
function dragOffset(dx, limitCells) {
|
|
310
|
+
const feel = {
|
|
311
|
+
cell: TREE_DETENT_PX,
|
|
312
|
+
unit: TREE_DETENT_PX,
|
|
313
|
+
max: TREE_DRAG_CELLS,
|
|
314
|
+
snap: TREE_SNAP,
|
|
315
|
+
stretch: TREE_STRETCH,
|
|
316
|
+
stop: TREE_DRAG_CELLS * TREE_DETENT_PX
|
|
317
|
+
};
|
|
318
|
+
if (limitCells === void 0) return snapDetent(dx, feel);
|
|
319
|
+
const edge = limitCells * TREE_DETENT_PX;
|
|
320
|
+
const past = dx - edge;
|
|
321
|
+
if (Math.sign(past) !== Math.sign(limitCells || dx) || past === 0) return snapDetent(dx, feel);
|
|
322
|
+
return snapDetent(edge, feel) + past * TREE_STRETCH;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
//#endregion
|
|
326
|
+
//#region src/float-lines.ts
|
|
327
|
+
/**
|
|
328
|
+
* The minimized chat's floating lines: a message that arrives while the chat is
|
|
329
|
+
* minimized floats above the bar for as long as it takes to read it twice,
|
|
330
|
+
* then fades. Hovering or touching the lines pauses their timers.
|
|
331
|
+
*/
|
|
332
|
+
/** Characters per second read in CJK scripts (Han, kana, Hangul). */
|
|
333
|
+
const READ_RATE_CJK = 6;
|
|
334
|
+
/** Characters per second for everything else (~180 words per minute). */
|
|
335
|
+
const READ_RATE_LATIN = 15;
|
|
336
|
+
/** A line stays up for this many reading times... */
|
|
337
|
+
const DWELL_FACTOR = 2;
|
|
338
|
+
/** ...and never less than this. */
|
|
339
|
+
const DWELL_MIN_MS = 2500;
|
|
340
|
+
/** The slow fade-out once the dwell is over (gone at once under reduced motion). */
|
|
341
|
+
const FADE_MS = 1e4;
|
|
342
|
+
/** At most this many lines float at once; the oldest goes first. */
|
|
343
|
+
const FLOAT_MAX = 6;
|
|
344
|
+
const CJK = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u;
|
|
345
|
+
/** Seconds to read `text` once: CJK characters at 6/s, the rest at 15/s. */
|
|
346
|
+
function readTime(text) {
|
|
347
|
+
let cjk = 0;
|
|
348
|
+
let other = 0;
|
|
349
|
+
for (const ch of text.trim()) if (CJK.test(ch)) cjk++;
|
|
350
|
+
else other++;
|
|
351
|
+
return cjk / READ_RATE_CJK + other / READ_RATE_LATIN;
|
|
352
|
+
}
|
|
353
|
+
/** How long a floating line stays before it fades, in ms. */
|
|
354
|
+
function dwellMs(text) {
|
|
355
|
+
return Math.max(DWELL_MIN_MS, Math.round(readTime(text) * 1e3 * DWELL_FACTOR));
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* One line's countdown: a single setTimeout, stopped by `pause` and restarted
|
|
359
|
+
* by `resume` with the time that was left. Clock and timers are injected for
|
|
360
|
+
* tests.
|
|
361
|
+
*/
|
|
362
|
+
function createDwellTimer(d) {
|
|
363
|
+
const now = d.now ?? (() => Date.now());
|
|
364
|
+
const setTimer = d.setTimer ?? ((f, ms) => setTimeout(f, ms));
|
|
365
|
+
const clearTimer = d.clearTimer ?? ((t) => clearTimeout(t));
|
|
366
|
+
let left = d.ms;
|
|
367
|
+
let started = now();
|
|
368
|
+
let timer = null;
|
|
369
|
+
let done = false;
|
|
370
|
+
const start = () => {
|
|
371
|
+
started = now();
|
|
372
|
+
timer = setTimer(() => {
|
|
373
|
+
timer = null;
|
|
374
|
+
done = true;
|
|
375
|
+
d.onDone();
|
|
376
|
+
}, left);
|
|
377
|
+
};
|
|
378
|
+
start();
|
|
379
|
+
return {
|
|
380
|
+
pause() {
|
|
381
|
+
if (timer === null || done) return;
|
|
382
|
+
clearTimer(timer);
|
|
383
|
+
timer = null;
|
|
384
|
+
left = Math.max(0, left - (now() - started));
|
|
385
|
+
},
|
|
386
|
+
resume() {
|
|
387
|
+
if (timer !== null || done) return;
|
|
388
|
+
start();
|
|
389
|
+
},
|
|
390
|
+
cancel() {
|
|
391
|
+
if (timer !== null) clearTimer(timer);
|
|
392
|
+
timer = null;
|
|
393
|
+
done = true;
|
|
394
|
+
},
|
|
395
|
+
remaining: () => timer === null ? left : Math.max(0, left - (now() - started))
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
/** The latest message floats on minimize only if it arrived at most this long ago. */
|
|
399
|
+
const MINIMIZE_FLOAT_MAX_AGE_MS = 10 * 6e4;
|
|
400
|
+
/**
|
|
401
|
+
* When this widget first saw each message, by id — this device's clock, never
|
|
402
|
+
* the message's own `at` (another clock, which may be skewed). New messages
|
|
403
|
+
* are told by id, not by the list's length: the host caps its history, so
|
|
404
|
+
* once full the list stays the same length as new lines push old ones out.
|
|
405
|
+
*/
|
|
406
|
+
function createArrivals() {
|
|
407
|
+
const seen = /* @__PURE__ */ new Map();
|
|
408
|
+
/** Arrival order, by id: 1, 2, 3… (never a clock, so never a tie). */
|
|
409
|
+
const order = /* @__PURE__ */ new Map();
|
|
410
|
+
let count = 0;
|
|
411
|
+
let loaded = false;
|
|
412
|
+
return {
|
|
413
|
+
see(messages, now) {
|
|
414
|
+
const fresh = messages.filter((m) => !seen.has(m.id));
|
|
415
|
+
for (const m of fresh) {
|
|
416
|
+
seen.set(m.id, now);
|
|
417
|
+
order.set(m.id, ++count);
|
|
418
|
+
}
|
|
419
|
+
const history = !loaded;
|
|
420
|
+
if (messages.length) loaded = true;
|
|
421
|
+
if (seen.size > 2 * messages.length + 100) {
|
|
422
|
+
const ids = new Set(messages.map((m) => m.id));
|
|
423
|
+
for (const id of seen.keys()) if (!ids.has(id)) {
|
|
424
|
+
seen.delete(id);
|
|
425
|
+
order.delete(id);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
return {
|
|
429
|
+
fresh,
|
|
430
|
+
history
|
|
431
|
+
};
|
|
432
|
+
},
|
|
433
|
+
at: (id) => seen.get(id),
|
|
434
|
+
seqOf: (id) => order.get(id),
|
|
435
|
+
seq: () => count
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* The minimized bar's unread badge: the agent's messages that arrived after
|
|
440
|
+
* `readSeq` (the arrival order when the chat was last open, or the history
|
|
441
|
+
* loaded). By arrival, not by list position: a capped list keeps its length.
|
|
442
|
+
*/
|
|
443
|
+
function countUnread(messages, seqOf, readSeq) {
|
|
444
|
+
return messages.filter((m) => m.from === "agent" && (seqOf(m.id) ?? 0) > readSeq).length;
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* At the moment the chat is minimized, the latest message (from anyone) is
|
|
448
|
+
* treated as unread and floats, unless it arrived here more than
|
|
449
|
+
* MINIMIZE_FLOAT_MAX_AGE_MS ago. Its dwell starts then, not when it arrived.
|
|
450
|
+
*/
|
|
451
|
+
function minimizeFloat(messages, now, arrivedAt) {
|
|
452
|
+
const last = messages.at(-1);
|
|
453
|
+
if (!last) return null;
|
|
454
|
+
const at = arrivedAt(last.id);
|
|
455
|
+
return at !== void 0 && now - at <= MINIMIZE_FLOAT_MAX_AGE_MS ? last : null;
|
|
456
|
+
}
|
|
457
|
+
function createFloatLife(d) {
|
|
458
|
+
const setTimer = d.setTimer ?? ((f, ms) => setTimeout(f, ms));
|
|
459
|
+
const clearTimer = d.clearTimer ?? ((t) => clearTimeout(t));
|
|
460
|
+
let phase = "dwell";
|
|
461
|
+
let paused = false;
|
|
462
|
+
let fade = null;
|
|
463
|
+
const set = (p) => {
|
|
464
|
+
phase = p;
|
|
465
|
+
d.onPhase(p);
|
|
466
|
+
};
|
|
467
|
+
const startFade = () => {
|
|
468
|
+
set("fade");
|
|
469
|
+
fade = setTimer(() => {
|
|
470
|
+
fade = null;
|
|
471
|
+
set("gone");
|
|
472
|
+
}, d.fadeMs ?? FADE_MS);
|
|
473
|
+
};
|
|
474
|
+
const dwell = createDwellTimer({
|
|
475
|
+
ms: d.ms,
|
|
476
|
+
onDone: () => d.reducedMotion ? set("gone") : startFade(),
|
|
477
|
+
now: d.now,
|
|
478
|
+
setTimer,
|
|
479
|
+
clearTimer
|
|
480
|
+
});
|
|
481
|
+
const life = {
|
|
482
|
+
pause() {
|
|
483
|
+
if (paused) return;
|
|
484
|
+
paused = true;
|
|
485
|
+
if (phase === "dwell") dwell.pause();
|
|
486
|
+
else if (phase === "fade") {
|
|
487
|
+
clearTimer(fade);
|
|
488
|
+
fade = null;
|
|
489
|
+
set("held");
|
|
490
|
+
}
|
|
491
|
+
},
|
|
492
|
+
resume() {
|
|
493
|
+
if (!paused) return;
|
|
494
|
+
paused = false;
|
|
495
|
+
if (phase === "dwell") dwell.resume();
|
|
496
|
+
else if (phase === "held") startFade();
|
|
497
|
+
},
|
|
498
|
+
cancel() {
|
|
499
|
+
dwell.cancel();
|
|
500
|
+
if (fade !== null) clearTimer(fade);
|
|
501
|
+
fade = null;
|
|
502
|
+
},
|
|
503
|
+
phase: () => phase
|
|
504
|
+
};
|
|
505
|
+
if (d.paused) life.pause();
|
|
506
|
+
return life;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
//#endregion
|
|
510
|
+
//#region src/anchor.ts
|
|
511
|
+
const ANCHOR_GUTTER_PX = 8;
|
|
512
|
+
/** The bar's side of the screen, by its centre: thirds. */
|
|
513
|
+
function anchorSide(barLeft, barRight, vw) {
|
|
514
|
+
const mid = (barLeft + barRight) / 2;
|
|
515
|
+
return mid < vw / 3 ? "left" : mid > 2 * vw / 3 ? "right" : "center";
|
|
516
|
+
}
|
|
517
|
+
/** The box's left edge (viewport px) for its width, anchored to the bar and clamped. */
|
|
518
|
+
function placeBox(d) {
|
|
519
|
+
const g = d.gutter ?? ANCHOR_GUTTER_PX;
|
|
520
|
+
const side = anchorSide(d.barLeft, d.barRight, d.vw);
|
|
521
|
+
const want = side === "left" ? d.barLeft : side === "right" ? d.barRight - d.boxWidth : (d.barLeft + d.barRight) / 2 - d.boxWidth / 2;
|
|
522
|
+
const min = (d.insetLeft ?? 0) + g;
|
|
523
|
+
const max = d.vw - (d.insetRight ?? 0) - g - d.boxWidth;
|
|
524
|
+
return {
|
|
525
|
+
side,
|
|
526
|
+
left: Math.round(max < min ? min : Math.min(max, Math.max(min, want)))
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
//#endregion
|
|
531
|
+
//#region src/frontier-view.ts
|
|
532
|
+
/**
|
|
533
|
+
* The minimized chat's frontier lines: the last thing done, what is in
|
|
534
|
+
* progress, and what comes next. The data comes from src/state-tree.ts
|
|
535
|
+
* (`frontier`); this file has only the small display rules, so they can be
|
|
536
|
+
* tested without a DOM.
|
|
537
|
+
*/
|
|
538
|
+
const FRONTIER_ROWS = [
|
|
539
|
+
{
|
|
540
|
+
key: "done",
|
|
541
|
+
mark: "✓",
|
|
542
|
+
label: "Last done"
|
|
543
|
+
},
|
|
544
|
+
{
|
|
545
|
+
key: "doing",
|
|
546
|
+
mark: "▶",
|
|
547
|
+
label: "In progress"
|
|
548
|
+
},
|
|
549
|
+
{
|
|
550
|
+
key: "next",
|
|
551
|
+
mark: "›",
|
|
552
|
+
label: "Next"
|
|
553
|
+
}
|
|
554
|
+
];
|
|
555
|
+
/** Visible characters of an agent id at the line's end. */
|
|
556
|
+
const SHORT_ID_LEN = 6;
|
|
557
|
+
/** Longer than this, an "id" is more likely a token than a slug: hidden. */
|
|
558
|
+
const MAX_ID_LEN = 64;
|
|
559
|
+
/** How long a touch must rest on the id to show the full one. */
|
|
560
|
+
const LONG_PRESS_MS = 500;
|
|
561
|
+
/**
|
|
562
|
+
* The agent id to show, or null. Only agents have one shown, and only an
|
|
563
|
+
* opaque slug: anything that looks like a host, a path, a pid:port or a
|
|
564
|
+
* token (a dot, colon or slash, or over 64 characters) is dropped.
|
|
565
|
+
*/
|
|
566
|
+
function shownAgentId(a) {
|
|
567
|
+
if (!a || a.type !== "agent" || !a.id) return null;
|
|
568
|
+
const id = a.id.trim();
|
|
569
|
+
if (!id || id.length > MAX_ID_LEN || /[.:/\\]/.test(id)) return null;
|
|
570
|
+
return id;
|
|
571
|
+
}
|
|
572
|
+
/** The last SHORT_ID_LEN characters, for the line's end. */
|
|
573
|
+
const shortId = (id) => id.slice(-SHORT_ID_LEN);
|
|
574
|
+
/** The `〔N〕` after a group's summary; nothing for a single item. */
|
|
575
|
+
const countBadge = (n) => n && n > 1 ? `〔${n}〕` : "";
|
|
576
|
+
/**
|
|
577
|
+
* The bar's lines from state-tree.ts frontier(): a group as its summary (or,
|
|
578
|
+
* without one, its first item's title) and count, its items with breadcrumbs;
|
|
579
|
+
* one item as its title. Undefined when there is nothing to show.
|
|
580
|
+
*/
|
|
581
|
+
function frontierView(f) {
|
|
582
|
+
const line = (e) => e && {
|
|
583
|
+
text: e.count > 1 && e.summary ? e.summary : e.title,
|
|
584
|
+
count: e.count,
|
|
585
|
+
...e.assignee ? { assignee: e.assignee } : {},
|
|
586
|
+
...e.count > 1 ? { items: e.items.map((it) => ({
|
|
587
|
+
title: it.title,
|
|
588
|
+
path: crumbs(it.path),
|
|
589
|
+
...it.assignee ? { assignee: it.assignee } : {}
|
|
590
|
+
})) } : {}
|
|
591
|
+
};
|
|
592
|
+
const out = {};
|
|
593
|
+
const done = line(f.done);
|
|
594
|
+
const doing = line(f.doing);
|
|
595
|
+
const next = line(f.next);
|
|
596
|
+
if (done) out.done = done;
|
|
597
|
+
if (doing) out.doing = doing;
|
|
598
|
+
if (next) out.next = next;
|
|
599
|
+
return done || doing || next ? out : void 0;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
//#endregion
|
|
603
|
+
//#region src/tap-gesture.ts
|
|
604
|
+
/**
|
|
605
|
+
* One tap or two (the chat box's grip): a single tap acts only once
|
|
606
|
+
* `delayMs` pass without a second; a second tap inside that window cancels it
|
|
607
|
+
* and acts as a double tap. Timers are injected for tests.
|
|
608
|
+
*/
|
|
609
|
+
const DOUBLE_TAP_MS = 280;
|
|
610
|
+
function createTapper(d) {
|
|
611
|
+
const setTimer = d.setTimer ?? ((f, ms) => setTimeout(f, ms));
|
|
612
|
+
const clearTimer = d.clearTimer ?? ((t) => clearTimeout(t));
|
|
613
|
+
let waiting = null;
|
|
614
|
+
return {
|
|
615
|
+
tap() {
|
|
616
|
+
if (waiting !== null) {
|
|
617
|
+
clearTimer(waiting);
|
|
618
|
+
waiting = null;
|
|
619
|
+
return d.onDouble();
|
|
620
|
+
}
|
|
621
|
+
waiting = setTimer(() => {
|
|
622
|
+
waiting = null;
|
|
623
|
+
d.onSingle();
|
|
624
|
+
}, d.delayMs ?? DOUBLE_TAP_MS);
|
|
625
|
+
},
|
|
626
|
+
cancel() {
|
|
627
|
+
if (waiting !== null) clearTimer(waiting);
|
|
628
|
+
waiting = null;
|
|
629
|
+
}
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
/** How long after a drag ends its click is still "the click that ended a drag". */
|
|
633
|
+
const DRAG_CLICK_MS = 400;
|
|
634
|
+
/**
|
|
635
|
+
* Tells the click that ends a drag from a real tap. The flag is cleared by
|
|
636
|
+
* the next pointerdown and expires after DRAG_CLICK_MS, so a browser that
|
|
637
|
+
* sends no click after a touch drag (iOS) never swallows the next tap.
|
|
638
|
+
*/
|
|
639
|
+
function createDragFlag(now = Date.now) {
|
|
640
|
+
let endedAt = null;
|
|
641
|
+
return {
|
|
642
|
+
down() {
|
|
643
|
+
endedAt = null;
|
|
644
|
+
},
|
|
645
|
+
dragEnded() {
|
|
646
|
+
endedAt = now();
|
|
647
|
+
},
|
|
648
|
+
wasDrag() {
|
|
649
|
+
const d = endedAt !== null && now() - endedAt < DRAG_CLICK_MS;
|
|
650
|
+
endedAt = null;
|
|
651
|
+
return d;
|
|
652
|
+
}
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
/** A press must move this far before it counts as a drag, and its axis is locked. */
|
|
656
|
+
const AXIS_LOCK_PX = 8;
|
|
657
|
+
/**
|
|
658
|
+
* One press on the mic, told apart by its first AXIS_LOCK_PX of movement:
|
|
659
|
+
* under that it stays a tap (the mic toggles); then it locks to an axis for
|
|
660
|
+
* the rest of the press — "y" scrubs the chat history, "x" moves the bar.
|
|
661
|
+
* `up` says whether the click that follows must be swallowed (any lock).
|
|
662
|
+
*/
|
|
663
|
+
function createAxisLock(lockPx = AXIS_LOCK_PX) {
|
|
664
|
+
let start = null;
|
|
665
|
+
let axis = null;
|
|
666
|
+
return {
|
|
667
|
+
down(x, y) {
|
|
668
|
+
start = {
|
|
669
|
+
x,
|
|
670
|
+
y
|
|
671
|
+
};
|
|
672
|
+
axis = null;
|
|
673
|
+
},
|
|
674
|
+
move(x, y) {
|
|
675
|
+
if (!start) return null;
|
|
676
|
+
const dx = x - start.x;
|
|
677
|
+
const dy = y - start.y;
|
|
678
|
+
if (!axis) {
|
|
679
|
+
if (Math.hypot(dx, dy) < lockPx) return null;
|
|
680
|
+
axis = Math.abs(dy) > Math.abs(dx) ? "y" : "x";
|
|
681
|
+
}
|
|
682
|
+
return {
|
|
683
|
+
axis,
|
|
684
|
+
dx,
|
|
685
|
+
dy
|
|
686
|
+
};
|
|
687
|
+
},
|
|
688
|
+
up() {
|
|
689
|
+
const a = axis;
|
|
690
|
+
start = null;
|
|
691
|
+
axis = null;
|
|
692
|
+
return a;
|
|
693
|
+
},
|
|
694
|
+
axis: () => axis
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
/** Pixels of vertical drag per message line scrubbed. */
|
|
698
|
+
const SCRUB_STEP_PX = 28;
|
|
699
|
+
/**
|
|
700
|
+
* Where a scrub lands: `back` lines from the newest, from where it started and
|
|
701
|
+
* the finger's vertical travel. Finger down = older (as the expanded log's
|
|
702
|
+
* swipe: the content follows the finger), clamped to [0, max].
|
|
703
|
+
*/
|
|
704
|
+
function scrubBack(startBack, dy, max, step = SCRUB_STEP_PX) {
|
|
705
|
+
return Math.max(0, Math.min(max, startBack + Math.trunc(dy / step)));
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* A press held for `ms` (500 by default) without moving off: `onLong` fires
|
|
709
|
+
* once. `down` starts it; `up` or `cancel` (the press ended or moved away)
|
|
710
|
+
* stops it. Timers are injected for tests.
|
|
711
|
+
*/
|
|
712
|
+
function createLongPress(d) {
|
|
713
|
+
const setTimer = d.setTimer ?? ((f, ms) => setTimeout(f, ms));
|
|
714
|
+
const clearTimer = d.clearTimer ?? ((t) => clearTimeout(t));
|
|
715
|
+
let t = null;
|
|
716
|
+
let fired = false;
|
|
717
|
+
const stop = () => {
|
|
718
|
+
if (t !== null) clearTimer(t);
|
|
719
|
+
t = null;
|
|
720
|
+
};
|
|
721
|
+
return {
|
|
722
|
+
down() {
|
|
723
|
+
stop();
|
|
724
|
+
fired = false;
|
|
725
|
+
t = setTimer(() => {
|
|
726
|
+
t = null;
|
|
727
|
+
fired = true;
|
|
728
|
+
d.onLong();
|
|
729
|
+
}, d.ms ?? 500);
|
|
730
|
+
},
|
|
731
|
+
up() {
|
|
732
|
+
stop();
|
|
733
|
+
return fired;
|
|
734
|
+
},
|
|
735
|
+
cancel: stop
|
|
736
|
+
};
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
//#endregion
|
|
740
|
+
//#region src/ui-strings.ts
|
|
741
|
+
const UI_EN = {
|
|
742
|
+
stateTree: "State tree",
|
|
743
|
+
closeTree: "Close the state tree",
|
|
744
|
+
noTreeSource: "No tree source",
|
|
745
|
+
lastDone: "Last done",
|
|
746
|
+
nowDoing: "In progress",
|
|
747
|
+
upNext: "Next",
|
|
748
|
+
needsYou: "needs you",
|
|
749
|
+
items: "items",
|
|
750
|
+
polished: "Polished"
|
|
751
|
+
};
|
|
752
|
+
const UI_ZH = {
|
|
753
|
+
stateTree: "状态树",
|
|
754
|
+
closeTree: "关闭状态树",
|
|
755
|
+
noTreeSource: "没有状态树来源",
|
|
756
|
+
lastDone: "最近完成",
|
|
757
|
+
nowDoing: "进行中",
|
|
758
|
+
upNext: "下一步",
|
|
759
|
+
needsYou: "等你处理",
|
|
760
|
+
items: "项",
|
|
761
|
+
polished: "已润色"
|
|
762
|
+
};
|
|
763
|
+
/** The tree's strings in Chinese (tree.ts TreeStrings). */
|
|
764
|
+
const TREE_ZH = {
|
|
765
|
+
tree: "状态树",
|
|
766
|
+
back: "返回聊天",
|
|
767
|
+
needsMe: "待我处理",
|
|
768
|
+
needsYou: "等你处理",
|
|
769
|
+
openCount: "{n} 项未完成",
|
|
770
|
+
needsYouCount: "{n} 项等你",
|
|
771
|
+
copy: "复制",
|
|
772
|
+
copied: "已复制",
|
|
773
|
+
loading: "加载中…",
|
|
774
|
+
failed: "无法加载状态树",
|
|
775
|
+
empty: "状态树是空的。",
|
|
776
|
+
nothingNeedsYou: "没有等你处理的事。",
|
|
777
|
+
you: "你",
|
|
778
|
+
lastDone: "最近完成",
|
|
779
|
+
nowDoing: "进行中",
|
|
780
|
+
upNext: "下一步",
|
|
781
|
+
live: "实时数据"
|
|
782
|
+
};
|
|
783
|
+
/** The page's language is Chinese. */
|
|
784
|
+
function isZh(lang = globalThis.document?.documentElement.lang) {
|
|
785
|
+
return /^zh\b/i.test(lang ?? "");
|
|
786
|
+
}
|
|
787
|
+
/** The box's strings for the page's language. */
|
|
788
|
+
const uiStrings = (lang) => isZh(lang) ? UI_ZH : UI_EN;
|
|
789
|
+
/** The tree's defaults for the page's language, under the host's own. */
|
|
790
|
+
const treeDefaults = (lang) => isZh(lang) ? TREE_ZH : {};
|
|
791
|
+
|
|
792
|
+
//#endregion
|
|
793
|
+
export { maxDetent as $, FLOAT_MAX as A, readTime as B, shownAgentId as C, DWELL_FACTOR as D, placeBox as E, createArrivals as F, TREE_SNAP as G, TREE_DETENT_PX as H, createDwellTimer as I, dragOffset as J, TREE_STRETCH as K, createFloatLife as L, READ_RATE_CJK as M, READ_RATE_LATIN as N, DWELL_MIN_MS as O, countUnread as P, isVisible as Q, dwellMs as R, shortId as S, anchorSide as T, TREE_DRAG_CELLS as U, MAX_DETENT as V, TREE_HYSTERESIS as W, indexTree as X, height as Y, initialNav as Z, LONG_PRESS_MS as _, treeDefaults as a, countBadge as b, DOUBLE_TAP_MS as c, createAxisLock as d, treeNav as et, createDragFlag as f, FRONTIER_ROWS as g, scrubBack as h, isZh as i, MINIMIZE_FLOAT_MAX_AGE_MS as j, FADE_MS as k, DRAG_CLICK_MS as l, createTapper as m, UI_EN as n, snapDetent as nt, uiStrings as o, createLongPress as p, dragCells as q, UI_ZH as r, AXIS_LOCK_PX as s, TREE_ZH as t, detentLevel as tt, SCRUB_STEP_PX as u, MAX_ID_LEN as v, ANCHOR_GUTTER_PX as w, frontierView as x, SHORT_ID_LEN as y, minimizeFloat as z };
|
|
794
|
+
//# sourceMappingURL=ui-strings-CJIwW5Gf.js.map
|