Files
deepseek-harness/examples/desktop/test/nav-structure.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

159 lines
7.6 KiB
JavaScript

// Nav structure static gate (task #189). The three-group left-nav is a
// coordination point for four parallel lanes — context / hub / bench /
// rubrics each swap one `data-lane="pending"` button for a wired one.
// If a lane inadvertently rewrites the whole nav (or a merge conflict
// erases a group header), this gate fails loudly. It's a shape test,
// not a screenshot test — the CDP shots in docs/demo-shots cover the
// visual side.
'use strict'
const test = require('node:test')
const assert = require('node:assert')
const fs = require('node:fs')
const path = require('node:path')
const HTML = fs.readFileSync(
path.resolve(__dirname, '..', 'src/renderer/index.html'),
'utf8'
)
test('sidebar declares three activity groups plus admin', () => {
const groups = HTML.match(/data-nav-group="([^"]+)"/g) || []
const names = groups.map((m) => m.match(/data-nav-group="([^"]+)"/)[1])
// Order matters: observation first (scanning), iteration second
// (making), runtime last (managing). Admin lives after the trio.
assert.deepStrictEqual(names, ['observation', 'iteration', 'runtime', 'admin'])
})
test('no lane still carries pending — all four slots flipped', () => {
// Merge history: bench flipped at BENCH merge; context flipped at CTX
// merge; hub + rubrics flipped at NAV delta merge (per team-lead rule
// "each slot flips in its own lane's merge — since neither HUB nor RUB
// touched index.html on their merge path, and NAV delta is the first
// merge after HUB/RUB that DOES touch index.html for a related reason,
// their attr flip is bundled into NAV delta"). The whole four-lane
// pending-slot coordination is now closed; if a future lane needs a
// reserved slot, add a fresh comment block and reintroduce the assert.
const lines = HTML.split('\n')
const buttonPending = lines.filter((l) => /<button[^>]*data-lane="pending"/.test(l))
assert.strictEqual(buttonPending.length, 0,
`all four coordinated slots should be flipped (found ${buttonPending.length} still-pending)`)
})
test('Runtimes tab and pane exist', () => {
assert.match(HTML, /data-tab="runtimes"/)
assert.match(HTML, /data-pane="runtimes"/)
assert.match(HTML, /id="runtimes-pane"/)
})
test('Settings tab and pane exist', () => {
assert.match(HTML, /data-tab="settings"/)
assert.match(HTML, /data-pane="settings"/)
assert.match(HTML, /id="settings-pane"/)
})
test('Tracing tab and pane exist (#225 lane-tracing slot)', () => {
// Lane-tracing slot lives in the `observation` group next to Chat /
// Session Tree / Context. The button is a plain `data-tab="tracing"`
// (no data-lane="pending" fence — landed live in the lane-tracing
// merge, same pattern as the context slot). Pane is `data-pane
// ="tracing"`, hosting the reference tracing UI-style project runs table. This
// gate protects the wire so a future left-nav reshuffle doesn't
// silently orphan the Tracing surface.
assert.match(HTML, /data-tab="tracing"/, 'Tracing sidebar button missing')
assert.match(HTML, /data-pane="tracing"/, 'Tracing pane section missing')
// The observation group bumps to 4 items when Tracing lands (Chat,
// Session Tree, Context, Tracing). If a lane inadvertently drops it
// back to 3, this fails loudly.
assert.match(
HTML,
/data-nav-group="observation"\s+data-item-count="4"/,
'observation group data-item-count must be 4 with Tracing in place'
)
})
test('Missions retitle landed (both header + sidebar label)', () => {
// Nav label
assert.match(HTML, /<span>Missions<\/span>/)
// Pane page-title
assert.match(HTML, /<div class="page-title">Missions<\/div>/)
// Sidebar section-label
assert.match(HTML, /<span class="section-label">Missions<\/span>/)
})
test('Sample-trace button + fixture exist', () => {
assert.match(HTML, /id="empty-load-sample-trace"/)
const fixturePath = path.resolve(__dirname, '..', 'fixtures/trace-samples/sample-session.json')
assert.ok(fs.existsSync(fixturePath), 'sample-session.json fixture must exist')
const events = JSON.parse(fs.readFileSync(fixturePath, 'utf8'))
assert.ok(Array.isArray(events), 'fixture is a JSON array')
assert.ok(events.length >= 60, 'fixture holds a multi-turn session (>=60 events)')
})
test('Rec 29 revision: empty-state launcher offers the four canonical doors', () => {
// User ruling 2026-07-17 ("两种风格重复了,只保留一种"): the empty
// state was collapsed from 8 cards (4 vertical launcher + 4 horizontal
// prompt-chip) down to a single 4-card horizontal row. Door set was
// reprioritized around "everything is a plugin" and context/tracing
// as the DSH differentiators:
// • vibe-plugin — Have the agent write a plugin (C-slot)
// • context — Explore context & composition
// • try-chat — Try a chat
// • sample-trace — See a full trace (loads fixture + jumps Tracing)
// Retired from the empty state (still reachable via left-nav):
// bench, growth. This test guards the door set so any future rename
// lands here first and forces the renderer branch to move in lockstep.
assert.match(HTML, /data-empty-launcher/, 'launcher container marker present')
for (const which of ['vibe-plugin', 'context', 'try-chat', 'sample-trace']) {
const re = new RegExp(`data-launcher="${which}"`)
assert.match(HTML, re, `launcher card for "${which}" missing`)
}
// Retired doors must NOT appear as launcher entries — they add
// scroll and dilute the "plugin + context + tracing" story. Their
// nav-item buttons in the sidebar are unaffected.
for (const which of ['bench', 'growth']) {
const re = new RegExp(`data-launcher="${which}"`)
assert.doesNotMatch(HTML, re, `retired launcher card for "${which}" must be removed`)
}
})
test('Rec 30: API keys table declares the resource-schema columns', () => {
// Column order matches reference tracing UI Settings > API Keys:
// Name / Tier / Description / Presence / Last used
assert.match(HTML, /data-settings-keys-table/, 'keys resource table present')
assert.match(HTML, /data-settings-keys-tbody/, 'keys tbody hook present')
// Header cells in order — grabs the first <thead> under the keys table.
const tableMatch = HTML.match(/<table[^>]*data-settings-keys-table[\s\S]*?<\/table>/)
assert.ok(tableMatch, 'keys table block found')
const headers = [...tableMatch[0].matchAll(/<th>([^<]+)<\/th>/g)].map((m) => m[1].trim())
assert.deepStrictEqual(
headers,
['Name', 'Tier', 'Description', 'Presence', 'Last used'],
'keys table column order must match the LangSmith resource schema (rec 30)'
)
})
test('Sample-trace fixture covers every family the empty state promises', () => {
const fixturePath = path.resolve(__dirname, '..', 'fixtures/trace-samples/sample-session.json')
const events = JSON.parse(fs.readFileSync(fixturePath, 'utf8'))
const types = new Set(events.filter((e) => e && e.type).map((e) => e.type))
// Turn container: needs step/start + assistant/message + turn/end.
assert.ok(types.has('step/start'))
assert.ok(types.has('assistant/message'))
assert.ok(types.has('turn/end'))
// Partial tool-row: tool/call + tool/result (2.3 stream).
assert.ok(types.has('tool/call'))
assert.ok(types.has('tool/result'))
// Compact card family: compact/start + compact/summary + compact/end.
assert.ok(types.has('compact/start'))
assert.ok(types.has('compact/summary'))
assert.ok(types.has('compact/end'))
// Subagent inline: the 2.6 notification carries a subagent.finished
// notification-shaped event (type "_notification").
const subagentFinishes = events.filter(
(e) => e && e.type === '_notification' && e.method === 'subagent.finished'
)
assert.ok(subagentFinishes.length >= 1, 'subagent.finished notification present')
})