The fork was pinned at upstream v0.18.0. That is the entire reason the window
ran TWO sidebars and TWO near-identical panel toggles: DSH 2.0.10 ships its own
right sidebar (@deepseek-ai/dsh-client-ui-sidebar-right), and upstream only
adopted it in v0.19.0-alpha.1 — which arrived after our fork point. v0.19.1 is
also the one upstream line whose support range actually matches our host
(engines.dsh >=0.1.5-rc.1, 14 DSH peers ^0.1.5-rc.1, host = 0.1.5-rc.2), so it
is the only tag the host's startup precheck accepts.
What upstream v0.18.0 → v0.19.1 brings
- src/client/native/{index,surface,tab-adapter}.tsx: every tab the plugin can
draw becomes an OFFICIAL native tab type + body, and an external plugin's
descriptor registered later gets its native type too. This is what retires
the fork's own right panel — and with it the duplicate toggle cluster
(`toggleCluster` is gone from v0.19.1).
- native tab-chip icons via the `sidebar.right.pane.tab.title` seat, coloured
built-in tab icons, file/folder glyphs from DSH's own `FileTypeIcon`.
- guide descriptions (DSH renders them while the guide lists <= 4 entries),
tab bodies that fill the panel, and the 0.1.5-rc.2 adaptation work we were
carrying by hand (peer/devDep pinning, primitives' transitive devDeps).
How the sync was done
Rebuilt the tree from the v0.19.1 tag rather than resolving 53 conflicted
files: our v0.18.0 delta was measured first and is only (a) one mechanical
rename `dsh-better-sidebar` -> `dsh-apes-sidebar` and (b) ten real edits. So:
tag tree + rename (scoped: code/config/scripts/tests/README, while the 46
historical docs/plans records and switch.sh's upstream package name stay
untouched) + re-applied deltas + our apes module.
Fork deltas re-applied on the new base
- src/client/apes/ (icons / locales / tabs): the three apes:* information-layer
tabs (agents / apps / profile), registered through the same BetterSidebarService
as the builtins — which is exactly why they now ride upstream's native adapter
into the official sidebar for free.
- identity: package.json (name/version 1.2.0/description/forkedFrom), dsh.plugin.json
(id/version), SIDEBAR_SERVICE_VERSION 1.2.0, README fork notice,
docs/external-plugin-guide.md.
- scripts/switch.sh + the pnpm switch* scripts (apes <-> upstream two-line switch).
- tests/apes-tabs.spec.ts (unescaped: it starts from the v0.19.1 base).
Dropped
- the Phase A native-registration spike (`apes/native-tabs.tsx` + its spec): it
re-derived by hand exactly what upstream's native layer already does — the
hand-written bridge is dead weight now, and v0.19.1's own e2e/jsdom lanes
cover the same seat contract far better.
- the unused apesProfileGuideDesc key and the two package.json.bak.* backups.
Verified on the new base: typecheck clean; build clean; 1351 passed / 9 skipped
(128 files), up from 1255 on the old base.
90 lines
3.3 KiB
TypeScript
90 lines
3.3 KiB
TypeScript
/**
|
|
* Lazy chunk view wrapper: mounts a component that lives in a lazy chunk,
|
|
* showing a loading placeholder while the chunk script loads and an error +
|
|
* retry affordance on failure. Used by the built-in tab/viewer descriptors.
|
|
*
|
|
* Contract note: {@link lazyChunkComponent} returns a plain render-prop
|
|
* function — the descriptor contract is `component: (props) => ReactNode`,
|
|
* and the repo renders descriptors BOTH ways: Sidebar calls
|
|
* `descriptor.component(props)` directly, EditorHost renders it via
|
|
* `createElement`. The wrapper function body therefore contains no hooks;
|
|
* all state lives in the inner {@link LazyChunkView} component.
|
|
*/
|
|
import { createElement, useEffect, useState, type ComponentType, type ReactNode } from 'react'
|
|
import { loadChunk, type ChunkExports, type ChunkName } from './chunk-loader.ts'
|
|
import { t } from './locales.ts'
|
|
import css from './sidebar.module.css'
|
|
|
|
interface LazyChunkViewProps<P> {
|
|
chunk: ChunkName
|
|
/** Module-level-stable selector (an inline lambda would re-trigger the effect). */
|
|
pick: (mod: ChunkExports) => ComponentType<P> | undefined
|
|
props: P
|
|
}
|
|
|
|
function LazyChunkView<P extends object>({ chunk, pick, props }: LazyChunkViewProps<P>): ReactNode {
|
|
const [attempt, setAttempt] = useState(0)
|
|
const [state, setState] = useState<
|
|
| { status: 'loading' }
|
|
| { status: 'error'; message: string }
|
|
| { status: 'ready'; Comp: ComponentType<P> }
|
|
>({ status: 'loading' })
|
|
|
|
useEffect(() => {
|
|
let cancelled = false
|
|
setState({ status: 'loading' })
|
|
loadChunk(chunk).then((mod) => {
|
|
if (cancelled) return
|
|
const Comp = pick(mod)
|
|
if (Comp === undefined) {
|
|
setState({ status: 'error', message: `[dsh-apes-sidebar] chunk "${chunk}" is missing its component` })
|
|
return
|
|
}
|
|
setState({ status: 'ready', Comp })
|
|
}).catch((error: unknown) => {
|
|
if (cancelled) return
|
|
setState({ status: 'error', message: error instanceof Error ? error.message : String(error) })
|
|
})
|
|
return () => { cancelled = true }
|
|
}, [chunk, pick, attempt])
|
|
|
|
if (state.status === 'loading') {
|
|
return <div className={css.editorPlaceholder}>{t('loading')}</div>
|
|
}
|
|
if (state.status === 'error') {
|
|
return (
|
|
<div className={css.editorError}>
|
|
<span>{state.message}</span>
|
|
<button
|
|
type="button"
|
|
className={css.terminalRetry}
|
|
onClick={() => { setAttempt(current => current + 1) }}
|
|
>
|
|
{t('terminalRetry')}
|
|
</button>
|
|
</div>
|
|
)
|
|
}
|
|
return createElement(state.Comp, props)
|
|
}
|
|
|
|
/**
|
|
* Build a descriptor-compatible lazy wrapper for a chunk-resident component.
|
|
* The returned function is the descriptor `component` itself: it returns an
|
|
* element and never calls hooks, so both invocation styles (plain function
|
|
* call and createElement/JSX render) work. `pick` must be a module-level
|
|
* function (stable identity) — an inline lambda would re-trigger the load
|
|
* effect on every render.
|
|
* @param chunk - the chunk name (see chunk-loader.ts).
|
|
* @param pick - select the component from the chunk's exports.
|
|
*/
|
|
export function lazyChunkComponent<P extends object>(
|
|
chunk: ChunkName,
|
|
pick: (mod: ChunkExports) => ComponentType<P> | undefined,
|
|
): (props: P) => ReactNode {
|
|
return (props: P) => createElement(
|
|
LazyChunkView as ComponentType<LazyChunkViewProps<P>>,
|
|
{ chunk, pick, props },
|
|
)
|
|
}
|