Skip to content

desktop: 桌面栈收敛(思考档位、记忆技能、社区积分、回复插图、长文本落盘) - #18

Merged
taisuii merged 52 commits into
mainfrom
feat/paste-and-seat
Nov 2, 2026
Merged

taisuii merged 52 commits into
mainfrom
feat/paste-and-seat

Conversation

@taisuii

@taisuii taisuii commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

把此前分散在 #16 / #17 与工作区未提交改动里的桌面端功能收敛成单一 PR。

包含

顺带修掉的真问题

  • 思考块展开状态不再跨刷新保留:原先写进 localStorage,刷新后页面一进来就把整段推理摊开,与 docs/conversation-presentation.md 的「思考过程默认收起」冲突,check-ui 因此必红。
  • 找回被静默回退的 CI 加固:a043f9c 合并 main 时没报冲突,但把 脚本: UI 检查与桌面调试端口支持环境变量覆盖 #12 的端口环境变量、测试: 放宽 CI 上不够用的终端与 shell 等待窗口 #15 的四处等待窗口覆盖回旧值(setDefaultTimeout(60000) 整行消失、PTY 90000→15000、shell 90000→30000、提示符 45000→20000)。这类回退不红不报错,只把窗口悄悄收窄。
  • 两个新浏览器测试补上回退链:scroll-restore / stream-render 原本在 CI 因缺浏览器全红,现抽 shared launchBrowser(WDH_TEST_EXECUTABLE → CHROME_PATH → 系统 Chrome/Edge),找不到时 skip 并说明原因。

验证

taisuii and others added 30 commits October 28, 2026 19:09
- workspace tabs, compact menus and dock tab handling
- session sidebar, turn navigation and project tree
- community account login through the loopback browser flow
- UI fixtures for account, conversation and sidebar
…e header

- render ProjectPicker in both empty and session headers
- add a direct 重新选择目录 action to the unavailable-directory banner
- reintroduce the 查看执行环境 dialog with capability and workspace details
The packaged smoke test assumed a draft session and the removed workspace-set RPC. Create a project with a signed folder grant and a session under it, then assert the session workspace points at that directory.
session-snapshot exposes the project root after realpath resolution and does not include the availability field; compare canonical paths instead.
Type only after the interactive shell has printed its prompt, extend the Windows timeouts, and include the output tail when verification times out so CI logs show what the PTY produced.
Wait for the interactive prompt before writing, so typed-ahead input is not lost on a cold Windows runner; include the PTY output tail when the marker never arrives.
The PTY echoed the typed line but never accepted it, so send the command and the Enter keystroke as separate writes and use CRLF on Windows.
Send Enter as its own write, then allow up to 20s for the interactive prompt to execute and render the marker on slow Windows runners.
…Y follow-up

The Windows runner echoes the typed command but never executes it; keep the Linux/macOS coverage and record the Windows gap explicitly until it can be debugged on a real machine.
Kernel info, download, probe and repair used the session-scoped browser manager, so a fresh install with zero projects failed at the plugin page. Give kernel operations their own browser host rooted at the user data dir.
Assert that a brand-new data directory stays at zero sessions and still exposes kernel-info without a session error.
Keep one title and one action in the center, and drop the repeated sidebar hint and the project picker when no project exists.
The download button was a sibling of the gapped flex container, so it stuck to the file name field; group progress and button with margins. Drop the stale system Chrome copy.
check:ui used to time out waiting for the kernel probe when WDH or CloakBrowser was absent. Ask the sidecar for kernel state and fail with an actionable message.
Typing "baidu" became https://baidu/, which has no TLD and fails DNS. Guess .com for a single word, search for phrases, and keep explicit URLs unchanged.
…rors

The controlled input could navigate with the previous render's text if Enter arrived before the last state update. Read the live input value instead, and turn raw Chromium network errors into readable messages.
…age header

