Files
deepseek-harness/examples/desktop/test/renderer-switchto-orphan-drawer-close.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

63 lines
2.6 KiB
JavaScript

// Bug D layer 5 (2026-07-18) — static test that switchTo cleans up the
// three orphan drawers documented in layout-overlap-audit.md.
//
// The audit found three drawers that historically stayed open across
// tab switches:
// - .fork-compare-drawer (#168 side-by-side compare)
// - .playground-compare-drawer (playground compare)
// - .devtools-drawer (Devtools event log)
//
// Team-lead's directive: navigating implicitly dismisses. This test locks
// the guard in renderer.js by pattern-matching the switchTo prologue so
// the branch can't silently regress.
'use strict'
const test = require('node:test')
const assert = require('node:assert/strict')
const fs = require('node:fs')
const path = require('node:path')
const SRC = fs.readFileSync(
path.join(__dirname, '..', 'src', 'renderer', 'renderer.js'),
'utf8',
)
test('switchTo closes fork-compare drawer', () => {
const idx = SRC.indexOf('function switchTo(name)')
assert.ok(idx > 0, 'switchTo function must exist in renderer.js')
const body = SRC.slice(idx, idx + 3000)
assert.match(body, /window\.__dshForkCompare[\s\S]*closeForkCompare/,
'switchTo must delegate to window.__dshForkCompare.closeForkCompare')
})
test('switchTo hides playground-compare-drawer element', () => {
const idx = SRC.indexOf('function switchTo(name)')
const body = SRC.slice(idx, idx + 3000)
assert.match(body, /getElementById\(['"]playground-compare-drawer['"]\)/,
'switchTo must find and hide the playground-compare-drawer element')
// The line right after must set hidden = true.
assert.match(body, /playground-compare-drawer[\s\S]{0,120}hidden\s*=\s*true/,
'switchTo must set the playground-compare-drawer .hidden = true')
})
test('switchTo hides every .devtools-drawer', () => {
const idx = SRC.indexOf('function switchTo(name)')
const body = SRC.slice(idx, idx + 3000)
assert.match(body, /querySelectorAll\(['"]\.devtools-drawer['"]\)/,
'switchTo must querySelectorAll .devtools-drawer')
assert.match(body, /devtools-drawer[\s\S]{0,200}hidden\s*=\s*true/,
'switchTo must hide every .devtools-drawer')
})
test('switchTo cleanup is defensive (try/catch around drawer hiding)', () => {
const idx = SRC.indexOf('function switchTo(name)')
const body = SRC.slice(idx, idx + 3000)
// The cleanup block should be try-wrapped so a stray null.dashN or
// missing __dshForkCompare export in a stripped build never breaks tab
// navigation. Presence of `try {` + `catch` inside the first 3 KB of
// the switchTo body proves this.
assert.match(body, /try\s*\{[\s\S]{0,1500}closeForkCompare[\s\S]{0,1500}catch/,
'the drawer-cleanup block must be try/catch guarded')
})