Files
deepseek-harness/examples/desktop/test/renderer-compact-meta.test.js
ZiyaZhang e8f5c0b51b feat(desktop): DSH Electron desktop shell — harness internals visualized
Minimal Electron shell over the DSH JSON-RPC runtime — a first-look at
what a ChatGPT.app-style host on top of the DeepSeek Harness looks
like, with the harness's normally-invisible internals (trace timeline,
context surface, subagent tree, compaction, plugin registry, rubrics)
brought forward as first-class UI surfaces so plugin authors and
researchers can see what the agent is actually doing.

Runs against three keyless-to-live profiles (stdio-echo works on
master out of the box; daemon-echo / daemon-vibe-echo activate once
the daemon-demo lands; stdio-deepseek and daemon-vibe hit the real
DeepSeek API when you supply a key). HARNESS_DEV auto-resolves to the
in-repo runtime when this shell ships under examples/desktop/, so a
fresh clone launches without config; env DSH_DEV_ROOT overrides for
custom layouts, and a sibling deepseek-harness-dev/ checkout is the
original dev workflow.

Cold-clone gate (P0 fixes for first-time-clone usability):
- HARNESS_DEV: 3-candidate resolver (env → walk-up in-repo marker →
  sibling), unit-tested via mock fs so ordering is locked without
  needing either real layout on disk.
- config yml leaves rewritten at assemble time so the sibling-clone
  paths (../../deepseek-harness-dev/examples/echo-agent/…) become
  the in-repo paths (../../echo-agent/…) in the released tree —
  source yml stays usable for local dev, released tree ships a
  working shape.
- pnpm-workspace.yaml allowBuilds.electron = true (was placeholder).
- missing-key card in stdio-deepseek offers a one-click switch to
  stdio-echo (the keyless profile that works on master) rather than
  daemon-echo (blocked on the not-yet-shipped daemon-demo).
- assemble-oss-release.sh rewrites the source-side breadcrumb name
  'dsh-desktop-demo' → 'dsh-desktop' for the released package.json.

FOUC guard on the onboarding gate (41fc5df carried) keeps the
first-launch splash from flashing before the runtime probe finishes.

Test suite (1634 tests in source, 3990 in the runtime repo) covers
resolver ordering, renderer classifiers, trace timeline shape,
compaction diff rendering, rubric parity, and the missing-key
onboarding paths.
2026-07-18 12:59:34 -07:00

102 lines
3.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Compact card meta rendering — now on the "Policy & accounting" tab (task #137).
//
// Post demo 批 2 §1.7, the meta line moved out of `.compact-card .meta`
// and into a definition-list rendered inside the third tab of the new
// three-tab shell. Ticket F fields (model / maxTokens / reason) still
// land here, alongside §1.7's trigger kind / shadowedRange /
// shadowedTokenCount / shadowedSeqs.length rows.
//
// Missing/whitespace fields drop rows — never render "unknown" placeholders.
'use strict'
const test = require('node:test')
const assert = require('node:assert/strict')
const { loadRenderer } = require('./renderer-harness.js')
async function driveCompact(dataOverride) {
const { renderer, document } = await loadRenderer()
renderer.ensureSession('sid-meta', { title: 't', header: {} })
await renderer.selectSession('sid-meta')
renderer.onSessionEvent('sid-meta', {
type: 'compact/summary',
seq: 12,
time: 2,
data: {
summary: [{ type: 'text', text: 'summary body.' }],
shadowedTokenCount: 640,
shadowedSeqs: [1, 2, 3],
...dataOverride,
},
})
return { renderer, document }
}
function metaRows(document) {
const card = document.querySelector('.compact-card')
if (!card) return null
const dl = card.querySelector('.compact-card-tab-meta')
if (!dl) return null
const rows = []
const kids = Array.from(dl.children || [])
for (let i = 0; i + 1 < kids.length; i += 2) {
const dt = kids[i]
const dd = kids[i + 1]
if (dt && dd) rows.push({ label: dt.textContent, value: dd.textContent })
}
return rows
}
function findRow(rows, label) {
if (!rows) return null
return rows.find((r) => r.label === label) || null
}
test('meta tab renders model as its own row', async () => {
const { document } = await driveCompact({ model: 'test-model-42' })
const row = findRow(metaRows(document), 'Summary model')
assert.ok(row, 'meta tab must include Summary model row when data.model is present')
assert.equal(row.value, 'test-model-42')
})
test('meta tab renders maxTokens as ≤N tok', async () => {
const { document } = await driveCompact({ model: 'x', maxTokens: 8192 })
const row = findRow(metaRows(document), 'Summary cap')
assert.ok(row)
assert.equal(row.value, '≤8192 tok')
})
test('meta tab renders trimmed user reason', async () => {
const { document } = await driveCompact({
model: 'x', reason: 'freeing headroom before a long browse',
})
const row = findRow(metaRows(document), 'User reason')
assert.ok(row)
assert.equal(row.value, 'freeing headroom before a long browse')
})
test('meta tab drops empty/whitespace reason', async () => {
const { document } = await driveCompact({ model: 'x', reason: ' ' })
assert.equal(findRow(metaRows(document), 'User reason'), null)
})
test('meta tab drops non-number maxTokens (legacy null)', async () => {
const { document } = await driveCompact({ model: 'x', maxTokens: null })
assert.equal(findRow(metaRows(document), 'Summary cap'), null)
})
test('meta tab always renders trigger row (Trigger) even for bare compact', async () => {
const { document } = await driveCompact({})
const row = findRow(metaRows(document), 'Trigger')
assert.ok(row, 'trigger row is mandatory — always tells the reader why compaction fired')
assert.match(row.value, /idle/)
})
test('meta tab renders shadowedRange as seq X Y', async () => {
const { document } = await driveCompact({
shadowedRange: { start: 10, end: 90 },
})
const row = findRow(metaRows(document), 'Compacted range')
assert.ok(row)
assert.equal(row.value, 'seq 10 90')
})