Keep compaction summary previews in Chat

This commit is contained in:
yudshj committed 2026-11-19 13:37:41 +08:00
1 parent c435f12473
commit 45e873da0b
46 files changed
+175 -671

No files matched your search

-6
View File
@@ -54,12 +54,6 @@ const COMMAND_ROW_EXPECTED = fileURLToPath(new URL('../../../snapshots/web/seede
const FEEDBACK_ROW_EXPECTED = fileURLToPath(new URL('../../../snapshots/web/seeded-history/feedback-row.expected.md', import.meta.url))
const FILE_PREVIEW_EXPECTED = join(SNAPSHOT_DIR, 'file-preview.expected.md')
const CHECKPOINT_SIDEBAR_EXPECTED = join(SNAPSHOT_DIR, 'checkpoint-sidebar.expected.md')
// Copies of MARKDOWN_BODY_ID in
// packages/client/ui-sidebar-documentpreview/src/client/markdown/index.ts and
// of the English `preview.title` in
// packages/client/ui-compaction/src/client/locales.ts. apps/web does not
// declare either feature plugin as a dependency, so this spec cannot import
// their source values.
const CHECKPOINT_TITLE = 'Context summary'
const MODE = webSnapshotMode()
const SEED_ID = 'seeded-history-web-e2e'
-1
View File
@@ -5436,7 +5436,6 @@ These load from a `cordis.yml` entry with no `config:` block; they declare no co
| `@deepseek-ai/dsh-client-ui-brand-official` | — | [`packages/client/ui-brand-official/src/index.ts`](../packages/client/ui-brand-official/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-chat` | — | [`packages/client/ui-chat/src/index.ts`](../packages/client/ui-chat/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-commands` | — | [`packages/client/ui-commands/src/index.ts`](../packages/client/ui-commands/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-compaction` | — | [`packages/client/ui-compaction/src/index.ts`](../packages/client/ui-compaction/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-connector-account` | — | [`packages/client/ui-connector-account/src/index.ts`](../packages/client/ui-connector-account/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-conversation` | — | [`packages/client/ui-conversation/src/index.ts`](../packages/client/ui-conversation/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-cordis` | — | [`packages/extensions/ui-cordis/src/index.ts`](../packages/extensions/ui-cordis/src/index.ts) |
-1
View File
@@ -5438,7 +5438,6 @@ export interface Config {
| `@deepseek-ai/dsh-client-ui-brand-official` | — | [`packages/client/ui-brand-official/src/index.ts`](../packages/client/ui-brand-official/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-chat` | — | [`packages/client/ui-chat/src/index.ts`](../packages/client/ui-chat/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-commands` | — | [`packages/client/ui-commands/src/index.ts`](../packages/client/ui-commands/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-compaction` | — | [`packages/client/ui-compaction/src/index.ts`](../packages/client/ui-compaction/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-connector-account` | — | [`packages/client/ui-connector-account/src/index.ts`](../packages/client/ui-connector-account/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-conversation` | — | [`packages/client/ui-conversation/src/index.ts`](../packages/client/ui-conversation/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-cordis` | — | [`packages/extensions/ui-cordis/src/index.ts`](../packages/extensions/ui-cordis/src/index.ts) |
-2
View File
@@ -176,7 +176,6 @@ flowchart TD
pkg_client_ui_brand_official["client-ui-brand-official"]
pkg_client_ui_chat["client-ui-chat"]
pkg_client_ui_commands["client-ui-commands"]
pkg_client_ui_compaction["client-ui-compaction"]
pkg_client_ui_connector_account["client-ui-connector-account"]
pkg_client_ui_context_menu["client-ui-context-menu"]
pkg_client_ui_conversation["client-ui-conversation"]
@@ -1667,7 +1666,6 @@ flowchart TD
| [`client-ui-brand-official`](../packages/client/ui-brand-official) | `client` | — |
| [`client-ui-chat`](../packages/client/ui-chat) | `client` | — |
| [`client-ui-commands`](../packages/client/ui-commands) | `client` | — |
| [`client-ui-compaction`](../packages/client/ui-compaction) | `client` | — |
| [`client-ui-connector-account`](../packages/client/ui-connector-account) | `client` | — |
| [`client-ui-context-menu`](../packages/client/ui-context-menu) | `client` | — |
| [`client-ui-conversation`](../packages/client/ui-conversation) | `client` | — |
-2
View File
@@ -178,7 +178,6 @@ flowchart TD
pkg_client_ui_brand_official["client-ui-brand-official"]
pkg_client_ui_chat["client-ui-chat"]
pkg_client_ui_commands["client-ui-commands"]
pkg_client_ui_compaction["client-ui-compaction"]
pkg_client_ui_connector_account["client-ui-connector-account"]
pkg_client_ui_context_menu["client-ui-context-menu"]
pkg_client_ui_conversation["client-ui-conversation"]
@@ -1669,7 +1668,6 @@ flowchart TD
| [`client-ui-brand-official`](../packages/client/ui-brand-official) | `client` | — |
| [`client-ui-chat`](../packages/client/ui-chat) | `client` | — |
| [`client-ui-commands`](../packages/client/ui-commands) | `client` | — |
| [`client-ui-compaction`](../packages/client/ui-compaction) | `client` | — |
| [`client-ui-connector-account`](../packages/client/ui-connector-account) | `client` | — |
| [`client-ui-context-menu`](../packages/client/ui-context-menu) | `client` | — |
| [`client-ui-conversation`](../packages/client/ui-conversation) | `client` | — |
@@ -12,5 +12,5 @@
en: 13655501c3ad3c14
zh: 5ca7d430dc797250
/shared-sidebar-content-previews/migration:
en: 465c685a88e300d4
zh: b6f25e9308b5060f
en: 7494c41cce37c0e3
zh: d881da3d8ca1d0f5
@@ -18,4 +18,4 @@ Custom document bodies use the `sidebar.right.document.body` Factory. Its input
1. Close unavailable saved plan tabs and reopen their plan or review cards. Include `@deepseek-ai/dsh-client-ui-sidebar-documentpreview` in compositions that need previews; without its optional service, plan openers are disabled.
2. Open text with `ctx.sidebarRight.openContent({ mediaType: 'text/markdown', text }, { title, key })`. The method opens the sidebar directly; use `destination: 'float'` for a floating panel. Reopen previews after a browser reload.
3. Mount custom document renderers through `sidebar.right.document.body`, supplying `rendererId` and `useTabInfo`. Pass `baseAddress: resourceAddress` for workspace files and omit it for content without a file base.
4. Pass the marker’s non-null `summaryEventSeq` to the compaction preview service to display the recorded summary.
4. Use the marker’s `summaryEventSeq` to read its recorded summary from Session history.
@@ -18,4 +18,4 @@ description: 重新打开已保存的计划预览,并把自定义文档正文
1. 关闭旧布局中不可用的计划标签,并从计划或审批卡片重新打开。需要预览的组合应加载 `@deepseek-ai/dsh-client-ui-sidebar-documentpreview`;它的可选服务缺席时,计划打开按钮保持禁用。
2. 调用 `ctx.sidebarRight.openContent({ mediaType: 'text/markdown', text }, { title, key })` 打开正文。方法直接打开侧栏,`destination: 'float'` 使用浮窗。刷新浏览器后请重新打开预览。
3. 通过 `sidebar.right.document.body` 挂载自定义渲染器,提供 `rendererId` 和 `useTabInfo`。工作区文件传入 `baseAddress: resourceAddress`,没有文件基址的正文省略它。
4. 将压缩标记上非空的 `summaryEventSeq` 传给压缩预览服务以显示记录的摘要。
4. 使用压缩标记上的 `summaryEventSeq` 从会话历史读取对应摘要。
-5
View File
@@ -329,11 +329,6 @@
- id: ui-sidebar-documentpreview
name: '@deepseek-ai/dsh-client-ui-sidebar-documentpreview'
# Compaction checkpoints in the content tab: the replacement message the
# model reads after a compact, opened from Chat's compact rows.
- id: ui-compaction
name: '@deepseek-ai/dsh-client-ui-compaction'
# Web profiles opt in; Desktop retains sandboxed HTTP(S) Browser tabs.
- id: ui-sidebar-browser
name: '@deepseek-ai/dsh-client-ui-sidebar-browser'
-1
View File
@@ -87,7 +87,6 @@
"@deepseek-ai/dsh-client-ui-brand-official": "workspace:*",
"@deepseek-ai/dsh-client-ui-chat": "workspace:*",
"@deepseek-ai/dsh-client-ui-commands": "workspace:*",
"@deepseek-ai/dsh-client-ui-compaction": "workspace:*",
"@deepseek-ai/dsh-client-ui-connector-account": "workspace:*",
"@deepseek-ai/dsh-client-ui-context-menu": "workspace:*",
"@deepseek-ai/dsh-client-ui-conversation": "workspace:*",
+2 -2
View File
@@ -15,8 +15,8 @@
en: 1eb35b015a6c423f
zh: a8a3dceee2c9e943
/client-web-gui-browser-half/packages:
en: e6ff2dcda65beacf
zh: 98f103a7c8028160
en: a88259ae25f1c6d4
zh: 3bc18746457f7dbf
/client-web-gui-browser-half/related-documentation:
en: d1d506e68fab7333
zh: 1a90fe6f3f8f24a9
-1
View File
@@ -48,7 +48,6 @@ The kernel packages boot and serve the page; the UI feature packages present it.
| [`ui-sidebar/`](ui-sidebar/README.md) | Presents workspace and session navigation | — |
| [`ui-sidebar-right/`](ui-sidebar-right/README.md) | Owns the right Sidebar and its tab types | `ctx.sidebarRight`, `ctx.sidebarRightTabs` |
| [`ui-sidebar-documentpreview/`](ui-sidebar-documentpreview/README.md) | Displays documents in right Sidebar tabs: workspace files, and in-memory content that is not a workspace file | `ctx.documentPreviews` |
| [`ui-compaction/`](ui-compaction/README.md) | Opens recorded compaction summaries in temporary sidebar tabs | `ctx.compactionPreviews` |
| [`ui-sidebar-browser/`](ui-sidebar-browser/README.md) | Browses sandboxed HTTP(S) pages, including loopback services, in right-Sidebar tabs | — |
| [`resources/`](resources/README.md) | Unified resource model: protocol providers behind the `useResource` session standard hook | `ctx.resources` |
| [`ui-sidebar-files/`](ui-sidebar-files/README.md) | The workspace files page and one workspace tree per pane beside docked and floating previews | — |
-1
View File
@@ -48,7 +48,6 @@ kind: "package-group"
| [`ui-sidebar/`](ui-sidebar/README.zh.md) | 展示工作区与会话导航 | — |
| [`ui-sidebar-right/`](ui-sidebar-right/README.zh.md) | 管理右侧 Sidebar 及其 tab 类型 | `ctx.sidebarRight`, `ctx.sidebarRightTabs` |
| [`ui-sidebar-documentpreview/`](ui-sidebar-documentpreview/README.zh.md) | 在右侧 Sidebar 的 tab 中显示文档:工作区文件,以及不是工作区文件的内存内容 | `ctx.documentPreviews` |
| [`ui-compaction/`](ui-compaction/README.zh.md) | 在临时侧栏标签中显示已记录的压缩摘要 | `ctx.compactionPreviews` |
| [`ui-sidebar-browser/`](ui-sidebar-browser/README.zh.md) | 在右侧 Sidebar tab 中浏览 sandboxed HTTP(S) 页面,包括 loopback 服务 | — |
| [`resources/`](resources/README.zh.md) | 统一资源模型:`useResource` 会话标准钩子背后的协议提供方 | `ctx.resources` |
| [`ui-sidebar-files/`](ui-sidebar-files/README.zh.md) | 工作区文件页,以及停靠与浮动文件预览旁每个分栏一棵的工作区目录树 | — |
+2 -2
View File
@@ -21,8 +21,8 @@
en: 8ca277dc7fed699f
zh: 167478dba50f3904
/deepseek-ai-dsh-client-ui-chat/command-and-failure-rows:
en: 89a525179bcd92a7
zh: 2a4795cc1b451f67
en: 6b89f99bb3d378d9
zh: 18e7b084164577ba
/deepseek-ai-dsh-client-ui-chat/inherited-history-divider:
en: a191f90e9a64f6fe
zh: 8e91b8660f9baa18
+1 -1
View File
@@ -70,7 +70,7 @@ Text and reasoning contribute to Assistant visibility only when they contain a n
Subagent result notices use the Users icon and show only the localized execution outcome in their heading, without a task description or child ID. Completed means that execution ended normally, not that its output passed validation. Historical notices without a readable outcome retain the generic title; unfamiliar outcomes display “Subagent run ended unexpectedly”. Expanded notices preserve their original model-facing body.
Automatic compaction shows a progress row until a checkpoint lands or the operation ends. Completed automatic and manual rows show the replaced item and token counts. The optional `compactionPreviews` service opens the recorded `compaction/summary` text in a temporary sidebar tab. Rows disable the opener while the service or summary sequence is unavailable; the row displays read errors.
Automatic compaction shows a progress row until a checkpoint lands or the operation ends. Completed automatic and manual rows show the replaced item and token counts. Chat opens the recorded `compaction/summary` text in a temporary sidebar tab. Rows disable the opener while the document viewer or summary sequence is unavailable; the row displays read errors.
Generic command rows retain the ordinary command glyph in every lifecycle state; failure remains explicit through the row state and summary. Every terminal Turn failure renders its inline red-dot row; a quota failure's row states the neutral `message.failure.quota` copy instead of the provider message. The transient notice for a newly appended `QUOTA` or `ACCOUNT_QUOTA` comes from this package's frame-wide entry in `shell.overlay`, which outlives the Chat panel: it offers the one live notice to the `shell.quota-notice` chain and falls back to its own warning Toast, while an entry that claims the code replaces that fallback. Only Sessions whose `conversation` retain facet a rendering reference currently holds publish; quota failures in Sessions this Client never opened, or that occur while a Session is kept only as a recent view, do not, and resuming the facet does not replay them. A newer notice replaces the current one unless a claiming entry retains it with `keepOpen()`: that call returns a release the caller owns and must run on unmount, any live hold keeps the claiming entry mounted and drops later notices, and releasing resumes later notices without replaying the dropped ones. The fallback Toast has no deferral of its own: while the Desktop account's opaque native Platform page covers the document, it still runs underneath and its display timer may elapse unseen, dismissing the notice itself, so only the persistent failure row remains. A release drops only its own hold, so one that runs after a dismissal or a newer hold leaves that newer hold intact. Dismissal and sign-out clear every hold, and dropped notices are not queued while their persistent failure rows still render. History replacement and pagination never publish a notice. Intermediate retries do not create a terminal row; output-token limits use the amber warning dot. A Turn that restart recovery closed as `interrupted` renders a localized stopped row stating that the DSH process exited mid-Turn, without a code chip, and its process summary reads Stopped.
+1 -1
View File
@@ -70,7 +70,7 @@ Assistant 尝试结束且没有可见消息时,Chat 隐藏已发布的 Node,
子智能体结果通知使用 Users 图标,标题仅显示本地化的执行状态,不附加任务描述或子智能体 ID。完成表示执行正常结束,不表示输出已通过验证。历史通知没有可读取的结束状态时保留通用标题;未知状态显示“子智能体异常结束”。展开后的通知保留原始模型可见正文。
自动压缩从开始到生成 checkpoint 或结束期间显示进度行。自动和手动压缩完成后显示替换条目数与 token 数。可选的 `compactionPreviews` 服务在临时侧栏标签中打开 `compaction/summary` 记录的正文。服务或摘要序号不可用时按钮禁用,读取错误显示在压缩行中。
自动压缩从开始到生成 checkpoint 或结束期间显示进度行。自动和手动压缩完成后显示替换条目数与 token 数。Chat 在临时侧栏标签中打开 `compaction/summary` 记录的正文。文档预览或摘要序号不可用时按钮禁用,读取错误显示在压缩行中。
通用指令行在所有生命周期状态中都保留普通指令图标;失败仍通过行状态与摘要表达。每个终止轮次都渲染自己的红点行;欠费失败的行使用中立的 `message.failure.quota` 文案,而不是提供方消息。新追加的 `QUOTA` 或 `ACCOUNT_QUOTA` 产生的瞬时提示来自本包注册在 `shell.overlay` 的全局条目,它不随 Chat 面板消失:该条目把唯一一条实时提示交给 `shell.quota-notice` 链,并在无人接管时回退到自己的警告 Toast,接管该错误码的条目会替换该回退。只有当前被渲染方引用保留了 `conversation` retain 子要素的 Session 会发布提示;本 Client 从未打开的 Session,以及仅作为最近访问会话保留期间发生的欠费都不会发布,恢复保留后也不补发。更新的提示会替换当前提示,除非认领条目用 `keepOpen()` 保持住当前提示:该调用返回一个由调用方持有、必须在卸载时调用的释放函数,只要存在保持,认领条目就继续挂载,后续提示被丢弃,释放后恢复后续提示但不重放已丢弃的提示。回退 Toast 自身没有延后策略:当 Desktop 账号的不透明原生 Platform 页盖住本页时,它仍会在下方运行,其显示计时器可能在不可见时走完并自行撤下提示,因此只留下持久化失败行。释放只移除自己的保持,因此它在关闭或更新的保持之后执行时不会影响更新的保持。关闭与退出登录会清空所有保持;被丢弃的提示不排队,其对应的持久化失败行仍会渲染。历史替换和分页不会发布提示。中间重试不会创建终止行;输出 token 上限使用琥珀色警告点。重启恢复以 `interrupted` 结束的轮次会渲染本地化的停止行,说明 DSH 进程在轮次中途退出,不显示代码标签,其过程摘要显示“已停止”。
+1 -2
View File
@@ -100,8 +100,7 @@
"@deepseek-ai/dsh-settings": "workspace:*",
"@deepseek-ai/dsh-client-product-analytics": "workspace:*",
"@deepseek-ai/dsh-client-ui-file-drag": "workspace:*",
"@deepseek-ai/dsh-client-ui-context-menu": "workspace:*",
"@deepseek-ai/dsh-client-ui-compaction": "workspace:*"
"@deepseek-ai/dsh-client-ui-context-menu": "workspace:*"
},
"dependencies": {
"@deepseek-ai/schemastery": "workspace:~"
@@ -0,0 +1,76 @@
/** Session-bound Markdown previews for manual and automatic compaction rows. */
import type { Context } from '@deepseek-ai/cordis'
import type { SessionAddress } from '@deepseek-ai/dsh-api-session-controller/types'
import type {} from '@deepseek-ai/dsh-client-ui-sidebar-documentpreview/client'
import { createSnapshotStore } from '@deepseek-ai/dsh-client-store'
import type { SessionId } from '@deepseek-ai/dsh-session/types'
import { NS } from '../locale.ts'
import type { CompactionRowInjected } from './CompactionItem.tsx'
/** Bind summary reads to the requesting row and the document viewer lifetime.
* @param ctx - Chat plugin context.
* @returns the preview action and availability hook for a Session.
*/
export function compactionRows(ctx: Context): (sessionId: SessionId) => CompactionRowInjected {
const compactionPreview = createSnapshotStore(false)
const t = ctx.locale.bind(NS)
let lifetime: AbortController | undefined
ctx.inject(['documentPreviews'], scope => scope.effect(() => {
const controller = new AbortController()
lifetime = controller
compactionPreview.set(true)
return () => {
controller.abort()
lifetime = undefined
compactionPreview.set(false)
}
}))
return sessionId => ({
hooks: { compactionPreview },
async openCompaction(summarySeq, signal) {
if (lifetime === undefined) return null
const child = ctx.sessions.subagentAddress(sessionId)
const address: SessionAddress = child === undefined ? { kind: 'session', sessionId } : { kind: 'subagent', ...child }
const active = AbortSignal.any([signal, lifetime.signal])
const cancelled = (): boolean => active.aborted
if (cancelled()) return null
let result
try {
result = await ctx.remote.session.events({ address, throughSeq: summarySeq, maxMessages: 1 }, active)
} catch (_error) {
// A cancelled row has no read failure to display.
return cancelled() ? null : t('message.compaction.readFailed')
}
if (cancelled()) return null
if (!result.ok) return t('message.compaction.readFailed')
const event = result.value.records.find(entry => entry.event.seq === summarySeq)?.event
const text = event && summaryText(event)
if (text === undefined) return t('message.compaction.notFound')
const identity = address.kind === 'session' ? [address.sessionId] : [address.parentSessionId, address.childSessionId, address.mode]
const opened = ctx.sidebarRight.openContent({ mediaType: 'text/markdown', text }, {
title: t('message.compaction.title'), key: `compaction:${JSON.stringify([...identity, summarySeq])}`,
})
return opened ? null : t('message.compaction.notFound')
},
})
}
/** Extract text only from a valid summary event returned by the history API.
* @param event - Wire event with untrusted JSON data.
* @returns Markdown, or undefined for unrelated, empty or malformed content.
*/
function summaryText(event: { readonly type: string; readonly data: unknown }): string | undefined {
if (event.type !== 'compaction/summary') return undefined
const data = event.data
if (typeof data !== 'object' || data === null || !('summary' in data) || !Array.isArray(data.summary)) return undefined
const text: string[] = []
const blocks: readonly unknown[] = data.summary
for (const block of blocks) {
if (typeof block !== 'object' || block === null || !('type' in block)) return undefined
if (block.type !== 'text') continue
if (!('text' in block) || typeof block.text !== 'string') return undefined
text.push(block.text)
}
const markdown = text.join('')
return markdown.trim() === '' ? undefined : markdown
}
@@ -1,9 +1,6 @@
import type { Context } from '@deepseek-ai/cordis'
import type { SessionAddress } from '@deepseek-ai/dsh-api-session-controller/types'
import type {} from '@deepseek-ai/dsh-client-ui-compaction/client'
import type { SessionId } from '@deepseek-ai/dsh-session/types'
import type { CompactionRowInjected } from './CompactionItem.tsx'
import { createSnapshotStore, type ObservableSnapshot } from '@deepseek-ai/dsh-client-store'
import { compactionRows } from './compaction-preview.ts'
import type { ObservableSnapshot } from '@deepseek-ai/dsh-client-store'
import type { PerformanceUsageMode } from '../../chat-settings.ts'
import type { ChatPresentationPolicy } from '../presentation-policy.ts'
import { NS } from '../locale.ts'
@@ -33,23 +30,7 @@ export function registerChatNodeRenderers(
performanceUsage: ObservableSnapshot<PerformanceUsageMode>,
presentation: ObservableSnapshot<ChatPresentationPolicy>,
): void {
const compactionPreview = createSnapshotStore<boolean>(false)
let compactionPreviews: Context['compactionPreviews'] | undefined
ctx.inject(['compactionPreviews'], (scope) => {
scope.effect(() => {
compactionPreviews = scope.compactionPreviews
compactionPreview.set(true)
return () => { compactionPreviews = undefined; compactionPreview.set(false) }
}, 'ui-chat: compaction preview availability')
})
const injectCompaction = (sessionId: SessionId): CompactionRowInjected => ({
hooks: { compactionPreview },
openCompaction: (seq, signal) => {
const child = ctx.sessions.subagentAddress(sessionId)
const address: SessionAddress = child === undefined ? { kind: 'session', sessionId } : { kind: 'subagent', ...child }
return compactionPreviews?.open(address, seq, signal) ?? Promise.resolve(null)
},
})
const injectCompaction = compactionRows(ctx)
ctx.effect(() => ctx.slots.registerFactory({
name: 'conversation.chat.reasoning.content',
scope: 'root',
@@ -157,6 +157,9 @@ export const zh = {
'message.compaction.running': '正在压缩…',
'message.compaction.completed': '已压缩 {items} 条历史记录(约 {tokens} tokens)',
'message.compaction.open': '在侧栏查看压缩摘要',
'message.compaction.title': '上下文摘要',
'message.compaction.notFound': '摘要不可用:预览服务不可用,或摘要记录缺失、为空或无效。',
'message.compaction.readFailed': '无法读取摘要',
'message.compaction.landed': '较早的历史已压缩为摘要',
'message.compaction.commandTitle': 'compact',
'message.think': '思考',
@@ -372,6 +375,9 @@ export const en = {
'message.compaction.running': 'Compacting context…',
'message.compaction.completed': 'Compacted {items} history items (~{tokens} tokens)',
'message.compaction.open': 'View compaction summary in the sidebar',
'message.compaction.title': 'Context summary',
'message.compaction.notFound': 'Summary unavailable: the preview service is unavailable, or the summary record is missing, empty or invalid.',
'message.compaction.readFailed': 'Unable to read the summary',
'message.compaction.landed': 'Earlier history condensed into a summary',
'message.compaction.commandTitle': 'compact',
'message.think': 'Think',
@@ -584,6 +590,9 @@ export const ja = {
'message.compaction.running': 'コンテキストを圧縮中…',
'message.compaction.completed': '履歴 {items} 件を圧縮しました(約 {tokens} トークン)',
'message.compaction.open': '圧縮の要約をサイドバーで表示',
'message.compaction.title': 'コンテキストの要約',
'message.compaction.notFound': '要約を利用できません。プレビューサービスが利用できないか、要約が存在しない、空、または無効です。',
'message.compaction.readFailed': '要約を読み込めません',
'message.compaction.landed': '以前の履歴を要約に圧縮しました',
'message.compaction.commandTitle': 'compact',
'message.think': '思考',
@@ -796,6 +805,9 @@ export const es = {
'message.compaction.running': 'Contexto de compactación…',
'message.compaction.completed': 'Elementos del historial {items} compactados (~tokens {tokens})',
'message.compaction.open': 'Ver el resumen de compactación en la barra lateral',
'message.compaction.title': 'Resumen del contexto',
'message.compaction.notFound': 'Resumen no disponible: el servicio no está disponible o el registro falta, está vacío o no es válido.',
'message.compaction.readFailed': 'No se pudo leer el resumen',
'message.compaction.landed': 'Historial anterior condensado en un resumen',
'message.compaction.commandTitle': 'compacto',
'message.think': 'pensar',
@@ -1008,6 +1020,9 @@ export const fr = {
'message.compaction.running': 'Contexte de compactage…',
'message.compaction.completed': "Éléments d'historique {items} compactés (~jetons {tokens})",
'message.compaction.open': 'Afficher le résumé de compactage dans le panneau latéral',
'message.compaction.title': 'Résumé du contexte',
'message.compaction.notFound': 'Résumé indisponible : le service est indisponible ou le résumé est absent, vide ou invalide.',
'message.compaction.readFailed': 'Impossible de lire le résumé',
'message.compaction.landed': 'Historique antérieur condensé en résumé',
'message.compaction.commandTitle': 'compacte',
'message.think': 'Pensez',
@@ -1220,6 +1235,9 @@ export const de = {
'message.compaction.running': 'Kontext verdichten…',
'message.compaction.completed': 'Komprimierte {items}-Verlaufselemente (~{tokens}-Tokens)',
'message.compaction.open': 'Zusammenfassung der Komprimierung in der Seitenleiste anzeigen',
'message.compaction.title': 'Kontextzusammenfassung',
'message.compaction.notFound': 'Zusammenfassung nicht verfügbar: Der Dienst ist nicht verfügbar oder der Eintrag fehlt, ist leer oder ungültig.',
'message.compaction.readFailed': 'Zusammenfassung konnte nicht gelesen werden',
'message.compaction.landed': 'Früherer Verlauf zu einer Zusammenfassung verdichtet',
'message.compaction.commandTitle': 'kompakt',
'message.think': 'Denken Sie nach',
@@ -1432,6 +1450,9 @@ export const ru = {
'message.compaction.running': 'Сжатие контекста…',
'message.compaction.completed': 'Сжатые элементы истории {items} (токены ~{tokens})',
'message.compaction.open': 'Открыть сводку сжатия на боковой панели',
'message.compaction.title': 'Сводка контекста',
'message.compaction.notFound': 'Сводка недоступна: сервис недоступен либо запись отсутствует, пуста или недействительна.',
'message.compaction.readFailed': 'Не удалось прочитать сводку',
'message.compaction.landed': 'Ранняя история сжата в сводку',
'message.compaction.commandTitle': 'компактный',
'message.think': 'Подумайте',
@@ -1644,6 +1665,9 @@ export const pt = {
'message.compaction.running': 'Contexto compactado…',
'message.compaction.completed': '{items} itens de histórico compactados (~{tokens} tokens)',
'message.compaction.open': 'Ver o resumo da compactação na barra lateral',
'message.compaction.title': 'Resumo do contexto',
'message.compaction.notFound': 'Resumo indisponível: o serviço está indisponível ou o registro está ausente, vazio ou inválido.',
'message.compaction.readFailed': 'Não foi possível ler o resumo',
'message.compaction.landed': 'Histórico anterior condensado em um resumo',
'message.compaction.commandTitle': 'compacto',
'message.think': 'Pense',
@@ -24,6 +24,8 @@ import {
import {
apply as applyChat, inject as injectChat, type ChatFlowDataInjected, type ChatViewInjected,
} from '@deepseek-ai/dsh-client-ui-chat/client'
import { RemoteError } from '@deepseek-ai/dsh-typert-protocol'
import type { SessionWireEvent } from '@deepseek-ai/dsh-api-session-controller/types'
import { SessionSeq, type SessionId } from '@deepseek-ai/dsh-session/types'
import type { WorkspaceId } from '@deepseek-ai/dsh-workspace/types'
import { createChatStore } from '../src/client/stores.ts'
@@ -72,6 +74,7 @@ async function bench(initialSettings?: ChatSettings, withBrowserRegistry = true,
runtime.ctx.provide('fileDrag', { actions: fileDrag, read: () => undefined })
runtime.ctx.provide('layout', layout as never)
const sidebarRight = {
openContent: vi.fn<typeof runtime.ctx.sidebarRight.openContent>(() => true),
openResource: vi.fn<(address: string) => void>(),
openTab: vi.fn<(kind: string, options?: unknown) => void>(),
}
@@ -87,7 +90,12 @@ async function bench(initialSettings?: ChatSettings, withBrowserRegistry = true,
const openWorkspacePath = vi.fn<ClientRemote['session']['openWorkspacePath']>(
() => Promise.resolve({ ok: true, value: { opened: true } }),
)
runtime.remote.provideNamespaces({ session: { openWorkspacePath } })
const events = vi.fn<ClientRemote['session']['events']>(async ({ throughSeq }) => ({
ok: true, value: { cursor: 42, hasMore: false, records: [{ type: 'event', event: {
type: 'compaction/summary', seq: throughSeq ?? 42, time: 0, data: { summary: [{ type: 'text', text: '# Summary' }] },
} }] },
}))
runtime.remote.provideNamespaces({ session: { openWorkspacePath, events } })
const openSession = vi.fn<(id: SessionId) => void>()
runtime.ctx.provide('uiWorkspace', {
openWorkspace: vi.fn(async (_workspaceId: WorkspaceId, beforeOpen: (id: SessionId) => void) => {
@@ -147,7 +155,7 @@ async function bench(initialSettings?: ChatSettings, withBrowserRegistry = true,
const preference: object = row.inject!()
return preference as LinkOpeningRowInjected
},
runtime, chat, chatSettings, browserAvailable,
events, runtime, chat, chatSettings, browserAvailable,
layout, openWorkspacePath, sidebarRight, sidebarRightTabs, session, chatViewApi, chatFlowApi, rootReference, openSession,
}
}
@@ -456,40 +464,66 @@ describe('Chat inject API', () => {
}
})
it('opens ordinary and subagent checkpoints through the optional preview service', async () => {
it('opens recorded summaries by Session and stops pending reads when the viewer unloads', async () => {
const b = await bench()
const open = vi.fn(async () => null)
try {
const injected = b.compactionRow('compaction')
const row = b.compactionRow('manual-compaction')
const signal = new AbortController().signal
expect(await injected.openCompaction(42, signal)).toBeNull()
const service = await b.runtime.mount({ apply(ctx) { ctx.provide('compactionPreviews', { open }) } })
await vi.waitFor(() => { expect(injected.hooks.compactionPreview.getSnapshot()).toBe(true) })
await injected.openCompaction(42, signal)
expect(open).toHaveBeenLastCalledWith({ kind: 'session', sessionId: ROOT }, 42, signal)
expect(await row.openCompaction(42, signal)).toBeNull()
expect(b.events).not.toHaveBeenCalled()
const viewer = await b.runtime.mount({ apply(ctx) { ctx.provide('documentPreviews', {} as never) } })
await vi.waitFor(() => { expect(row.hooks.compactionPreview.getSnapshot()).toBe(true) })
await row.openCompaction(42, signal)
expect(b.events).toHaveBeenLastCalledWith({ address: { kind: 'session', sessionId: ROOT }, throughSeq: 42, maxMessages: 1 }, expect.any(AbortSignal))
expect(b.sidebarRight.openContent).toHaveBeenCalledWith({ mediaType: 'text/markdown', text: '# Summary' },
expect.objectContaining({ title: '上下文摘要' }))
const child = { parentSessionId: 'parent/1' as SessionId, childSessionId: ROOT, mode: 'continuable' as const }
vi.spyOn(b.runtime.ctx.sessions, 'subagentAddress').mockReturnValue(child)
await injected.openCompaction(7, signal)
expect(open).toHaveBeenLastCalledWith({ kind: 'subagent', ...child }, 7, signal)
await service.dispose()
expect(injected.hooks.compactionPreview.getSnapshot()).toBe(false)
await row.openCompaction(42, signal)
expect(b.events).toHaveBeenLastCalledWith({ address: { kind: 'subagent', ...child }, throughSeq: 42, maxMessages: 1 }, expect.any(AbortSignal))
expect(b.sidebarRight.openContent.mock.calls[0]![1].key).not.toBe(b.sidebarRight.openContent.mock.calls[1]![1].key)
b.events.mockImplementationOnce(async (_query, active) => {
await viewer.dispose()
expect(active?.aborted).toBe(true)
throw new Error('cancelled')
})
expect(await row.openCompaction(42, signal)).toBeNull()
expect(row.hooks.compactionPreview.getSnapshot()).toBe(false)
expect(b.sidebarRight.openContent).toHaveBeenCalledTimes(2)
} finally { await b.runtime.dispose() }
})
it('tracks preview service availability independently of sidebar tab registration', async () => {
const b = await bench(undefined, false)
it('reports unreadable summaries and keeps cancelled reads out of the sidebar', async () => {
const b = await bench()
try {
const preview = b.compactionRow('manual-compaction').hooks.compactionPreview
expect(preview.getSnapshot()).toBe(false)
const changed = vi.fn()
const unsubscribe = preview.subscribe(changed)
const service = await b.runtime.mount({ apply(ctx) { ctx.provide('compactionPreviews', { open: async () => null }) } })
await vi.waitFor(() => { expect(preview.getSnapshot()).toBe(true) })
expect(changed).toHaveBeenCalledOnce()
await service.dispose()
expect(preview.getSnapshot()).toBe(false)
expect(changed).toHaveBeenCalledTimes(2)
unsubscribe()
const row = b.compactionRow('compaction')
const signal = new AbortController().signal
await b.runtime.mount({ apply(ctx) { ctx.provide('documentPreviews', {} as never) } })
await vi.waitFor(() => { expect(row.hooks.compactionPreview.getSnapshot()).toBe(true) })
const event = { seq: 42, time: 0, type: 'compaction/summary', data: { summary: [{ type: 'text', text: 'summary' }] } }
const records: SessionWireEvent[] = [{ ...event, seq: 41 }, { ...event, type: 'other' },
...[null, {}, { summary: [null] }, { summary: [{}] }, { summary: [{ type: 'text', text: 5 }] },
{ summary: [{ type: 'image' }, { type: 'text', text: ' ' }] }].map(data => ({ ...event, data }))]
for (const invalid of records) {
b.events.mockResolvedValueOnce({ ok: true, value: { cursor: 42, hasMore: false, records: [{ type: 'event', event: invalid }] } })
expect(await row.openCompaction(42, signal)).toContain('摘要不可用')
}
b.events.mockRejectedValueOnce(new Error('offline'))
expect(await row.openCompaction(42, signal)).toBe('无法读取摘要')
b.events.mockResolvedValueOnce({ ok: false, error: new RemoteError('gateway/internal', 'offline', {}) })
expect(await row.openCompaction(42, signal)).toBe('无法读取摘要')
b.events.mockResolvedValueOnce({ ok: true, value: { cursor: 42, hasMore: false, records: [] } })
expect(await row.openCompaction(42, signal)).toContain('摘要不可用')
expect(await row.openCompaction(42, AbortSignal.abort())).toBeNull()
const pending = new AbortController()
b.events.mockImplementationOnce(async () => {
pending.abort()
return { ok: true, value: { cursor: 42, hasMore: false, records: [{ type: 'event', event }] } }
})
expect(await row.openCompaction(42, pending.signal)).toBeNull()
expect(b.sidebarRight.openContent).not.toHaveBeenCalled()
b.sidebarRight.openContent.mockReturnValueOnce(false)
expect(await row.openCompaction(42, signal)).toContain('摘要不可用')
} finally { await b.runtime.dispose() }
})
@@ -125,9 +125,6 @@
},
{
"path": "../ui-context-menu"
},
{
"path": "../ui-compaction"
}
],
"exclude": [
@@ -1,34 +0,0 @@
# Bilingual-pair consistency record for README.md (docs/i18n/README.md): per heading
# section, a hash of its English and Chinese blocks outside code blocks and generated regions.
# After editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write packages/client/ui-compaction/README.md
/:
en: f08e4f7372e89553
zh: e14e4dab70119e88
/deepseek-ai-dsh-client-ui-compaction:
en: 453f619db5ec29a6
zh: 962a998670eb8253
/deepseek-ai-dsh-client-ui-compaction/summary:
en: aa6865eaafdbf837
zh: 3bddc62b0765f428
/deepseek-ai-dsh-client-ui-compaction/table-of-contents:
en: d3ca4204ae112422
zh: 7b3a3c6e211edeb0
/deepseek-ai-dsh-client-ui-compaction/what-it-registers:
en: 98a28bdf0c002067
zh: 95459ac0d88655cc
/deepseek-ai-dsh-client-ui-compaction/reading-a-summary:
en: 098b709b76a6068f
zh: 86848c4bfc43f0a6
/deepseek-ai-dsh-client-ui-compaction/model-experience:
en: f51ca904b3454532
zh: 92b6f1bcaeeaf3f2
/deepseek-ai-dsh-client-ui-compaction/model-experience/kv-cache-effect:
en: 900e7c177de0539e
zh: 08875689803df6c6
/deepseek-ai-dsh-client-ui-compaction/known-limitations-and-deferred-work:
en: fcd9b8c47f1b719b
zh: d49e599d119b0850
/deepseek-ai-dsh-client-ui-compaction/known-limitations-and-deferred-work/dev-note:
en: e67f633dc6fe7773
zh: e88aeb617ffb74ea
-58
View File
@@ -1,58 +0,0 @@
---
description: "Right sidebar previews of recorded conversation compaction summaries."
kind: "package-reference"
---
# @deepseek-ai/dsh-client-ui-compaction
English | [中文](README.zh.md)
## Summary
Chat opens a recorded summary with `ctx.compactionPreviews.open(address, summarySeq, signal)`. After reloading the browser, reopen it from its compaction row.
## Table of Contents
- [What it registers](#what-it-registers)
- [Reading a summary](#reading-a-summary)
- [Model Experience](#model-experience)
- [Known Limitations and Deferred Work](#known-limitations-and-deferred-work)
- [Dev Note](#dev-note)
-----
<a id="what-it-registers"></a>
## What it registers
While document previews are available, the plugin provides the compaction preview service to Chat.
<a id="reading-a-summary"></a>
## Reading a summary
The service reads the exact `compaction/summary` event with the Session address, `throughSeq`, and `maxMessages: 1`. Missing or empty summaries and read failures appear on the requesting row. Cancellation stops navigation.
The service passes the joined Markdown text to `sidebarRight.openContent`. Reopening the same event reuses its tab.
<a id="model-experience"></a>
## Model Experience
None, as the package displays a logged summary and registers no tool, prompt section, or session event.
#### KV Cache effect
No direct effect on model requests or caching.
## Known Limitations and Deferred Work
<a id="known-limitations-and-deferred-work"></a>
- **Partial history.** The preview button is disabled while the associated summary event is outside the loaded history.
<a id="dev-note"></a>
### Dev Note
<details>
<summary>Working context for maintainers — click to expand</summary>
None.
</details>
@@ -1,58 +0,0 @@
---
description: "在右侧栏预览会话日志中的压缩摘要。"
kind: "package-reference"
---
# @deepseek-ai/dsh-client-ui-compaction
[English](README.md) | 中文
## 概述
Chat 通过 `ctx.compactionPreviews.open(address, summarySeq, signal)` 打开已记录的摘要。刷新浏览器后,从压缩行重新打开摘要。
## 目录
- [注册了什么](#what-it-registers)
- [读取摘要](#reading-a-summary)
- [模型体验](#model-experience)
- [已知限制与延期工作](#known-limitations-and-deferred-work)
- [开发备注](#dev-note)
-----
<a id="what-it-registers"></a>
## 注册了什么
文档预览可用时,插件向 Chat 提供压缩摘要预览服务。
<a id="reading-a-summary"></a>
## 读取摘要
服务使用会话地址、`throughSeq` 和 `maxMessages: 1` 读取指定的 `compaction/summary` 事件。摘要缺失、为空或读取失败时,发起请求的压缩行显示错误。取消请求会停止导航。
服务将按顺序拼接的 Markdown 文本传给 `sidebarRight.openContent`。重复打开同一事件会复用标签。
<a id="model-experience"></a>
## 模型体验
无,本包只显示会话日志中的摘要,不注册工具、提示词段或会话事件。
#### KV Cache 影响
对模型请求和缓存无直接影响。
## 已知限制与延期工作
<a id="known-limitations-and-deferred-work"></a>
- **部分历史。** 关联的摘要事件尚未加载时,预览按钮禁用。
<a id="dev-note"></a>
### 开发备注
<details>
<summary>维护者工作上下文——点击展开</summary>
无。
</details>
@@ -1,6 +0,0 @@
{
"meta": {
"title": "Vorschau der Komprimierungszusammenfassung",
"description": "Zeigt Zusammenfassungen komprimierter Gespräche in der rechten Seitenleiste an."
}
}
@@ -1,6 +0,0 @@
{
"meta": {
"title": "Compaction summary preview",
"description": "Read conversation compaction summaries in the right sidebar."
}
}
@@ -1,6 +0,0 @@
{
"meta": {
"title": "Vista previa del resumen de compactación",
"description": "Consulta los resúmenes de compactación de conversaciones en la barra lateral derecha."
}
}
@@ -1,6 +0,0 @@
{
"meta": {
"title": "Aperçu du résumé de compactage",
"description": "Consultez les résumés de compactage des conversations dans la barre latérale droite."
}
}
@@ -1,6 +0,0 @@
{
"meta": {
"title": "圧縮要約プレビュー",
"description": "右サイドバーで会話の圧縮要約を表示します。"
}
}
@@ -1,6 +0,0 @@
{
"meta": {
"title": "Prévia do resumo de compactação",
"description": "Consulte os resumos de compactação de conversas na barra lateral direita."
}
}
@@ -1,6 +0,0 @@
{
"meta": {
"title": "Предпросмотр сводки сжатия",
"description": "Просматривайте сводки сжатых разговоров на правой боковой панели."
}
}
@@ -1,6 +0,0 @@
{
"meta": {
"title": "压缩摘要预览",
"description": "在右侧栏查看对话压缩摘要。"
}
}
@@ -1,67 +0,0 @@
{
"name": "@deepseek-ai/dsh-client-ui-compaction",
"description": "Right sidebar previews of recorded conversation compaction summaries",
"version": "0.2.2-rc.5",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/deepseek-ai/deepseek-harness.git",
"directory": "packages/client/ui-compaction"
},
"type": "module",
"main": "lib/index.js",
"types": "lib/types/index.d.ts",
"exports": {
".": {
"types": "./lib/types/index.d.ts",
"default": "./lib/index.js"
},
"./client": {
"types": "./lib/types/client/index.d.ts",
"default": "./lib/client.js"
},
"./src/*": "./src/*",
"./package.json": "./package.json",
"./locale/*.json": "./locale/*.json"
},
"dsh": {
"client": {
"inject": [
"@deepseek-ai/dsh-api-remotes",
"@deepseek-ai/dsh-api-session-controller",
"@deepseek-ai/dsh-client-locale",
"@deepseek-ai/dsh-client-ui-sidebar-documentpreview",
"@deepseek-ai/dsh-client-ui-sidebar-right"
],
"platform": "web"
}
},
"scripts": {
"bundle": "tsdown",
"watch": "tsdown --watch"
},
"license": "MIT",
"peerDependencies": {
"@deepseek-ai/cordis": "workspace:~"
},
"devDependencies": {
"@deepseek-ai/cordis": "workspace:~",
"@deepseek-ai/dsh-api-remotes": "workspace:*",
"@deepseek-ai/dsh-api-session-controller": "workspace:*",
"@deepseek-ai/dsh-client-locale": "workspace:*",
"@deepseek-ai/dsh-client-ui-sidebar-documentpreview": "workspace:*",
"@deepseek-ai/dsh-client-ui-sidebar-right": "workspace:*",
"@deepseek-ai/dsh-client-ui-slots": "workspace:*"
},
"files": [
"locale/*.json",
"lib/index.js",
"lib/client.js",
"lib/types/**/*.d.ts",
"lib/types/**/*.d.ts.map",
"lib/**/*.js.map",
"src"
]
}
@@ -1,89 +0,0 @@
/** Read a recorded summary into a temporary Markdown preview. */
import type { Context } from '@deepseek-ai/cordis'
import type {} from '@deepseek-ai/dsh-api-remotes/client'
import type {} from '@deepseek-ai/dsh-api-session-controller/remote'
import type {} from '@deepseek-ai/dsh-client-locale/client'
import type {} from '@deepseek-ai/dsh-client-ui-sidebar-documentpreview/client'
import type { SessionAddress } from '@deepseek-ai/dsh-api-session-controller/types'
import { en, ja, es, fr, de, ru, pt, zh } from './locales.ts'
import type {} from '@deepseek-ai/dsh-client-ui-sidebar-right/client'
export type { CompactionKey } from './locales.ts'
/** Summary preview navigation. */
export interface CompactionPreviews {
/**
* Open the recorded summary unless the requesting row has been cancelled.
* @param address - complete history address.
* @param summarySeq - compaction/summary event sequence.
* @param signal - requesting row lifetime.
* @returns a localized failure for the row, or null after navigation or cancellation.
*/
open(address: SessionAddress, summarySeq: number, signal: AbortSignal): Promise<string | null>
}
declare module '@deepseek-ai/cordis' {
interface Context {
/** Available while document previews are loaded. */
compactionPreviews: CompactionPreviews
}
}
/** Services required to read summary text. */
export const inject = ['locale', 'remote', 'remote.session', 'sidebarRight']
/** @param ctx - browser context with Session history and locale services. */
export function apply(ctx: Context): void {
const t = ctx.locale.bind('compaction')
ctx.effect(() => ctx.locale.register('compaction', { zh, en, ja, es, fr, de, ru, pt }), 'ui-compaction: dictionaries')
ctx.inject(['documentPreviews'], (scope) => {
const lifetime = new AbortController()
scope.effect(() => () => { lifetime.abort() }, 'ui-compaction: navigation lifetime')
const service: CompactionPreviews = {
async open(address, summarySeq, signal) {
const active = AbortSignal.any([signal, lifetime.signal])
const cancelled = (): boolean => active.aborted
if (cancelled()) return null
let result
try {
result = await scope.remote.session.events({ address, throughSeq: summarySeq, maxMessages: 1 }, active)
} catch (_error) {
// A cancelled row has no read failure to display.
return cancelled() ? null : t('preview.readFailed')
}
if (cancelled()) return null
if (!result.ok) return t('preview.readFailed')
const event = result.value.records.find(entry => entry.event.seq === summarySeq)?.event
const text = event && summaryText(event)
if (text === undefined) return t('preview.notFound')
const identity = address.kind === 'session' ? [address.sessionId] : [address.parentSessionId, address.childSessionId, address.mode]
const opened = scope.sidebarRight.openContent({ mediaType: 'text/markdown', text }, {
title: t('preview.title'), key: `compaction:${JSON.stringify([...identity, summarySeq])}`,
})
return opened ? null : t('preview.notFound')
},
}
const dispose = scope.reflect.provide('compactionPreviews', service)
scope.effect(() => dispose, 'ui-compaction: preview service')
})
}
/** Extract text only from a valid summary event returned by the history API.
* @param event - Wire event with untrusted JSON data.
* @returns Markdown, or undefined for unrelated, empty or malformed content.
*/
function summaryText(event: { readonly type: string; readonly data: unknown }): string | undefined {
if (event.type !== 'compaction/summary') return undefined
const data = event.data
if (typeof data !== 'object' || data === null || !('summary' in data) || !Array.isArray(data.summary)) return undefined
const text: string[] = []
const blocks: readonly unknown[] = data.summary
for (const block of blocks) {
if (typeof block !== 'object' || block === null || !('type' in block)) return undefined
if (block.type !== 'text') continue
if (!('text' in block) || typeof block.text !== 'string') return undefined
text.push(block.text)
}
const markdown = text.join('')
return markdown.trim() === '' ? undefined : markdown
}
@@ -1,67 +0,0 @@
/** `compaction` namespace dictionaries: the summary title and read failures. */
/** Simplified Chinese dictionary and key-set source of truth. */
export const zh = {
'preview.title': '上下文摘要',
'preview.notFound': '摘要不可用:预览服务不可用,或摘要记录缺失、为空或无效。',
'preview.readFailed': '无法读取摘要',
} satisfies Record<string, string>
/** Compaction preview dictionary key union. */
export type CompactionKey = keyof typeof zh
/** English dictionary, checked against the Chinese key set. */
export const en = {
'preview.title': 'Context summary',
'preview.notFound': 'Summary unavailable: the preview service is unavailable, or the summary record is missing, empty or invalid.',
'preview.readFailed': 'Unable to read the summary',
} satisfies Record<CompactionKey, string>
/** Japanese dictionary. */
export const ja = {
'preview.title': 'コンテキストの要約',
'preview.notFound': '要約を利用できません。プレビューサービスが利用できないか、要約が存在しない、空、または無効です。',
'preview.readFailed': '要約を読み込めません',
} satisfies Record<CompactionKey, string>
/** Spanish dictionary. */
export const es = {
'preview.title': 'Resumen del contexto',
'preview.notFound': 'Resumen no disponible: el servicio no está disponible o el registro falta, está vacío o no es válido.',
'preview.readFailed': 'No se pudo leer el resumen',
} satisfies Record<CompactionKey, string>
/** French dictionary. */
export const fr = {
'preview.title': 'Résumé du contexte',
'preview.notFound': 'Résumé indisponible : le service est indisponible ou le résumé est absent, vide ou invalide.',
'preview.readFailed': 'Impossible de lire le résumé',
} satisfies Record<CompactionKey, string>
/** German dictionary. */
export const de = {
'preview.title': 'Kontextzusammenfassung',
'preview.notFound': 'Zusammenfassung nicht verfügbar: Der Dienst ist nicht verfügbar oder der Eintrag fehlt, ist leer oder ungültig.',
'preview.readFailed': 'Zusammenfassung konnte nicht gelesen werden',
} satisfies Record<CompactionKey, string>
/** Russian dictionary. */
export const ru = {
'preview.title': 'Сводка контекста',
'preview.notFound': 'Сводка недоступна: сервис недоступен либо запись отсутствует, пуста или недействительна.',
'preview.readFailed': 'Не удалось прочитать сводку',
} satisfies Record<CompactionKey, string>
/** Portuguese dictionary. */
export const pt = {
'preview.title': 'Resumo do contexto',
'preview.notFound': 'Resumo indisponível: o serviço está indisponível ou o registro está ausente, vazio ou inválido.',
'preview.readFailed': 'Não foi possível ler o resumo',
} satisfies Record<CompactionKey, string>
declare module '@deepseek-ai/dsh-client-ui-slots' {
interface LocaleNamespaceMap {
/** The compaction summary title and read failures. */
compaction: CompactionKey
}
}
@@ -1,9 +0,0 @@
/**
* Compaction summary preview plugin, node half. Pure UI plugin: the empty
* apply exists so the plugin appears in the host cordis.yml / Loader; the
* browser half ships via exports["./client"], discovered through the
* package.json dsh.client declaration.
*/
/** Host plugin body — no host-side behavior for this surface plugin. */
export function apply(): void {}
@@ -1,85 +0,0 @@
import { Context } from '@deepseek-ai/cordis'
import { brandString } from '@deepseek-ai/dsh-brand'
import type { SessionEventEntry } from '@deepseek-ai/dsh-api-session-controller/types'
import type { SessionId } from '@deepseek-ai/dsh-session/types'
import { RemoteError } from '@deepseek-ai/dsh-typert-protocol'
import { expect, it, onTestFinished, vi } from 'vitest'
import { apply, inject } from '../src/client/index.ts'
import { apply as hostApply } from '../src/index.ts'
const sessionId = brandString<SessionId>('session/1')
const address = { kind: 'session' as const, sessionId }
const signal = new AbortController().signal
function history(data: SessionEventEntry['event']['data'], type = 'compaction/summary', seq = 7) {
const records: SessionEventEntry[] = [{ type: 'event', event: { type, seq, time: 100, data } }]
return { ok: true as const, value: { cursor: seq, records, hasMore: true } }
}
async function boot() {
const ctx = new Context()
const events = vi.fn<Context['remote']['session']['events']>(async () => history({
summary: [{ type: 'text', text: '# A' }, { type: 'image' }, { type: 'text', text: ' summary' }],
}))
const openContent = vi.fn<Context['sidebarRight']['openContent']>(() => true)
ctx.provide('locale', { bind: () => (key: string) => key, register: () => () => {} } as never)
ctx.provide('remote', { session: { events } } as never)
ctx.provide('remote.session', { events } as never)
ctx.provide('sidebarRight', { openContent } as never)
const fiber = ctx.plugin({ inject: [...inject], apply })
onTestFinished(async () => { await fiber.dispose() })
await fiber.await()
expect(ctx.get('compactionPreviews')).toBeUndefined()
const withdraw = ctx.provide('documentPreviews', {} as never)
await vi.waitFor(() => { expect(ctx.get('compactionPreviews')).toBeDefined() })
return { ctx, preview: ctx.compactionPreviews, events, openContent, withdraw }
}
it('opens the exact event with a repeatable key scoped to its Session', async () => {
const { preview, events, openContent } = await boot()
const child = { kind: 'subagent' as const, parentSessionId: sessionId, childSessionId: sessionId, mode: 'continuable' as const }
for (const target of [address, address, child]) {
expect(await preview.open(target, 7, signal)).toBeNull()
expect(events).toHaveBeenLastCalledWith({ address: target, throughSeq: 7, maxMessages: 1 }, expect.any(AbortSignal))
expect(openContent).toHaveBeenLastCalledWith({ mediaType: 'text/markdown', text: '# A summary' },
expect.objectContaining({ title: 'preview.title' }))
}
const keys = openContent.mock.calls.map(([, options]) => options.key)
expect(keys[0]).toEqual(expect.any(String))
expect(keys[0]).toBe(keys[1])
expect(keys[1]).not.toBe(keys[2])
})
it('reports missing or malformed history and failed reads on the requesting row', async () => {
const { preview, events, openContent } = await boot()
for (const result of [history({}, 'other'), history({}, undefined, 8), history(null), history({}),
history({ summary: [null] }), history({ summary: [{}] }), history({ summary: [{ type: 'text', text: 5 }] }),
history({ summary: [{ type: 'text', text: ' ' }] })]) {
events.mockResolvedValueOnce(result)
expect(await preview.open(address, 7, signal)).toBe('preview.notFound')
}
events.mockResolvedValueOnce({ ok: false, error: new RemoteError('gateway/internal', 'offline', {}) })
expect(await preview.open(address, 7, signal)).toBe('preview.readFailed')
events.mockRejectedValueOnce(new Error('offline'))
expect(await preview.open(address, 7, signal)).toBe('preview.readFailed')
expect(openContent).not.toHaveBeenCalled()
openContent.mockReturnValueOnce(false)
expect(await preview.open(address, 7, signal)).toBe('preview.notFound')
})
it('suppresses navigation and read errors after row cancellation or plugin disposal', async () => {
const { preview, events, openContent, ctx, withdraw } = await boot()
expect(await preview.open(address, 7, AbortSignal.abort())).toBeNull()
expect(events).not.toHaveBeenCalled()
const row = new AbortController()
events.mockImplementationOnce(async () => { row.abort(); throw new Error('cancelled') })
expect(await preview.open(address, 7, row.signal)).toBeNull()
events.mockImplementationOnce(async () => {
withdraw()
await vi.waitFor(() => { expect(ctx.get('compactionPreviews')).toBeUndefined() })
return history({})
})
expect(await preview.open(address, 7, signal)).toBeNull()
expect(openContent).not.toHaveBeenCalled()
})
it('loads the host entry without browser services', () => { expect(() => { hostApply() }).not.toThrow() })
@@ -1,33 +0,0 @@
{
"extends": "../../../tsconfig.base.client.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "lib/types"
},
"include": [
"src"
],
"references": [
{
"path": "../../../vendor/cordis"
},
{
"path": "../../api/remotes/tsconfig.client.json"
},
{
"path": "../../api/session-controller/tsconfig.client.json"
},
{
"path": "../locale/tsconfig.client.json"
},
{
"path": "../ui-sidebar-documentpreview/tsconfig.client.json"
},
{
"path": "../ui-slots"
},
{
"path": "../ui-sidebar-right"
}
]
}
@@ -1,3 +0,0 @@
import { clientBundle } from '../tsdown.client.ts'
export default clientBundle(import.meta.dirname, ['lib/types/index.js'])
@@ -84,7 +84,6 @@ Every package below exports a Cordis plugin that a bundle patch can name in a Lo
| `@deepseek-ai/dsh-client-ui-brand-official` | no | Official DeepSeek Harness brand artwork and click-triggered home background |
| `@deepseek-ai/dsh-client-ui-chat` | no | Chat Conversation target, node definitions, renderers, and details surface |
| `@deepseek-ai/dsh-client-ui-commands` | no | Client command surface: global directory cache, '/' source, three command UI kinds, popupSelect registry |
| `@deepseek-ai/dsh-client-ui-compaction` | no | Right sidebar previews of recorded conversation compaction summaries |
| `@deepseek-ai/dsh-client-ui-connector-account` | no | Connector account surfaces: the Host registry CLI app plugins and MCP connectors register their accounts with, and the Plugins page section, title tag, activation prompt, and notices it serves over one Remote |
| `@deepseek-ai/dsh-client-ui-context-menu` | yes | Typed, plugin-extensible context menus with captured targets and shared Web presentation |
| `@deepseek-ai/dsh-client-ui-conversation` | no | Target-neutral Conversation assembly, shell, composer, queue, and view navigation |
-30
View File
@@ -3200,9 +3200,6 @@ importers:
'@deepseek-ai/dsh-client-ui-commands':
specifier: workspace:*
version: link:../../client/ui-commands
'@deepseek-ai/dsh-client-ui-compaction':
specifier: workspace:*
version: link:../../client/ui-compaction
'@deepseek-ai/dsh-client-ui-connector-account':
specifier: workspace:*
version: link:../../client/ui-connector-account
@@ -4331,9 +4328,6 @@ importers:
'@deepseek-ai/dsh-client-ui-approval':
specifier: workspace:*
version: link:../ui-approval
'@deepseek-ai/dsh-client-ui-compaction':
specifier: workspace:*
version: link:../ui-compaction
'@deepseek-ai/dsh-client-ui-context-menu':
specifier: workspace:*
version: link:../ui-context-menu
@@ -4491,30 +4485,6 @@ importers:
specifier: ^18.2.0
version: 18.3.1
packages/client/ui-compaction:
devDependencies:
'@deepseek-ai/cordis':
specifier: workspace:~
version: link:../../../vendor/cordis
'@deepseek-ai/dsh-api-remotes':
specifier: workspace:*
version: link:../../api/remotes
'@deepseek-ai/dsh-api-session-controller':
specifier: workspace:*
version: link:../../api/session-controller
'@deepseek-ai/dsh-client-locale':
specifier: workspace:*
version: link:../locale
'@deepseek-ai/dsh-client-ui-sidebar-documentpreview':
specifier: workspace:*
version: link:../ui-sidebar-documentpreview
'@deepseek-ai/dsh-client-ui-sidebar-right':
specifier: workspace:*
version: link:../ui-sidebar-right
'@deepseek-ai/dsh-client-ui-slots':
specifier: workspace:*
version: link:../ui-slots
packages/client/ui-connector-account:
dependencies:
'@deepseek-ai/dsh-typert-protocol':
-1
View File
@@ -238,7 +238,6 @@ export const SERVICE_WALK_EXEMPTIONS: Record<string, string> = {
sidebarRightTabs: 'client-side right-Sidebar tab-type registry — packages/client/ui-sidebar-right/README.md owns the API',
forgeChanges: 'client-side changes view face for other plugins — docs/subsystems/forge.md#extension-api owns the API',
documentPreviews: 'client-side document renderer registry — docs/subsystems/sidebar-right.md owns the API',
compactionPreviews: 'client-side checkpoint preview navigation — packages/client/ui-compaction/README.md owns the API',
}
/**
@@ -186,7 +186,6 @@ const SENTENCE_MODEL_EXPERIENCE: Readonly<Record<string, SentenceContract>> = {
'packages/client/ui-directory-picker-native': { kind: 'none', reason: 'Browser-side surface driving the local Desktop or Host OS chooser; registers nothing model-facing.' },
'packages/client/ui-theme': { kind: 'none', reason: 'Browser-side UI plugin layer; registers nothing model-facing.' },
'packages/client/ui-sidebar-documentpreview': { kind: 'none', reason: 'Browser-only viewer for workspace files and in-memory content; registers no tool, prompt section, or session event, and what the user reads never enters a model request.' },
'packages/client/ui-compaction': { kind: 'none', reason: 'Browser-only viewer of a compaction checkpoint the model has already read; registers no tool, prompt section, or session event.' },
'packages/client/ui-sidebar-browser': { kind: 'none', reason: 'Browser-only navigation surface; visited content never enters a model request.' },
'packages/client/ui-sidebar-files': { kind: 'none', reason: 'Browser-only workspace file tree; registers no tool, prompt section, or session event.' },
'packages/client/resources': { kind: 'none', reason: 'Browser-side resource model (providers, pinning, useResource); registers nothing model-facing.' },
-2
View File
@@ -291,8 +291,6 @@
"@deepseek-ai/dsh-client-ui-sidebar-right/client": ["./packages/client/ui-sidebar-right/src/client"],
"@deepseek-ai/dsh-client-ui-sidebar-documentpreview": ["./packages/client/ui-sidebar-documentpreview/src"],
"@deepseek-ai/dsh-client-ui-sidebar-documentpreview/client": ["./packages/client/ui-sidebar-documentpreview/src/client"],
"@deepseek-ai/dsh-client-ui-compaction": ["./packages/client/ui-compaction/src"],
"@deepseek-ai/dsh-client-ui-compaction/client": ["./packages/client/ui-compaction/src/client"],
"@deepseek-ai/dsh-client-ui-sidebar-browser": ["./packages/client/ui-sidebar-browser/src"],
"@deepseek-ai/dsh-client-ui-sidebar-browser/client": ["./packages/client/ui-sidebar-browser/src/client"],
"@deepseek-ai/dsh-client-ui-sidebar-browser/types": ["./packages/client/ui-sidebar-browser/src/types.ts"],
-1
View File
@@ -137,7 +137,6 @@
{ "path": "./packages/client/ui-sidebar-right" },
{ "path": "./packages/client/ui-entry-customization" },
{ "path": "./packages/client/ui-sidebar-documentpreview/tsconfig.client.json" },
{ "path": "./packages/client/ui-compaction" },
{ "path": "./packages/client/ui-sidebar-browser/tsconfig.client.json" },
{ "path": "./packages/client/ui-sidebar-files" },
{ "path": "./packages/client/ui-jobs" },