The header only needs the session identity and run state. Project switching already lives in the session menu (移动到项目…), project creation/editing in the sidebar, and the execution environment entry duplicated the permission model. Update the UI contract checks to follow that decision instead of preserving the old widgets.
Ask for the reverse-engineering domains, experience level and an optional model key on first launch. Persist the profile in settings, inject it into the agent system prompt, skip without nagging, and allow rerunning the wizard from the model settings.
Script and command tools keep the model-set timeoutMs with documented caps; browser, debugger and MCP calls now get category budgets too. A timeout aborts the underlying work through the call signal and returns an actionable error instead of stalling the run. ask_user stays exempt; the system prompt and tool descriptions explain defaults and caps.
Subagents now receive a bounded prompt made of the current goal, recent user/assistant messages and the workspace root unless with_context=false, so they stop guessing about the parent conversation. Paused or failed goals render an inline banner with the stop reason and a one-click 继续目标 action instead of hiding resume inside the goal popover.
agent_spawn now returns immediately and the parent gets a completion notice (queued mid-run or delivered at the next turn) instead of polling. agent_message continues a settled child with the same read-only history and context, and the UI shows a completion toast. Each round keeps the 10-step/5-minute budget.
agent_message now delivers a mid-run steer when the child is still working: the text becomes a user instruction before the next model decision, instead of forcing the parent to wait for completion. Settled children keep the existing continuation path; queueSteer refuses once the child stopped.
agent_spawn mode=fork seeds the child history with the parent's completed user/assistant turns instead of a short summary. The concurrency cap now comes from settings (1–8, default 3) and is editable in 运行参数; depth stays 1 because research children have no delegation tools.
- goal resume keeps token accounting and goal actions/updates carry a revision CAS
- fork seeds only completed turns (tool calls included, in-flight turn and attachments excluded)
- subagent notifications persist in session state so they survive a restart
- steer is accepted only while the child turn is still open
- integration CI caches and installs CloakBrowser, and check:ui accepts a deterministic data dir
- fixture picks the last real user prompt, so injected subagent notices no longer hijack it
- goal resume assertions target the new inline banner
- Windows terminal uses the OS ConPTY instead of the bundled conpty.dll
- integration keeps its temporary UI data dir outside the checkout so the Git tab still sees a non-repository workspace
- completed reasoning is checked after expanding the process summary
- account logout failure asserts the retained profile instead of overlay-dependent visibility
- Windows terminal sends a second Enter after the line settles
… event

- every check:ui context skips the first-run onboarding via an init script
- terminal worker tracks win32-input-mode and encodes CR as a VK_RETURN sequence for PSReadLine
- terminal tests send a single Enter again
taisuii and others added 20 commits October 31, 2026 22:36
The browser init-script hook stalled app boot in the headless check; write the completed onboarding preference through the sidecar instead and keep the page untouched.
…tegrity budget

PSReadLine's win32-input-mode turns a raw CR into a line break, so interactive input never submits; the terminal now starts PowerShell without that module. The integrity helper compiles C# and can exceed 45s on a loaded runner, so allow 90s.
…th CRLF

Integration installs the kernel with the job token now that WDH sends Authorization headers. On Windows the terminal translates a submitted CR into CRLF because the console treats a bare CR as an in-line return.
… commit

PSReadLine's win32-input-mode escape sequence can be split across ConPTY chunks, so track a small tail instead of matching one chunk. Actions checkout needs the full commit SHA for the token-aware WDH ref.
ConPTY plus PSReadLine's win32-input-mode turns raw CR into a line break in CI, so Windows terminals now use node-pty's winpty backend, which translates console characters into key input.
Windows CI types immediately after spawn; PowerShell has printed the prompt but is still binding PSReadLine, so the first lines and Enter can be lost. Wait for the prompt plus a short settle in both terminal tests.
The diagnostic opens three PTYs and compares raw CR, CRLF and win32-input-mode Enter submissions, printing platform, PowerShell and Node versions plus the last output tail. A raw-input env switch lets it bypass the worker translation.
- goal continuations record their source and a goal snapshot, and are broadcast live to the UI
- conversation turns derive an expandable trigger row (DSH TurnTriggerNodeView style): target icon, 继续执行目标, time, stop status, objective/summary/next action
- old histories without metadata are recognised by the internal continuation prefix
- check:ui starts an auto-continuing goal and asserts the row and its expanded content
The MCP client kept only the tool list from initialize and dropped the
server's instructions. ADH declares its device channel and analysis
discipline there, so the model never saw that adb can drive the phone and
misread a stalled privacy dialog as an anti-debug defense.

McpHost now retains instructions per connection, clears them when the
connection drops, and Agent rebuilds the system prompt each turn from the
currently connected plugins. System memory is read-only product/plugin
fact: it is not shown for editing in settings and grants no permission.
Users can now see and delete what the agent saved for itself. A new
settings tab lists memories and skills across user, project and session
scopes, shows where each one applies, and removes a single entry from a
single scope.

