fix(web): size the drop target's highlighted card to the right sidebar
Co-authored-by: liukx0205 <[email protected]> Co-authored-by: Yifffan <[email protected]>
This commit is contained in:
1 parent
c7225ab990
commit
d03be2bf85
8 files changed
+53
-20
No files matched your search
@@ -15,8 +15,8 @@
|
||||
en: d152484eb41ac6b4
|
||||
zh: 09388d293f9be9cb
|
||||
/deepseek-ai-dsh-client-ui-subagent/use-this-package:
|
||||
en: 0ac6deb29564f9e8
|
||||
zh: b2bb27848569fc9a
|
||||
en: 7e3eece5a469ece5
|
||||
zh: 806e7485183135b1
|
||||
/deepseek-ai-dsh-client-ui-subagent/use-this-package/browsing-the-tree:
|
||||
en: da87d582146106c4
|
||||
zh: f640b3a3fcc11209
|
||||
|
||||
@@ -29,7 +29,7 @@ The session header uses the session title for ordinary breadcrumbs. Subagent bre
|
||||
|
||||
This package registers the `dsh-resource://subagentchat/session/<child>?parent=<parent>&mode=<mode>` resource and builtin Sidebar tab type. The resource retains the child `SessionReference` directly from its address without refreshing the parent catalog, and releases the reference when the tab record closes. The tab renders the shared `conversation.content` Factory through `sidebar.chat.conversation`, fixes the local View to Chat, and omits the main Conversation header and width controls. A Workspace picked in a blank child's Hero opens that Workspace's blank Session as the main Session and moves the draft to it, as the main Conversation does.
|
||||
|
||||
Dragging a root Session row from the Session list shows a drop target while another Session is on screen. The target covers the whole window to the right of the navigation column or narrow-window drawer that the row left, with the same 8px inset on every side, and stacks above the drawer's mask. Dropping there opens the dragged Session as `dsh-resource://subagentchat/session/<id>`, an address without a query, in the on-screen Session's Sidebar column, or reveals the tab that already shows it. Its Conversation accepts follow-up prompts like the main Conversation, and the tab is saved with that Session's browser-local Sidebar layout. The tab title is the Session's display title.
|
||||
Dragging a root Session row from the Session list shows a drop target while another Session is on screen. The target blurs the whole window to the right of the navigation column or narrow-window drawer that the row left and accepts the drop anywhere there; its highlighted card sits at the right edge, as wide as the right Sidebar would open, with an 8px inset on every side. The target stacks above the drawer's mask. Dropping there opens the dragged Session as `dsh-resource://subagentchat/session/<id>`, an address without a query, in the on-screen Session's Sidebar column, or reveals the tab that already shows it. Its Conversation accepts follow-up prompts like the main Conversation, and the tab is saved with that Session's browser-local Sidebar layout. The tab title is the Session's display title.
|
||||
|
||||
The section's title control (`conversation.session.panel.section.actions`, key `subagents`) shows direct-member progress: completed, in progress, not running, and external counts in that order, with zero counts omitted and the separator matching the input task list. External tasks never count as running or completed. The section lists running subagents first, the most recently started first, and then the others, the most recently updated first. It shows five rows and then the Session panel's fold control, “Show {count} more”, which shows the rest and then reads “Show less”; the list folds only when that holds back two rows or more, the choice holds for the Session, also after the panel is hidden and shown again, and an expanded branch's own rows all show. The section hides with its title while the Session has no subagents and no failed catalog read. While direct subagents run and the panel does not show, a blue dot on the panel toggle (`conversation.session.panel.indicator`) says so and names their number for assistive technology; external tasks do not count. The Session panel scrolls the section; the tree has no nested scrolling. The breadcrumb switcher menu is 360px wide with 6px outer padding, constrained to fit the layout viewport, and only the menu scrolls. In WebKit-compatible browsers, its native 5px scrollbar sits in the right 6px inset with inset track ends and a stable gutter, preserving content width when scrolling becomes necessary. Other browsers retain their standard native scrollbar.
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ kind: "package-reference"
|
||||
|
||||
本包注册 `dsh-resource://subagentchat/session/<child>?parent=<parent>&mode=<mode>` 资源与 builtin Sidebar tab 类型。资源直接根据地址保留 child 的 `SessionReference`,不刷新 parent 目录,并在 tab 记录关闭时释放 reference。tab 通过 `sidebar.chat.conversation` 渲染共享 `conversation.content` Factory,把局部 View 固定为 Chat,并省略主 Conversation 的 Header 与宽度控制。在空白 child 的 Hero 中选择工作区时,与主 Conversation 一样,把该工作区的空白 Session 打开为主 Session,并把草稿移过去。
|
||||
|
||||
从会话列表拖拽根 Session 行时,如果屏幕上正显示另一个 Session,会显示放置目标。放置目标覆盖该行被拖出的导航栏或窄窗口抽屉右侧的整个窗口区域,四边均内缩 8px,并显示在抽屉遮罩之上。在此放下后,会在屏幕上那个 Session 的 Sidebar 栏中把被拖拽的 Session 打开为 `dsh-resource://subagentchat/session/<id>`(不带查询参数的地址);如果已有 tab 显示该 Session,则改为显示该 tab。其 Conversation 与主 Conversation 一样接受后续提示词,该 tab 随屏幕上那个 Session 的浏览器本地 Sidebar 布局保存。tab 标题为该 Session 的显示标题。
|
||||
从会话列表拖拽根 Session 行时,如果屏幕上正显示另一个 Session,会显示放置目标。放置目标将该行被拖出的导航栏或窄窗口抽屉右侧的整个窗口区域模糊处理,并在该区域内任意位置接受放置;其高亮卡片位于右边缘,宽度与右侧侧边栏打开时的宽度相同,四边均内缩 8px。放置目标显示在抽屉遮罩之上。在此放下后,会在屏幕上那个 Session 的 Sidebar 栏中把被拖拽的 Session 打开为 `dsh-resource://subagentchat/session/<id>`(不带查询参数的地址);如果已有 tab 显示该 Session,则改为显示该 tab。其 Conversation 与主 Conversation 一样接受后续提示词,该 tab 随屏幕上那个 Session 的浏览器本地 Sidebar 布局保存。tab 标题为该 Session 的显示标题。
|
||||
|
||||
分栏的标题控件(`conversation.session.panel.section.actions`,键为 `subagents`)显示直接成员进度:依次为已完成、进行中、未运行和外部任务数量;省略零值,分隔符与输入区任务列表一致。外部任务不计入运行中或已完成数量。分栏把运行中的子智能体排在最前,最近开始的在前,然后是其余的,最近更新的在前。它只显示五行,然后是会话面板的收起控件「显示其余 {count} 个」,点击后显示其余的行并变为「收起」;只有能收起两行及以上时列表才收起,这个选择在 Session 内保持,隐藏后再次显示面板也不变;展开某个分支后,该分支自己的行全部显示。会话没有子智能体且目录读取未失败时,分栏连同标题一起隐藏。直接子智能体运行中且面板未显示时,面板开关上的蓝点(`conversation.session.panel.indicator`)会提示这一状态,并向辅助技术说明数量;外部任务不计入。会话面板负责分栏滚动,目录树不单独滚动。面包屑切换器菜单宽度为 360px,外层内边距为 6px,并受布局视口可用宽度约束,仅菜单本身滚动。在兼容 WebKit 的浏览器中,其原生 5px 滚动条位于右侧 6px 内边距内,轨道两端内缩,并保留稳定的滚动条空间,使内容在需要滚动时保持原有宽度。其他浏览器保留标准原生滚动条。
|
||||
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
/* The drop target covers the window right of the navigation column the row
|
||||
left (its left edge is set inline), with an 8px inset on every side, and
|
||||
draws the dock kit's drop hint: a blurred ground under a dashed card that
|
||||
takes the accent while the pointer is over it. It stacks above the
|
||||
narrow-window drawer (71) and its mask (70), below menus and toasts. */
|
||||
left (its left edge is set inline) with the dock kit's blurred drop-hint
|
||||
ground, and accepts the drop anywhere on it. The dashed card that takes the
|
||||
accent while the pointer is over the target sits at the right edge with an
|
||||
8px inset on every side, as wide as the right Sidebar would open (set
|
||||
inline), or across the whole target when that width is unknown. It stacks
|
||||
above the narrow-window drawer (71) and its mask (70), below menus and
|
||||
toasts. */
|
||||
.zone {
|
||||
position: fixed;
|
||||
z-index: 72;
|
||||
@@ -11,6 +14,7 @@
|
||||
bottom: 0;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
padding: 8px;
|
||||
pointer-events: auto;
|
||||
background: color-mix(in srgb, var(--dsw-alias-bg-base) 72%, transparent);
|
||||
@@ -21,6 +25,8 @@
|
||||
.card {
|
||||
display: flex;
|
||||
flex: 1 1 auto;
|
||||
max-width: 100%;
|
||||
box-sizing: border-box;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
|
||||
@@ -16,6 +16,8 @@ export interface SessionDrag {
|
||||
readonly sessionId: SessionId
|
||||
/** Right edge of the navigation column the row left, in px; the target covers the window to its right. */
|
||||
readonly inset: number
|
||||
/** Width of the on-screen Session's right Sidebar, in px, which the highlighted card takes; zero when unknown. */
|
||||
readonly width: number
|
||||
}
|
||||
|
||||
/** Session drag tracking and the open operation supplied by the plugin. */
|
||||
@@ -40,12 +42,13 @@ export type SessionDropZoneProps =
|
||||
export function SessionDropZone({ useSessionDrag, openAside, t }: SessionDropZoneProps) {
|
||||
const drag = useSessionDrag(value => value)
|
||||
if (drag === undefined) return null
|
||||
const { sessionId, inset } = drag
|
||||
return <DropTarget key={sessionId} inset={inset} label={t('open.sidebar')} onDrop={() => { openAside(sessionId) }} />
|
||||
const { sessionId, inset, width } = drag
|
||||
return <DropTarget key={sessionId} inset={inset} width={width} label={t('open.sidebar')} onDrop={() => { openAside(sessionId) }} />
|
||||
}
|
||||
|
||||
function DropTarget({ inset, label, onDrop }: {
|
||||
function DropTarget({ inset, width, label, onDrop }: {
|
||||
readonly inset: number
|
||||
readonly width: number
|
||||
readonly label: string
|
||||
readonly onDrop: () => void
|
||||
}) {
|
||||
@@ -77,7 +80,7 @@ function DropTarget({ inset, label, onDrop }: {
|
||||
onDrop()
|
||||
}}
|
||||
>
|
||||
<div className={css.card}>
|
||||
<div className={css.card} style={width > 0 ? { flex: `0 1 ${String(width - 16)}px` } : undefined}>
|
||||
<IconPanelLeftOutlineRegular className={css.icon} aria-hidden="true" />
|
||||
<span className={css.label}>{label}</span>
|
||||
</div>
|
||||
|
||||
@@ -142,7 +142,8 @@ function frameColumnOf(node: Element): Element | undefined {
|
||||
* Track Session rows dragged from the Session list while another Session is on screen.
|
||||
* @param doc - document whose drag events carry the rows' data.
|
||||
* @param mounted - reads the on-screen Session.
|
||||
* @returns the dragged Session with the right edge of the column it left, in px, and the listener disposer.
|
||||
* @returns the dragged Session with the right edge of the column it left and the on-screen Sidebar's width, in px,
|
||||
* and the listener disposer.
|
||||
*/
|
||||
export function trackSessionDrags(doc: Document, mounted: () => SessionId | undefined): {
|
||||
readonly source: HostObservable<SessionDrag | undefined>
|
||||
@@ -164,7 +165,14 @@ export function trackSessionDrags(doc: Document, mounted: () => SessionId | unde
|
||||
return
|
||||
}
|
||||
const column = event.target instanceof Element ? frameColumnOf(event.target) : undefined
|
||||
publish({ sessionId: id, inset: Math.round(column?.getBoundingClientRect().right ?? 0) })
|
||||
// The panel keeps its resolved width while collapsed; zero means it cannot fit beside the conversation.
|
||||
const panel = [...doc.querySelectorAll('[data-sidebar-right-panel]')]
|
||||
.find(element => element.getAttribute('data-sidebar-right-session') === onScreen)
|
||||
publish({
|
||||
sessionId: id,
|
||||
inset: Math.round(column?.getBoundingClientRect().right ?? 0),
|
||||
width: Math.round(panel?.getBoundingClientRect().width ?? 0),
|
||||
})
|
||||
}
|
||||
const end = (): void => { publish(undefined) }
|
||||
// A source row unmounted mid-drag fires dragend on a detached node; the first
|
||||
|
||||
@@ -20,7 +20,7 @@ function dispatchDrag(type: string, data: Record<string, string> = {}, target: E
|
||||
target.dispatchEvent(event)
|
||||
}
|
||||
|
||||
const outside = { sessionId: OTHER, inset: 0 }
|
||||
const outside = { sessionId: OTHER, inset: 0, width: 0 }
|
||||
|
||||
describe('Session drag tracking', () => {
|
||||
it('publishes a dragged list Session that another on-screen Session can open', () => {
|
||||
@@ -74,13 +74,23 @@ describe('Session drag tracking', () => {
|
||||
frame.append(column, overlay)
|
||||
document.body.append(frame)
|
||||
column.getBoundingClientRect = () => ({ right: 279.6 }) as DOMRect
|
||||
// The on-screen Session's right Sidebar panel sets the highlighted card's width; another Session's is ignored.
|
||||
const panel = document.createElement('div')
|
||||
panel.setAttribute('data-sidebar-right-panel', 'push')
|
||||
panel.setAttribute('data-sidebar-right-session', MAIN)
|
||||
panel.getBoundingClientRect = () => ({ width: 520.2 }) as DOMRect
|
||||
const otherPanel = document.createElement('div')
|
||||
otherPanel.setAttribute('data-sidebar-right-panel', 'push')
|
||||
otherPanel.setAttribute('data-sidebar-right-session', OTHER)
|
||||
otherPanel.getBoundingClientRect = () => ({ width: 900 }) as DOMRect
|
||||
frame.append(otherPanel, panel)
|
||||
const drags = trackSessionDrags(document, () => MAIN)
|
||||
dispatchDrag('dragstart', { 'application/x-dsh-session': OTHER }, row)
|
||||
expect(drags.source.getSnapshot()).toEqual({ sessionId: OTHER, inset: 280 })
|
||||
expect(drags.source.getSnapshot()).toEqual({ sessionId: OTHER, inset: 280, width: 520 })
|
||||
// A drag whose target is not an element starts at the window edge.
|
||||
dispatchDrag('dragend')
|
||||
dispatchDrag('dragstart', { 'application/x-dsh-session': OTHER }, document)
|
||||
expect(drags.source.getSnapshot()).toEqual(outside)
|
||||
expect(drags.source.getSnapshot()).toEqual({ ...outside, width: 520 })
|
||||
drags.dispose()
|
||||
frame.remove()
|
||||
})
|
||||
@@ -91,7 +101,7 @@ describe('Session drop zone', () => {
|
||||
let current = initial
|
||||
const openAside = vi.fn()
|
||||
const source: HostObservable<SessionDrag | undefined> = {
|
||||
getSnapshot: () => current === undefined ? undefined : { sessionId: current, inset: 280 },
|
||||
getSnapshot: () => current === undefined ? undefined : { sessionId: current, inset: 280, width: current === OTHER ? 516 : 0 },
|
||||
subscribe: () => () => {},
|
||||
}
|
||||
const props = {
|
||||
@@ -127,6 +137,8 @@ describe('Session drop zone', () => {
|
||||
const zone = document.querySelector<HTMLElement>('[data-session-drop-zone]')!
|
||||
expect(zone.parentElement).toBe(document.body)
|
||||
expect(zone.style.left).toBe('280px')
|
||||
// The highlighted card is as wide as the Sidebar would open, inside the 8px inset.
|
||||
expect((zone.firstElementChild as HTMLElement).style.flex).toBe('0 1 500px')
|
||||
expect(view.container.innerHTML).toBe('')
|
||||
expect(zone.hasAttribute('data-active')).toBe(false)
|
||||
|
||||
@@ -151,6 +163,10 @@ describe('Session drop zone', () => {
|
||||
expect(view.openAside).toHaveBeenCalledExactlyOnceWith(OTHER)
|
||||
expect(zone.hasAttribute('data-active')).toBe(false)
|
||||
|
||||
// Without a known Sidebar width the card spans the whole target.
|
||||
view.set(MAIN)
|
||||
expect((document.querySelector('[data-session-drop-zone]')!.firstElementChild as HTMLElement).style.flex).toBe('')
|
||||
|
||||
view.set(undefined)
|
||||
expect(document.querySelector('[data-session-drop-zone]')).toBeNull()
|
||||
})
|
||||
|
||||
@@ -143,7 +143,7 @@ describe('Sidebar chat registration', () => {
|
||||
])
|
||||
// A dropped root Session opens in the on-screen Session's Sidebar column.
|
||||
const drop = registrations[2]?.options.inject as () => {
|
||||
hooks: { sessionDrag: { getSnapshot: () => { sessionId: SessionId; inset: number } | undefined } }
|
||||
hooks: { sessionDrag: { getSnapshot: () => { sessionId: SessionId; inset: number; width: number } | undefined } }
|
||||
openAside: (sessionId: SessionId) => void
|
||||
}
|
||||
drop().openAside(CHILD)
|
||||
@@ -159,7 +159,7 @@ describe('Sidebar chat registration', () => {
|
||||
document.body.dispatchEvent(event)
|
||||
}
|
||||
dragStart()
|
||||
expect(drop().hooks.sessionDrag.getSnapshot()).toEqual({ sessionId: CHILD, inset: 0 })
|
||||
expect(drop().hooks.sessionDrag.getSnapshot()).toEqual({ sessionId: CHILD, inset: 0, width: 0 })
|
||||
document.body.dispatchEvent(new Event('dragend', { bubbles: true }))
|
||||
for (const dispose of disposers) dispose()
|
||||
dragStart()
|
||||
|
||||
Reference in new issue
Block a user