dsh-ide-window 0.4.3 → 0.4.4
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/AGENTS.md +7 -0
- package/CHANGELOG.md +15 -0
- package/client.js +475 -26
- package/locale/en.json +8 -1
- package/locale/zh.json +8 -1
- package/package.json +1 -1
package/AGENTS.md
CHANGED
|
@@ -339,6 +339,13 @@ tail -f /tmp/dsh-ide-test/logs/dsh-ide-window.log # 自测实例
|
|
|
339
339
|
- **跟随当前会话(`floatFollow`,默认开,持久化)**:`ideFloatTargetSession(state)` 决定卡片展示哪个会话——跟随用 `state.sessionId`;关掉后用卡片自己的 `state.floatSessionId`(只本次进程有效),DSH 里怎么切都不动。卡片标题菜单里点会话:跟随时照旧 `openSession()`,不跟随时只 `store.setFloatSessionId()`(不动面板);不跟随时菜单顶部有「不跟随当前会话 · 在下面手动切换」提示。卡片里点「+ 新建会话」用 `pinnedAdoptRef` 收养新会话,避免不跟随时新建完还停在旧会话。重新打开跟随会清掉钉子
|
|
340
340
|
- **表头**:`▾` 标题 **居中、16px、最多 20 个字**(超出加省略号,悬停给完整标题 + 工作区路径),标题颜色按**工作区**取色相(`ideFloatWorkspaceHue(path)` → `--iw-float-hue`,再和正文主色 `color-mix` 混,浅色/深色都压得住对比度);右侧 `+` 与 `–`/`×` 放在绝对定位的 `.iw-float-head-right` 里,标题才会在整条表头里真正居中
|
|
341
341
|
- **滚到顶 = 翻历史**:正文滚到顶部时(`scrollTop <= 4`)调用 `binding.session.loadOlder()` 补一页(DSH 的会话窗口是分页的:首屏 ≥50 条消息、最多 500 条),同时打开 `historyMode`——**否则补进来的旧行会被「只画本轮」过滤掉,看起来像没加载**。historyMode 下 `ideFloatVisibleRows(..., history)` 铺开整个已加载窗口的对话(`step`/`reasoning`/`context`/`notice` 仍然不画)。补完把 `scrollTop` 推到「长出来的高度」,视线不跳;`rowLimit` 每次 +200(上限 2000)让补进来的行真的出现。发消息或切会话回到「本轮状态板」;没有更多历史时滚到顶只展开已加载的历史,不再请求
|
|
342
|
+
- **到顶继续上滑 = 加载更早(回弹手势)**:正文滚到顶后继续往上滚(滚轮 `deltaY < 0` / 触摸下拉),内容被「拉」下来一段(`pull` 像素,最多 `IDE_FLOAT_PULL_MAX`),到 `IDE_FLOAT_PULL_TRIGGER`(64px)自动调 `loadOlderRows({ reveal: true })`,补完把视图移到新加载那段的开头;不用点任何按钮(用户明确要求「不想再点一次」)
|
|
343
|
+
- **不要再挂「滚到顶就加载」**:到顶立刻翻页的话,回弹一下子都看不到;`onScroll` 只管贴底状态
|
|
344
|
+
- **监听器用回调 ref 挂,不要用 effect**:`createOlderGesture(node, api)` 在 `ref={attachBody}` 里创建——节点一出现就挂、卸载就解绑。用 `useEffect` + 依赖数组时,收起成球期间 `bodyRef` 是空的,展开口很容易错过重挂,手势就整个失效(踩过:浏览器实测拉不出任何反应)。依赖里也**不能写 `collapsed`**(它在组件后面才声明,会抛 `Cannot access 'collapsed' before initialization`,整个 `shell.overlay` 槽直接崩掉、卡片整个不见)
|
|
345
|
+
- **回弹行是 flex 子项**:正文是 `flex-direction: column`,只写 `height` 会被 `flex-shrink` 压成 padding 高度(实测拉不动),必须同时写 `flex: 0 0 <h>px` + `minHeight`
|
|
346
|
+
- **高度不加 transition**:每个 wheel 事件都会重启过渡,看着像卡住;跟着滚轮实时变
|
|
347
|
+
- **补历史期间不许贴底**:贴底 effect 在 `olderRef.current.busy || pending` 时直接 return,`loadOlderRows` 先把 `stickRef.current = false`——否则补完立刻被拽回底部,看着像「没加载」
|
|
348
|
+
- **程序化滚动要防自触发**:`reveal` 把 `scrollTop` 设为 0 会再发一次 scroll 事件;`suppressUntil` 未过期时不重复加载
|
|
342
349
|
- **表头按钮**:`+` 新建、`–` 收起、`×` 关闭(模型与思考等级在输入区,别重复)
|
|
343
350
|
- **每次打开 DSH 都从「收起来」开始**:卡片存在,但只占一个 44px 圆球(`floatCollapsed` 初值 `true`,不持久化);球**由 CSS 钉在窗口右下角**(`right/bottom: 20px`,`left/top: auto`),窗口放大缩小都在原位——早先用卡片坐标算,最大化后还停在旧尺寸的位置,看着像跑到屏幕中间
|
|
344
351
|
- **窗口尺寸变化要重渲染**:`resize` 监听里 `setViewportTick` 一次,否则卡片坐标还是旧视口的夹取结果
|
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,21 @@
|
|
|
6
6
|
升级方式:DSH →「插件」→ 打开插件的「版本」区 →「检查更新」,或直接卸载后重新安装。
|
|
7
7
|
(`link:` 本地安装不参与版本检查,拉取仓库即可。)
|
|
8
8
|
|
|
9
|
+
## [0.4.4] — 2026-11-26
|
|
10
|
+
|
|
11
|
+
### 新增
|
|
12
|
+
|
|
13
|
+
- **悬浮框滚到顶继续上滑就加载更早的消息**:以前滚到顶要么没反应、要么得点一下提示。现在到顶后继续往上滚(滚轮 / 触摸下拉),内容会被「拉」下一段,到 64px 自动加载更早一页,视图停在新加载那段的开头;没有更多时直接告诉你「没有可加载的消息了 · 更多细节请移步会话框查看」。
|
|
14
|
+
|
|
15
|
+
### 改进
|
|
16
|
+
|
|
17
|
+
- **调用链不再只看 3 层**:`⌥+单击` 的调用链以前最多往上追 3 层,再往上就断了。现在一路追到没有调用方为止(只为防递归截断同一条路径),分支按实参归属重载、并按文件名排序,`⌥+单击` 看到的入口更完整。
|
|
18
|
+
|
|
19
|
+
### 修复
|
|
20
|
+
|
|
21
|
+
- **上滑手势在部分情况下完全没反应**:手势监听原来跟着渲染时机挂载,卡片收起成球再展开后可能一直挂不上,怎么拉都没反应。现在节点一出现就挂、卸载就解绑。
|
|
22
|
+
- **卡片谎称「已经到会话开头」**:以前只看会话窗口还有没有更早的页,忽略了卡片自己的行数上限,于是「上面还有内容」时也会说到了开头,和对话里看到的不一致。现在会先放开上限、再展开已加载的历史,真的没得加载了才给提示。
|
|
23
|
+
|
|
9
24
|
## [0.4.3] — 2026-11-26
|
|
10
25
|
|
|
11
26
|
### 新增
|
package/client.js
CHANGED
|
@@ -342,6 +342,11 @@ window.__ModuleLoader__.load({
|
|
|
342
342
|
"floatExpand": "Expand assistant",
|
|
343
343
|
"floatEmpty": "Ask something; the answer lands in this session",
|
|
344
344
|
"floatLoadingOlder": "Loading earlier messages…",
|
|
345
|
+
"floatPullOlder": "Keep pulling for earlier messages",
|
|
346
|
+
"floatPullArmed": "Loading…",
|
|
347
|
+
"floatStartReached": "Nothing left to load here — see the conversation for the full history",
|
|
348
|
+
"floatLoadOlder": "↑ Keep scrolling up for earlier messages",
|
|
349
|
+
"floatLoadOlderHint": "Pull past the top, or click here",
|
|
345
350
|
"floatNoSession": "No session bound yet",
|
|
346
351
|
"floatNoWorkspace": "no workspace",
|
|
347
352
|
"floatPlaceholder": "Message or create a task, / for commands, @ for files or chats",
|
|
@@ -465,6 +470,8 @@ window.__ModuleLoader__.load({
|
|
|
465
470
|
"settingsFloatEventsHint": "List reasoning, context, Tool arguments and system events; off shows only the latest status line",
|
|
466
471
|
"floatWrap": "Wrap lines",
|
|
467
472
|
"floatLiveAnalyze": "Analyzing the request",
|
|
473
|
+
"chainRecursive": "recursive",
|
|
474
|
+
"chainTruncated": "More callers exist (display limit reached)",
|
|
468
475
|
}
|
|
469
476
|
const IDE_TEXT_ZH = {
|
|
470
477
|
"floatCommandNoEditor": "对话框还没就绪,稍后再试",
|
|
@@ -800,6 +807,11 @@ window.__ModuleLoader__.load({
|
|
|
800
807
|
"floatExpand": "展开助手",
|
|
801
808
|
"floatEmpty": "问点什么,回答会出现在当前会话里",
|
|
802
809
|
"floatLoadingOlder": "正在加载更早的消息…",
|
|
810
|
+
"floatPullOlder": "上滑加载更早",
|
|
811
|
+
"floatPullArmed": "即将加载…",
|
|
812
|
+
"floatStartReached": "没有可加载的消息了 · 更多细节请移步会话框查看",
|
|
813
|
+
"floatLoadOlder": "↑ 继续上滑加载更早",
|
|
814
|
+
"floatLoadOlderHint": "滚到顶后继续上滑,或点这里",
|
|
803
815
|
"floatNoSession": "还没有绑定会话",
|
|
804
816
|
"floatNoWorkspace": "未选择工作区",
|
|
805
817
|
"floatPlaceholder": "发消息或创建任务,/ 调用指令,@ 文件或对话",
|
|
@@ -923,6 +935,8 @@ window.__ModuleLoader__.load({
|
|
|
923
935
|
"settingsFloatEventsHint": "把思考、上下文注入、工具参数与系统事件全部列出来;关闭时只显示最新一条状态",
|
|
924
936
|
"floatWrap": "自动换行",
|
|
925
937
|
"floatLiveAnalyze": "正在分析请求",
|
|
938
|
+
"chainRecursive": "递归",
|
|
939
|
+
"chainTruncated": "还有调用方未展开(已达展开上限)",
|
|
926
940
|
}
|
|
927
941
|
|
|
928
942
|
// ---- 00-css.js -----------------------------------------------------------
|
|
@@ -1556,6 +1570,16 @@ html.iw-select-code .iw-code .iw-vision {
|
|
|
1556
1570
|
font-size: 11px;
|
|
1557
1571
|
white-space: nowrap;
|
|
1558
1572
|
}
|
|
1573
|
+
/* A branch that stopped because the caller is already on this path. */
|
|
1574
|
+
.iw-chain-recursive {
|
|
1575
|
+
flex: none;
|
|
1576
|
+
padding: 0 7px;
|
|
1577
|
+
border-radius: 999px;
|
|
1578
|
+
background: rgba(240, 178, 107, 0.16);
|
|
1579
|
+
color: #f0b26b;
|
|
1580
|
+
font-size: 10.5px;
|
|
1581
|
+
white-space: nowrap;
|
|
1582
|
+
}
|
|
1559
1583
|
.iw-pop-section-head {
|
|
1560
1584
|
position: sticky;
|
|
1561
1585
|
top: -4px;
|
|
@@ -2715,6 +2739,31 @@ html.iw-select-code .iw-code .iw-vision {
|
|
|
2715
2739
|
line-height: 18px;
|
|
2716
2740
|
color: var(--dsw-alias-label-tertiary, #81858c);
|
|
2717
2741
|
}
|
|
2742
|
+
/* 已经到顶还继续上滑:内容被拉下来一段(回弹),到阈值自动加载更早一页。 */
|
|
2743
|
+
.iw-float-puller {
|
|
2744
|
+
display: flex;
|
|
2745
|
+
align-items: flex-end;
|
|
2746
|
+
justify-content: center;
|
|
2747
|
+
overflow: hidden;
|
|
2748
|
+
padding-bottom: 4px;
|
|
2749
|
+
color: var(--dsw-alias-label-tertiary, #81858c);
|
|
2750
|
+
font-size: 12.5px;
|
|
2751
|
+
line-height: 16px;
|
|
2752
|
+
/* 高度跟着滚轮实时走,不加 transition——否则每来一个 wheel 事件都会重启过渡,
|
|
2753
|
+
看着像「拉不动」。 */
|
|
2754
|
+
}
|
|
2755
|
+
.iw-float-puller.armed { color: var(--dsw-alias-brand-primary, #4f7cf7); }
|
|
2756
|
+
/* 还有更早历史时常驻的一行提示;点一下也能加载(手势之外的口子)。 */
|
|
2757
|
+
.iw-float-older-hint {
|
|
2758
|
+
display: block;
|
|
2759
|
+
width: 100%;
|
|
2760
|
+
border: 0;
|
|
2761
|
+
background: transparent;
|
|
2762
|
+
cursor: pointer;
|
|
2763
|
+
color: var(--dsw-alias-label-tertiary, #81858c);
|
|
2764
|
+
text-align: center;
|
|
2765
|
+
}
|
|
2766
|
+
.iw-float-older-hint:hover { color: var(--dsw-alias-brand-primary, #4f7cf7); }
|
|
2718
2767
|
.iw-float-title-btn:hover { background: var(--dsw-alias-card-fill-hover, rgba(255, 255, 255, 0.08)); }
|
|
2719
2768
|
/* A model row must be clickable across its whole width, not just on the text. */
|
|
2720
2769
|
.iw-float-menu-item {
|
|
@@ -11651,10 +11700,14 @@ async function ideLspHoverText(store, tabPath, position) {
|
|
|
11651
11700
|
* resolving each call site to the method that contains it — is what produces the
|
|
11652
11701
|
* chain from an entry point down to the clicked method. Every node carries the
|
|
11653
11702
|
* location of its declaration, so a click in the popup is an ordinary jump.
|
|
11703
|
+
*
|
|
11704
|
+
* The walk has no depth limit: it keeps climbing level by level until a level
|
|
11705
|
+
* finds no caller at all. A branch stops early only for recursion — a caller
|
|
11706
|
+
* that already sits on the same path — so "the chain ends here" means the
|
|
11707
|
+
* entry point really was reached. The two limits below bound rows, not hops.
|
|
11654
11708
|
*/
|
|
11655
11709
|
|
|
11656
|
-
const
|
|
11657
|
-
const IDE_CHAIN_NODES = 40
|
|
11710
|
+
const IDE_CHAIN_NODES = 160
|
|
11658
11711
|
const IDE_CHAIN_CHILDREN = 6
|
|
11659
11712
|
|
|
11660
11713
|
/** The last declaration strictly above `line` (1-based) in one file. */
|
|
@@ -11733,6 +11786,85 @@ function ideChainDeclaresAt(lines, line) {
|
|
|
11733
11786
|
return ideDeclarations(lines, line - 1, line).length > 0
|
|
11734
11787
|
}
|
|
11735
11788
|
|
|
11789
|
+
/**
|
|
11790
|
+
* Index of the `(` that opens `name(...)` on one line, or `-1`.
|
|
11791
|
+
*
|
|
11792
|
+
* `indexOf(name)` alone is not enough: the receiver may contain the name
|
|
11793
|
+
* (`generateService.generate(`) and a name that is a prefix of another
|
|
11794
|
+
* identifier would point at the wrong place.
|
|
11795
|
+
*/
|
|
11796
|
+
function ideChainParenAt(text, name) {
|
|
11797
|
+
const line = String(text ?? '')
|
|
11798
|
+
let from = 0
|
|
11799
|
+
while (from < line.length) {
|
|
11800
|
+
const at = line.indexOf(name, from)
|
|
11801
|
+
if (at < 0) return -1
|
|
11802
|
+
const before = at === 0 ? '' : line[at - 1]
|
|
11803
|
+
const rest = line.slice(at + name.length)
|
|
11804
|
+
const indent = rest.length - rest.trimStart().length
|
|
11805
|
+
if (!/[\w$]/.test(before) && rest[indent] === '(') return at + name.length + indent
|
|
11806
|
+
from = at + name.length
|
|
11807
|
+
}
|
|
11808
|
+
return -1
|
|
11809
|
+
}
|
|
11810
|
+
|
|
11811
|
+
/**
|
|
11812
|
+
* How many arguments (or parameters) sit inside the `(...)` that starts at
|
|
11813
|
+
* `line`/`column`.
|
|
11814
|
+
*
|
|
11815
|
+
* `-1` means "could not read it with confidence" — the list never closes inside
|
|
11816
|
+
* a 200-line window, or it holds a comma whose nesting is ambiguous (`<>`,
|
|
11817
|
+
* `{}`, a comment). Callers must treat that as unknown, never as zero: the
|
|
11818
|
+
* count is what tells overloads apart, and a wrong number would drop a real
|
|
11819
|
+
* call edge.
|
|
11820
|
+
*/
|
|
11821
|
+
function ideChainArity(lines, line, column) {
|
|
11822
|
+
let depth = 0
|
|
11823
|
+
let commas = 0
|
|
11824
|
+
let content = false
|
|
11825
|
+
let started = false
|
|
11826
|
+
for (let index = Math.max(0, line); index < lines.length && index <= line + 200; index += 1) {
|
|
11827
|
+
const text = String(lines[index] ?? '')
|
|
11828
|
+
for (let at = index === line ? Math.max(0, column) : 0; at < text.length; at += 1) {
|
|
11829
|
+
const char = text[at]
|
|
11830
|
+
if (char === '"' || char === "'") {
|
|
11831
|
+
const quote = char
|
|
11832
|
+
at += 1
|
|
11833
|
+
while (at < text.length && text[at] !== quote) {
|
|
11834
|
+
if (text[at] === '\\') at += 1
|
|
11835
|
+
at += 1
|
|
11836
|
+
}
|
|
11837
|
+
if (started && depth === 1) content = true
|
|
11838
|
+
continue
|
|
11839
|
+
}
|
|
11840
|
+
if (char === '/' && (text[at + 1] === '/' || text[at + 1] === '*')) return -1
|
|
11841
|
+
if (char === '<' || char === '>' || char === '{' || char === '}') {
|
|
11842
|
+
if (started) return -1
|
|
11843
|
+
continue
|
|
11844
|
+
}
|
|
11845
|
+
if (char === '(') {
|
|
11846
|
+
depth += 1
|
|
11847
|
+
started = true
|
|
11848
|
+
continue
|
|
11849
|
+
}
|
|
11850
|
+
if (char === ')') {
|
|
11851
|
+
if (depth === 0) return -1
|
|
11852
|
+
depth -= 1
|
|
11853
|
+
if (depth === 0 && started) return content ? commas + 1 : 0
|
|
11854
|
+
continue
|
|
11855
|
+
}
|
|
11856
|
+
if (!started || depth !== 1) continue
|
|
11857
|
+
if (char === ',') {
|
|
11858
|
+
commas += 1
|
|
11859
|
+
content = true
|
|
11860
|
+
continue
|
|
11861
|
+
}
|
|
11862
|
+
if (char !== ' ' && char !== '\t') content = true
|
|
11863
|
+
}
|
|
11864
|
+
}
|
|
11865
|
+
return -1
|
|
11866
|
+
}
|
|
11867
|
+
|
|
11736
11868
|
/**
|
|
11737
11869
|
* Turn the caller tree into the tree the popup shows.
|
|
11738
11870
|
*
|
|
@@ -11758,6 +11890,7 @@ function ideChainInverted(tree) {
|
|
|
11758
11890
|
line: node.line,
|
|
11759
11891
|
callSite: node.callSite,
|
|
11760
11892
|
focus: node.focus === true,
|
|
11893
|
+
recursive: node.recursive === true,
|
|
11761
11894
|
children: parentOf.has(node) ? [build(parentOf.get(node))] : [],
|
|
11762
11895
|
})
|
|
11763
11896
|
return leaves.map(build)
|
|
@@ -11779,7 +11912,16 @@ function ideChainCount(node) {
|
|
|
11779
11912
|
* @returns the tree, filled in.
|
|
11780
11913
|
*/
|
|
11781
11914
|
async function ideCallChain(store, root, options = {}) {
|
|
11782
|
-
|
|
11915
|
+
// Which declarations already sit on the path from the clicked method to this
|
|
11916
|
+
// node. Recursion is the only natural stop, and it has to be per path: a
|
|
11917
|
+
// method reached through two routes is drawn on both.
|
|
11918
|
+
const tree = {
|
|
11919
|
+
...root,
|
|
11920
|
+
focus: true,
|
|
11921
|
+
children: [],
|
|
11922
|
+
chainKeys: new Set([`${root.path}:${root.line}`]),
|
|
11923
|
+
childKeys: new Set(),
|
|
11924
|
+
}
|
|
11783
11925
|
const files = new Map()
|
|
11784
11926
|
const linesOf = (path) => {
|
|
11785
11927
|
let pending = files.get(path)
|
|
@@ -11789,6 +11931,34 @@ async function ideCallChain(store, root, options = {}) {
|
|
|
11789
11931
|
}
|
|
11790
11932
|
return pending
|
|
11791
11933
|
}
|
|
11934
|
+
const declarationsByFile = new Map()
|
|
11935
|
+
const declarationsOf = (path) => {
|
|
11936
|
+
let pending = declarationsByFile.get(path)
|
|
11937
|
+
if (pending === undefined) {
|
|
11938
|
+
pending = linesOf(path).then((lines) => ideDeclarations(lines, 0, lines.length))
|
|
11939
|
+
declarationsByFile.set(path, pending)
|
|
11940
|
+
}
|
|
11941
|
+
return pending
|
|
11942
|
+
}
|
|
11943
|
+
/**
|
|
11944
|
+
* Whether a call site belongs to a different declaration of the same name.
|
|
11945
|
+
*
|
|
11946
|
+
* `findReferences` may answer with the whole overload group, and the text
|
|
11947
|
+
* fallback cannot tell two overloads apart at all — both hand a 4-argument
|
|
11948
|
+
* call to the 5-parameter method. Arity is the one thing a call site states
|
|
11949
|
+
* about itself, so it decides; when either side cannot be read the call is
|
|
11950
|
+
* kept, because a missing caller is worse than a doubtful one.
|
|
11951
|
+
*/
|
|
11952
|
+
const belongsToAnotherOverload = async (node, location) => {
|
|
11953
|
+
const callerLines = await linesOf(location.path)
|
|
11954
|
+
const open = ideChainParenAt(callerLines[location.line - 1], node.name)
|
|
11955
|
+
if (open < 0) return false
|
|
11956
|
+
const overloads = (await declarationsOf(node.path)).filter((entry) => entry.name === node.name)
|
|
11957
|
+
if (overloads.length < 2) return false
|
|
11958
|
+
const args = ideChainArity(callerLines, location.line - 1, open)
|
|
11959
|
+
const params = ideChainArity(await linesOf(node.path), node.position.line, node.position.character)
|
|
11960
|
+
return args >= 0 && params >= 0 && args !== params
|
|
11961
|
+
}
|
|
11792
11962
|
/**
|
|
11793
11963
|
* The method containing a call site, or nothing when it sits outside one.
|
|
11794
11964
|
*
|
|
@@ -11831,16 +12001,23 @@ async function ideCallChain(store, root, options = {}) {
|
|
|
11831
12001
|
return rows.map((row) => ({ path: row.path, line: row.line }))
|
|
11832
12002
|
}
|
|
11833
12003
|
|
|
11834
|
-
const seen = new Set([`${root.path}:${root.line}`])
|
|
11835
12004
|
let level = [tree]
|
|
11836
12005
|
let count = 1
|
|
11837
|
-
|
|
12006
|
+
let truncated = false
|
|
12007
|
+
while (level.length > 0) {
|
|
12008
|
+
if (count >= IDE_CHAIN_NODES) {
|
|
12009
|
+
truncated = true
|
|
12010
|
+
break
|
|
12011
|
+
}
|
|
11838
12012
|
const next = []
|
|
11839
12013
|
/** Turn caller locations into child nodes; returns how many were added. */
|
|
11840
12014
|
const attach = async (node, list) => {
|
|
11841
12015
|
let added = 0
|
|
11842
12016
|
for (const location of list) {
|
|
11843
|
-
if (count >= IDE_CHAIN_NODES
|
|
12017
|
+
if (count >= IDE_CHAIN_NODES) {
|
|
12018
|
+
truncated = true
|
|
12019
|
+
break
|
|
12020
|
+
}
|
|
11844
12021
|
if (typeof location?.path !== 'string' || typeof location?.line !== 'number') continue
|
|
11845
12022
|
// The declaration of the method we are walking is not a call to it.
|
|
11846
12023
|
if (location.path === node.path && location.line === node.line) continue
|
|
@@ -11854,15 +12031,38 @@ async function ideCallChain(store, root, options = {}) {
|
|
|
11854
12031
|
position: { line: location.line - 1, character: 0 },
|
|
11855
12032
|
}
|
|
11856
12033
|
const key = `${location.path}:${target.line}`
|
|
11857
|
-
if (
|
|
11858
|
-
|
|
12034
|
+
if (node.childKeys.has(key)) continue
|
|
12035
|
+
// A call site names its method by name alone, so it can land under the
|
|
12036
|
+
// wrong overload — the same line then shows up in two branches.
|
|
12037
|
+
if (await belongsToAnotherOverload(node, location)) continue
|
|
12038
|
+
// Checked after the filters, so the flag means a real caller was left
|
|
12039
|
+
// out — a seventh declaration on the line is not "more callers".
|
|
12040
|
+
if (added >= IDE_CHAIN_CHILDREN) {
|
|
12041
|
+
truncated = true
|
|
12042
|
+
break
|
|
12043
|
+
}
|
|
12044
|
+
node.childKeys.add(key)
|
|
11859
12045
|
count += 1
|
|
11860
12046
|
added += 1
|
|
12047
|
+
if (node.chainKeys.has(key)) {
|
|
12048
|
+
// The caller is already on this path: recursion, the one case where a
|
|
12049
|
+
// branch stops while callers still exist.
|
|
12050
|
+
node.children.push({
|
|
12051
|
+
...target,
|
|
12052
|
+
path: location.path,
|
|
12053
|
+
callSite: { path: location.path, line: location.line },
|
|
12054
|
+
recursive: true,
|
|
12055
|
+
children: [],
|
|
12056
|
+
})
|
|
12057
|
+
continue
|
|
12058
|
+
}
|
|
11861
12059
|
const child = {
|
|
11862
12060
|
...target,
|
|
11863
12061
|
path: location.path,
|
|
11864
12062
|
callSite: { path: location.path, line: location.line },
|
|
11865
12063
|
children: [],
|
|
12064
|
+
chainKeys: new Set([...node.chainKeys, key]),
|
|
12065
|
+
childKeys: new Set(),
|
|
11866
12066
|
}
|
|
11867
12067
|
node.children.push(child)
|
|
11868
12068
|
next.push(child)
|
|
@@ -11905,6 +12105,7 @@ async function ideCallChain(store, root, options = {}) {
|
|
|
11905
12105
|
}
|
|
11906
12106
|
tree.textual = textual
|
|
11907
12107
|
tree.failed = textual ? '' : failure
|
|
12108
|
+
tree.truncated = truncated
|
|
11908
12109
|
return tree
|
|
11909
12110
|
}
|
|
11910
12111
|
|
|
@@ -11914,8 +12115,45 @@ function ideChainFileOf(path) {
|
|
|
11914
12115
|
return name.endsWith('.java') ? name.slice(0, -'.java'.length) : name
|
|
11915
12116
|
}
|
|
11916
12117
|
|
|
12118
|
+
/**
|
|
12119
|
+
* Branch order for the popup: by the caller's file name, so every branch that
|
|
12120
|
+
* starts in one file sits together. A same-name tie falls back to the whole
|
|
12121
|
+
* path and then the line, which keeps the list stable while it is being filled
|
|
12122
|
+
* in level by level.
|
|
12123
|
+
*
|
|
12124
|
+
* Plain code-unit comparison, not `localeCompare`: the order must not depend on
|
|
12125
|
+
* the machine's locale (and the same list has to be checked by the tests).
|
|
12126
|
+
*/
|
|
12127
|
+
function ideChainCompareBranches(a, b) {
|
|
12128
|
+
const compare = (left, right) => (left < right ? -1 : (left > right ? 1 : 0))
|
|
12129
|
+
const byFile = compare(ideChainFileOf(a?.path ?? '').toLowerCase(), ideChainFileOf(b?.path ?? '').toLowerCase())
|
|
12130
|
+
if (byFile !== 0) return byFile
|
|
12131
|
+
const byPath = compare(String(a?.path ?? ''), String(b?.path ?? ''))
|
|
12132
|
+
if (byPath !== 0) return byPath
|
|
12133
|
+
return (Number(a?.line) || 0) - (Number(b?.line) || 0)
|
|
12134
|
+
}
|
|
12135
|
+
|
|
12136
|
+
/** The rows one branch would draw, as a single comparable string. */
|
|
12137
|
+
function ideChainSignature(node) {
|
|
12138
|
+
const site = node.callSite === undefined ? '' : node.callSite.line
|
|
12139
|
+
return `${node.path}:${node.line}@${site}/${node.children.map(ideChainSignature).join(',')}`
|
|
12140
|
+
}
|
|
12141
|
+
|
|
12142
|
+
/** One row per distinct chain: two walks that draw the same rows are noise. */
|
|
12143
|
+
function ideChainDistinct(forest) {
|
|
12144
|
+
const seen = new Set()
|
|
12145
|
+
const out = []
|
|
12146
|
+
for (const entry of forest) {
|
|
12147
|
+
const key = ideChainSignature(entry)
|
|
12148
|
+
if (seen.has(key)) continue
|
|
12149
|
+
seen.add(key)
|
|
12150
|
+
out.push(entry)
|
|
12151
|
+
}
|
|
12152
|
+
return out
|
|
12153
|
+
}
|
|
12154
|
+
|
|
11917
12155
|
/** One node card plus its children, joined by rounded elbows. */
|
|
11918
|
-
function IdeChainNode({ node, depth, onPick }) {
|
|
12156
|
+
function IdeChainNode({ node, depth, onPick, tr }) {
|
|
11919
12157
|
const where = `${ideChainFileOf(node.path)}:${node.line}`
|
|
11920
12158
|
return h('div', { className: 'iw-chain-node' }, [
|
|
11921
12159
|
h('button', {
|
|
@@ -11928,6 +12166,9 @@ function IdeChainNode({ node, depth, onPick }) {
|
|
|
11928
12166
|
h('span', { key: 'dot', className: 'iw-chain-dot' }),
|
|
11929
12167
|
h('span', { key: 'n', className: 'iw-chain-name' }, node.name),
|
|
11930
12168
|
h('span', { key: 'p', className: 'iw-chain-where' }, where),
|
|
12169
|
+
node.recursive === true
|
|
12170
|
+
? h('span', { key: 'r', className: 'iw-chain-recursive' }, tr('chainRecursive'))
|
|
12171
|
+
: null,
|
|
11931
12172
|
node.callSite === undefined
|
|
11932
12173
|
? null
|
|
11933
12174
|
: h('span', { key: 's', className: 'iw-chain-site', title: `${node.callSite.path}:${node.callSite.line}` }, `← :${node.callSite.line}`),
|
|
@@ -11939,6 +12180,7 @@ function IdeChainNode({ node, depth, onPick }) {
|
|
|
11939
12180
|
node: child,
|
|
11940
12181
|
depth: depth + 1,
|
|
11941
12182
|
onPick,
|
|
12183
|
+
tr,
|
|
11942
12184
|
}))),
|
|
11943
12185
|
])
|
|
11944
12186
|
}
|
|
@@ -11982,12 +12224,14 @@ function IdeChainPopup({ popup, tr, onPick, onClose }) {
|
|
|
11982
12224
|
const status = popup.state === 'loading'
|
|
11983
12225
|
? tr('chainLoading')
|
|
11984
12226
|
: `${count}${typeof popup.ms === 'number' ? ` · ${popup.ms}ms` : ''}`
|
|
11985
|
-
const forest = root === undefined ? [] : ideChainInverted(root)
|
|
11986
|
-
const
|
|
11987
|
-
|
|
11988
|
-
|
|
11989
|
-
|
|
11990
|
-
|
|
12227
|
+
const forest = root === undefined ? [] : ideChainDistinct(ideChainInverted(root).sort(ideChainCompareBranches))
|
|
12228
|
+
const notes = []
|
|
12229
|
+
if (root !== undefined) {
|
|
12230
|
+
if (typeof root.failed === 'string' && root.failed.startsWith('license:')) notes.push(tr('lspLicense'))
|
|
12231
|
+
else if (root.textual === true || root.failed) notes.push(tr('chainTextual'))
|
|
12232
|
+
if (root.truncated === true) notes.push(tr('chainTruncated'))
|
|
12233
|
+
}
|
|
12234
|
+
const note = notes.join(' · ')
|
|
11991
12235
|
const body = h(React.Fragment, null, [
|
|
11992
12236
|
h('div', { key: 'rule', className: 'iw-chain-rule' }, tr('chainRule')),
|
|
11993
12237
|
note === '' ? null : h('div', { key: 'note', className: 'iw-chain-note' }, note),
|
|
@@ -11998,6 +12242,7 @@ function IdeChainPopup({ popup, tr, onPick, onClose }) {
|
|
|
11998
12242
|
node: entry,
|
|
11999
12243
|
depth: 0,
|
|
12000
12244
|
onPick,
|
|
12245
|
+
tr,
|
|
12001
12246
|
}))),
|
|
12002
12247
|
])
|
|
12003
12248
|
return h('div', {
|
|
@@ -14305,6 +14550,15 @@ async function ideDataWindowOpenMapper(store, tr, root, path, symbol, line) {
|
|
|
14305
14550
|
// everything but the last few rows off a long turn; the card scrolls, so the
|
|
14306
14551
|
// whole tail of the log is worth keeping.
|
|
14307
14552
|
const IDE_FLOAT_MESSAGES = 200
|
|
14553
|
+
/** 往回翻历史时卡片最多渲染这么多行(再多就该去对话里看了)。 */
|
|
14554
|
+
const IDE_FLOAT_MESSAGES_MAX = 1200
|
|
14555
|
+
/** 上拉回弹:到阈值自动加载更早一页(像素)。 */
|
|
14556
|
+
const IDE_FLOAT_PULL_TRIGGER = 64
|
|
14557
|
+
/** 回弹最多拉这么高,再多也没有意义。 */
|
|
14558
|
+
const IDE_FLOAT_PULL_MAX = 96
|
|
14559
|
+
/** 停止滚动这么久后回弹归零。 */
|
|
14560
|
+
const IDE_FLOAT_PULL_IDLE_MS = 420
|
|
14561
|
+
|
|
14308
14562
|
/** 表头标题最多显示多少个字(超出加省略号)。 */
|
|
14309
14563
|
const IDE_FLOAT_TITLE_CHARS = 20
|
|
14310
14564
|
/** Longest text a folded row shows once opened; longer payloads are clipped. */
|
|
@@ -14464,6 +14718,27 @@ function ideFloatTargetSession(state) {
|
|
|
14464
14718
|
return pinned !== '' ? pinned : panel
|
|
14465
14719
|
}
|
|
14466
14720
|
|
|
14721
|
+
/**
|
|
14722
|
+
* 往回翻历史时的下一步。判定与副作用分开,方便测。
|
|
14723
|
+
*
|
|
14724
|
+
* `hasMore` 只说明窗口里还有没有更早的**页**;卡片自己还有 `rowLimit` 这个渲染上限,
|
|
14725
|
+
* 两者不是一回事——早先只看 `hasMore`,于是在「上限截掉了更早的行」时也宣布
|
|
14726
|
+
* 「已经到会话开头」,和 DSH 对话显示的开头对不上(用户实测反馈)。
|
|
14727
|
+
*/
|
|
14728
|
+
function ideFloatOlderStep(state) {
|
|
14729
|
+
const hasMore = state?.hasMore === true
|
|
14730
|
+
const total = Number(state?.total ?? 0)
|
|
14731
|
+
const limit = Number(state?.limit ?? 0)
|
|
14732
|
+
const history = state?.history === true
|
|
14733
|
+
if (state?.loadable === false) return 'none'
|
|
14734
|
+
if (hasMore) return 'load'
|
|
14735
|
+
// 窗口没有更早的页了,但手里的行还没放完:先放开上限。
|
|
14736
|
+
if (total > limit) return 'raise'
|
|
14737
|
+
// 放完了,但正文还停在「本轮状态板」:先展开整段已加载的历史。
|
|
14738
|
+
if (!history) return 'expand'
|
|
14739
|
+
return 'start'
|
|
14740
|
+
}
|
|
14741
|
+
|
|
14467
14742
|
/** 会话的模式:`agentPreset` 投影的值(字符串或 `{currentValue}`,没配置就是空)。 */
|
|
14468
14743
|
function ideFloatPresetId(value) {
|
|
14469
14744
|
if (typeof value === 'string') return value
|
|
@@ -14481,6 +14756,75 @@ function ideFloatPresetName(presets, id, translate) {
|
|
|
14481
14756
|
return typeof text === 'string' && text !== '' ? text : id
|
|
14482
14757
|
}
|
|
14483
14758
|
|
|
14759
|
+
/**
|
|
14760
|
+
* 到顶继续上滑的手势:累积回弹距离,到阈值回调 `load`。
|
|
14761
|
+
*
|
|
14762
|
+
* 返回解绑函数。所有可变输入都走 `api`(`pull` 是同一个对象引用、`setPull` 是稳定的
|
|
14763
|
+
* setState),所以监听器不需要随每次渲染重建。
|
|
14764
|
+
*/
|
|
14765
|
+
function createOlderGesture(node, api) {
|
|
14766
|
+
const settle = (timer) => {
|
|
14767
|
+
if (timer !== 0) globalThis.clearTimeout(timer)
|
|
14768
|
+
}
|
|
14769
|
+
const reset = () => {
|
|
14770
|
+
api.pull.value = 0
|
|
14771
|
+
api.setPull(0)
|
|
14772
|
+
}
|
|
14773
|
+
const decay = () => {
|
|
14774
|
+
settle(api.pull.timer)
|
|
14775
|
+
api.pull.timer = globalThis.setTimeout(reset, IDE_FLOAT_PULL_IDLE_MS)
|
|
14776
|
+
}
|
|
14777
|
+
const push = (distance) => {
|
|
14778
|
+
if (api.isBusy() === true) return
|
|
14779
|
+
if (node.scrollTop > 2) return
|
|
14780
|
+
const next = Math.min(IDE_FLOAT_PULL_MAX, api.pull.value + distance)
|
|
14781
|
+
api.pull.value = next
|
|
14782
|
+
api.setPull(next)
|
|
14783
|
+
if (next >= IDE_FLOAT_PULL_TRIGGER) {
|
|
14784
|
+
settle(api.pull.timer)
|
|
14785
|
+
reset()
|
|
14786
|
+
api.load({ reveal: true })
|
|
14787
|
+
return
|
|
14788
|
+
}
|
|
14789
|
+
decay()
|
|
14790
|
+
}
|
|
14791
|
+
const onWheel = (event) => {
|
|
14792
|
+
if (event.deltaY >= 0) return
|
|
14793
|
+
// 到顶了才拦:否则正常滚动会被吃掉。
|
|
14794
|
+
if (node.scrollTop > 2) return
|
|
14795
|
+
event.preventDefault()
|
|
14796
|
+
push(-event.deltaY)
|
|
14797
|
+
}
|
|
14798
|
+
let touchY = null
|
|
14799
|
+
const onTouchStart = (event) => {
|
|
14800
|
+
touchY = event.touches?.[0]?.clientY ?? null
|
|
14801
|
+
}
|
|
14802
|
+
const onTouchMove = (event) => {
|
|
14803
|
+
if (touchY === null) return
|
|
14804
|
+
const y = event.touches?.[0]?.clientY ?? touchY
|
|
14805
|
+
const delta = y - touchY
|
|
14806
|
+
touchY = y
|
|
14807
|
+
if (delta <= 0) return
|
|
14808
|
+
if (node.scrollTop > 2) return
|
|
14809
|
+
push(delta)
|
|
14810
|
+
}
|
|
14811
|
+
const onTouchEnd = () => {
|
|
14812
|
+
touchY = null
|
|
14813
|
+
decay()
|
|
14814
|
+
}
|
|
14815
|
+
node.addEventListener('wheel', onWheel, { passive: false })
|
|
14816
|
+
node.addEventListener('touchstart', onTouchStart, { passive: true })
|
|
14817
|
+
node.addEventListener('touchmove', onTouchMove, { passive: true })
|
|
14818
|
+
node.addEventListener('touchend', onTouchEnd, { passive: true })
|
|
14819
|
+
return () => {
|
|
14820
|
+
settle(api.pull.timer)
|
|
14821
|
+
node.removeEventListener('wheel', onWheel)
|
|
14822
|
+
node.removeEventListener('touchstart', onTouchStart)
|
|
14823
|
+
node.removeEventListener('touchmove', onTouchMove)
|
|
14824
|
+
node.removeEventListener('touchend', onTouchEnd)
|
|
14825
|
+
}
|
|
14826
|
+
}
|
|
14827
|
+
|
|
14484
14828
|
/** 表头标题最多 `limit` 个字,超出用省略号——再长就分不清是哪个会话了。 */
|
|
14485
14829
|
function ideFloatTitleText(text, limit = IDE_FLOAT_TITLE_CHARS) {
|
|
14486
14830
|
const value = String(text ?? '').trim()
|
|
@@ -16209,7 +16553,22 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
|
|
|
16209
16553
|
const olderRef = useRef({ busy: false, pending: false, height: 0 })
|
|
16210
16554
|
// 「+ 新建会话」之后,不跟随时把卡片收养到新会话上(只认卡片自己发起的创建)。
|
|
16211
16555
|
const pinnedAdoptRef = useRef(false)
|
|
16556
|
+
// 上拉回弹的实时值(不在 state 里累积,避免每帧渲染整个卡片)。
|
|
16557
|
+
const pullRef = useRef({ value: 0, timer: 0 })
|
|
16558
|
+
// 监听器里要调最新的 loadOlderRows(每次渲染都会重建)。
|
|
16559
|
+
const loadOlderRef = useRef(null)
|
|
16560
|
+
const olderAvailableRef = useRef(false)
|
|
16561
|
+
// 当前窗口折出来的总行数(含被 rowLimit 截掉的部分)。
|
|
16562
|
+
const transcriptTotalRef = useRef(0)
|
|
16563
|
+
// 回调 ref 挂上的手势清理函数(节点卸载或重新渲染时先解绑)。
|
|
16564
|
+
const gestureCleanupRef = useRef(null)
|
|
16212
16565
|
const [olderBusy, setOlderBusy] = useState(false)
|
|
16566
|
+
// 会话窗口里还有没有更早的一页(有才允许上拉加载)。
|
|
16567
|
+
const [olderAvailable, setOlderAvailable] = useState(false)
|
|
16568
|
+
// 上拉到顶后的「回弹」高度:内容整体往下推,松手/到阈值就加载。
|
|
16569
|
+
const [pull, setPull] = useState(0)
|
|
16570
|
+
// 拉到顶时的提示(已到开头 / 只保留最近若干行):一句话,看完自己消失。
|
|
16571
|
+
const [startHint, setStartHint] = useState('')
|
|
16213
16572
|
// 会话的模式(Agent 预设):DSH 表头显示的就是它,卡片只展示不改。
|
|
16214
16573
|
const [presetId, setPresetId] = useState('')
|
|
16215
16574
|
const [presets, setPresets] = useState([])
|
|
@@ -16374,25 +16733,54 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
|
|
|
16374
16733
|
|
|
16375
16734
|
// 滚到「更早」补一页:DSH 的会话窗口是分页的(首屏 ≥50 条消息、最多 500 条),
|
|
16376
16735
|
// 卡片自己不请求就只能看到那一屏。补完把滚动位置往下推同样高度,视觉上停在原处。
|
|
16377
|
-
const loadOlderRows = async () => {
|
|
16736
|
+
const loadOlderRows = async (options) => {
|
|
16737
|
+
// 点「加载更早的消息」是明确要看旧内容:补完把视图挪到新加载那段的开头。
|
|
16738
|
+
// 滚到顶触发时相反——保持原位置,新内容自然出现在上方。
|
|
16739
|
+
const reveal = options?.reveal === true
|
|
16378
16740
|
const session = binding?.session
|
|
16379
16741
|
const source = binding?.eventSource
|
|
16380
16742
|
if (olderRef.current.busy) return
|
|
16743
|
+
// 往回翻就不再跟着最新一条走:否则补完历史,负责「贴底」的那个 effect 会
|
|
16744
|
+
// 立刻把视图拽回底部,用户根本看不到刚加载出来的旧消息。
|
|
16745
|
+
stickRef.current = false
|
|
16381
16746
|
const element = bodyRef.current
|
|
16382
16747
|
const taller = () => (element === null || element === undefined ? 0 : element.scrollHeight)
|
|
16383
16748
|
const hasMore = source?.getSnapshot()?.hasMore === true
|
|
16384
16749
|
const canLoad = session !== undefined && session !== null && typeof session.loadOlder === 'function'
|
|
16385
16750
|
// 已经到会话开头(或这条会话没有分页):不用请求,只把历史展开,
|
|
16386
16751
|
// 让已经拿到的更早内容显示出来。
|
|
16387
|
-
|
|
16388
|
-
|
|
16752
|
+
const step = ideFloatOlderStep({
|
|
16753
|
+
hasMore,
|
|
16754
|
+
loadable: canLoad,
|
|
16755
|
+
total: transcriptTotalRef.current,
|
|
16756
|
+
limit: rowLimit,
|
|
16757
|
+
history: historyMode,
|
|
16758
|
+
})
|
|
16759
|
+
if (step === 'raise') {
|
|
16760
|
+
// 上限截掉了更早的行:先把它放出来,绝不在这时候说「已经到开头」。
|
|
16389
16761
|
olderRef.current.height = taller()
|
|
16762
|
+
olderRef.current.top = element === null || element === undefined ? 0 : element.scrollTop
|
|
16763
|
+
setRowLimit(Math.min(transcriptTotalRef.current, IDE_FLOAT_MESSAGES_MAX))
|
|
16764
|
+
olderRef.current.pending = true
|
|
16765
|
+
return
|
|
16766
|
+
}
|
|
16767
|
+
if (step === 'expand') {
|
|
16768
|
+
// 展开「已加载但被本轮过滤掉」的历史。
|
|
16769
|
+
olderRef.current.height = taller()
|
|
16770
|
+
olderRef.current.top = element === null || element === undefined ? 0 : element.scrollTop
|
|
16390
16771
|
setHistoryMode(true)
|
|
16391
16772
|
olderRef.current.pending = true
|
|
16392
16773
|
return
|
|
16393
16774
|
}
|
|
16775
|
+
if (step === 'start' || step === 'none') {
|
|
16776
|
+
// 没得加载了就直说,并把人引到会话框——卡片不是阅读器,细节去对话看。
|
|
16777
|
+
setStartHint(tr('floatStartReached'))
|
|
16778
|
+
globalThis.setTimeout(() => setStartHint(''), 2600)
|
|
16779
|
+
return
|
|
16780
|
+
}
|
|
16394
16781
|
olderRef.current.busy = true
|
|
16395
16782
|
olderRef.current.height = taller()
|
|
16783
|
+
olderRef.current.top = element === null || element === undefined ? 0 : element.scrollTop
|
|
16396
16784
|
setOlderBusy(true)
|
|
16397
16785
|
if (!historyMode) setHistoryMode(true)
|
|
16398
16786
|
try {
|
|
@@ -16400,6 +16788,7 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
|
|
|
16400
16788
|
// 窗口补进来了,但卡片只画最后 N 行;放宽上限,让补进来的行真的出现。
|
|
16401
16789
|
setRowLimit((current) => Math.min(current + IDE_FLOAT_MESSAGES, IDE_FLOAT_MESSAGES * 10))
|
|
16402
16790
|
olderRef.current.pending = true
|
|
16791
|
+
olderRef.current.reveal = reveal
|
|
16403
16792
|
} catch (error) {
|
|
16404
16793
|
ideLogRecord('warn', 'float', 'load older failed', error?.message ?? String(error))
|
|
16405
16794
|
} finally {
|
|
@@ -16408,6 +16797,29 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
|
|
|
16408
16797
|
}
|
|
16409
16798
|
}
|
|
16410
16799
|
|
|
16800
|
+
// 已经到顶还继续往上滑:内容被「拉」下来一段,到阈值就自动加载更早一页。
|
|
16801
|
+
// 监听器挂在 body 节点上,用回调 ref(节点一出现就挂),不依赖 effect 的依赖数组:
|
|
16802
|
+
// 收起成球时 body 不存在,靠 effect 重挂很容易错过,手势就整个失效(踩过)。
|
|
16803
|
+
const attachBody = (node) => {
|
|
16804
|
+
if (typeof gestureCleanupRef.current === 'function') {
|
|
16805
|
+
gestureCleanupRef.current()
|
|
16806
|
+
gestureCleanupRef.current = null
|
|
16807
|
+
}
|
|
16808
|
+
bodyRef.current = node
|
|
16809
|
+
if (node === null || node === undefined) return
|
|
16810
|
+
gestureCleanupRef.current = createOlderGesture(node, {
|
|
16811
|
+
isBusy: () => olderRef.current.busy === true,
|
|
16812
|
+
load: (options) => {
|
|
16813
|
+
if (typeof loadOlderRef.current === 'function') void loadOlderRef.current(options)
|
|
16814
|
+
},
|
|
16815
|
+
pull: pullRef.current,
|
|
16816
|
+
setPull,
|
|
16817
|
+
})
|
|
16818
|
+
}
|
|
16819
|
+
|
|
16820
|
+
loadOlderRef.current = loadOlderRows
|
|
16821
|
+
olderAvailableRef.current = olderAvailable
|
|
16822
|
+
|
|
16411
16823
|
// 新行渲染完再量高度:把滚动条往下推「长出来的那一段」,视线不跳。
|
|
16412
16824
|
useLayoutEffect(() => {
|
|
16413
16825
|
const older = olderRef.current
|
|
@@ -16415,8 +16827,16 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
|
|
|
16415
16827
|
const element = bodyRef.current
|
|
16416
16828
|
if (element === null || element === undefined) return
|
|
16417
16829
|
const grown = element.scrollHeight - older.height
|
|
16418
|
-
//
|
|
16419
|
-
|
|
16830
|
+
// 下面这行是自己滚动:滚动事件会再进来一次,别把它当成用户在往回翻。
|
|
16831
|
+
older.suppressUntil = Date.now() + 800
|
|
16832
|
+
if (older.reveal === true) {
|
|
16833
|
+
// 明确点了「加载更早」:直接看到新加载的那段(它的开头就是最上面一行)。
|
|
16834
|
+
element.scrollTop = 0
|
|
16835
|
+
} else if (grown > 0) {
|
|
16836
|
+
// 滚到顶触发的:按点击时看到的位置还原,新内容自然出现在上方。
|
|
16837
|
+
element.scrollTop = Math.max(0, Number(older.top ?? 0) + grown)
|
|
16838
|
+
}
|
|
16839
|
+
older.reveal = false
|
|
16420
16840
|
older.height = element.scrollHeight
|
|
16421
16841
|
older.pending = false
|
|
16422
16842
|
})
|
|
@@ -16427,6 +16847,8 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
|
|
|
16427
16847
|
useEffect(() => {
|
|
16428
16848
|
const element = bodyRef.current
|
|
16429
16849
|
if (element === null || element === undefined || stickRef.current !== true) return undefined
|
|
16850
|
+
// 正在往回补历史:这时候贴到底就等于把刚加载出来的旧消息藏起来。
|
|
16851
|
+
if (olderRef.current.busy === true || olderRef.current.pending === true) return undefined
|
|
16430
16852
|
const toBottom = () => { element.scrollTop = element.scrollHeight }
|
|
16431
16853
|
toBottom()
|
|
16432
16854
|
// A picture or a code block grows the transcript after it lays out, which
|
|
@@ -16473,14 +16895,20 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
|
|
|
16473
16895
|
setRowLimit((current) => (current === IDE_FLOAT_MESSAGES ? current : IDE_FLOAT_MESSAGES))
|
|
16474
16896
|
olderRef.current = { busy: false, pending: false, height: 0 }
|
|
16475
16897
|
setHistoryMode(false)
|
|
16898
|
+
setOlderAvailable(false)
|
|
16476
16899
|
return undefined
|
|
16477
16900
|
}
|
|
16478
16901
|
const source = binding.eventSource
|
|
16479
16902
|
const read = () => {
|
|
16480
|
-
const
|
|
16903
|
+
const snapshot = source.getSnapshot()
|
|
16904
|
+
const raw = snapshot?.entries
|
|
16481
16905
|
// The transcript drops Tool calls; the progress line needs them.
|
|
16482
16906
|
rawEntries.current = Array.isArray(raw) ? raw : []
|
|
16483
|
-
|
|
16907
|
+
// 一次折出全部行,再按上限截断:这样才能判断「截掉的那些是不是比窗口还早」。
|
|
16908
|
+
const all = ideFloatTranscript(raw)
|
|
16909
|
+
transcriptTotalRef.current = all.length
|
|
16910
|
+
setEntries(all.length > rowLimit ? all.slice(-rowLimit) : all)
|
|
16911
|
+
setOlderAvailable(snapshot?.hasMore === true)
|
|
16484
16912
|
}
|
|
16485
16913
|
read()
|
|
16486
16914
|
return source.subscribe(read)
|
|
@@ -17587,15 +18015,36 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
|
|
|
17587
18015
|
h('div', {
|
|
17588
18016
|
key: 'body',
|
|
17589
18017
|
className: 'iw-float-body',
|
|
17590
|
-
ref:
|
|
18018
|
+
ref: attachBody,
|
|
17591
18019
|
onScroll: (event) => {
|
|
17592
18020
|
const element = event.currentTarget
|
|
17593
18021
|
stickRef.current = element.scrollTop + element.clientHeight >= element.scrollHeight - 40
|
|
17594
|
-
//
|
|
17595
|
-
|
|
18022
|
+
// 加载更早一页不在这里触发:到顶后继续上滑由上面的回弹累积器负责,
|
|
18023
|
+
// 否则一碰到顶就立刻翻页,用户根本看不到「拉扯」的那一下。
|
|
17596
18024
|
},
|
|
17597
18025
|
}, [
|
|
17598
|
-
|
|
18026
|
+
startHint !== '' && pull === 0
|
|
18027
|
+
? h('div', { key: 'start', className: 'iw-float-older' }, startHint)
|
|
18028
|
+
: olderBusy
|
|
18029
|
+
? h('div', { key: 'older', className: 'iw-float-older' }, tr('floatLoadingOlder'))
|
|
18030
|
+
: pull > 0
|
|
18031
|
+
? h('div', {
|
|
18032
|
+
key: 'older',
|
|
18033
|
+
className: `iw-float-puller${pull >= IDE_FLOAT_PULL_TRIGGER * 0.75 ? ' armed' : ''}`,
|
|
18034
|
+
// 正文是 flex 列:只写 height 会被 flex-shrink 压回 padding 高度,
|
|
18035
|
+
// 必须连 `flex` 一起钉住,回弹才拉得出来。
|
|
18036
|
+
style: { height: `${pull}px`, flex: `0 0 ${pull}px`, minHeight: `${pull}px` },
|
|
18037
|
+
}, pull >= IDE_FLOAT_PULL_TRIGGER * 0.75 ? tr('floatPullArmed') : tr('floatPullOlder'))
|
|
18038
|
+
: olderAvailable
|
|
18039
|
+
// 常驻一行提示:让人知道这个方向还有内容(点一下也能加载,手势失灵时的兜底)。
|
|
18040
|
+
? h('button', {
|
|
18041
|
+
key: 'older',
|
|
18042
|
+
type: 'button',
|
|
18043
|
+
className: 'iw-float-older iw-float-older-hint',
|
|
18044
|
+
title: tr('floatLoadOlderHint'),
|
|
18045
|
+
onClick: () => { void loadOlderRows({ reveal: true }) },
|
|
18046
|
+
}, tr('floatLoadOlder'))
|
|
18047
|
+
: null,
|
|
17599
18048
|
visibleEntries.length === 0 && running !== true
|
|
17600
18049
|
? h('div', { key: 'empty', className: 'iw-float-empty' }, sessionId === '' ? tr('floatNoSession') : tr('floatEmpty'))
|
|
17601
18050
|
: visibleEntries.map((row) => {
|
package/locale/en.json
CHANGED
|
@@ -336,6 +336,11 @@
|
|
|
336
336
|
"floatExpand": "Expand assistant",
|
|
337
337
|
"floatEmpty": "Ask something; the answer lands in this session",
|
|
338
338
|
"floatLoadingOlder": "Loading earlier messages…",
|
|
339
|
+
"floatPullOlder": "Keep pulling for earlier messages",
|
|
340
|
+
"floatPullArmed": "Loading…",
|
|
341
|
+
"floatStartReached": "Nothing left to load here — see the conversation for the full history",
|
|
342
|
+
"floatLoadOlder": "↑ Keep scrolling up for earlier messages",
|
|
343
|
+
"floatLoadOlderHint": "Pull past the top, or click here",
|
|
339
344
|
"floatNoSession": "No session bound yet",
|
|
340
345
|
"floatNoWorkspace": "no workspace",
|
|
341
346
|
"floatPlaceholder": "Message or create a task, / for commands, @ for files or chats",
|
|
@@ -458,5 +463,7 @@
|
|
|
458
463
|
"settingsFloatEvents": "Show full detail",
|
|
459
464
|
"settingsFloatEventsHint": "List reasoning, context, Tool arguments and system events; off shows only the latest status line",
|
|
460
465
|
"floatWrap": "Wrap lines",
|
|
461
|
-
"floatLiveAnalyze": "Analyzing the request"
|
|
466
|
+
"floatLiveAnalyze": "Analyzing the request",
|
|
467
|
+
"chainRecursive": "recursive",
|
|
468
|
+
"chainTruncated": "More callers exist (display limit reached)"
|
|
462
469
|
}
|
package/locale/zh.json
CHANGED
|
@@ -336,6 +336,11 @@
|
|
|
336
336
|
"floatExpand": "展开助手",
|
|
337
337
|
"floatEmpty": "问点什么,回答会出现在当前会话里",
|
|
338
338
|
"floatLoadingOlder": "正在加载更早的消息…",
|
|
339
|
+
"floatPullOlder": "上滑加载更早",
|
|
340
|
+
"floatPullArmed": "即将加载…",
|
|
341
|
+
"floatStartReached": "没有可加载的消息了 · 更多细节请移步会话框查看",
|
|
342
|
+
"floatLoadOlder": "↑ 继续上滑加载更早",
|
|
343
|
+
"floatLoadOlderHint": "滚到顶后继续上滑,或点这里",
|
|
339
344
|
"floatNoSession": "还没有绑定会话",
|
|
340
345
|
"floatNoWorkspace": "未选择工作区",
|
|
341
346
|
"floatPlaceholder": "发消息或创建任务,/ 调用指令,@ 文件或对话",
|
|
@@ -458,5 +463,7 @@
|
|
|
458
463
|
"settingsFloatEvents": "显示详细过程",
|
|
459
464
|
"settingsFloatEventsHint": "把思考、上下文注入、工具参数与系统事件全部列出来;关闭时只显示最新一条状态",
|
|
460
465
|
"floatWrap": "自动换行",
|
|
461
|
-
"floatLiveAnalyze": "正在分析请求"
|
|
466
|
+
"floatLiveAnalyze": "正在分析请求",
|
|
467
|
+
"chainRecursive": "递归",
|
|
468
|
+
"chainTruncated": "还有调用方未展开(已达展开上限)"
|
|
462
469
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-ide-window",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "IDEA-style code workspace for DeepSeek Harness: a centre panel with a workspace file tree, editor tabs and live-updating source, while the left navigation column hides.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"icon": "icon.svg",
|