docs(changelog): keep the final #1147 sidechat behavior

This commit is contained in:
Menghuan1918 committed 2026-11-09 12:13:05 +08:00
1 parent a3f057528a
commit 3f4d75a090
2 files changed
-21

No files matched your search

-8
View File
@@ -16,18 +16,10 @@
- 🧪 测试:`tests/sidechat-create-timeout-config.spec.ts`(默认 120000、显式值原样透传、schema 填默认并接受上下边界、越界/小数被拒、路由按配置构造取消信号且不再出现 15000、未传配置时回落默认、create 拒绝仍包成 500)。
- 🧷 **从侧栏打开的历史会话里也能新建侧边对话了**:`sidechat.start` 只在 LIVE 注册表里找父会话的 agent,于是「重启后还没跑过回合」的冷存储会话被直接判成 `409 parent session "…" is not running`——而「不在 live 表里」并不等于「没在运行」:宿主本来就能把它 resume 起来。现在 live 表未命中时再用结构探针问一次 `ctx.get('sessionController').resolveAgent(sessionId)`,只有真的拿到 `{ agent }` 才采用;服务缺失、resume 抛错、或宿主回 `{ error }`(Session 域失败)时保持原来的 409 与原文案;父会话本来就 live 时**绝不**触发 resume。
- 🧪 测试:`tests/sidechat-start-cold-parent.spec.ts`(冷父会话经宿主 resume 后正常建线程且子会话绑定父 id;live 父会话零 resume;无服务/抛错/`{ error }` 三种失败都保持 409 原文案且不创建线程)。
- 🧵 **fork 处不再是一张卡片,而是「分割线 + 两段普通消息」;继承的内容也不再截断**:横幅卡片(可展开、带说明行、正文截到 4000 字符)在真机上被判为不对——读者要看的是主会话原话,不是被摘要过的一段。现在 `data-sidechat-fork-point` 只是一个普通容器:先是一条发丝分割线(文案「分支前的主会话」),接着**继承的提问**用本线程普通用户气泡的同一呈现块与同一 markdown 渲染(`data-sidechat-fork-question` 保留、逐字全量),再接着**继承的回答**用普通 assistant 消息的同一呈现块(`**强调**`→`<strong>`、`` `代码` ``→`<code>`、逐字全量);这段继承内容被**两条同款分割线夹住**——开头那条「分支前的主会话」,以及新加的结尾那条 `data-sidechat-fork-divider-end`(文案「分支前的主会话结束」,与开头线同一元素种类、共用同一套样式类、同样不可交互且不计入转录行),读者由此看得出继承的上下文到哪里为止;没有回答时是开头线、提问、结尾线,不出现空的 assistant 块。路由侧的 400 / 4000 字符上限与边界截断一并删除:`fork` 的 `user` / `assistant` 按日志原样返回,无省略号。`sideChatForkBanner` / `sideChatForkAnswer` 从全部 21 份词典退休,新增 `sideChatForkDivider` 与 `sideChatForkDividerEnd`(均 21 份)。
- 🧪 测试:`tests/sidechat-fork-route.spec.ts`(超长提问与回答逐字返回、无省略号);`tests/sidechat-fork-point.spec.tsx`(块内无 `<details>`/`<summary>`、开头分割线在前、结尾分割线在继承内容之后且显示译文而非原始 key、两条线是同一元素种类且不可交互、提问用用户气泡呈现且逐字、回答用 assistant 呈现且 markdown 生效、无回答时不出 assistant 块且仍有结尾线、不占转录行)。
- 🗂 **「工作细节」控制行的文案改成主会话同款,fork 横幅也不再给出空展开器**:折叠行的标题此前是一句插件自造的「工作细节」,而主会话这里用的是 `message.turnProcess.*`——已结算且有实测耗时 → 「已完成,用时 1.2s」(耗时取该轮 `turn/end` 自己的 `durationMs`,与转录尾部的用量行走同一个 `formatDurationMs`,两处不可能打架);已结算但测不到耗时 → 「已完成」;仍在运行 → 「运行中…」并保持展开。另:fork 横幅只有在**确实有「分叉前的回答」**时才渲染可展开的 `<details>`,只有问题(或什么都没有)时退化成一行静态卡片——不再出现「点开是空的」。`sideChatWorkDetails` 从全部 21 份词典里退休,三个新文案进全部 21 份。
- 🧪 测试:`tests/sidechat-work-details-mode.spec.tsx`(三种模式的折叠行显示「已完成,用时 4s」且不出现「运行中」、运行行显示「运行中…」且不显示「已完成」、无 `turn/start` 的回合只显示「已完成」);`tests/sidechat-fork-point.spec.tsx`(既有用例保持:有回答时仍可展开)。
- ✂️ **fork 横幅不再把主会话的回答截成半句**:回答此前按 240 字符硬切,展开后读到一半就断在词中间。现在回答按 **4000 字符**整体携带(展开体本就滚动),并且任何截断都落在**边界**上:优先最后一个换行(整段保留)→ 句末标点(`。!?` 与 `. ! ? …`,标点保留)→ 最后一个空白(不切断单词)→ 只有整段是一个超长单词时才硬切。只有真的丢了内容才补 `…`,且省略号**计入**上限(`user` 仍是 400 字符的单行摘要,同样按边界切);装得下就原样照抄、不加任何标记。
- 🧪 测试:`tests/sidechat-fork-route.spec.ts`(回答超过旧 240 上限仍完整携带、按句末/换行/空白三种边界切且不切断单词、装得下时逐字一致且无省略号)。
- 🎨 **上一批记下的三处「欠账」令牌也换成了宿主真实的拼写,此前根本没画出来的颜色、边框与字号回来了**:`--dsw-alias-danger` / `--dsw-alias-bg-l2` / `--dsw-font-xs-regular-13` 在宿主 `ui-theme` 里零定义,引用它们的 11 条声明在 computed-value 阶段整条失效——侧边对话的错误横幅文案与失败行的文案/边框、侧栏页签与条目上的未读红点、终端面板的状态栏与错误块背景、以及 changes 面板的 markdown 正文与图谱说明的字体简写,全部没有画出来(或退回浏览器默认)。现在换成宿主真实定义的 `--dsw-alias-state-error-primary` / `--dsw-alias-bg-layer-2` / `--dsw-font-xs-13`(在宿主 `packages/client/ui-theme/src/styles/` 里逐个核实存在)。只改令牌名:那些规则里的其它属性、选择器与格式逐条不动。守卫的欠账名单随之清空,并把这三个旧拼写钉成「再写回来立即变红」的回归项;排版契约同步记录唯一一处跟着变的 paint 值。
- 🧪 测试:`tests/css-host-tokens.spec.ts`(欠账名单为空、三个旧名字作为回归项钉住、全部 `var(--dsw-…)` 引用无未解析)与 `tests/sidechat-typography-contract.spec.tsx`(错误横幅与失败行改走 `--dsw-alias-state-error-primary`,其余 12 条规则的排版快照不变)。
- 🧱 **侧边栏那些「一直没画出来」的边框回来了,并加了一条静态守卫**:CSS 变量在 computed-value 阶段解析,名字不存在会让**整条声明**失效——没有报错、没有提示。插件里有 6 处引用了宿主根本没定义的 `--dsw-alias-hairline`(模型按钮、可折叠行的引导竖线、相邻代码块之间的分隔线、composer 的兜底边框、以及 fork 横幅的卡片边与内部分隔),于是这些边线全部是空的。现在按视觉轻重换成宿主真实定义的 `--dsw-alias-border-l1` / `-l2`(composer 保留 `-l2-darkmode-thin`,只换兜底)。另加 `tests/css-host-tokens.spec.ts`:扫描 `src/client/**/*.css` 里所有 `var(--dsw-…)`,不带兜底的引用必须命中宿主令牌快照或插件自己声明的名字;已有的三处同类欠账(`--dsw-alias-danger` / `--dsw-alias-bg-l2` / `--dsw-font-xs-regular-13`)逐条列在测试里并标注应替换的宿主令牌,任一欠账被修好而未从名单移除也会红(名单只准变短)。
- 🧪 测试:`tests/css-host-tokens.spec.ts`(先自检扫描面,再断言无未解析引用、欠账名单无过期条目;把任一修复改回 `--dsw-alias-hairline` 立即变红)。
- 🌿 **侧边对话会说清它是从主会话的哪一刻分支出来的**:侧线程的日志以父会话整段历史作为 fork 种子开头,而 `sidechat.events` 路由在最后一个 inherited `session/end-seed` 标记处把它切掉——于是转录直接从侧问开始,读者看不出自己是从哪个主栏问题分支出来的,也看不到分支前主栏刚答了什么(父前缀从不过线,客户端无法自行重建)。现在**首拉**多带一个增量字段 `fork: { cutSeq, user?: {seq,text}, assistant?: {seq,text} }`:`cutSeq` 是切点标记自己的 seq(与转录的切刀同一个边界),`user` 取切点前最后一条**真实**用户消息(压缩检查点那种 replacement 不算,别把摘要当成读者问的话;运行时注入的 `time-context` / `tmux-context` / `plugin:…` 这类「用户消息」也不算,倒扫时跳过;只有图片的提问不出现该字段),`assistant` 取切点前最后一条 assistant 消息的 text 块(推理绝不泄漏),两段各自截头保留(提问 ≤400 字符、回答 ≤240)。delta 拉取不带该字段,`events`/`live`/`pending`/`truncated` 形状与取值不变。客户端在转录滚动区顶部、首行之前渲染一个默认收起的 `<details data-sidechat-fork-point>`:行上是「从主会话分支」+ 主栏那个问题 + 父会话标题;展开后是「分支前主会话的回答」+ 那段回答。两个文案进全部 21 份词典。
- 🧪 测试:`tests/sidechat-fork-route.spec.ts`(首拉带 cutSeq/user/assistant、events 仍是切后尾巴、压缩检查点被跳过、取最后一个 inherited 标记、截头保留、推理不泄漏、图片提问不出现 user、空种子只剩 cutSeq、无继承标记不带字段、delta 不带字段)与 `tests/sidechat-fork-point.spec.tsx`(默认收起且位于首行之上、行上三个信息、展开体里的回答与标题、无字段/空字段不出横幅、不是转录行也不改变行数)。
- 🗂 **侧边对话跟随主会话的「工作细节」设置**:主会话把一轮的思考与工具行收进一个可展开的「工作细节」控制行,侧边对话却完全不读这个偏好——同一段对话在右侧面板里永远是一堵过程行,读者把设置调成「精简」也毫无变化。现在侧边对话从宿主的公开设置服务(`ctx.get('configForms')` → `ui-chat`,结构性探针,不进 inject)读 `transcriptView` 与 `collapseTiming`,并按宿主同一套规则归一(`normal` / `expanded` → `detailed`;服务缺失、表单尚未 ready 或值不可用时保持客户端默认——Web 为 `detailed`、桌面壳为 `standard`)。`compact` / `standard` / `detailed` 下,**每一轮已结算的过程行**(思考 / 工具)收进一个 `<details data-sidechat-turn-fold>`(默认收起,行上按主会话的轮次文案显示,行仍在 DOM 里);**未结算的轮次**有同一控制行但保持展开;`verbose` 完全不折叠。提问与回答永远不进折叠。`collapseTiming` 为 `next-input` 时最新一轮保持展开、`completion`(默认)时照常收起;`standard` / `detailed` 还会把运行中的工具名/命令或思考首行写到该控制行的 tooltip 上,`compact` 只留通用文案。设置变更实时生效(订阅推送即重渲染,无需重挂载)。
- 🧪 测试:`tests/sidechat-work-details-mode.spec.tsx`(三种折叠模式各一控制行且默认收起、过程行仍在 DOM、提问/回答不在折叠内、`next-input` 保留最新一轮、`verbose` 不折叠、未结算轮次不隐藏、运行行在 `compact` 无细节而 `standard`/`detailed` 有、订阅推送实时跟随、无服务/未 ready/legacy 值都落到正确默认)。
-13
View File
@@ -18,19 +18,6 @@
- 🧪 `tests/sidechat-create-timeout-config.spec.ts` (the 120000 default, an explicit value passed through, the schema filling the default and accepting both bounds, out-of-range/fractional values rejected, the route building its signal from the config and never from 15000, the resolved default when no config is handed in, and a create rejection still reported as 500).
- 🧷 **A side conversation can now be started from a stored session opened in the sidebar.** `sidechat.start` resolved the parent only through the LIVE agent registry, so a conversation whose last turn predates this process was refused with `409 parent session "…" is not running` — yet "absent from the live registry" is not "not running": the host can resume it. A registry miss now asks `ctx.get('sessionController').resolveAgent(sessionId)` (a structural probe) and accepts only a real `{ agent }`; a missing service, a throwing resume, or a Session-domain `{ error }` keeps the existing 409 and its wording, and a parent that IS live never triggers a resume.
- 🧪 `tests/sidechat-start-cold-parent.spec.ts` (a cold parent is resumed through the host and the thread is created with the child bound to its parent; a live parent costs zero resumes; no service / a throw / `{ error }` each keep the 409 and create no thread).
- 🧵 **The fork point is no longer a card: a divider plus two ordinary messages, and the inherited text is no longer truncated.** The card (a disclosure with a caption and a body cut at 4000 characters) was judged wrong on the real thing — the reader wants the parent's own words, not a summary of them. `data-sidechat-fork-point` is now a plain container: a hairline divider carrying `sideChatForkDivider`, then the inherited QUESTION in the same presentation block this thread's own user bubbles use and through the same markdown renderer (the `data-sidechat-fork-question` hook stays, the text is verbatim), then the inherited ANSWER as ordinary assistant prose (`**emphasis**` → `<strong>`, a code span → `<code>`, verbatim). The exchange is bracketed by two matching divider lines: the opening `sideChatForkDivider` one and a closing `sideChatForkDividerEnd` one ("End of the pre-fork context"), the same element kind on the same style class, both plain non-focusable lines that never count as a transcript row. With no answer the block is the opening divider, the question, and the closing divider — never an empty assistant block. The route's 400 / 4000 caps and the boundary truncation are gone with it: `fork`'s `user` / `assistant` travel exactly as the log holds them, with no ellipsis. `sideChatForkBanner` / `sideChatForkAnswer` retire from all 21 dictionaries; `sideChatForkDivider` and `sideChatForkDividerEnd` arrive in all 21.
- 🧪 `tests/sidechat-fork-route.spec.ts` (an oversize question and answer come back verbatim, with no truncation mark); `tests/sidechat-fork-point.spec.tsx` (no `<details>`/`<summary>` inside the block, the divider comes first, the closing divider comes after the exchange and reads as translated copy, both dividers are the same non-interactive line that is never a transcript row, the question is presented as a user bubble and quoted verbatim, the answer is presented as assistant prose with markdown applied, no assistant block without an answer, and the block adds no transcript row).
- 🗂 **The work-details control line now speaks the main pane's language, and the fork banner stops offering an empty disclosure.** The fold line used to carry a plugin-invented caption; the host labels this same control from `message.turnProcess.*`. A settled turn with a measured duration now reads "Completed in 1.2s" (the duration is that turn's own `turn/end` measurement, formatted by the same `formatDurationMs` the usage line prints, so the two can never disagree), a settled turn without one reads "Completed", and a running turn reads "Running…" and stays open. The fork banner is now expandable ONLY when there really is a pre-fork answer: a fork summarised with just the question (or with neither part) degrades to a single static card, so it no longer opens onto nothing. `sideChatWorkDetails` retires from all 21 dictionaries; the three new copies are in all 21.
- 🧪 `tests/sidechat-work-details-mode.spec.tsx` (all three modes show "Completed in 4s" and never "Running…", the running line says "Running…" and never "Completed", and a turn without `turn/start` shows plain "Completed"); `tests/sidechat-fork-point.spec.tsx` (the existing cases: a fork with an answer is still expandable).
- ✂️ **The fork banner no longer cuts the parent's answer into half a sentence.** The answer used to be hard-truncated at 240 characters, so expanding it stopped mid-word. It is now carried up to **4000 characters** whole (the expanded body scrolls), and any cut lands on a BOUNDARY: the last line break (a whole paragraph survives) → sentence-ending punctuation (`。!?` and `. ! ? …`, punctuation kept) → the last whitespace (a word is never split) → a hard cut only when the whole text is one over-long word. The `…` appears only when something was really lost and counts toward the cap (`user` stays a 400-character single-line summary, cut the same way); a text that fits is carried verbatim with no mark at all.
- 🧪 `tests/sidechat-fork-route.spec.ts` (the answer is carried complete well past the old 240 cap, all three boundary kinds are honoured without splitting a word, and a fitting text comes back byte-identical with no mark).
- 🎨 **The three "debt" tokens recorded last time are renamed to spellings the host actually defines, restoring colours, borders and font sizes that never painted.** `--dsw-alias-danger` / `--dsw-alias-bg-l2` / `--dsw-font-xs-regular-13` are defined nowhere in the host theme, so the 11 declarations that referenced them were invalid at computed-value time — the side chat's error banner copy and the failed row's copy/border, the unread dots on sidebar tabs and entries, the terminal panel's status bar and error-block background, and the changes pane's markdown body and graph caption font shorthand all painted nothing (or fell back to the browser default). They now use the host's real `--dsw-alias-state-error-primary` / `--dsw-alias-bg-layer-2` / `--dsw-font-xs-13`, each verified present under `packages/client/ui-theme/src/styles/`. Only the token names changed: no other property, selector or formatting in those rules was touched. The guard's debt list is now empty and pins the three retired spellings as regressions that fail the suite if they come back, and the typography contract records the one paint value that moved with them.
- 🧪 `tests/css-host-tokens.spec.ts` (empty debt list, the three retired names pinned as regressions, every `var(--dsw-...)` reference resolves) and `tests/sidechat-typography-contract.spec.tsx` (the error banner and failed row paint through `--dsw-alias-state-error-primary`; the other 12 rules' typography snapshot is unchanged).
- 🧱 **The sidebar's borders that never appeared are back, with a static guard behind them.** A CSS custom property resolves at computed-value time, so an unknown name invalidates the WHOLE declaration — silently, with nothing to notice. Six declarations referenced `--dsw-alias-hairline`, which the host never defines (the model button, the guide line beside collapsible row bodies, the separator between adjacent code blocks, the composer's fallback border, and the fork banner's card edge plus its inner divider), so every one of those lines was simply absent. They now use the host's real `--dsw-alias-border-l1` / `-l2` by visual weight (the composer keeps `-l2-darkmode-thin`, only its fallback changed). `tests/css-host-tokens.spec.ts` scans every `var(--dsw-...)` in `src/client/**/*.css`: a reference without a fallback must name a host snapshot token or one the plugin declares itself. Three pre-existing debts of the same class (`--dsw-alias-danger` / `--dsw-alias-bg-l2` / `--dsw-font-xs-regular-13`) are listed with the host token that should replace them, and the list may only shrink — paying one debt without removing it fails the suite.
- 🧪 `tests/css-host-tokens.spec.ts` (the scan self-checks first, then asserts no unresolved reference and no stale debt entry; reverting any fix to `--dsw-alias-hairline` turns it red).
- 🌿 **The side chat says where it forked off the main conversation.** A side thread's log opens with the parent log as a fork seed, and `sidechat.events` cuts it at the last inherited `session/end-seed` marker — invisibly, so the transcript started on the side question with no hint of which main-pane question it continued, and the parent prefix never crosses the wire for the client to reconstruct. The FIRST pull now carries an additive `fork: { cutSeq, user?: {seq,text}, assistant?: {seq,text} }`: `cutSeq` is the cut marker's own seq (the same boundary the transcript cuts at), `user` is the last REAL user message before the cut (a replacement such as a compaction checkpoint is never presented as the reader's question, a runtime injection — `time-context`, `tmux-context`, `plugin:…` — is skipped too because it is logged as a user message the reader never typed, and an image-only prompt leaves the part out), `assistant` is the last assistant message's text blocks before the cut (reasoning never leaks), and each part keeps its opening (question ≤400 chars, answer ≤240). A delta pull carries no such field, and `events`/`live`/`pending`/`truncated` keep their shapes and values. The transcript renders a collapsed `<details data-sidechat-fork-point>` above the first row inside the scroller: the line reads "forked from the main session" plus the main-pane question and the parent session's title, and expanding it shows the pre-fork answer under its own heading. Both strings are in all 21 dictionaries.
- 🧪 `tests/sidechat-fork-route.spec.ts` (cutSeq/user/assistant on the first pull, events still the cut tail, a compaction checkpoint skipped, the LAST inherited marker read, head-kept caps, no reasoning leak, no user part for an image-only prompt, `{cutSeq}` alone for an empty seed, no field without an inherited marker, no field on a delta pull) and `tests/sidechat-fork-point.spec.tsx` (collapsed by default and above the first row, the three facts on the line, the answer and its heading behind it, no banner without the field or with an empty one, not a transcript row and no change to the row count).
- 🗂 **The side chat follows the main conversation's "work details" setting.** The main pane folds a turn's reasoning and tool rows behind one expandable control; the side chat read no preference at all, so the same conversation was a wall of process rows in the panel no matter what the reader had chosen. The transcript now reads `transcriptView` and `collapseTiming` from the host's public settings service (`ctx.get('configForms')` → `ui-chat`, a structural probe — no inject, no value-import of the settings package) and normalizes them exactly like the host (`normal` / `expanded` → `detailed`; a missing service, a form that is not ready, or an unusable value keep the client default — `detailed` on the Web, `standard` on the desktop shell). Under `compact` / `standard` / `detailed` every SETTLED turn's work rows (reasoning / tools) fold into one `<details data-sidechat-turn-fold>` (closed by default, its line carrying the host's turn copy, the rows still in the DOM); a turn that has not ended yet keeps the same control OPEN; `verbose` folds nothing at all. The question and the answer never enter the fold. `collapseTiming: next-input` leaves the newest completed turn open while the default `completion` folds it, and `standard` / `detailed` put the running tool/command or the first line of streaming reasoning on the control's tooltip where `compact` keeps the bare label. A settings change applies live (a subscription push re-renders the mounted transcript; no remount).
- 🧪 `tests/sidechat-work-details-mode.spec.tsx` (one control per settled turn in all three folding modes and closed by default, the work rows still in the DOM, question/answer outside the fold, `next-input` keeping the newest turn open, `verbose` folding nothing, a running turn never hidden, the running line generic in `compact` and detailed in `standard` / `detailed`, a subscription push followed live, the correct defaults without a service / while not ready / for legacy values).