Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 1 addition & 99 deletions scripts/checks/check-client-bundles.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// check-client-bundles.mjs - load the pack's browser bundles the way the shell
// check-client-bundles.mjs - load the pack's browser bundles the way the shell
// does (module table + factory) and drive them with a REAL React runtime.
//
// Why this exists: the client halves have no build step and no type checker, so
Expand Down Expand Up @@ -304,9 +304,6 @@ function loadBundle(relative, extraRequire) {
return props && props.anchor !== undefined ? props.anchor : null
}
const Child = (props) => (props && props.children !== undefined ? props.children : null)
// A path label draws the path it is given; the review header uses it, and
// a static render only needs the text to be there.
const Path = (props) => (props && props.path !== undefined ? props.path : null)
// MarkdownText renders its text: the editor's rendered-view body draws it.
// IT IS `React.memo`-WRAPPED ON PURPOSE, because the shipped primitive is
// (`const MarkdownText = React.memo(...)`) and a memo component is an
Expand Down Expand Up @@ -379,16 +376,6 @@ function loadBundle(relative, extraRequire) {
// the new ones. (Medium is here because the real ui-theme reads it.)
IconChevronDownOutlineRegular: Null,
IconChevronUpOutlineRegular: Null,
// The turn review's own controls: split, wrap and open-file.
IconCompareSplitOutlineRegular: Null,
IconNowrapFillRegular: Null,
IconWrapFillRegular: Null,
IconInspectOutlineRegular: Null,
PathLabel: Path,
// The diff's code highlighter: the review renders plain spans when the
// highlighter returns nothing, which is what a static check needs.
languageForPath: () => undefined,
useCodeHighlighter: () => () => undefined,
IconLightOutlineRegular: Null,
IconLightOutlineMedium: Null,
IconDarkOutlineRegular: Null,
Expand Down Expand Up @@ -7098,91 +7085,6 @@ if (coreThemeBundle === null) {
check('shaders: the tab has no corpus browser in it', /corpus|gallery|search/i.test(viewerMarkup), false)
}

// ---------------------------------------------------------------- dsh-deliverables
// The pack forks the harness's deliverables bundle for ONE reason: the turn
// Review tab answers a binary change with "Binary file; changes cannot be
// shown", and a picture is a binary change. Loading the fork proves the patch
// did not break activation; server-rendering its review body once per kind
// proves the branch it added is the one that draws - and that a text diff and a
// non-image binary still take the shipped path.
{
const deliverables = loadBundle('packages/dsh-deliverables/lib/client.js', {})
const types = []
const seats = {}
let mentionApi = null
const t = (key) => key
const deliverablesCtx = {
effect: (fn) => { fn(); return () => {} },
on: () => {},
provide: (name, api) => { if (name === 'chatFileMentions') mentionApi = api; return () => {} },
locale: { register: () => () => {}, bind: () => t },
slots: {
inject: (name, fn) => { fn(); return () => {} },
register(spec, component) {
seats[spec.name + '#' + (spec.key ?? spec.id ?? '')] = { spec, component }
return () => {}
},
},
sidebarRightTabs: { register: (definition) => { types.push(definition); return () => {} } },
uiConversation: { events: { register: () => {} } },
configForms: { developerTools: { enabled: true } },
logger: { debug() {}, warn() {} },
}
deliverables.exports.apply(deliverablesCtx)
check('deliverables: one review tab type is registered', types.length === 1 && types[0].id + '/' + types[0].kind, '@deepseek-ai/dsh-client-ui-deliverables/changes-review')
check('deliverables: it claims the review address and nothing else', types[0].patterns.join(',') + '|' + types[0].canOpen('dsh-resource://changes-review/session/s1/7/2') + '|' + types[0].canOpen('dsh-resource://file/session/s1/a.png'), 'dsh-resource://changes-review/**|true|false')
check('deliverables: the changed-files card is registered', seats['conversation.chat.turnTail#@deepseek-ai/dsh-client-ui-deliverables'] !== undefined)
check('deliverables: the review body is registered', seats['sidebar.right.pane.tab#@deepseek-ai/dsh-client-ui-deliverables'] !== undefined)
check('deliverables: it still provides the chat file mentions', typeof mentionApi?.forClosing === 'function')

const body = seats['sidebar.right.pane.tab#@deepseek-ai/dsh-client-ui-deliverables']
const tab = {
id: 'tab-review',
contentId: 'dsh-resource://changes-review/session/session-1/7/2',
title: 'Review 2',
navigation: { params: { index: 0 }, revision: 1 },
signal: new AbortController().signal,
actions: { bindCommands: () => {}, openResource: () => {} },
}
/** One review render: the summary and comparison a turn announced, as the stores would serve them. */
const renderReview = (files, diff) => renderToStaticMarkup(h(body.component, {
useTabInfo: () => ({ tab, panel: { id: 'pane-1' } }),
sessionId: 'session-1',
useSessions: (selector) => selector({ byId: { 'session-1': { cwd: 'C:/work/repo' } } }),
useStore: (selector) => selector({ byTab: { 'tab-review': { index: 0, split: false, wrap: false } } }),
actions: { navigated() {}, selected() {}, toggledSplit() {}, toggledWrap() {} },
useChangesSummary: (selector) => selector(new Proxy({}, { get: () => ({ turn: 2, files, total: files.length, added: 0, deleted: 0 }) })),
useChangesDiff: (selector) => selector(new Proxy({}, { get: () => diff })),
usePresentedOpen: (selector) => selector(new Proxy({}, { get: () => undefined })),
usePresentedHost: (selector) => selector(null),
loadChangesSummary: () => {},
loadChangesDiff: () => {},
reloadPresentedHost: () => {},
openChanged: () => {},
renderSlot: () => null,
t,
}))

const image = { path: 'assets/vncode-banner6.png', display: 'assets/vncode-banner6.png', added: 0, deleted: 0, binary: true }
const imageMarkup = renderReview([image], { kind: 'binary', path: image.path, display: image.display })
check('deliverables: a binary image renders the picture', imageMarkup.includes('data-review-image="true"'))
check('deliverables: ...from the harness file route at the workspace path',
imageMarkup.includes('/api/file?path=' + encodeURIComponent('C:/work/repo/assets/vncode-banner6.png')))
check('deliverables: ...and no longer says changes cannot be shown', imageMarkup.includes('diff.binary'), false)
check('deliverables: the header counts it as an image', imageMarkup.includes('>Image<'))

const text = { path: 'src/app.ts', display: 'src/app.ts', added: 1, deleted: 0 }
const textMarkup = renderReview([text], { kind: 'text', path: text.path, display: text.display, before: true, after: true, coarse: false, hunks: [{ oldStart: 1, oldLines: 1, newStart: 1, newLines: 1, lines: ['+const answer = 42'] }] })
check('deliverables: a text change keeps the shipped comparison', textMarkup.includes('data-diff-line'))
check('deliverables: ...and does not draw a picture', textMarkup.includes('data-review-image'), false)

const archive = { path: 'dist/pack.zip', display: 'dist/pack.zip', added: 0, deleted: 0, binary: true }
const archiveMarkup = renderReview([archive], { kind: 'binary', path: archive.path, display: archive.display })
check('deliverables: a non-image binary keeps the shipped sentence', archiveMarkup.includes('diff.binary'))
check('deliverables: ...and is not drawn as a picture', archiveMarkup.includes('data-review-image'), false)
}

console.log('')
console.log(failures === 0 ? 'all client-bundle checks passed' : failures + ' check(s) FAILED')
process.exitCode = failures === 0 ? 0 : 1