Merge branch 'master' into claude/unified-environment-credentials-c8841a

Master removed the TUI package, the `meta` and `upgrade` subcommands, and
`--config-replace`, and made raw `dsh` require a `--config` overlay. Resolved
onto that shape:

- Dropped this branch's TUI edits with the surface itself, including
  `tui.cordis.yml`, `runTui`, and the TUI keyless PTY smoke.
- Dropped the `--config-replace` plumbing rather than reintroducing a flag
  master deliberately removed. The gap this branch fixed remains: `dsh -p`
  still could not name its composition, so it keeps `--config`.
- Kept this branch's deletion of the personal `$DSH_HOME/config.yaml` layer,
  which master still carried, and provided the environment snapshot in the new
  raw `runConfig` surface alongside web and headless.
- Ported the headless shutdown PTY test off the personal overlay onto a named
  `--config` file, which is what proves that flag now exists on `-p`.
This commit is contained in:
Yichen Jiang
2026-08-04 17:51:44 +08:00
668 changed files with 10527 additions and 30408 deletions

View File

@@ -2,5 +2,5 @@
# side as of the last confirmed-consistent state. Both languages carry equal authority;
# after editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write packages/client/ui-sidebar/README.md
README.md: 19c2d1033de4475816249aa8429f4a589eeb6481
README.zh.md: b8c154586570cf1b9fd4bf776bc09b36ab5ee7d2
README.md: 5bb697b3d2f9b5eaea9c382765d2510fa24806ce
README.zh.md: 302f66c540774b1f209fc797201e41c56b849310

View File

@@ -8,6 +8,8 @@ New Session starts the runtime's page-local frontend Session Intent; a real Work
`SidebarRootComponentProps` composes the layout owner share, the global `useSessions` and `useWorkspaces` hooks, the declared `sidebar.workspace` and `sidebar.settings` child slots, and injected `startSession`, `open`, and sidebar-toggle callbacks. There is no plugin store: `deriveGroups` consumes object-layer snapshots and component-local expansion/search state.
Scrollbars in the column are a pointer affordance: the shell rebinds ui-theme's [scrollbar indirection](../ui-theme/README.md) to `transparent` whenever the pointer is outside it, and keeps the thumb drawn for 2s after the pointer leaves, so a list nobody is pointing at carries no bar. The reservation that keeps rows from moving belongs to the scrolling region ([ui-workspace](../ui-workspace/README.md)), so revealing a thumb never reflows.
The foot is the `sidebar.settings` seat: the sidebar renders only the bottom-pinned layout slot and shares its column state (`wide`); ui-settings registers the trigger row and settings panel there.
The `/client` export surface is the plugin body (`apply`/`inject`) plus the contract types only — SidebarRoot, the row components, and the tree derivation are internal (the slot registration closes over them; tests import src paths directly).

View File

@@ -8,6 +8,8 @@ New Session 会启动运行时的页面局部前端 Session Intent;真实 Work
`SidebarRootComponentProps` 组合布局 owner share、全局 `useSessions` 和 `useWorkspaces` 钩子、已声明的 `sidebar.workspace` 与 `sidebar.settings` 子 slot,以及注入的 `startSession`、`open` 和侧边栏切换回调。这里没有插件 store:`deriveGroups` 消费对象层快照与组件局部的展开/搜索状态。
栏内的滚动条是一种指针可供性:只要指针不在栏内,外壳就把 ui-theme 的[滚动条间接层](../ui-theme/README.md)重新绑定为 `transparent`;指针离开后滑块再保留 2 秒,因此没人指向的列表不会带着滚动条。避免行位移的空间预留属于滚动区域本身([ui-workspace](../ui-workspace/README.md)),所以显示滑块不会引起重排。
页脚承载 `sidebar.settings`:侧边栏只渲染固定在底部的布局 slot,并共享其栏状态(`wide`);ui-settings 在此注册触发行和设置面板。
`/client` 导出表层只包含插件主体(`apply`/`inject`)及契约类型:SidebarRoot、行组件和树派生均属于内部实现(slot 注册通过闭包引用它们;测试直接导入 src 路径)。

View File

