dsh-ws-recency 0.30.1 → 0.30.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/client.js +944 -51
- package/index.js +133 -10
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -49,6 +49,12 @@
|
|
|
49
49
|
var NS = "ws-recency";
|
|
50
50
|
var h = react.createElement;
|
|
51
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Master switch for the search feature: its panel icon and the page behind
|
|
54
|
+
* it. Off leaves the plugin present but registers no search side at all.
|
|
55
|
+
*/
|
|
56
|
+
var SEARCH_ENABLED = true;
|
|
57
|
+
|
|
52
58
|
var HEADER_PREFIX = "workspace:";
|
|
53
59
|
var SESSION_PREFIX = "session:";
|
|
54
60
|
var SECTION_TOKEN = "_groupSection";
|
|
@@ -352,6 +358,19 @@
|
|
|
352
358
|
'[' + STATE_ATTR + '="followup"] [class*="_title"]{color:#d99a2b}',
|
|
353
359
|
'[' + STATE_ATTR + '="waiting"] [class*="_title"]{color:#d99a2b}',
|
|
354
360
|
".wsr-search-bar{display:flex;gap:8px;align-items:center}",
|
|
361
|
+
".wsr-hit-actions{display:flex;gap:6px;justify-content:flex-end;margin-top:2px}",
|
|
362
|
+
".wsr-hit-context-toggle,.wsr-hit-context-jump{border:.5px solid var(--dsw-alias-border-l2,rgba(255,255,255,.14));background:0 0;color:var(--dsw-alias-label-tertiary);font:inherit;font-size:11px;line-height:18px;padding:0 8px;border-radius:9px;cursor:pointer}",
|
|
363
|
+
".wsr-hit-context-toggle:hover,.wsr-hit-context-jump:hover{color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-border-l3,rgba(255,255,255,.24))}",
|
|
364
|
+
".wsr-hit-context{max-height:38vh;overflow:auto;margin-top:4px;padding:6px 8px;border-radius:6px;background:var(--dsw-alias-bg-layer-2,rgba(255,255,255,.04));color:var(--dsw-alias-label-secondary);font-size:11px;line-height:1.65;white-space:pre-wrap;word-break:break-word}",
|
|
365
|
+
".wsr-search-history{display:flex;align-items:center;flex-wrap:wrap;gap:6px;font-size:11px;color:var(--dsw-alias-label-tertiary)}",
|
|
366
|
+
".wsr-search-history-label{flex:none}",
|
|
367
|
+
".wsr-search-chip{display:inline-flex;align-items:center;border-radius:9px;background:var(--dsw-alias-bg-layer-3,rgba(255,255,255,.07));overflow:hidden}",
|
|
368
|
+
".wsr-search-chip-run{border:none;background:0 0;color:var(--dsw-alias-label-secondary);font:inherit;font-size:11px;line-height:18px;padding:0 4px 0 8px;cursor:pointer;max-width:220px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
|
|
369
|
+
".wsr-search-chip-run:hover{color:var(--dsw-alias-label-primary)}",
|
|
370
|
+
".wsr-search-chip-drop{border:none;background:0 0;color:var(--dsw-alias-label-tertiary);font:inherit;font-size:12px;line-height:18px;padding:0 7px 0 2px;cursor:pointer}",
|
|
371
|
+
".wsr-search-chip-drop:hover{color:var(--dsw-alias-state-error-primary,#d9534f)}",
|
|
372
|
+
".wsr-search-history-clear{border:none;background:0 0;color:var(--dsw-alias-label-tertiary);font:inherit;font-size:11px;cursor:pointer;text-decoration:underline;padding:0 2px}",
|
|
373
|
+
".wsr-search-history-clear:hover{color:var(--dsw-alias-label-primary)}",
|
|
355
374
|
".wsr-search-input{flex:1;min-width:0;height:30px;padding:0 10px;border-radius:6px;border:.5px solid var(--dsw-alias-border-l2);background:transparent;color:inherit;font-size:13px}",
|
|
356
375
|
".wsr-hit{display:flex;flex-direction:column;gap:4px;padding:8px 10px;border-radius:8px;cursor:pointer}",
|
|
357
376
|
".wsr-hit:hover{background:var(--dsw-alias-bg-layer-2)}",
|
|
@@ -363,6 +382,13 @@
|
|
|
363
382
|
".wsr-hit-ws{flex:none;max-width:30%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
|
|
364
383
|
".wsr-hit-turn{flex:none}",
|
|
365
384
|
".wsr-hit-snippet{font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary);word-break:break-word}",
|
|
385
|
+
".wsr-hit-meta{display:flex;align-items:center;gap:8px;font-size:11px;color:var(--dsw-alias-label-tertiary)}",
|
|
386
|
+
".wsr-hit-time{flex:none;font-variant-numeric:tabular-nums}",
|
|
387
|
+
".wsr-hit-step{flex:none;color:var(--dsw-alias-label-secondary)}",
|
|
388
|
+
".wsr-jump-toast{position:fixed;left:50%;bottom:28px;transform:translateX(-50%);z-index:9999;padding:6px 12px;border-radius:8px;font-size:12px;background:var(--dsw-alias-bg-layer-3,rgba(32,34,38,.96));color:var(--dsw-alias-label-primary);border:.5px solid var(--dsw-alias-border-l2,rgba(255,255,255,.14));box-shadow:0 8px 24px rgba(0,0,0,.4);pointer-events:none}",
|
|
389
|
+
".wsr-diagnose-toast{max-width:min(680px,90vw);white-space:normal;line-height:1.6;text-align:left;font-variant-numeric:tabular-nums}",
|
|
390
|
+
".wsr-jump-toast-warn{border-color:color-mix(in srgb,var(--dsw-alias-state-error-primary,#d9534f) 45%,transparent);color:var(--dsw-alias-state-error-primary,#d9534f)}",
|
|
391
|
+
".wsr-hit-cwd{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;direction:rtl;text-align:left}",
|
|
366
392
|
".wsr-mark{background:rgba(79,142,247,.28);color:inherit;border-radius:2px}",
|
|
367
393
|
'[data-wsr-flash="true"]{outline:2px solid #4f8ef7;outline-offset:2px;border-radius:8px}',
|
|
368
394
|
".wsr-dot{display:block;width:7px;height:7px;border-radius:50%;margin:0 auto;background:#d99a2b;cursor:pointer}",
|
|
@@ -479,6 +505,22 @@
|
|
|
479
505
|
"search.you": "你",
|
|
480
506
|
"search.assistant": "助手",
|
|
481
507
|
"search.turn": "第 {n} 轮",
|
|
508
|
+
"search.pluginCost": "插件 {ms}ms",
|
|
509
|
+
"menu.diagnose": "插件耗时诊断",
|
|
510
|
+
"diagnose.report": "近 60 秒:扫描 {passes} 次 / 共 {total}ms / 最慢 {worst}ms · 页面节点 {nodes} · 已挂载轮次 {turns}",
|
|
511
|
+
"search.contextShow": "看上下文",
|
|
512
|
+
"search.contextHide": "收起",
|
|
513
|
+
"search.openSession": "打开会话",
|
|
514
|
+
"search.history": "最近搜索",
|
|
515
|
+
"search.historyRun": "再搜一次:{query}",
|
|
516
|
+
"search.historyDrop": "从历史里删除",
|
|
517
|
+
"search.historyClear": "清空",
|
|
518
|
+
"search.step": "第 {n} 步",
|
|
519
|
+
"search.jumpTurn": "已定位:第 {turn} 轮 · 按轮次",
|
|
520
|
+
"search.jumpText": "已定位:第 {turn} 轮 · 按文字",
|
|
521
|
+
"search.jumpNoSession": "打不开这个会话(可能已归档、或不在当前工作区)",
|
|
522
|
+
"search.jumpNoTurn": "会话已打开,但没找到第 {turn} 轮(共 {turns} 轮)",
|
|
523
|
+
"search.jumpCollapsed": "找到了第 {turn} 轮,但这一轮的历史内容没有被渲染(长会话的旧轮次是折叠的),请手动向上翻一点",
|
|
482
524
|
"ui.reload": "刷新界面",
|
|
483
525
|
"ui.refresh": "刷新列表",
|
|
484
526
|
"trash.title": "回收站",
|
|
@@ -664,6 +706,22 @@
|
|
|
664
706
|
"search.you": "You",
|
|
665
707
|
"search.assistant": "Assistant",
|
|
666
708
|
"search.turn": "turn {n}",
|
|
709
|
+
"search.pluginCost": "plugin {ms}ms",
|
|
710
|
+
"menu.diagnose": "Plugin cost",
|
|
711
|
+
"diagnose.report": "Last 60s: {passes} passes / {total}ms total / {worst}ms worst · {nodes} nodes · {turns} turns mounted",
|
|
712
|
+
"search.contextShow": "Show context",
|
|
713
|
+
"search.contextHide": "Hide",
|
|
714
|
+
"search.openSession": "Open session",
|
|
715
|
+
"search.history": "Recent",
|
|
716
|
+
"search.historyRun": "Search again: {query}",
|
|
717
|
+
"search.historyDrop": "Remove from history",
|
|
718
|
+
"search.historyClear": "Clear",
|
|
719
|
+
"search.step": "step {n}",
|
|
720
|
+
"search.jumpTurn": "Landed on turn {turn} (by turn)",
|
|
721
|
+
"search.jumpText": "Landed on turn {turn} (by text)",
|
|
722
|
+
"search.jumpNoSession": "Could not open that session (archived, or outside the current workspace)",
|
|
723
|
+
"search.jumpNoTurn": "Session opened, but turn {turn} was not found (of {turns})",
|
|
724
|
+
"search.jumpCollapsed": "Turn {turn} was found, but its history is not rendered (old turns of a long session are collapsed); scroll up a little",
|
|
667
725
|
"ui.reload": "Reload UI",
|
|
668
726
|
"ui.refresh": "Refresh",
|
|
669
727
|
"trash.title": "Trash",
|
|
@@ -779,7 +837,62 @@
|
|
|
779
837
|
return text;
|
|
780
838
|
}
|
|
781
839
|
|
|
782
|
-
|
|
840
|
+
/**
|
|
841
|
+
* Whether a mutated node belongs to the conversation, not the sidebar.
|
|
842
|
+
*
|
|
843
|
+
* The observer used to watch the whole body, so a chat that mounts a page
|
|
844
|
+
* of history - thousands of nodes - ran this plugin's sidebar pass over and
|
|
845
|
+
* over while the host was rendering, and that is what made a jump into a
|
|
846
|
+
* long session feel frozen. Nothing here decorates the chat, so its
|
|
847
|
+
* mutations are none of this observer's business.
|
|
848
|
+
*/
|
|
849
|
+
/**
|
|
850
|
+
* The sidebar's own containers, as a set of ancestors of a workspace row.
|
|
851
|
+
*
|
|
852
|
+
* Filtering by "is the chat in this node" was not enough: the turn rail and
|
|
853
|
+
* the host's hover preview are portalled onto <body>, outside the chat, so
|
|
854
|
+
* moving the pointer along the rail ran this plugin's sidebar pass on every
|
|
855
|
+
* preview repaint - which is exactly the delay felt after a long jump. The
|
|
856
|
+
* sidebar is a sibling subtree, and only its containers can hold a row.
|
|
857
|
+
*/
|
|
858
|
+
var sidebarAncestors = null;
|
|
859
|
+
|
|
860
|
+
function sidebarChain() {
|
|
861
|
+
if (sidebarAncestors !== null && sidebarAncestors.size > 0) {
|
|
862
|
+
/* Revalidate cheaply: a stale set would stop noticing real changes. */
|
|
863
|
+
var alive = 0;
|
|
864
|
+
sidebarAncestors.forEach(function (node) {
|
|
865
|
+
if (node.isConnected !== false) alive += 1;
|
|
866
|
+
});
|
|
867
|
+
if (alive > 0) return sidebarAncestors;
|
|
868
|
+
}
|
|
869
|
+
var set = new Set();
|
|
870
|
+
var header = document.querySelector('[data-row-key^="' + HEADER_PREFIX + '"]');
|
|
871
|
+
if (header === null || header === undefined) return set;
|
|
872
|
+
var node = header.parentElement;
|
|
873
|
+
while (node !== null && node !== undefined && node.parentElement !== null
|
|
874
|
+
&& node.parentElement !== undefined && node.parentElement !== document.body) {
|
|
875
|
+
set.add(node);
|
|
876
|
+
node = node.parentElement;
|
|
877
|
+
}
|
|
878
|
+
sidebarAncestors = set;
|
|
879
|
+
return set;
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
function outsideSidebar(node, chain) {
|
|
883
|
+
if (node === null || node === undefined) return false;
|
|
884
|
+
var element = node;
|
|
885
|
+
if (element.nodeType !== 1) element = element.parentElement;
|
|
886
|
+
if (element === null || element === undefined) return false;
|
|
887
|
+
var containers = chain === undefined || chain === null ? sidebarChain() : chain;
|
|
888
|
+
var current = element;
|
|
889
|
+
while (current !== null && current !== undefined) {
|
|
890
|
+
if (containers.has(current)) return false;
|
|
891
|
+
if (current === document.body) return true;
|
|
892
|
+
current = current.parentElement;
|
|
893
|
+
}
|
|
894
|
+
return true;
|
|
895
|
+
} function top() {
|
|
783
896
|
return typeof document !== "undefined" && document.body !== null ? document.body : null;
|
|
784
897
|
}
|
|
785
898
|
|
|
@@ -1719,18 +1832,66 @@
|
|
|
1719
1832
|
decorateComposerStats();
|
|
1720
1833
|
}
|
|
1721
1834
|
|
|
1835
|
+
/**
|
|
1836
|
+
* While this is in the future the sidebar pass stays off.
|
|
1837
|
+
*
|
|
1838
|
+
* Jumping to a hit in a long session makes the host mount a whole page of
|
|
1839
|
+
* history. That is thousands of DOM changes, and each one used to run this
|
|
1840
|
+
* plugin's sidebar pass on top of the host's own rendering, which is what
|
|
1841
|
+
* still froze the window even after chat mutations were filtered out.
|
|
1842
|
+
*/
|
|
1843
|
+
var suppressedUntil = 0;
|
|
1844
|
+
|
|
1845
|
+
function suspendPasses(ms) {
|
|
1846
|
+
var span = typeof ms === "number" && ms > 0 ? ms : 8000;
|
|
1847
|
+
suppressedUntil = Date.now() + span;
|
|
1848
|
+
}
|
|
1849
|
+
|
|
1850
|
+
function passesSuspended() {
|
|
1851
|
+
return suppressedUntil !== 0 && Date.now() < suppressedUntil;
|
|
1852
|
+
}
|
|
1853
|
+
/** At most this often, whatever happens: a pass writes DOM, and writing DOM
|
|
1854
|
+
* can be observed by our own observer, so the interval is the guarantee that
|
|
1855
|
+
* a feedback loop cannot turn into a busy main thread. */
|
|
1856
|
+
var PASS_MIN_GAP = 400;
|
|
1857
|
+
var lastPassAt = 0;
|
|
1858
|
+
var passCount = 0;
|
|
1859
|
+
/* Rolling record for the diagnostic row: how often the pass runs and how
|
|
1860
|
+
long it takes, so a claim about cost can be checked on screen. */
|
|
1861
|
+
var passSamples = [];
|
|
1862
|
+
|
|
1863
|
+
function recordPass(spent) {
|
|
1864
|
+
passSamples.push({ at: Date.now(), ms: spent });
|
|
1865
|
+
if (passSamples.length > 200) passSamples.shift();
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1722
1868
|
function schedule() {
|
|
1723
1869
|
if (disposed || timer !== null) return;
|
|
1870
|
+
sidebarAncestors = null;
|
|
1871
|
+
if (passesSuspended()) {
|
|
1872
|
+
/* One pass, once the host has finished mounting. */
|
|
1873
|
+
var wait = Math.max(120, suppressedUntil - Date.now() + 60);
|
|
1874
|
+
window.setTimeout(function () {
|
|
1875
|
+
if (!disposed) schedule();
|
|
1876
|
+
}, wait);
|
|
1877
|
+
return;
|
|
1878
|
+
}
|
|
1879
|
+
var since = Date.now() - lastPassAt;
|
|
1880
|
+
var delay = since >= PASS_MIN_GAP ? 60 : PASS_MIN_GAP - since + 16;
|
|
1724
1881
|
timer = window.setTimeout(function () {
|
|
1725
1882
|
timer = null;
|
|
1883
|
+
lastPassAt = Date.now();
|
|
1884
|
+
passCount += 1;
|
|
1885
|
+
var began = Date.now();
|
|
1726
1886
|
try {
|
|
1727
1887
|
apply();
|
|
1728
1888
|
} catch (error) {
|
|
1729
1889
|
console.warn("[dsh-ws-recency] pass failed:", error);
|
|
1730
1890
|
}
|
|
1731
|
-
|
|
1891
|
+
recordPass(Date.now() - began);
|
|
1892
|
+
if (typeof window !== "undefined") window.__DSH_WSR_PASSES__ = passCount;
|
|
1893
|
+
}, delay);
|
|
1732
1894
|
}
|
|
1733
|
-
|
|
1734
1895
|
/** `shell.overlay` occupant; it renders no chrome of its own. */
|
|
1735
1896
|
function Sorter(props) {
|
|
1736
1897
|
if (typeof props.useSessions === "function") {
|
|
@@ -1797,6 +1958,46 @@
|
|
|
1797
1958
|
* `<home>/.trash/ws-recency/`. The browser half only asks for confirmation
|
|
1798
1959
|
* and posts the id.
|
|
1799
1960
|
*/
|
|
1961
|
+
/**
|
|
1962
|
+
* Session menu row that reports this plugin's own cost.
|
|
1963
|
+
*
|
|
1964
|
+
* Without devtools there was no way to tell a slow plugin from a slow host,
|
|
1965
|
+
* and several rounds went into guessing. This prints the numbers where the
|
|
1966
|
+
* lag is felt. */
|
|
1967
|
+
function DiagnoseMenuItem(props) {
|
|
1968
|
+
var Item = ui.MenuItemButton;
|
|
1969
|
+
if (typeof Item !== "function") return null;
|
|
1970
|
+
return h(Item, {
|
|
1971
|
+
icon: undefined,
|
|
1972
|
+
onSelect: function () {
|
|
1973
|
+
var now = Date.now();
|
|
1974
|
+
var recent = passSamples.filter(function (sample) {
|
|
1975
|
+
return now - sample.at <= 60000;
|
|
1976
|
+
});
|
|
1977
|
+
var total = 0;
|
|
1978
|
+
var worst = 0;
|
|
1979
|
+
for (var i = 0; i < recent.length; i += 1) {
|
|
1980
|
+
total += recent[i].ms;
|
|
1981
|
+
if (recent[i].ms > worst) worst = recent[i].ms;
|
|
1982
|
+
}
|
|
1983
|
+
var nodes = typeof document !== "undefined" ? document.querySelectorAll("*").length : 0;
|
|
1984
|
+
var turns = typeof document !== "undefined" ? document.querySelectorAll("[data-chat-turn]").length : 0;
|
|
1985
|
+
var note = statsDiv("wsr-jump-toast wsr-diagnose-toast");
|
|
1986
|
+
note.textContent = t("diagnose.report", {
|
|
1987
|
+
passes: String(recent.length),
|
|
1988
|
+
total: String(total),
|
|
1989
|
+
worst: String(worst),
|
|
1990
|
+
nodes: String(nodes),
|
|
1991
|
+
turns: String(turns),
|
|
1992
|
+
});
|
|
1993
|
+
document.body.appendChild(note);
|
|
1994
|
+
window.setTimeout(function () {
|
|
1995
|
+
if (note.parentElement !== null) note.remove();
|
|
1996
|
+
}, 8000);
|
|
1997
|
+
},
|
|
1998
|
+
}, t("menu.diagnose"));
|
|
1999
|
+
}
|
|
2000
|
+
|
|
1800
2001
|
function TrashMenuItem(props) {
|
|
1801
2002
|
var Item = ui.MenuItemButton;
|
|
1802
2003
|
if (typeof Item !== "function") return null;
|
|
@@ -3775,10 +3976,21 @@
|
|
|
3775
3976
|
|
|
3776
3977
|
/* ---------- session content search -------------------------------- */
|
|
3777
3978
|
|
|
3979
|
+
/** How many recent queries the panel remembers. */
|
|
3980
|
+
var SEARCH_HISTORY_MAX = 12;
|
|
3981
|
+
|
|
3778
3982
|
/** What the uncontrolled input holds; the panel keeps only results in state. */
|
|
3779
3983
|
var searchDraft = "";
|
|
3780
3984
|
/** Bumped per search so a slow answer cannot overwrite a newer one. */
|
|
3781
3985
|
var searchGeneration = 0;
|
|
3986
|
+
/**
|
|
3987
|
+
* The last answer, kept outside the component.
|
|
3988
|
+
*
|
|
3989
|
+
* Opening a hit switches the main view to the conversation, which unmounts
|
|
3990
|
+
* this page; without this the results were gone when the user came back
|
|
3991
|
+
* and every search had to be run again.
|
|
3992
|
+
*/
|
|
3993
|
+
var searchLast = null;
|
|
3782
3994
|
|
|
3783
3995
|
function searchPost(body) {
|
|
3784
3996
|
return fetch("/ws-recency/search", {
|
|
@@ -3801,6 +4013,39 @@
|
|
|
3801
4013
|
return h(Icon, { size: size });
|
|
3802
4014
|
}
|
|
3803
4015
|
|
|
4016
|
+
/**
|
|
4017
|
+
* Move a scroller and announce it.
|
|
4018
|
+
*
|
|
4019
|
+
* The chat pages older history in when its own scroll handler sees movement.
|
|
4020
|
+
* Assigning `scrollTop` from script does not fire that handler, so a long
|
|
4021
|
+
* session stayed at the same page no matter how often the value was set;
|
|
4022
|
+
* a synthetic scroll event is what lets the next page load.
|
|
4023
|
+
*/
|
|
4024
|
+
function scrollTo(scroller, top) {
|
|
4025
|
+
if (scroller === null || scroller === undefined) return;
|
|
4026
|
+
var target = Math.max(0, Number(top) || 0);
|
|
4027
|
+
try {
|
|
4028
|
+
scroller.scrollTop = target;
|
|
4029
|
+
} catch (error) {
|
|
4030
|
+
return;
|
|
4031
|
+
}
|
|
4032
|
+
var fire = function () {
|
|
4033
|
+
try {
|
|
4034
|
+
var event = document.createEvent("Event");
|
|
4035
|
+
event.initEvent("scroll", true, false);
|
|
4036
|
+
scroller.dispatchEvent(event);
|
|
4037
|
+
} catch (error) {
|
|
4038
|
+
/* an engine without createEvent still got the assignment */
|
|
4039
|
+
}
|
|
4040
|
+
};
|
|
4041
|
+
fire();
|
|
4042
|
+
try {
|
|
4043
|
+
if (typeof requestAnimationFrame === "function") requestAnimationFrame(fire);
|
|
4044
|
+
else window.setTimeout(fire, 16);
|
|
4045
|
+
} catch (error) {
|
|
4046
|
+
/* the first dispatch is usually enough */
|
|
4047
|
+
}
|
|
4048
|
+
}
|
|
3804
4049
|
function conversationScroller() {
|
|
3805
4050
|
if (typeof document === "undefined") return null;
|
|
3806
4051
|
try {
|
|
@@ -3823,12 +4068,60 @@
|
|
|
3823
4068
|
function turnRowOf(turn) {
|
|
3824
4069
|
if (typeof document === "undefined" || !isFinite(turn)) return null;
|
|
3825
4070
|
try {
|
|
3826
|
-
|
|
4071
|
+
/* Scoped when possible: a document-wide attribute query on a long
|
|
4072
|
+
transcript is the expensive part of a jump's polling loop. The
|
|
4073
|
+
document stays as the fallback because the scroller is not always
|
|
4074
|
+
the element that holds the rows. */
|
|
4075
|
+
var selector = '[data-chat-turn="' + String(turn) + '"]';
|
|
4076
|
+
var scope = conversationScroller();
|
|
4077
|
+
if (scope !== null && typeof scope.querySelector === "function") {
|
|
4078
|
+
var scoped = scope.querySelector(selector);
|
|
4079
|
+
if (scoped !== null && scoped !== undefined) return scoped;
|
|
4080
|
+
}
|
|
4081
|
+
return document.querySelector(selector);
|
|
3827
4082
|
} catch (error) {
|
|
3828
4083
|
return null;
|
|
3829
4084
|
}
|
|
3830
4085
|
}
|
|
3831
4086
|
|
|
4087
|
+
/** A short-lived line that says where the jump landed and how it got there. */
|
|
4088
|
+
function announceJump(hit, byText, costMs) {
|
|
4089
|
+
if (typeof document === "undefined") return;
|
|
4090
|
+
try {
|
|
4091
|
+
var note = statsDiv("wsr-jump-toast");
|
|
4092
|
+
var text = t(byText === true ? "search.jumpText" : "search.jumpTurn", { turn: String(hit.turn) });
|
|
4093
|
+
if (isFinite(Number(costMs))) text += " · " + t("search.pluginCost", { ms: String(Math.round(Number(costMs))) });
|
|
4094
|
+
note.textContent = text;
|
|
4095
|
+
document.body.appendChild(note);
|
|
4096
|
+
window.setTimeout(function () {
|
|
4097
|
+
if (note.parentElement !== null) note.remove();
|
|
4098
|
+
}, 3200);
|
|
4099
|
+
} catch (error) {
|
|
4100
|
+
/* a toast is a nicety: never break the jump for it */
|
|
4101
|
+
}
|
|
4102
|
+
}
|
|
4103
|
+
/**
|
|
4104
|
+
* Say why a jump did not land.
|
|
4105
|
+
*
|
|
4106
|
+
* Without this a failed jump is indistinguishable from a jump that landed
|
|
4107
|
+
* in the wrong place: the panel just sits where it was and the user cannot
|
|
4108
|
+
* tell whether the session opened, whether the turn exists, or whether the
|
|
4109
|
+
* text was never rendered.
|
|
4110
|
+
*/
|
|
4111
|
+
function announceJumpFailure(hit, reason) {
|
|
4112
|
+
if (typeof document === "undefined") return;
|
|
4113
|
+
try {
|
|
4114
|
+
var note = statsDiv("wsr-jump-toast wsr-jump-toast-warn");
|
|
4115
|
+
note.textContent = t(reason, { turn: String(hit.turn), turns: String(hit.turns) });
|
|
4116
|
+
document.body.appendChild(note);
|
|
4117
|
+
window.setTimeout(function () {
|
|
4118
|
+
if (note.parentElement !== null) note.remove();
|
|
4119
|
+
}, 5000);
|
|
4120
|
+
} catch (error) {
|
|
4121
|
+
/* nothing to do if the toast itself fails */
|
|
4122
|
+
}
|
|
4123
|
+
}
|
|
4124
|
+
|
|
3832
4125
|
/** Ring the row the search sent the user to, without taking keyboard focus. */
|
|
3833
4126
|
function flashTurnRow(row) {
|
|
3834
4127
|
try {
|
|
@@ -3887,9 +4180,422 @@
|
|
|
3887
4180
|
window.setTimeout(tick, 120);
|
|
3888
4181
|
}
|
|
3889
4182
|
|
|
3890
|
-
|
|
4183
|
+
/** Collapsed text of an element, for matching a message fragment. */
|
|
4184
|
+
function normalizedText(node) {
|
|
4185
|
+
var text = node !== null && node !== undefined && typeof node.textContent === "string" ? node.textContent : "";
|
|
4186
|
+
return text.replace(/\s+/g, " ").trim();
|
|
4187
|
+
}
|
|
4188
|
+
|
|
4189
|
+
/**
|
|
4190
|
+
* The smallest element in the transcript that holds this fragment.
|
|
4191
|
+
*
|
|
4192
|
+
* The conversation view renders no per-turn anchor (`data-chat-turn` does
|
|
4193
|
+
* not exist in it), so text is the only handle a jump has. The needle is
|
|
4194
|
+
* retried in shorter pieces because markdown rendering can split or drop
|
|
4195
|
+
* parts of a long sentence.
|
|
4196
|
+
*/
|
|
4197
|
+
function findByText(scroller, seeks) {
|
|
4198
|
+
if (scroller === null) return null;
|
|
4199
|
+
var candidates = Array.isArray(seeks) ? seeks : (typeof seeks === "string" ? [seeks] : []);
|
|
4200
|
+
if (candidates.length === 0) return null;
|
|
4201
|
+
var probes = [];
|
|
4202
|
+
for (var c = 0; c < candidates.length; c += 1) {
|
|
4203
|
+
var needle = String(candidates[c] || "").replace(/\s+/g, " ").trim();
|
|
4204
|
+
if (needle === "") continue;
|
|
4205
|
+
probes.push(needle);
|
|
4206
|
+
if (needle.length > 34) probes.push(needle.slice(0, 34));
|
|
4207
|
+
if (needle.length > 16) probes.push(needle.slice(0, 16));
|
|
4208
|
+
}
|
|
4209
|
+
/* Walk the turn rows, not every element: one `textContent` read per row
|
|
4210
|
+
is a few dozen reads, where sweeping `querySelectorAll("*")` over a
|
|
4211
|
+
126-turn transcript is tens of thousands and freezes the panel. */
|
|
4212
|
+
var rows = [];
|
|
4213
|
+
try {
|
|
4214
|
+
var found = scroller.querySelectorAll("[data-chat-turn]");
|
|
4215
|
+
for (var r = 0; r < found.length && r < 400; r += 1) rows.push(found[r]);
|
|
4216
|
+
} catch (error) {
|
|
4217
|
+
rows = [];
|
|
4218
|
+
}
|
|
4219
|
+
for (var p = 0; p < probes.length; p += 1) {
|
|
4220
|
+
var probe = probes[p].trim();
|
|
4221
|
+
if (probe === "") continue;
|
|
4222
|
+
for (var q = 0; q < rows.length; q += 1) {
|
|
4223
|
+
if (normalizedText(rows[q]).indexOf(probe) !== -1) return rows[q];
|
|
4224
|
+
}
|
|
4225
|
+
}
|
|
4226
|
+
return null;
|
|
4227
|
+
}
|
|
4228
|
+
/**
|
|
4229
|
+
* Whether a turn row actually carries the matched text.
|
|
4230
|
+
*
|
|
4231
|
+
* A very long session renders its old turns through a lighter path than
|
|
4232
|
+
* the recent ones - the per-message action bar is absent - and that path
|
|
4233
|
+
* may hold a collapsed placeholder instead of the message body. Landing on
|
|
4234
|
+
* one of those scrolls somewhere useless, so a row is only trusted when
|
|
4235
|
+
* the matched text (or at least a real block of text) is inside it.
|
|
4236
|
+
*/
|
|
4237
|
+
function rowCarriesSeek(row, seeks) {
|
|
4238
|
+
if (row === null || row === undefined) return false;
|
|
4239
|
+
var text = normalizedText(row);
|
|
4240
|
+
var candidates = Array.isArray(seeks) ? seeks : (typeof seeks === "string" ? [seeks] : []);
|
|
4241
|
+
for (var i = 0; i < candidates.length; i += 1) {
|
|
4242
|
+
var needle = String(candidates[i] || "").replace(/\s+/g, " ").trim();
|
|
4243
|
+
if (needle === "") continue;
|
|
4244
|
+
if (text.indexOf(needle) !== -1) return true;
|
|
4245
|
+
if (needle.length > 20 && text.indexOf(needle.slice(0, 20)) !== -1) return true;
|
|
4246
|
+
}
|
|
4247
|
+
/* No needle matched: a body of text still proves the row is rendered. */
|
|
4248
|
+
return text.length > 200;
|
|
4249
|
+
}
|
|
4250
|
+
|
|
4251
|
+
|
|
4252
|
+
/** The rail mark for one turn, if the rail currently renders it. */
|
|
4253
|
+
function railMarkFor(turn) {
|
|
4254
|
+
var wanted = Number(turn);
|
|
4255
|
+
if (!isFinite(wanted)) return null;
|
|
4256
|
+
var marks = railMarks();
|
|
4257
|
+
for (var i = 0; i < marks.length; i += 1) {
|
|
4258
|
+
if (turnOfRailMark(marks[i]) === wanted) return marks[i];
|
|
4259
|
+
}
|
|
4260
|
+
return null;
|
|
4261
|
+
}
|
|
4262
|
+
/**
|
|
4263
|
+
* The rail's own scroll container.
|
|
4264
|
+
*
|
|
4265
|
+
* A mark's parent is the marks list, not the scroller: scrolling the list
|
|
4266
|
+
* does nothing, so the ancestor that actually scrolls is what has to move.
|
|
4267
|
+
*/
|
|
4268
|
+
function railList() {
|
|
4269
|
+
var marks = railMarks();
|
|
4270
|
+
if (marks.length === 0) return null;
|
|
4271
|
+
var node = marks[0].parentElement;
|
|
4272
|
+
while (node !== null && node !== undefined) {
|
|
4273
|
+
var scrolls = typeof node.scrollHeight === "number" && typeof node.clientHeight === "number"
|
|
4274
|
+
&& node.scrollHeight > node.clientHeight && node.clientHeight > 0;
|
|
4275
|
+
if (scrolls) return node;
|
|
4276
|
+
node = node.parentElement;
|
|
4277
|
+
}
|
|
4278
|
+
return null;
|
|
4279
|
+
}
|
|
4280
|
+
|
|
4281
|
+
/** The style rule the Custom Highlight API paints matches with. */
|
|
4282
|
+
var searchHighlightReady = false;
|
|
4283
|
+
|
|
4284
|
+
function ensureSearchHighlight() {
|
|
4285
|
+
if (searchHighlightReady || typeof document === "undefined") return;
|
|
4286
|
+
searchHighlightReady = true;
|
|
4287
|
+
try {
|
|
4288
|
+
var style = document.createElement("style");
|
|
4289
|
+
style.setAttribute("data-wsr-search-highlight", "true");
|
|
4290
|
+
style.textContent = "::highlight(wsr-search-hit){background:rgba(245,197,66,.45);color:inherit}";
|
|
4291
|
+
if (document.head !== null && document.head !== undefined) document.head.appendChild(style);
|
|
4292
|
+
} catch (error) {
|
|
4293
|
+
/* without the rule the jump still scrolls; only the paint is lost */
|
|
4294
|
+
}
|
|
4295
|
+
}
|
|
4296
|
+
|
|
4297
|
+
/** Text nodes under a root, for finding the query terms inside a message. */
|
|
4298
|
+
function textNodesIn(root, limit) {
|
|
4299
|
+
var out = [];
|
|
4300
|
+
var cap = typeof limit === "number" && limit > 0 ? limit : 3000;
|
|
4301
|
+
if (root === null || root === undefined) return out;
|
|
4302
|
+
if (typeof NodeFilter === "undefined" || typeof document.createTreeWalker !== "function") return out;
|
|
4303
|
+
try {
|
|
4304
|
+
var walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, null);
|
|
4305
|
+
while (out.length < cap && walker.nextNode() !== null) out.push(walker.currentNode);
|
|
4306
|
+
} catch (error) {
|
|
4307
|
+
return out;
|
|
4308
|
+
}
|
|
4309
|
+
return out;
|
|
4310
|
+
}
|
|
4311
|
+
/**
|
|
4312
|
+
* Paints the query's terms where they appear and centres the first one.
|
|
4313
|
+
*
|
|
4314
|
+
* Landing on the right turn is not enough: a long turn buries the match,
|
|
4315
|
+
* and reading it out of the chat by hand is what this panel exists to
|
|
4316
|
+
* avoid. The Custom Highlight API paints the ranges without touching the
|
|
4317
|
+
* React-managed DOM, so nothing is re-rendered or fought over.
|
|
4318
|
+
*/
|
|
4319
|
+
function markHitTerms(terms) {
|
|
4320
|
+
if (typeof document === "undefined") return;
|
|
4321
|
+
var needles = [];
|
|
4322
|
+
for (var i = 0; i < (Array.isArray(terms) ? terms.length : 0); i += 1) {
|
|
4323
|
+
var term = String(terms[i] || "").toLowerCase();
|
|
4324
|
+
if (term !== "" && needles.indexOf(term) === -1) needles.push(term);
|
|
4325
|
+
}
|
|
4326
|
+
if (needles.length === 0) return;
|
|
4327
|
+
/* Four short attempts at most: every attempt walks text nodes, and a
|
|
4328
|
+
long transcript has enough of them that polling was felt as lag. */
|
|
4329
|
+
var attempts = 0;
|
|
4330
|
+
var tick = function () {
|
|
4331
|
+
attempts += 1;
|
|
4332
|
+
if (attempts > 2) return;
|
|
4333
|
+
var scroller = conversationScroller();
|
|
4334
|
+
if (scroller === null) {
|
|
4335
|
+
window.setTimeout(tick, 300);
|
|
4336
|
+
return;
|
|
4337
|
+
}
|
|
4338
|
+
var beganScan = Date.now();
|
|
4339
|
+
var nodes = textNodesIn(scroller, 1200);
|
|
4340
|
+
var ranges = [];
|
|
4341
|
+
for (var n = 0; n < nodes.length && ranges.length < 40; n += 1) {
|
|
4342
|
+
var node = nodes[n];
|
|
4343
|
+
var text = String(node.nodeValue || "");
|
|
4344
|
+
if (text === "") continue;
|
|
4345
|
+
var lower = text.toLowerCase();
|
|
4346
|
+
for (var k = 0; k < needles.length && ranges.length < 40; k += 1) {
|
|
4347
|
+
var from = 0;
|
|
4348
|
+
while (from < lower.length && ranges.length < 40) {
|
|
4349
|
+
var at = lower.indexOf(needles[k], from);
|
|
4350
|
+
if (at < 0) break;
|
|
4351
|
+
try {
|
|
4352
|
+
var range = document.createRange();
|
|
4353
|
+
range.setStart(node, at);
|
|
4354
|
+
range.setEnd(node, at + needles[k].length);
|
|
4355
|
+
ranges.push(range);
|
|
4356
|
+
} catch (error) {
|
|
4357
|
+
/* a node the range API refuses is simply skipped */
|
|
4358
|
+
}
|
|
4359
|
+
from = at + needles[k].length;
|
|
4360
|
+
}
|
|
4361
|
+
}
|
|
4362
|
+
}
|
|
4363
|
+
if (ranges.length === 0) {
|
|
4364
|
+
if (attempts < 2) window.setTimeout(tick, 600);
|
|
4365
|
+
return;
|
|
4366
|
+
}
|
|
4367
|
+
var painted = false;
|
|
4368
|
+
try {
|
|
4369
|
+
/* `CSS` in this module is the plugin's stylesheet array, so the
|
|
4370
|
+
DOM API has to be reached through `window`. */
|
|
4371
|
+
var cssApi = typeof window !== "undefined" && window !== null ? window.CSS : undefined;
|
|
4372
|
+
var HighlightCtor = typeof window !== "undefined" && window !== null ? window.Highlight : undefined;
|
|
4373
|
+
if (cssApi !== undefined && cssApi !== null && cssApi.highlights !== undefined && typeof HighlightCtor === "function") {
|
|
4374
|
+
ensureSearchHighlight();
|
|
4375
|
+
cssApi.highlights.set("wsr-search-hit", new HighlightCtor(ranges));
|
|
4376
|
+
painted = true;
|
|
4377
|
+
window.setTimeout(function () {
|
|
4378
|
+
try {
|
|
4379
|
+
cssApi.highlights.delete("wsr-search-hit");
|
|
4380
|
+
} catch (error) {
|
|
4381
|
+
/* the panel may have closed already */
|
|
4382
|
+
}
|
|
4383
|
+
}, 12000);
|
|
4384
|
+
}
|
|
4385
|
+
} catch (error) {
|
|
4386
|
+
painted = false;
|
|
4387
|
+
}
|
|
4388
|
+
var spentScan = Date.now() - beganScan;
|
|
4389
|
+
if (spentScan > 120 && typeof window !== "undefined") window.__DSH_WSR_LAST_TAIL_MS__ = spentScan;
|
|
4390
|
+
var first = ranges[0];
|
|
4391
|
+
var holder = first !== undefined && first !== null
|
|
4392
|
+
&& first.startContainer !== undefined && first.startContainer !== null
|
|
4393
|
+
? first.startContainer.parentElement
|
|
4394
|
+
: null;
|
|
4395
|
+
if (holder !== null && holder !== undefined) flashTurnRow(holder);
|
|
4396
|
+
else if (!painted) window.setTimeout(tick, 300);
|
|
4397
|
+
};
|
|
4398
|
+
window.setTimeout(tick, 120);
|
|
4399
|
+
} /**
|
|
4400
|
+
* Bring one search hit into view.
|
|
4401
|
+
*
|
|
4402
|
+
* Three routes, best first: a mounted `data-chat-turn` row (the chat keeps
|
|
4403
|
+
* one per flow item), the turn rail's own mark for that turn (it loads a
|
|
4404
|
+
* turn that is outside the window), and finally a proportional scroll plus
|
|
4405
|
+
* a text search, with the upward walk while older history loads.
|
|
4406
|
+
*/
|
|
4407
|
+
/** The badge currently pinned to a rail cell, if any. */
|
|
4408
|
+
|
|
4409
|
+
|
|
4410
|
+
/**
|
|
4411
|
+
* Bring one search hit into view.
|
|
4412
|
+
*
|
|
4413
|
+
* Scrolling the transcript does not page older history in: the chat asks the
|
|
4414
|
+
* user to load it. Clicking the turn rail's mark for that turn does load it,
|
|
4415
|
+
* which is the route the host itself uses, so the rail is the primary path
|
|
4416
|
+
* here. Mounted rows and a text search remain as fallbacks.
|
|
4417
|
+
*/
|
|
4418
|
+
/**
|
|
4419
|
+
* One last look after a rail click: the host is loading a whole page of
|
|
4420
|
+
* history, so nothing here may poll while that runs.
|
|
4421
|
+
*/
|
|
4422
|
+
function finaliseJump(hit, terms) {
|
|
4423
|
+
if (typeof document === "undefined") return;
|
|
4424
|
+
var began = Date.now();
|
|
4425
|
+
var seeks = Array.isArray(hit.seeks) ? hit.seeks : hit.seek;
|
|
4426
|
+
var scroller = conversationScroller();
|
|
4427
|
+
if (scroller !== null) {
|
|
4428
|
+
var row = findByText(scroller, seeks);
|
|
4429
|
+
if (row !== null) flashTurnRow(row);
|
|
4430
|
+
}
|
|
4431
|
+
markHitTerms(terms);
|
|
4432
|
+
/* Anything past a frame is ours to answer for, so say so rather than
|
|
4433
|
+
letting it pass as the host being slow. */
|
|
4434
|
+
var spent = Date.now() - began;
|
|
4435
|
+
if (spent > 120 && typeof window !== "undefined") {
|
|
4436
|
+
window.__DSH_WSR_LAST_TAIL_MS__ = spent;
|
|
4437
|
+
}
|
|
4438
|
+
}
|
|
4439
|
+
/**
|
|
4440
|
+
* Bring one search hit into view.
|
|
4441
|
+
*
|
|
4442
|
+
* Scrolling the transcript does not page older history in: the chat asks the
|
|
4443
|
+
* user to load it, while clicking the turn rail's mark loads and aligns that
|
|
4444
|
+
* turn. The rail is therefore the primary route. Everything here is kept
|
|
4445
|
+
* to a few cheap lookups: the host is rendering history at the same time,
|
|
4446
|
+
* and a polling loop on top of that is what made the jump feel frozen.
|
|
4447
|
+
*/
|
|
4448
|
+
function revealHit(hit, terms) {
|
|
4449
|
+
if (typeof document === "undefined" || hit === null || hit === undefined) return;
|
|
4450
|
+
var sessionId = hit.sessionId;
|
|
4451
|
+
var turn = Number(hit.turn);
|
|
4452
|
+
var seeksNow = Array.isArray(hit.seeks) ? hit.seeks : hit.seek;
|
|
4453
|
+
var deadline = Date.now() + (Number(hit.turns) > 40 ? 15000 : 9000);
|
|
4454
|
+
var opened = false;
|
|
4455
|
+
var reportedStub = false;
|
|
4456
|
+
var pokes = 0;
|
|
4457
|
+
var ticks = 0;
|
|
4458
|
+
/* Wall time includes the host opening the session and loading its
|
|
4459
|
+
history; only the synchronous work in here belongs to this plugin. */
|
|
4460
|
+
var spentMs = 0;
|
|
4461
|
+
var started = Date.now();
|
|
4462
|
+
var tick = function () {
|
|
4463
|
+
var beganTick = Date.now();
|
|
4464
|
+
var done = function () {
|
|
4465
|
+
spentMs += Date.now() - beganTick;
|
|
4466
|
+
};
|
|
4467
|
+
var result = tickOnce();
|
|
4468
|
+
done();
|
|
4469
|
+
return result;
|
|
4470
|
+
};
|
|
4471
|
+
var tickOnce = function () {
|
|
4472
|
+
if (Date.now() > deadline) {
|
|
4473
|
+
announceJumpFailure(hit, opened ? "search.jumpNoTurn" : "search.jumpNoSession");
|
|
4474
|
+
return;
|
|
4475
|
+
}
|
|
4476
|
+
if (currentConversationId() !== sessionId) {
|
|
4477
|
+
window.setTimeout(tick, 250);
|
|
4478
|
+
return;
|
|
4479
|
+
}
|
|
4480
|
+
opened = true;
|
|
4481
|
+
ticks += 1;
|
|
4482
|
+
var row = turnRowOf(turn);
|
|
4483
|
+
if (row !== null) {
|
|
4484
|
+
flashTurnRow(row);
|
|
4485
|
+
if (rowCarriesSeek(row, seeksNow)) {
|
|
4486
|
+
announceJump(hit, false, spentMs);
|
|
4487
|
+
markHitTerms(terms);
|
|
4488
|
+
return;
|
|
4489
|
+
}
|
|
4490
|
+
if (!reportedStub) {
|
|
4491
|
+
reportedStub = true;
|
|
4492
|
+
announceJumpFailure(hit, "search.jumpCollapsed");
|
|
4493
|
+
}
|
|
4494
|
+
window.setTimeout(tick, 500);
|
|
4495
|
+
return;
|
|
4496
|
+
}
|
|
4497
|
+
/* Query the rail every other tick: it is a document-wide lookup. */
|
|
4498
|
+
if (ticks % 2 === 1) {
|
|
4499
|
+
var mark = railMarkFor(turn);
|
|
4500
|
+
if (mark !== null) {
|
|
4501
|
+
try {
|
|
4502
|
+
mark.click();
|
|
4503
|
+
announceJump(hit, false, spentMs);
|
|
4504
|
+
/* The click starts a real history load: hand the thread back to
|
|
4505
|
+
the host and look once when it has had time to render. */
|
|
4506
|
+
window.setTimeout(function () {
|
|
4507
|
+
finaliseJump(hit, terms);
|
|
4508
|
+
suppressedUntil = 0;
|
|
4509
|
+
schedule();
|
|
4510
|
+
}, 1200);
|
|
4511
|
+
return;
|
|
4512
|
+
} catch (error) {
|
|
4513
|
+
/* fall through */
|
|
4514
|
+
}
|
|
4515
|
+
}
|
|
4516
|
+
}
|
|
4517
|
+
/* The rail is virtualised too: nudge it so the wanted mark renders. */
|
|
4518
|
+
if (pokes < 4) {
|
|
4519
|
+
var list = railList();
|
|
4520
|
+
var turns = Number(hit.turns);
|
|
4521
|
+
if (list !== null && turn > 0 && turns > 0) {
|
|
4522
|
+
var span = Math.max(0, (Number(list.scrollHeight) || 0) - (Number(list.clientHeight) || 0));
|
|
4523
|
+
var ratio = Math.min(1, Math.max(0, (turn - 1) / Math.max(1, turns - 1)));
|
|
4524
|
+
scrollTo(list, span * ratio);
|
|
4525
|
+
pokes += 1;
|
|
4526
|
+
window.setTimeout(tick, 350);
|
|
4527
|
+
return;
|
|
4528
|
+
}
|
|
4529
|
+
}
|
|
4530
|
+
window.setTimeout(tick, 350);
|
|
4531
|
+
};
|
|
4532
|
+
window.setTimeout(tick, 200);
|
|
4533
|
+
}
|
|
4534
|
+
function jumpToSearchHit(hit, terms) {
|
|
4535
|
+
suspendPasses(12000);
|
|
3891
4536
|
openSessionRow(hit.sessionId);
|
|
3892
|
-
|
|
4537
|
+
revealHit(hit, terms);
|
|
4538
|
+
}
|
|
4539
|
+
|
|
4540
|
+
/**
|
|
4541
|
+
* The chat's own turn rail: one button per turn, `data-index` + an
|
|
4542
|
+
* aria-label that names the turn. Clicking a mark is the official
|
|
4543
|
+
* navigation, and it also loads a turn that is not in the window yet.
|
|
4544
|
+
*/
|
|
4545
|
+
function railMarks() {
|
|
4546
|
+
if (typeof document === "undefined") return [];
|
|
4547
|
+
var all = null;
|
|
4548
|
+
try {
|
|
4549
|
+
/* The rail's own frame first: the same collection, found without
|
|
4550
|
+
walking the whole document. */
|
|
4551
|
+
var frame = document.querySelector('[class*="_frame"]');
|
|
4552
|
+
var scopedAll = frame === null ? null : frame.querySelectorAll("button[data-index]");
|
|
4553
|
+
all = scopedAll !== null && scopedAll.length > 0 ? scopedAll : document.querySelectorAll("button[data-index]");
|
|
4554
|
+
} catch (error) {
|
|
4555
|
+
return [];
|
|
4556
|
+
}
|
|
4557
|
+
var marks = [];
|
|
4558
|
+
for (var i = 0; i < (all === null ? 0 : all.length); i += 1) {
|
|
4559
|
+
var button = all[i];
|
|
4560
|
+
var className = typeof button.className === "string" ? button.className : "";
|
|
4561
|
+
if (className.indexOf("_mark") === -1) continue;
|
|
4562
|
+
marks.push(button);
|
|
4563
|
+
}
|
|
4564
|
+
return marks;
|
|
4565
|
+
}
|
|
4566
|
+
|
|
4567
|
+
/** The turn a rail mark points at: the last integer in its label. */
|
|
4568
|
+
/**
|
|
4569
|
+
* The turn a rail mark points at.
|
|
4570
|
+
*
|
|
4571
|
+
* The label starts with the turn number ("Jump to turn 3", "跳转到第 3 轮");
|
|
4572
|
+
* any count a wording appends comes later, so the first integer is the turn.
|
|
4573
|
+
* A label that carries a count instead of a turn would make the FIRST match
|
|
4574
|
+
* wrong in exactly the same way the LAST one was, so both are tried and the
|
|
4575
|
+
* mark's own order breaks the tie.
|
|
4576
|
+
*/
|
|
4577
|
+
function turnOfRailMark(button) {
|
|
4578
|
+
if (button === null || button === undefined || typeof button.getAttribute !== "function") return NaN;
|
|
4579
|
+
var label = String(button.getAttribute("aria-label") || "");
|
|
4580
|
+
var found = label.match(/\d+/);
|
|
4581
|
+
return found === null ? NaN : Number(found[0]);
|
|
4582
|
+
}
|
|
4583
|
+
|
|
4584
|
+
/** Click the rail mark for one turn, if it is currently rendered. */
|
|
4585
|
+
function jumpViaRail(turn) {
|
|
4586
|
+
var wanted = Number(turn);
|
|
4587
|
+
if (!isFinite(wanted)) return false;
|
|
4588
|
+
var marks = railMarks();
|
|
4589
|
+
for (var i = 0; i < marks.length; i += 1) {
|
|
4590
|
+
if (turnOfRailMark(marks[i]) !== wanted) continue;
|
|
4591
|
+
try {
|
|
4592
|
+
marks[i].click();
|
|
4593
|
+
return true;
|
|
4594
|
+
} catch (error) {
|
|
4595
|
+
return false;
|
|
4596
|
+
}
|
|
4597
|
+
}
|
|
4598
|
+
return false;
|
|
3893
4599
|
}
|
|
3894
4600
|
|
|
3895
4601
|
/** Snippet text with every query term wrapped in a mark. */
|
|
@@ -3929,29 +4635,129 @@
|
|
|
3929
4635
|
* budget plus how many are still pending, so this asks again until the
|
|
3930
4636
|
* index has caught up instead of making the user press search twice.
|
|
3931
4637
|
*/
|
|
3932
|
-
|
|
3933
|
-
|
|
4638
|
+
/** A session id is a UUID; the head and tail are what tells two apart. */
|
|
4639
|
+
function shortSessionId(sessionId) {
|
|
4640
|
+
if (typeof sessionId !== "string" || sessionId === "") return "";
|
|
4641
|
+
return sessionId.length > 12 ? sessionId.slice(0, 8) + "\u2026" + sessionId.slice(-4) : sessionId;
|
|
4642
|
+
}
|
|
4643
|
+
|
|
4644
|
+
/**
|
|
4645
|
+
* One search hit.
|
|
4646
|
+
*
|
|
4647
|
+
* A hit is only useful if it says which conversation and when: the
|
|
4648
|
+
* workspace narrows it down, but two sessions in one workspace read the
|
|
4649
|
+
* same without a title and a timestamp.
|
|
4650
|
+
*/
|
|
4651
|
+
function searchHitRow(hit, terms, onClick, extra) {
|
|
4652
|
+
var title = typeof hit.title === "string" && hit.title.trim() !== ""
|
|
4653
|
+
? hit.title.trim()
|
|
4654
|
+
: (typeof hit.sessionId === "string" ? shortSessionId(hit.sessionId) : "");
|
|
4655
|
+
var when = formatWhen(Number(hit.at) || 0);
|
|
4656
|
+
return h("div", {
|
|
4657
|
+
className: "wsr-hit",
|
|
4658
|
+
title: hit.cwd || "",
|
|
4659
|
+
onClick: onClick,
|
|
4660
|
+
},
|
|
4661
|
+
h("div", { className: "wsr-hit-head" },
|
|
4662
|
+
h("span", { className: "wsr-hit-role " + (hit.role === "user" ? "wsr-hit-user" : "wsr-hit-agent") }, hit.role === "user" ? t("search.you") : t("search.assistant")),
|
|
4663
|
+
h("span", { className: "wsr-hit-title", title: title }, title),
|
|
4664
|
+
typeof hit.workspace === "string" && hit.workspace !== "" ? h("span", { className: "wsr-hit-ws" }, hit.workspace) : null,
|
|
4665
|
+
h("span", { className: "wsr-hit-turn" }, t("search.turn", { n: String(hit.turn) })),
|
|
4666
|
+
/* The step inside the turn: it is what the reader checks against the
|
|
4667
|
+
chat after jumping, so a hit that looks wrong can be told apart
|
|
4668
|
+
from a jump that landed wrong. */
|
|
4669
|
+
typeof hit.step === "number" && isFinite(hit.step)
|
|
4670
|
+
? h("span", { className: "wsr-hit-step" }, t("search.step", { n: String(hit.step) }))
|
|
4671
|
+
: null,
|
|
4672
|
+
),
|
|
4673
|
+
h("div", { className: "wsr-hit-meta" },
|
|
4674
|
+
when !== "" ? h("span", { className: "wsr-hit-time" }, when) : null,
|
|
4675
|
+
typeof hit.cwd === "string" && hit.cwd !== "" ? h("span", { className: "wsr-hit-cwd" }, hit.cwd) : null,
|
|
4676
|
+
),
|
|
4677
|
+
h("div", { className: "wsr-hit-snippet" },
|
|
4678
|
+
hit.lead === true ? "\u2026" : null,
|
|
4679
|
+
highlightSnippet(hit.snippet || "", terms),
|
|
4680
|
+
hit.tail === true ? "\u2026" : null,
|
|
4681
|
+
),
|
|
4682
|
+
extra === undefined || extra === null ? null : extra,
|
|
4683
|
+
);
|
|
4684
|
+
}
|
|
4685
|
+
|
|
4686
|
+
/**
|
|
4687
|
+
* One search hit, with the surrounding text on demand.
|
|
4688
|
+
*
|
|
4689
|
+
* Opening a hit in a long session makes the chat mount a page of history,
|
|
4690
|
+
* which can take seconds. Reading the hit does not have to: the host ships
|
|
4691
|
+
* the matched neighbourhood, so the row can show it where it stands.
|
|
4692
|
+
*/
|
|
4693
|
+
function SearchHitRow(props) {
|
|
4694
|
+
var opened = react.useState(false);
|
|
4695
|
+
var context = typeof props.hit.context === "string" ? props.hit.context : "";
|
|
4696
|
+
var extra = context === "" ? null : [
|
|
4697
|
+
h("div", { className: "wsr-hit-actions" },
|
|
4698
|
+
h("button", {
|
|
4699
|
+
type: "button",
|
|
4700
|
+
className: "wsr-hit-context-toggle",
|
|
4701
|
+
onClick: function (event) {
|
|
4702
|
+
if (event !== undefined && typeof event.stopPropagation === "function") event.stopPropagation();
|
|
4703
|
+
opened[1](opened[0] !== true);
|
|
4704
|
+
},
|
|
4705
|
+
}, opened[0] === true ? t("search.contextHide") : t("search.contextShow")),
|
|
4706
|
+
h("button", {
|
|
4707
|
+
type: "button",
|
|
4708
|
+
className: "wsr-hit-context-jump",
|
|
4709
|
+
onClick: function (event) {
|
|
4710
|
+
if (event !== undefined && typeof event.stopPropagation === "function") event.stopPropagation();
|
|
4711
|
+
if (typeof props.onJump === "function") props.onJump();
|
|
4712
|
+
},
|
|
4713
|
+
}, t("search.openSession")),
|
|
4714
|
+
),
|
|
4715
|
+
opened[0] === true ? h("div", { className: "wsr-hit-context" }, context) : null,
|
|
4716
|
+
];
|
|
4717
|
+
return searchHitRow(props.hit, props.terms, props.onJump, extra);
|
|
4718
|
+
}
|
|
4719
|
+
|
|
4720
|
+
function SearchPanelPage(props) {
|
|
4721
|
+
var state = react.useState(searchLast === null
|
|
4722
|
+
? { loaded: false, query: "", hits: [], terms: [], scanned: 0, total: 0, pending: 0, took: 0, busy: false, error: "" }
|
|
4723
|
+
: searchLast);
|
|
3934
4724
|
var view = state[0];
|
|
3935
4725
|
var setView = state[1];
|
|
4726
|
+
/* The recent-query list lives in the shared store, so it survives a
|
|
4727
|
+
restart and is the same list on every panel. */
|
|
4728
|
+
var preferences = props !== undefined && props !== null && typeof props.useStore === "function"
|
|
4729
|
+
? props.useStore(function (snapshot) { return snapshot; })
|
|
4730
|
+
: (data.settings || {});
|
|
4731
|
+
var actions = props !== undefined && props !== null && props.actions !== undefined ? props.actions : {};
|
|
4732
|
+
var historyList = preferences !== null && preferences !== undefined && Array.isArray(preferences.searchHistory)
|
|
4733
|
+
? preferences.searchHistory
|
|
4734
|
+
: [];
|
|
4735
|
+
/* Every update also parks the answer outside the component, so coming
|
|
4736
|
+
back from a hit restores the list instead of asking for a new search. */
|
|
4737
|
+
var commit = function (next) {
|
|
4738
|
+
searchLast = next;
|
|
4739
|
+
setView(next);
|
|
4740
|
+
};
|
|
3936
4741
|
|
|
3937
4742
|
var run = function (text, refresh) {
|
|
3938
4743
|
var query = typeof text === "string" ? text.trim() : "";
|
|
3939
4744
|
searchGeneration += 1;
|
|
3940
4745
|
var generation = searchGeneration;
|
|
3941
4746
|
if (query === "") {
|
|
3942
|
-
|
|
4747
|
+
commit({ loaded: true, query: "", hits: [], terms: [], scanned: 0, total: 0, pending: 0, took: 0, busy: false, error: "" });
|
|
3943
4748
|
return;
|
|
3944
4749
|
}
|
|
3945
|
-
|
|
4750
|
+
if (typeof actions.pushSearch === "function") actions.pushSearch(query);
|
|
4751
|
+
commit({ loaded: true, query: query, hits: view.hits, terms: view.terms, scanned: view.scanned, total: view.total, pending: view.pending, took: view.took, busy: true, error: "" });
|
|
3946
4752
|
var ask = function (needRefresh) {
|
|
3947
4753
|
searchPost({ query: query, refresh: needRefresh === true }).then(function (answer) {
|
|
3948
4754
|
if (generation !== searchGeneration) return;
|
|
3949
4755
|
var json = answer.json;
|
|
3950
4756
|
if (json === null || json.ok !== true) {
|
|
3951
|
-
|
|
4757
|
+
commit({ loaded: true, query: query, hits: [], terms: [], scanned: 0, total: 0, pending: 0, took: 0, busy: false, error: t("search.failed") + "HTTP " + answer.status });
|
|
3952
4758
|
return;
|
|
3953
4759
|
}
|
|
3954
|
-
|
|
4760
|
+
commit({
|
|
3955
4761
|
loaded: true,
|
|
3956
4762
|
query: query,
|
|
3957
4763
|
hits: Array.isArray(json.hits) ? json.hits : [],
|
|
@@ -3970,7 +4776,7 @@
|
|
|
3970
4776
|
}
|
|
3971
4777
|
}).catch(function (error) {
|
|
3972
4778
|
if (generation !== searchGeneration) return;
|
|
3973
|
-
|
|
4779
|
+
commit({ loaded: true, query: query, hits: [], terms: [], scanned: 0, total: 0, pending: 0, took: 0, busy: false, error: t("search.failed") + (error && error.message ? error.message : error) });
|
|
3974
4780
|
});
|
|
3975
4781
|
};
|
|
3976
4782
|
ask(refresh === true);
|
|
@@ -3980,7 +4786,8 @@
|
|
|
3980
4786
|
className: "wsr-search-input",
|
|
3981
4787
|
type: "search",
|
|
3982
4788
|
placeholder: t("search.placeholder"),
|
|
3983
|
-
|
|
4789
|
+
/* The box comes back with the query that produced the results below. */
|
|
4790
|
+
defaultValue: view.query || searchDraft,
|
|
3984
4791
|
onChange: function (event) {
|
|
3985
4792
|
searchDraft = event !== undefined && event.target !== undefined ? String(event.target.value || "") : "";
|
|
3986
4793
|
},
|
|
@@ -3993,31 +4800,54 @@
|
|
|
3993
4800
|
});
|
|
3994
4801
|
|
|
3995
4802
|
var rows = view.hits.map(function (hit, index) {
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
h("span", { className: "wsr-hit-role " + (hit.role === "user" ? "wsr-hit-user" : "wsr-hit-agent") }, hit.role === "user" ? t("search.you") : t("search.assistant")),
|
|
4004
|
-
h("span", { className: "wsr-hit-title" }, hit.title || hit.sessionId || ""),
|
|
4005
|
-
typeof hit.workspace === "string" && hit.workspace !== "" ? h("span", { className: "wsr-hit-ws" }, hit.workspace) : null,
|
|
4006
|
-
h("span", { className: "wsr-hit-turn" }, t("search.turn", { n: String(hit.turn) })),
|
|
4007
|
-
),
|
|
4008
|
-
h("div", { className: "wsr-hit-snippet" },
|
|
4009
|
-
hit.lead === true ? "\u2026" : null,
|
|
4010
|
-
highlightSnippet(hit.snippet || "", view.terms),
|
|
4011
|
-
hit.tail === true ? "\u2026" : null,
|
|
4012
|
-
),
|
|
4013
|
-
);
|
|
4803
|
+
var row = h(SearchHitRow, {
|
|
4804
|
+
hit: hit,
|
|
4805
|
+
terms: view.terms,
|
|
4806
|
+
onJump: function () { jumpToSearchHit(hit, view.terms); },
|
|
4807
|
+
});
|
|
4808
|
+
row.key = String(hit.sessionId || "") + ":" + String(hit.seq || 0) + ":" + String(index);
|
|
4809
|
+
return row;
|
|
4014
4810
|
});
|
|
4015
4811
|
|
|
4016
4812
|
return h("div", { className: "wsr-page wsr-search-page" },
|
|
4017
4813
|
h("div", { className: "wsr-page-head" },
|
|
4018
4814
|
h("div", { className: "wsr-page-heading" }, t("search.title")),
|
|
4019
4815
|
),
|
|
4020
|
-
h("div", { className: "wsr-search-
|
|
4816
|
+
historyList.length === 0 ? null : h("div", { className: "wsr-search-history" },
|
|
4817
|
+
h("span", { className: "wsr-search-history-label" }, t("search.history")),
|
|
4818
|
+
historyList.map(function (item, index) {
|
|
4819
|
+
var text = String(item);
|
|
4820
|
+
return h("span", { className: "wsr-search-chip", key: text + ":" + String(index) },
|
|
4821
|
+
h("button", {
|
|
4822
|
+
type: "button",
|
|
4823
|
+
className: "wsr-search-chip-run",
|
|
4824
|
+
title: t("search.historyRun", { query: text }),
|
|
4825
|
+
onClick: function () {
|
|
4826
|
+
searchDraft = text;
|
|
4827
|
+
run(text, false);
|
|
4828
|
+
},
|
|
4829
|
+
}, text),
|
|
4830
|
+
h("button", {
|
|
4831
|
+
type: "button",
|
|
4832
|
+
className: "wsr-search-chip-drop",
|
|
4833
|
+
title: t("search.historyDrop"),
|
|
4834
|
+
"aria-label": t("search.historyDrop"),
|
|
4835
|
+
onClick: function (event) {
|
|
4836
|
+
if (event !== undefined && typeof event.stopPropagation === "function") event.stopPropagation();
|
|
4837
|
+
if (typeof actions.dropSearch === "function") actions.dropSearch(text);
|
|
4838
|
+
},
|
|
4839
|
+
}, "\u00d7"),
|
|
4840
|
+
);
|
|
4841
|
+
}),
|
|
4842
|
+
h("button", {
|
|
4843
|
+
type: "button",
|
|
4844
|
+
className: "wsr-search-history-clear",
|
|
4845
|
+
onClick: function () {
|
|
4846
|
+
if (typeof actions.clearSearches === "function") actions.clearSearches();
|
|
4847
|
+
},
|
|
4848
|
+
}, t("search.historyClear")),
|
|
4849
|
+
),
|
|
4850
|
+
h("div", { className: "wsr-search-bar" },
|
|
4021
4851
|
input,
|
|
4022
4852
|
h("button", { type: "button", className: "wsr-btn", onClick: function () { run(searchDraft, false); } }, t("search.run")),
|
|
4023
4853
|
),
|
|
@@ -4485,6 +5315,10 @@
|
|
|
4485
5315
|
|
|
4486
5316
|
function apply_(ctx) {
|
|
4487
5317
|
installCss();
|
|
5318
|
+
/* The turn rail's cells carry no text, and the host's own hover preview
|
|
5319
|
+
shows a turn's prompt (a number appears only when that prompt is
|
|
5320
|
+
empty). Labelling belongs to the search feature, so it is off with
|
|
5321
|
+
it. */
|
|
4488
5322
|
/* Navigation and unpinning live in the Workspace UI service. It can be
|
|
4489
5323
|
provided after this plugin applies, so take it now when it is there and
|
|
4490
5324
|
let cordis hand it over later when it is not. Never fail the plugin over
|
|
@@ -4502,7 +5336,7 @@
|
|
|
4502
5336
|
}
|
|
4503
5337
|
var prefs = clientStore.defineStore({
|
|
4504
5338
|
init: function () {
|
|
4505
|
-
return { enabled: true, foldDays: DEFAULT_DAYS, keepActive: true, colors: true, pinnedSection: true, argMode: "tool", followUps: {} };
|
|
5339
|
+
return { enabled: true, foldDays: DEFAULT_DAYS, keepActive: true, colors: true, pinnedSection: true, argMode: "tool", followUps: {}, searchHistory: [] };
|
|
4506
5340
|
},
|
|
4507
5341
|
persist: "dsh.ws-recency.prefs.v1",
|
|
4508
5342
|
actions: {
|
|
@@ -4526,6 +5360,30 @@
|
|
|
4526
5360
|
if (draft.followUps === null || typeof draft.followUps !== "object") return;
|
|
4527
5361
|
if (draft.followUps[sessionId] !== undefined) delete draft.followUps[sessionId];
|
|
4528
5362
|
},
|
|
5363
|
+
/* Recent queries, newest first, case-insensitively de-duplicated. */
|
|
5364
|
+
pushSearch: function (draft, query) {
|
|
5365
|
+
var text = typeof query === "string" ? query.trim() : "";
|
|
5366
|
+
if (text === "") return;
|
|
5367
|
+
var list = Array.isArray(draft.searchHistory) ? draft.searchHistory : [];
|
|
5368
|
+
var lower = text.toLowerCase();
|
|
5369
|
+
var next = [text];
|
|
5370
|
+
for (var i = 0; i < list.length && next.length < SEARCH_HISTORY_MAX; i += 1) {
|
|
5371
|
+
if (String(list[i]).toLowerCase() === lower) continue;
|
|
5372
|
+
next.push(list[i]);
|
|
5373
|
+
}
|
|
5374
|
+
draft.searchHistory = next;
|
|
5375
|
+
},
|
|
5376
|
+
dropSearch: function (draft, query) {
|
|
5377
|
+
var text = typeof query === "string" ? query.trim().toLowerCase() : "";
|
|
5378
|
+
if (text === "") return;
|
|
5379
|
+
var list = Array.isArray(draft.searchHistory) ? draft.searchHistory : [];
|
|
5380
|
+
draft.searchHistory = list.filter(function (item) {
|
|
5381
|
+
return String(item).trim().toLowerCase() !== text;
|
|
5382
|
+
});
|
|
5383
|
+
},
|
|
5384
|
+
clearSearches: function (draft) {
|
|
5385
|
+
draft.searchHistory = [];
|
|
5386
|
+
},
|
|
4529
5387
|
},
|
|
4530
5388
|
});
|
|
4531
5389
|
|
|
@@ -4539,7 +5397,19 @@
|
|
|
4539
5397
|
prefsStore = prefs;
|
|
4540
5398
|
|
|
4541
5399
|
if (typeof MutationObserver === "function" && top() !== null) {
|
|
4542
|
-
observer = new MutationObserver(
|
|
5400
|
+
observer = new MutationObserver(function (records) {
|
|
5401
|
+
if (passesSuspended()) return;
|
|
5402
|
+
/* One relevant record is enough: the pass itself is the expensive
|
|
5403
|
+
part, and it always looks at the whole sidebar. */
|
|
5404
|
+
var list = Array.isArray(records) ? records : [];
|
|
5405
|
+
var chain = sidebarChain();
|
|
5406
|
+
for (var i = 0; i < list.length; i += 1) {
|
|
5407
|
+
if (outsideSidebar(list[i] === undefined || list[i] === null ? null : list[i].target, chain)) {
|
|
5408
|
+
schedule();
|
|
5409
|
+
return;
|
|
5410
|
+
}
|
|
5411
|
+
}
|
|
5412
|
+
});
|
|
4543
5413
|
observer.observe(top(), {
|
|
4544
5414
|
childList: true,
|
|
4545
5415
|
subtree: true,
|
|
@@ -4578,23 +5448,27 @@
|
|
|
4578
5448
|
}, ColorsRow);
|
|
4579
5449
|
});
|
|
4580
5450
|
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
5451
|
+
if (SEARCH_ENABLED) {
|
|
5452
|
+
ctx.slots.inject("sidebar.panellist", function () {
|
|
5453
|
+
return ctx.slots.register({
|
|
5454
|
+
name: "sidebar.panellist",
|
|
5455
|
+
id: "ws-recency-search",
|
|
5456
|
+
order: 19,
|
|
5457
|
+
locale: NS,
|
|
5458
|
+
label: function () { return t("search.title"); },
|
|
5459
|
+
}, SearchPanelIcon);
|
|
5460
|
+
});
|
|
5461
|
+
|
|
5462
|
+
ctx.slots.inject("main", function () {
|
|
5463
|
+
return ctx.slots.register({
|
|
5464
|
+
name: "main",
|
|
5465
|
+
key: "ws-recency-search",
|
|
5466
|
+
locale: NS,
|
|
5467
|
+
store: prefs,
|
|
5468
|
+
}, SearchPanelPage);
|
|
5469
|
+
});
|
|
5470
|
+
}
|
|
4590
5471
|
|
|
4591
|
-
ctx.slots.inject("main", function () {
|
|
4592
|
-
return ctx.slots.register({
|
|
4593
|
-
name: "main",
|
|
4594
|
-
key: "ws-recency-search",
|
|
4595
|
-
locale: NS,
|
|
4596
|
-
}, SearchPanelPage);
|
|
4597
|
-
});
|
|
4598
5472
|
|
|
4599
5473
|
ctx.slots.inject("sidebar.panellist", function () {
|
|
4600
5474
|
return ctx.slots.register({
|
|
@@ -4704,6 +5578,16 @@
|
|
|
4704
5578
|
}, StatsMenuItem);
|
|
4705
5579
|
});
|
|
4706
5580
|
|
|
5581
|
+
ctx.slots.inject("sidebar.workspaces.session.menu.item", function () {
|
|
5582
|
+
return ctx.slots.register({
|
|
5583
|
+
name: "sidebar.workspaces.session.menu.item",
|
|
5584
|
+
id: "ws-recency-diagnose",
|
|
5585
|
+
order: 690,
|
|
5586
|
+
store: prefs,
|
|
5587
|
+
locale: NS,
|
|
5588
|
+
}, DiagnoseMenuItem);
|
|
5589
|
+
});
|
|
5590
|
+
|
|
4707
5591
|
ctx.slots.inject("sidebar.workspaces.session.menu.item", function () {
|
|
4708
5592
|
return ctx.slots.register({
|
|
4709
5593
|
name: "sidebar.workspaces.session.menu.item",
|
|
@@ -4741,6 +5625,15 @@
|
|
|
4741
5625
|
reveal: revealTurn,
|
|
4742
5626
|
jump: jumpToSearchHit,
|
|
4743
5627
|
turnRow: turnRowOf,
|
|
5628
|
+
hitRow: searchHitRow,
|
|
5629
|
+
shortId: shortSessionId,
|
|
5630
|
+
resumePasses: function () { suppressedUntil = 0; },
|
|
5631
|
+
};
|
|
5632
|
+
|
|
5633
|
+
/* The search feature ships disabled while its cost is being isolated;
|
|
5634
|
+
tests turn it on so the code stays covered. */
|
|
5635
|
+
exports.__setSearchEnabled = function (value) {
|
|
5636
|
+
SEARCH_ENABLED = value === true;
|
|
4744
5637
|
};
|
|
4745
5638
|
|
|
4746
5639
|
exports.name = "dsh-ws-recency";
|