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.
132 lines
5.9 KiB
TypeScript
132 lines
5.9 KiB
TypeScript
/**
|
|
* Interception of the chat's produced-files row: the turn-tail chain entry
|
|
* that replaces ui-deliverables' row when the closing turn produced files.
|
|
* The takeover looks identical (same chip row); the chips open the file in
|
|
* the sidebar instead of the host OS. Priority -1 runs before the default-0
|
|
* deliverables entry; when nothing was produced the selector returns null
|
|
* and the original row renders unchanged.
|
|
*/
|
|
import { IconCodeOutline16 } from '@deepseek-ai/dsh-client-ui-primitives'
|
|
import type { Context } from '../context-types.ts'
|
|
import { revealPaths, type SidebarStore } from './state.ts'
|
|
import { t } from './locales.ts'
|
|
import { resolveSidebarPath, selectProducedFiles } from './produced-files.ts'
|
|
import css from './sidebar.module.css'
|
|
|
|
/** Open a file in the sidebar's editor (used by the intercepted row and the explorer). */
|
|
export function openSidebarFile(ctx: Context, store: SidebarStore, sessionId: string, path: string): void {
|
|
const summary = ctx.sessions.list.getSnapshot().byId[sessionId]
|
|
const absolute = resolveSidebarPath(summary?.cwd, path)
|
|
const at = Math.max(absolute.lastIndexOf('/'), absolute.lastIndexOf('\\'))
|
|
const title = at === -1 ? absolute : absolute.slice(at + 1)
|
|
// Route through the sidebar service so the editor descriptor's dedupeKey
|
|
// (per-path) applies; the id is path-derived so multiple editors coexist.
|
|
ctx.get('betterSidebar')?.openTab({ type: 'editor', title, path: absolute, id: `editor:${absolute}` })
|
|
}
|
|
|
|
/**
|
|
* Reveal the produced files in the sidebar explorer: expand their parent
|
|
* directories, highlight the rows, and focus the explorer tab. Unknown
|
|
* files fall back to revealing the workspace root itself.
|
|
*/
|
|
export function revealInExplorer(
|
|
ctx: Context,
|
|
store: SidebarStore,
|
|
sessionId: string,
|
|
files: readonly string[],
|
|
): void {
|
|
const summary = ctx.sessions.list.getSnapshot().byId[sessionId]
|
|
const cwd = summary?.cwd
|
|
// Deliverables report paths as-is (often relative to the session cwd), but
|
|
// the explorer tree and revealPaths work on absolute paths — resolve every
|
|
// target so the ancestors expand and the row actually matches.
|
|
const targets = files.length > 0
|
|
? files.map(path => resolveSidebarPath(cwd, path))
|
|
: cwd === undefined ? [] : [cwd]
|
|
store.reduce(state => revealPaths(state, cwd, targets))
|
|
// Focus the single-instance editor home tab (the files window) where the
|
|
// reveal highlight renders. Read via ctx.get like every other internal
|
|
// consumer (#357): the provider is not on this fiber chain, so a direct
|
|
// ctx.betterSidebar read can throw before optional chaining applies.
|
|
ctx.get('betterSidebar')?.openTab({ type: 'editor', title: t('files') })
|
|
}
|
|
|
|
/** The intercepted produced-files row (visual twin of the deliverables chips). */
|
|
export function SidebarProducedFiles(props: {
|
|
matched: readonly string[]
|
|
openInSidebar: (path: string) => void
|
|
/** Reveal the produced files in the explorer ("Show in folder" twin). */
|
|
onShowInFolder: (files: readonly string[]) => void
|
|
}) {
|
|
const { matched, openInSidebar, onShowInFolder } = props
|
|
const shown = matched.slice(0, 6)
|
|
const hidden = matched.length - shown.length
|
|
return (
|
|
<div className={css.producedRow}>
|
|
<span className={css.producedLabel}>{t('produced')}</span>
|
|
{shown.map(path => {
|
|
const at = Math.max(path.lastIndexOf('/'), path.lastIndexOf('\\'))
|
|
const name = at === -1 ? path : path.slice(at + 1)
|
|
return (
|
|
<button
|
|
key={path}
|
|
type="button"
|
|
className={css.producedChip}
|
|
title={path}
|
|
onClick={() => { openInSidebar(path) }}
|
|
>
|
|
<IconCodeOutline16 size={12} />
|
|
<span>{name}</span>
|
|
</button>
|
|
)
|
|
})}
|
|
{hidden > 0 && <span className={css.producedMore}>+{hidden}</span>}
|
|
{hidden > 0 && (
|
|
<button
|
|
type="button"
|
|
className={css.producedMore}
|
|
style={{ cursor: 'pointer', textDecoration: 'underline', textUnderlineOffset: 2 }}
|
|
onClick={() => { onShowInFolder(matched) }}
|
|
>
|
|
{t('showInFolder')}
|
|
</button>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
/**
|
|
* Register the turn-tail interception (returns the disposer).
|
|
*
|
|
* The slot is a CHILD slot the host's ui-conversation declares in its
|
|
* `conversation.chat.node` children table (kind: chain, scope: session).
|
|
* Registering it directly races the declaration — the ui-slots core's
|
|
* load-time validation throws "not declared (a parent entry's children
|
|
* table must declare it)" when the parent entry is not on the ledger yet.
|
|
* slots.inject waits for the declaration: the callback runs synchronously
|
|
* when the slot is already declared, otherwise it runs inside the declaring
|
|
* register() call once the declaration commits; declaration collapse
|
|
* disposes the entry and a later declaration re-registers it. This mirrors
|
|
* @deepseek-ai/dsh-client-ui-deliverables' registration of the same slot.
|
|
*/
|
|
export function registerTurnTailInterception(ctx: Context, store: SidebarStore): () => void {
|
|
return ctx.slots.inject('conversation.chat.turnTail', () => ctx.slots.register({
|
|
name: 'conversation.chat.turnTail',
|
|
// Decline the takeover while the editor tab type is disabled in the side
|
|
// card settings: the produced-files row falls back to the default
|
|
// deliverables behavior instead of offering chips that cannot open. Also
|
|
// while the sidebar is externally disabled (aionui-panel chosen).
|
|
select: (owner) => {
|
|
if (store.getSuspended()) return null
|
|
if (store.getPrefs().tabsEnabled['editor'] === false) return null
|
|
return selectProducedFiles(owner)
|
|
},
|
|
priority: -1,
|
|
registrant: 'dsh-apes-sidebar',
|
|
inject: (sessionId: string) => ({
|
|
openInSidebar: (path: string) => { openSidebarFile(ctx, store, sessionId, path) },
|
|
onShowInFolder: (files: readonly string[]) => { revealInExplorer(ctx, store, sessionId, files) },
|
|
}),
|
|
}, SidebarProducedFiles))
|
|
}
|