* fix(ui): avoid tooltip trigger overlap when a side fits
* feat(ui): add navigation entry customization
* fix(test): keep tooltip geometry independent of JSX types
* fix(ui): align customization catalogs and integration fixtures
* test(ui): complete customization lifecycle and release integration coverage
* fix(ui): return entry discovery to the installed plugin list
* docs: refresh module graph for entry customization
* build: refresh workspace links for the moved entry customization package
* docs: regenerate catalogs and pairing hashes for the moved entry customization package
* test(web): cover default-loaded entry customization in the Web e2e
* test(ui): describe entry customization as a browser plugin in the host entry spec
* build: order entry customization publication files as workspace constraints require
* test(release): drop the moved entry customization package from the experimental family list
* style(ui): use the shared focus ring color on entry customization triggers
* test(web): re-record goldens for the default-loaded More navigation menus
* test(web): add the More conversation views trigger to the remaining CI-reported goldens
* docs: record region-owned pins for plugin entry customization
* refactor(ui): rebuild entry customization on region-owned pins and More menus
- Each navigation region (left sidebar, Conversation header, right sidebar
guide) persists its own unpinned list under
dsh.slot.manual-order.<list slot key>.v1, filters its own launchers, and
draws its own More button and Menu around its actions slot.
- ui-entry-customization only registers the shared menu rows (entries with
pin buttons, Browse other plugins, Create your plugin) into the three
actions slots and keeps no state.
- Remove ctx.layout.entryVisibility, the plugin store, left-sidebar drag
reordering, and agentPresetNavigation; ui-layout and ui-agent-preset match
release/dsh-0.2.1 again.
- Keep the release <nav> and Conversation tab-bar visibility conditions.
- Move the More glyph into ui-primitives as IconAppsAddOutline{Regular,Medium}.
* docs: compile the entry customization owner props example
* docs(ui): describe the wrapping Conversation tab row in the header comment
* fix(ui): return New Session to the Workspace blank and its unsent draft
- New Session (startSession without options) takes the blank-reuse path
again instead of creating a fresh Session on every call, which hid the
previous blank and its unsent draft since a5c9c2aaeef (#5775).
- A request that names an Agent preset skips blanks listing a different
preset, so Creator entries no longer take over an ordinary draft.
- Record the change in a v0.2.1-rc.2 upgrade guide; the Host refresh of a
stale loaded blank stays deferred (see the Agent Note).
* docs: regenerate the Cordis inspect catalog for New Session blank reuse
* fix(ui): keep the selected entry visible while unpinned
- Left-sidebar rows and View tabs keep the selected entry, with aria-current or aria-selected, until another entry is selected.
- Entry menu Creator action takes no region argument; the registration's region selects the prompt.
- Document the 2px panel-row and 32px View-tab gaps; drop commit hashes from the New Session Agent Note.
* fix(ui): leave a blank of another preset unstaged when starting Creator
startCreatorDraft stages cordis only when the main blank lists no preset or already lists cordis; navigation opens a separate Creator blank otherwise, so a Standard draft blank keeps its preset.
* feat(ui): choose whether a draft prompt replaces, appends to, or keeps an existing draft
- DraftInitializationOptions gains whenDraftExists ('replace' | 'append' | 'keep', default 'keep'); clearPreviousDraft stays and maps to 'replace' only when whenDraftExists is omitted.
- Append adds the prompt as new paragraphs after the existing text and references; attachments stay in every mode.
- The three Create your plugin entries append their regional prompt.
* test(web): align e2e with New Session blank reuse and the visible selected entry
* refactor(ui): share the draft paragraph writer between setDraft and appendDraft
---------
Co-authored-by: Yif <[email protected]>
Co-authored-by: imccyu <[email protected]>
172 lines
7.6 KiB
TypeScript
172 lines
7.6 KiB
TypeScript
// @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 type { GlobalStandardProps } from '@deepseek-ai/dsh-client-ui-slots'
|
|
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
import { act, cleanup, fireEvent, render } from '@testing-library/react'
|
|
import { allowAllAccess } from '@deepseek-ai/dsh-client-test-runtime'
|
|
import type { SidebarRootComponentProps, SidebarSectionOwnerProps } from '../src/client/contract/slots.ts'
|
|
import { SidebarRoot } from '../src/client/SidebarRoot.tsx'
|
|
import { en } from '../src/client/locales.ts'
|
|
|
|
// Every fixture carries the resource hook the resources plugin merges into GlobalStandardProps.
|
|
const useResource = (() => ({ status: 'none' as const, value: undefined, failure: undefined, reload: () => {} })) as GlobalStandardProps['useResource']
|
|
const usePanelInfo: GlobalStandardProps['usePanelInfo'] = selector => selector({ activePanelId: null })
|
|
|
|
/** 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
|
|
type AttentionSnapshot = Parameters<Parameters<SidebarRootComponentProps['useSessionStatus']>[0]>[0]
|
|
const noAttention: AttentionSnapshot = new Map()
|
|
const useSessionStatus: SidebarRootComponentProps['useSessionStatus'] = selector => selector(noAttention)
|
|
|
|
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} useSessionStatus={useSessionStatus} useSessionRetainInfo={neverHook}
|
|
usePanelInfo={usePanelInfo} selectPanel={() => {}} usePanels={selector => selector([])} useEntryPins={selector => selector([])}
|
|
useEntryActions={selector => selector(false)} setPinned={vi.fn()}
|
|
useShortcuts={selector => selector([])}
|
|
useResource={useResource} useWorkspaces={neverHook}
|
|
{...allowAllAccess}
|
|
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)
|
|
})
|
|
})
|