@@ -7,10 +7,11 @@
mid-slide. */
.root {
--dsh-sidebar-inline-padding: 12px;
display: flex;
flex-direction: column;
height: 100%;
padding: 6px 12px;
padding: 6px var(--dsh-sidebar-inline-padding);
box-sizing: border-box;
background: var(--dsw-specific-sidebar-fill);
color: var(--dsw-alias-label-primary);
@@ -24,6 +25,19 @@
padding: 18px 10px 6px;
}
/* Scrollbars in the column are a pointer affordance: the shell adds this
class whenever the pointer is not inside (SidebarRoot.tsx owns the linger),
and rebinding ui-theme's indirection pair to `transparent` takes the thumb
out of every scroll region nested under it — the workspace browser's
session list today. `transparent` rather than `display: none` on the bar:
the reservation (`scrollbar-gutter: stable` on the list) stays in force, so
revealing the thumb never reflows a row. Rebinding contract and the two
rendering paths it reaches: ui-theme's README. */
.root.quietBars {
--dsh-scrollbar-thumb: transparent;
--dsh-scrollbar-thumb-hover: transparent;
}
/* Collapse phase 1: the whole frozen-width content fades out in place over
150ms; at settle the children unmount/snap to the rail layout. */
.fading > * {
@@ -189,16 +203,22 @@
max-width: 0;
}
/* Region seat: always mounted so the foot never moves; the browser inside
handles its own wide/rail content. */
/* Region seat: always mounted so the foot never moves. Its trailing margin
cancels the wide shell inset so the nested scrollbar can sit at the sidebar
edge; the browser restores that inset inside its own rows. */
.regionArea {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
margin-right: calc(-1 * var(--dsh-sidebar-inline-padding));
overflow: hidden;
}
.collapsed .regionArea {
margin-right: 0;
}
/* Foot seat: a pure layout socket pinned under the region; the ui-settings
trigger row inside owns its own geometry (49px wide row / 36px rail
circle) and hover chrome. */

View File

@@ -8,6 +8,11 @@
* button and the foot is the `sidebar.workspaces` registrant's, and the foot
* is the `sidebar.settings` registrant's; the shell hands them the wide flag
* (plus an expand request callback for the browser).
*
* The column also owns whether the scroll regions nested in it draw a
* scrollbar at all: the shell tracks the pointer and rebinds ui-theme's
* scrollbar indirection away while it is elsewhere, so a list the user is not
* pointing at carries no bar.
*/
import { useEffect, useRef, useState } from 'react'
import clsx from 'clsx'
@@ -22,6 +27,14 @@ import css from './SidebarRoot.module.css'
/** Wide-content unmount delay; matches the 150ms wide-content fade-out. */
const COLLAPSE_SETTLE_MS = 150
/**
* How long the column's scrollbars stay drawn after the pointer leaves it.
* The bar is a pointer affordance here, and hiding it on the leave event
* itself makes it blink out while the pointer is only crossing the column's
* edge — on the way to the conversation, or around a portalled menu.
*/
const SCROLLBAR_LINGER_MS = 2000
/**
* Render the sidebar column shell.
* @param props - composed slot props (runtime share + injected callbacks, contract/slots.ts).
@@ -56,10 +69,62 @@ export function SidebarRoot({
const everWide = useRef(!collapsed)
if (!collapsed) everWide.current = true
// Scrollbars in the column follow the pointer (.quietBars rebinds them
// away): drawn while it is inside, and for SCROLLBAR_LINGER_MS after it
// leaves. A pointer that returns within that window cancels the pending
// hide rather than restarting from a hidden bar.
const column = useRef<HTMLDivElement>(null)
const [pointerInside, setPointerInside] = useState(false)
const lingerTimer = useRef<number | undefined>(undefined)
const armLinger = (): void => {
if (lingerTimer.current !== undefined) return
lingerTimer.current = window.setTimeout(() => {
lingerTimer.current = undefined
setPointerInside(false)
}, SCROLLBAR_LINGER_MS)
}
const cancelLinger = (): void => {
window.clearTimeout(lingerTimer.current)
lingerTimer.current = undefined
}
// Leaving is decided by the column's BOX, not by DOM containment, and only
// while the bars are drawn. ui-settings renders its full-viewport panel as a
// fixed-position DESCENDANT of this column, so a pointer moved onto that
// panel — or onto the conversation once it closes — fires no `pointerleave`
// here, and the bars would stay drawn over a column nobody is pointing at.
// The element's own leave stays as the one signal geometry cannot give: a
// pointer that leaves the window emits no further moves.
useEffect(() => {
if (!pointerInside) return
const onMove = (event: PointerEvent): void => {
const rect = column.current?.getBoundingClientRect()
/* v8 ignore next -- the listener only exists while the column is mounted and revealed. */
if (rect === undefined) return
const inside = event.clientX >= rect.left && event.clientX < rect.right
&& event.clientY >= rect.top && event.clientY < rect.bottom
if (inside) cancelLinger()
else armLinger()
}
document.addEventListener('pointermove', onMove)
return () => {
document.removeEventListener('pointermove', onMove)
cancelLinger()
}
}, [pointerInside])
return (
<div
className={clsx(css.root, !wide && css.collapsed, !wide && everWide.current && css.railIn, collapsed && wide && css.fading)}
ref={column}
className={clsx(
css.root, !wide && css.collapsed, !wide && everWide.current && css.railIn,
collapsed && wide && css.fading, !pointerInside && css.quietBars,
)}
style={wide ? { width: collapsed ? lastWideWidth.current : width } : undefined}
onPointerEnter={() => {
cancelLinger()
setPointerInside(true)
}}
onPointerLeave={() => { armLinger() }}
>
<div className={css.logoRow}>
{/* Expanded, the wordmark doubles as a New Session shortcut; the

View File

@@ -5,7 +5,7 @@ exports[`sidebar shell snapshots > renders the collapsed rail after the crossfad
data-slot="sidebar"
>
<div
class="root collapsed railIn"
class="root collapsed railIn quietBars"
style=""
>
<div
@@ -65,7 +65,7 @@ exports[`sidebar shell snapshots > renders the expanded column (wordmark, capsul
data-slot="sidebar"
>
<div
class="root"
class="root quietBars"
style="width: 300px;"
>
<div
@@ -135,7 +135,7 @@ exports[`sidebar shell snapshots > renders the expanded column in the default lo
data-slot="sidebar"
>
<div
class="root"
class="root quietBars"
style="width: 300px;"
>
<div

View File

@@ -0,0 +1,157 @@
// @vitest-environment jsdom
/**
* Pointer-revealed scrollbars, the shell's half: which class state the column
* carries as the pointer crosses it. The stylesheet rule that state drives is
* asserted in scrollbar-quiet-styles.spec.ts (node environment — a jsdom spec
* has no file: module URL to read the sheet through).
*/
import { afterEach, describe, expect, it, vi } from 'vitest'
import { act, cleanup, fireEvent, render } from '@testing-library/react'
import type { SidebarRootComponentProps, SidebarSectionOwnerProps } from '../src/client/contract/slots.ts'
import { SidebarRoot } from '../src/client/SidebarRoot.tsx'
import { en } from '../src/client/locales.ts'
/** Pinned column box; the shell compares pointer coordinates against it. */
const COLUMN_WIDTH = 280
const COLUMN_HEIGHT = 600
const t: SidebarRootComponentProps['t'] = key => (en as Record<string, string>)[key] ?? key
/** The shell never reads the global hooks; the props share carries them regardless. */
const neverHook = (() => { throw new Error('shell must not read global hooks') }) as never
afterEach(() => {
cleanup()
vi.useRealTimers()
})
/**
* Render the shell and expose its column element.
* @returns the column element and whether it currently carries the quiet state.
*/
function mountColumn(): { column: HTMLElement; quiet: () => boolean } {
const view = render(
<SidebarRoot
collapsed={false} width={300}
useSessions={neverHook} useWorkspaces={neverHook}
startSession={vi.fn()} toggleSidebar={vi.fn()} t={t}
renderSlot={((_key: string, owner: SidebarSectionOwnerProps) =>
<div data-testid="region" data-wide={owner.wide} />) as SidebarRootComponentProps['renderSlot']}
/>,
)
const column = view.container.firstElementChild
if (!(column instanceof HTMLElement)) throw new Error('sidebar column not rendered')
// jsdom lays nothing out, and the leave decision is geometric: pin the box
// the shell reads so a coordinate can be inside or outside it.
Object.defineProperty(column, 'getBoundingClientRect', {
value: () => ({
left: 0, top: 0, right: COLUMN_WIDTH, bottom: COLUMN_HEIGHT,
x: 0, y: 0, width: COLUMN_WIDTH, height: COLUMN_HEIGHT, toJSON: () => ({}),
}),
})
// CSS-module locals are hashed in this bench, so the state is read as a
// substring of the class list rather than as an exact local name.
return { column, quiet: () => [...column.classList].some(name => name.includes('quietBars')) }
}
/**
* Cross the pointer into or out of the column. React synthesizes
* `pointerenter`/`pointerleave` from `pointerover`/`pointerout`, so the raw
* enter and leave events it does not listen to would assert nothing.
* @param column - the sidebar column element.
* @param direction - `in` to enter the column, `out` to leave it.
*/
function movePointer(column: HTMLElement, direction: 'in' | 'out'): void {
const outside = document.body
if (direction === 'in') fireEvent.pointerOver(column, { relatedTarget: outside })
else fireEvent.pointerOut(column, { relatedTarget: outside })
}
/**
* Move the pointer over the document, as a pointer crossing a fixed overlay
* that is a DOM descendant of the column does.
* @param x - client x coordinate.
* @param y - client y coordinate.
*/
function movePointerOverDocument(x: number, y: number): void {
fireEvent.pointerMove(document, { clientX: x, clientY: y })
}
describe('SidebarRoot pointer-revealed scrollbars', () => {
it('draws them only while the pointer is inside, and lingers on the way out', () => {
vi.useFakeTimers()
const { column, quiet } = mountColumn()
// At rest — the pointer has never been over the column — the bars are off.
expect(quiet()).toBe(true)
movePointer(column, 'in')
expect(quiet()).toBe(false)
movePointer(column, 'out')
// The linger: still drawn just before the window closes, gone just after.
act(() => { vi.advanceTimersByTime(1999) })
expect(quiet()).toBe(false)
act(() => { vi.advanceTimersByTime(1) })
expect(quiet()).toBe(true)
})
it('cancels a pending hide when the pointer comes back', () => {
vi.useFakeTimers()
const { column, quiet } = mountColumn()
movePointer(column, 'in')
movePointer(column, 'out')
act(() => { vi.advanceTimersByTime(1000) })
movePointer(column, 'in')
// The first leave's timer would fire here; a cancelled one leaves the bars
// drawn, which is what keeps a pointer skirting the edge from blinking them.
act(() => { vi.advanceTimersByTime(5000) })
expect(quiet()).toBe(false)
})
it('hides when the pointer moves outside the column box without leaving its subtree', () => {
// ui-settings renders its full-viewport panel as a fixed-position
// DESCENDANT of the column, so DOM containment reports the pointer as
// still inside while it is visually somewhere else entirely.
vi.useFakeTimers()
const { column, quiet } = mountColumn()
movePointer(column, 'in')
expect(quiet()).toBe(false)
movePointerOverDocument(COLUMN_WIDTH + 400, 300)
act(() => { vi.advanceTimersByTime(2000) })
expect(quiet()).toBe(true)
})
it('does not restart the window when the pointer keeps moving outside', () => {
vi.useFakeTimers()
const { column, quiet } = mountColumn()
movePointer(column, 'in')
movePointer(column, 'out')
act(() => { vi.advanceTimersByTime(1500) })
// A pending hide is left alone rather than re-armed: otherwise a pointer
// resting outside the column would keep pushing the bars' disappearance
// out, one move at a time.
movePointerOverDocument(COLUMN_WIDTH + 400, 300)
act(() => { vi.advanceTimersByTime(600) })
expect(quiet()).toBe(true)
})
it('keeps them drawn while the pointer moves inside the column box', () => {
vi.useFakeTimers()
const { column, quiet } = mountColumn()
movePointer(column, 'in')
movePointer(column, 'out')
// A move landing back inside the box cancels the pending hide, the same
// way re-entering the element does.
movePointerOverDocument(COLUMN_WIDTH - 10, 300)
act(() => { vi.advanceTimersByTime(5000) })
expect(quiet()).toBe(false)
})
it('drops the pending hide when the column unmounts', () => {
vi.useFakeTimers()
const { column } = mountColumn()
movePointer(column, 'in')
movePointer(column, 'out')
cleanup()
// A timer surviving the unmount would call setState on a dead component.
expect(() => { vi.advanceTimersByTime(5000) }).not.toThrow()
expect(vi.getTimerCount()).toBe(0)
})
})

View File

@@ -0,0 +1,33 @@
/**
* The quiet-column rule as CSS text: the state SidebarRoot toggles
* (pointer-scrollbars.spec.tsx) hides a scrollbar only through this rule, and
* ui-theme's gate checks the rebinding contract's shape without knowing which
* sheet states which half.
*/
import { readFileSync } from 'node:fs'
import { fileURLToPath } from 'node:url'
import { describe, expect, it } from 'vitest'
const css = readFileSync(fileURLToPath(new URL('../src/client/SidebarRoot.module.css', import.meta.url)), 'utf8')
/** Declarations only: the sheet's prose names the properties it explains. */
const declarationText = css.replace(/\/\*[\s\S]*?\*\//g, ' ')
describe('SidebarRoot.module.css quiet column', () => {
it('rebinds the ui-theme indirection pair to transparent', () => {
// The pair, not the resting thumb alone: rebinding one leaves the other
// painting its base-surface colour the moment the pointer reaches the bar.
const rule = /\.root\.quietBars\s*\{([^{}]*)\}/.exec(declarationText)
expect(rule).not.toBeNull()
const declarations = (rule![1] ?? '').split(';').map(part => part.trim()).filter(Boolean).sort()
expect(declarations).toEqual([
'--dsh-scrollbar-thumb-hover: transparent',
'--dsh-scrollbar-thumb: transparent',
].sort())
})
it('leaves the gutter reservation to the scrolling region', () => {
// Hiding the thumb must not move a row: the reservation lives on the list
// (ui-workspace), so the column states colour only.
expect(declarationText).not.toMatch(/scrollbar-gutter/)
})
})

View File

@@ -0,0 +1,38 @@
/** Sidebar shell inset contract shared with the nested workspace browser. */
import { readFileSync } from 'node:fs'
import { fileURLToPath } from 'node:url'
import { describe, expect, it } from 'vitest'
const css = readFileSync(fileURLToPath(new URL('../src/client/SidebarRoot.module.css', import.meta.url)), 'utf8')
/**
* Declarations of one exact selector, keyed by property.
* @param selector - exact selector text.
* @returns the normalized declarations, or undefined when absent.
*/
function declarations(selector: string): Map<string, string> | undefined {
const withoutComments = css.replace(/\/\*[\s\S]*?\*\//g, ' ')
for (const [, selectorList = '', body = ''] of withoutComments.matchAll(/([^{}]+)\{([^{}]*)\}/g)) {
if (!selectorList.split(',').map(value => value.trim()).includes(selector)) continue
const found = new Map<string, string>()
for (const part of body.split(';')) {
const colon = part.indexOf(':')
if (colon === -1) continue
found.set(part.slice(0, colon).trim(), part.slice(colon + 1).trim().replace(/\s+/g, ' '))
}
return found
}
return undefined
}
describe('SidebarRoot.module.css inset', () => {
it('shares and cancels the wide shell trailing padding structurally', () => {
const root = declarations('.root')
expect(root?.get('--dsh-sidebar-inline-padding')).toBe('12px')
expect(root?.get('padding')).toBe('6px var(--dsh-sidebar-inline-padding)')
expect(declarations('.regionArea')?.get('margin-right')).toBe(
'calc(-1 * var(--dsh-sidebar-inline-padding))',
)
expect(declarations('.collapsed .regionArea')?.get('margin-right')).toBe('0')
})
})