|
| 1 | +# Deep Copilot v0.41.0 |
| 2 | + |
| 3 | +> 中文版在下方 / English notes below. |
| 4 | +
|
| 5 | +## 🇨🇳 中文 |
| 6 | + |
| 7 | +主题:**Context Window 优化套件 · 三个新斜杠命令 · 底部 Context Ring · 会话切换闪屏修复** |
| 8 | + |
| 9 | +### ✨ 新功能 1:上下文窗口管理重构(Issue #142) |
| 10 | + |
| 11 | +长对话越来越容易吃满 token 窗口,0.41.0 把"上下文管理"做成了一套完整的机制: |
| 12 | + |
| 13 | +- **结构感知截断(structure-aware truncation)** |
| 14 | + - 保留最新工具调用的**完整内容** |
| 15 | + - 较旧的轮次自动折叠为"摘要骨架"(保留语义,丢弃大段冗余) |
| 16 | +- **同文件读取去重** |
| 17 | + - 多次读取同一路径时,**只保留最后一次完整内容** |
| 18 | + - 较早的读取被折叠为占位符:`<file path=... read-collapsed='true'/>` |
| 19 | +- **滚动摘要(rolling summary)** |
| 20 | + - 超阈值时按需调用模型,把更早的对话压缩为结构化摘要节点 |
| 21 | + - 会话历史持久化层(`session-store.js`)已适配,重新加载会话能正确回放摘要节点 |
| 22 | +- **MCP per-server opt-out**:可以为某个 MCP server 显式关闭上下文压缩参与 |
| 23 | +- **大文件读取提示**:`file-read.js` 在读取大文件时附带 `read-large-file` hint,引导模型先用 grep 而非整文件读入 |
| 24 | + |
| 25 | +### ✨ 新功能 2:三个新斜杠命令 |
| 26 | + |
| 27 | +| 命令 | 说明 | |
| 28 | +|---|---| |
| 29 | +| `/compact [focus]` | 立即压缩当前会话历史;`[focus]` 可选,作为摘要方向偏置;会自动合并工作区根目录下的 `.deepcopilot/compact.md` 或 `CLAUDE.md` 中的项目级 compact 指令 | |
| 30 | +| `/context` | 弹出当前会话的 token 占用细分(system / messages / tools / files / hints) | |
| 31 | +| `/fork [name]` | 把当前会话从某一条消息派生为一个**新会话**,保留该消息之前的全部上下文作为起点 | |
| 32 | + |
| 33 | +### ✨ 新功能 3:底部 Context Ring 指示器 |
| 34 | + |
| 35 | +- 替换原本底栏右下角的状态点(`#foot .dot`) |
| 36 | +- 新的环形进度(`#ft-ctx`)实时显示上下文窗口占用百分比 |
| 37 | +- 颜色按阈值渐变:`<60%` 绿 → `<85%` 黄 → `<100%` 橙 → 满 红 |
| 38 | +- 点击环形展开 popover,显示与 `/context` 一致的占用细分 |
| 39 | +- 数据源:agent-loop 每轮回写的 `ctxUsage` 事件 |
| 40 | + |
| 41 | +### 🐞 修复:会话切换闪屏 / 滚动条抖动(Issue #143) |
| 42 | + |
| 43 | +切走再切回正在运行的会话时,缓冲事件被同步全部重放,每个事件触发一次 `requestAnimationFrame` 滚动,导致: |
| 44 | + |
| 45 | +- 聊天面板明显闪烁 |
| 46 | +- 滚动条来回抖动 |
| 47 | +- 重放期间用户无法稳定阅读 |
| 48 | + |
| 49 | +**修复手法**: |
| 50 | + |
| 51 | +- `_loadSession` 用 `setTimeout(..., 0)` 把事件重放推到下一个宏任务 |
| 52 | +- 重放序列由 `replayStart` / `replayEnd` 信封包裹 |
| 53 | +- Webview 端新增 `_replaying` 标志,在重放期间 `ascroll()` 静默 |
| 54 | +- 重放结束时一次性滚到底部,体验与单条事件流入一致 |
| 55 | + |
| 56 | +### 🛠 内部改动 |
| 57 | + |
| 58 | +- `src/chat/agent-loop.js` / `src/chat/provider.js`:上下文窗口管理主逻辑、`ctxUsage` 事件源 |
| 59 | +- `src/chat/compact.js`:滚动摘要 + `/compact` 实现 |
| 60 | +- `src/chat/context-refs.js`:`/context` token 细分 |
| 61 | +- `src/chat/session-store.js`:摘要节点的持久化与回放 |
| 62 | +- `src/tools/file-read.js`:大文件 hint 输出 |
| 63 | +- `src/api/anthropic-client.js` / `src/api/openai-client.js`:客户端小幅清理 |
| 64 | +- `src/errors.js`:错误文案微调 |
| 65 | +- `media/chat.{css,js}` / `src/webview/html.js`:`#ft-ctx` 环形指示器 + popover;`_replaying` 抑制 |
| 66 | +- `src/utils/i18n.js`:新增上下文管理相关中英双语文案 |
| 67 | + |
| 68 | +### 🔒 安全 / 兼容性 |
| 69 | + |
| 70 | +- 不放宽 Webview CSP |
| 71 | +- 不引入新运行时依赖(运行时仍仅 `@anthropic-ai/sdk` / `openai` / `js-tiktoken`) |
| 72 | +- 滚动摘要使用既有 API 通道,无新网络入口 |
| 73 | +- 所有 token 统计在本地完成,不上送任何额外信息 |
| 74 | + |
| 75 | +--- |
| 76 | + |
| 77 | +## 🇺🇸 English |
| 78 | + |
| 79 | +Theme: **Context-window overhaul · three new slash commands · footer context ring · session-switch flash fix** |
| 80 | + |
| 81 | +### ✨ Feature 1 — Context-window overhaul (Issue #142) |
| 82 | + |
| 83 | +Long conversations chew through the token window quickly. 0.41.0 turns "context management" into a real mechanism: |
| 84 | + |
| 85 | +- **Structure-aware truncation** |
| 86 | + - Latest tool results kept **verbatim** |
| 87 | + - Older turns collapse to summary skeletons (semantics preserved, bulk dropped) |
| 88 | +- **Per-file read dedup** |
| 89 | + - Multiple reads of the same path keep only the **latest** payload |
| 90 | + - Earlier reads become placeholders: `<file path=... read-collapsed='true'/>` |
| 91 | +- **Rolling summary fallback** |
| 92 | + - When thresholds are crossed, the model is invoked on-demand to compress older history into structured summary nodes |
| 93 | + - `session-store.js` persists & replays these nodes correctly when sessions are reloaded |
| 94 | +- **MCP per-server opt-out**: any MCP server can explicitly opt out of compaction |
| 95 | +- **Large-file read hint**: `file-read.js` now ships a `read-large-file` hint nudging the model to grep first instead of slurping the whole file |
| 96 | + |
| 97 | +### ✨ Feature 2 — Three new slash commands |
| 98 | + |
| 99 | +| Command | Behaviour | |
| 100 | +|---|---| |
| 101 | +| `/compact [focus]` | Force-compacts the active session; optional `focus` biases the summarisation; merges project-level instructions from `.deepcopilot/compact.md` or `CLAUDE.md` in the workspace root | |
| 102 | +| `/context` | Opens a breakdown popover (system / messages / tools / files / hints) of the current token spend | |
| 103 | +| `/fork [name]` | Forks the current session from a chosen message into a brand-new session, with that message as the new origin | |
| 104 | + |
| 105 | +### ✨ Feature 3 — Footer context ring |
| 106 | + |
| 107 | +- Replaces the legacy footer status dot (`#foot .dot`) |
| 108 | +- The new ring indicator (`#ft-ctx`) shows live context-window usage |
| 109 | +- Colour ramps green → yellow → orange → red across the 60% / 85% / 100% thresholds |
| 110 | +- Click to open the same breakdown popover used by `/context` |
| 111 | +- Data source: the `ctxUsage` event written by the agent loop after every round |
| 112 | + |
| 113 | +### 🐞 Fix — Session-switch flash / scrollbar jitter (Issue #143) |
| 114 | + |
| 115 | +Switching away from and back to a running session previously replayed every buffered event in a tight loop, each one scheduling its own RAF scroll-to-bottom. Symptoms: |
| 116 | + |
| 117 | +- Visible flash in the chat panel |
| 118 | +- Scrollbar oscillating up/down |
| 119 | +- Unreadable during the replay burst |
| 120 | + |
| 121 | +**Fix**: |
| 122 | + |
| 123 | +- `_loadSession` defers the replay via `setTimeout(..., 0)` into the next macrotask |
| 124 | +- The replay burst is wrapped with `replayStart` / `replayEnd` envelopes |
| 125 | +- The webview adds a `_replaying` flag that silences `ascroll()` for the duration |
| 126 | +- A single final scroll-to-bottom is performed on `replayEnd` |
| 127 | + |
| 128 | +### 🛠 Internals |
| 129 | + |
| 130 | +- `src/chat/agent-loop.js` / `src/chat/provider.js` — context-window management core + `ctxUsage` event source |
| 131 | +- `src/chat/compact.js` — rolling summary + `/compact` implementation |
| 132 | +- `src/chat/context-refs.js` — `/context` token breakdown |
| 133 | +- `src/chat/session-store.js` — persist & replay summary nodes |
| 134 | +- `src/tools/file-read.js` — large-file hint output |
| 135 | +- `src/api/anthropic-client.js` / `src/api/openai-client.js` — minor cleanups |
| 136 | +- `src/errors.js` — copy tweaks |
| 137 | +- `media/chat.{css,js}` / `src/webview/html.js` — `#ft-ctx` ring + popover; `_replaying` suppression |
| 138 | +- `src/utils/i18n.js` — new bilingual strings for context management |
| 139 | + |
| 140 | +### 🔒 Security / compatibility |
| 141 | + |
| 142 | +- Webview CSP unchanged |
| 143 | +- No new runtime dependencies (still just `@anthropic-ai/sdk` / `openai` / `js-tiktoken`) |
| 144 | +- Rolling summary uses the existing API channel — no new network entrypoints |
| 145 | +- All token accounting happens locally; nothing extra is transmitted |
0 commit comments