Removal requires an explicit scope: the tool path never guesses which
copy to delete, so a user-level fact cannot be lost while editing a
project one. Writes and removals both check expectedHash, so a
concurrent agent edit is refused instead of silently overwritten.

System memory is deliberately absent from this page: it belongs to the
product and connected plugins, so settings only reports that it exists
and that it cannot be edited.
过去「思考」只处理接收侧(providers/* 解析 reasoning_content / thinking_delta 并渲染),
发送侧完全没有强度控制 —— 除了会话标题硬编码关掉 DeepSeek thinking,其余请求从不携带
任何思考参数。于是同一份渠道配置下,有的模型永远不思考,有的永远满功率思考,用户既
无法声明也无法选择。

- sidecar/thinking.mjs:渠道到端点的唯一事实来源,按四种真实传输方式声明
  effort(OpenAI reasoning_effort)/ budget(Claude thinking.budget_tokens)/
  switch(DeepSeek、GLM 的 thinking.type)/ none(只声明不发送)。零 top-level import,
  ui/src 可直接 import 而不把 node:* 打进浏览器产物。
- 发送侧接线:providers/{index,openai,anthropic}.mjs 按渠道发出对应参数,
  settings.mjs 保存选择,secrets.mjs 复用同一份归一化。
- 界面:thinking-picker.jsx 滑块只提供模型声明的档位;screens 设置页与 chat 输入区
  共用;scroll-stick.js 让贴底滚动不被流式渲染打断。
- 测试:thinking / session-title-prefix / scroll-restore / stream-render /
  view-persistence / approval-scope / ask-outcome / network-grant /
  browser-tabs-tool / shell-encoding 共 10 个新测试文件。

验证:node --test "sidecar/test/*.test.mjs" → 382 项全过。
栈(plugin-instructions → memory-skill → desktop-points)与 main 上的 PR #10-#15 改的是
同一批 UI/侧车文件,直接开 PR 会大面积冲突。这里先在隔离 worktree 里把 main 合进来,
逐块人工解冲突,确保两边的工作都留着。

解冲突时按「谁更完整」判定,而不是按边选:

- agent.mjs:保留栈的系统记忆(system-memory.mjs + 每轮重算),
  同时保留 main 的「上传附件前先生成文件」说明。
- sessions.mjs updateGoal:main 的状态标签更可读(已暂停 / 需要你处理 / 已完成),
  栈的 activeRun.source 判定更准,两者合并;文案同时满足两条既有断言。
- browsertools.mjs browser_new_tab:main 补了网址归一化(裸域名 → https、拦危险协议),
  栈补了多标签页接线。合并后先归一化再分流;capabilities.pageTabs 只在组件
  明确声明 false 时拦,snapshot 缺失时退回旧文案,避免纯接线场景被误伤。
- 其余 UI/样式/Rust 侧取栈版:main 在这些位置没有改动(逐个确认过),
  栈带的是积分经验拆分、思考档位、标题前缀、阅读位置等新功能。

验证:
- node --test --test-concurrency=2 "sidecar/test/*.test.mjs" → 390 项全过
- npm run build:ui 通过
- cargo check 因本机缺 build/resources/node 无法完成,交由 CI 验证
模型过去只能在文字里描述图片,用户看不到它刚截的那张。现在可以把工作区或附件里的
图片登记成「回复图片」,UI 用现成的 attachment-preview 通道按 id 取 dataUrl 渲染。

刻意没做成 Markdown 的 ![](data:...):那条路径会把 base64 写进 .agent-history.json,
直接破坏「历史不落 base64」这个既有不变量。历史里只记附件 id,和其他附件共用同一套
存储与校验。

安全边界:模型能决定用户屏幕上出现什么图(伪造登录框/系统提示都是现实的钓鱼面),
所以
- 不接受远端 URL,只接受工作区相对路径;
- 不接受 SVG(可内嵌脚本),一律按文件头真实嗅探格式;
- 复用已有附件时重新校验 hash,防止「登记后文件被换掉」。

- sidecar/reply-image.mjs:登记与校验;sidecar/reply-tools.mjs:reply_image 工具。
- ui/src/reply-markdown.jsx + image-refs.js:把回复里的图片引用切出来单独渲染。
- scripts/check-reply-images.mjs:UI 回归。

验证:node --test sidecar/test/reply-image.test.mjs → 7 项全过。
CI runner 与全新 clone 上都没有装 patchright 浏览器,
scroll-restore 与 stream-render 五个用例因此全红,而代码本身是好的。
假红比不测更糟:它会训练人忽略红灯,也让真回归淹没在噪声里。

抽一个 shared launchBrowser:优先 WDH_TEST_EXECUTABLE,
其次 CHROME_PATH(与 scripts/check-ui.mjs 同一约定),再次常见系统 Chrome/Edge。
都没有时返回 reason,用例用 t.skip 跳过并说明怎么装,
而不是抛 Executable doesn't exist。
一条几十万字符的消息会同时撑爆上下文与渲染,粘贴是最常见的入口。
现在超过 20000 字符的粘贴改为写入工作区的 .dh-paste/ 目录,
输入框里只留一行引用,模型按需用 workspace_read 分段读取。
sessions.send 里兜住绕过 UI 的路径(脚本、恢复、队列重发),
让守门在服务端也成立,而不是只靠前端自觉。

配套两处:
- workspace_read 增加 offset/limit 按行分段,否则落盘后模型读不到中间内容;
  path 与 file 同时给出时按目录+文件名拼接,读目录时给出明确报错。
- 项目概念出现之前的历史会话(无 projectId)不再让启动失败,
  改为如实报告并按用户选择删除;删除沿用正常删除的底线,
  拒绝删除被链接替换的目录。

.dh-paste/ 写入用户项目根下,属于会话运行产物,加进 .gitignore。
输入栏原来有两个控件:模型下拉和思考强度浮层。它们回答的是同一个问题
(这条消息谁来答、用多大力气),分开摆既占宽度又让窄窗口先挤掉强度。

现在照 DSH 的 ModelSelect 合成一个座位:触发器显示模型名与当前档位,
弹层里两面切换——模型列表(可搜索)与思考强度(含实际发出的参数)。
xhigh/max 是可选档,只有模型显式声明才出现;按模型名推断时只用基础档,
免得把端点不认的 reasoning_effort 发出去。

配套回归:
- check-ui 改成从座位里钻取到模型目录,并等权限菜单真正消失再点击
  (菜单关闭中的那次点击会被当成「关闭它」,座位不会打开)。
- check-thinking-ui 覆盖座位弹出、切换、返回与档位选择。
- composer-controls 尺寸断言把 .seat-trigger 纳入同一组。
a043f9c(把 main 合进桌面栈)没有报冲突,但结果里 main 上已有的
四处加固被分支侧的旧版本覆盖了:

- check-ui.mjs 的端口回到硬编码 5311,丢掉了 JSRA_UI_HTTP_PORT 覆盖
- check-ui.mjs 的 context.setDefaultTimeout(60000) 整行消失,回默认 30s
- check-sidecar.mjs 的打包 PTY 等待从 60000 退回 15000
- shell-encoding 的 8 处 timeoutMs 从 90000 退回 30000
- workspace-tabs 的提示符窗口退回默认 20000,用例 timeout 也一并退小

这类回退不红不报错,只把窗口悄悄收窄,等到下一次超时才表现为「新代码有问题」。
集成 job 那个 30 秒 locator 超时正是这条线的后果之一。

全部按 main 的值恢复,并在注释里保留原有的理由,避免下次再被静默覆盖。
思考的展开状态原本被写进 localStorage,于是刷新或重开会话后,
页面一进来就把整段推理摊开,把对话顶走 —— 与
docs/conversation-presentation.md 的「思考过程默认收起」直接冲突,
check-ui 的「刷新后思考应默认收起」也因此必然失败。

现在把它降级为运行期状态:内存里照常记录,当场点开立刻生效,
但持久化前由 persistedSessionViews 剥掉该字段,读回来一律是收起的。
阅读位置的持久化不变,仍按用户是否主动往上翻过决定。

测试改为直接调用产品里那一份 persistedSessionViews,而不是在测试里
重写一遍剥离逻辑 —— 否则实现改了测试也不会红。
- scroll-restore 的 smooth 动画前提:Windows headless Chromium 不一定播放平滑滚动,
  此时「直接赋值会从顶部动画」这个前提本身不成立。改为 skip 并说明实际值,
  而不是让用例在环境差异下假红。
- check-ui 的终端等待:提示符 15s→45s、命令回显 12s→60s。
  CI runner 上 PowerShell 冷启动与回显远超 12 秒,02:53 那次就是卡在这一步。
@taisuii
taisuii merged commit df022e6 into main Nov 2, 2026
3 checks passed
@taisuii
taisuii deleted the feat/paste-and-seat branch November 2, 2026 03:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant