mirror of
https://github.com/deepseek-ai/deepseek-harness.git
synced 2026-08-29 04:26:38 +00:00
Merge pull request #2794 from deepseek-harness/fix/web-new-session-first
fix(ui-workspace): pin the current blank New Session row first
This commit is contained in:
+2
-2
@@ -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 .agents/notes/implemented/feature/2026-08-11-workspace-sidebar-order-and-folding.md
|
||||
2026-08-11-workspace-sidebar-order-and-folding.md: d683d782454bb9fe1fad1fdc1d1a5fc3184a697b
|
||||
2026-08-11-workspace-sidebar-order-and-folding.zh.md: 99e1991cfbb7b1540235ab0190defb31ad0ed6d7
|
||||
2026-08-11-workspace-sidebar-order-and-folding.md: ad079cfc71d6efff7679ce3b8512167bce95e6c8
|
||||
2026-08-11-workspace-sidebar-order-and-folding.zh.md: fdc23fbc3a745b030c296d91257adb505b282471
|
||||
|
||||
@@ -24,6 +24,8 @@ Each Workspace persists one browser-local open state: closed means zero Session
|
||||
|
||||
The combined view menu offers **Manual** and **Last updated** in grouped and flat presentation, with one browser-local persisted order per account. A real Workspace initializes from `WorkspaceView.sessionIds`; Ungrouped and the cross-Workspace flat list initialize from recency and have no Host Session account. Entering Last updated performs one complete recency sort; a later user prompt or steer promotes that Session once, and dragging may edit the resulting order. Returning to Manual preserves the current order and only disables later activity promotion. Manual-mode drags for a real Workspace also write the Host Session account, while Ungrouped and flat-list drags and activity promotion remain browser-local. Flat rows omit an empty leading status slot because they have no parent hierarchy, while a visible status retains its slot.
|
||||
|
||||
When New Session creation selects a blank Session, the browser promotes it once in both its grouped account and the flat-list account. This explicit creation promotion does not advance `updatedAt`; later drag ordering treats the blank like any other Session, and the first prompt does not undo a Manual-mode drag.
|
||||
|
||||
### Drag and compact chrome
|
||||
|
||||
Workspace hit testing uses the complete rendered group section, including visible Session rows. One insertion boundary is shared by the preceding group's lower half and the following group's upper half, and the indicator is an absolutely positioned line with a joined right-facing chevron that does not affect layout. A tree-body overlay draws the first boundary at the same negative offset outside the scrolling clip, so the leading chevron remains visible without moving the list. During a Workspace or Session drag, document-level `dragover` and `drop` handlers accept the native operation; if release occurs outside the Workspace list, `dragend` commits the last valid marker.
|
||||
@@ -48,9 +50,10 @@ Search is a header action while collapsed and expands across the title and trail
|
||||
|
||||
- Workspace order is durable and shared through the Host, while grouping, open state, per-account Session view order, and query state remain browser-local presentation preferences. Ungrouped and the flat list support the same drag and promotion rules, but their orders are browser-local because neither has one Workspace account.
|
||||
- Last updated performs a complete recency sort on entry, then preserves manual adjustments until a user prompt or steer advances one Session and moves it to the front. Returning to Manual preserves every current position.
|
||||
- A newly selected blank New Session row enters grouped and flat orders first once, then follows the same drag and activity rules as every other Session.
|
||||
- Opening a Workspace never shows more than five Sessions without an explicit **Show more** gesture, and closing it resets only that transient gesture.
|
||||
- The Host Session account retains the manual-order meaning established by [Session List Browsing and Manual Workspace Order](2026-07-25-session-list-browsing-and-manual-order.md).
|
||||
|
||||
## Testing
|
||||
|
||||
Domain and Host tests cover durable Workspace moves, no-op and invalid anchors, restart recovery, full-order RPC responses, order frames, and one Workspace snapshot per Host-stream baseline. Runtime tests cover optimistic order, frame/response precedence, overlapping rejection rollback to Host-confirmed order, reconnect baselines, and New Session target priority. UI tests cover five-row folding, transient expansion reset, pruning persisted state after Workspace removal, order-preserving mode switches, one-time recent-update promotion, browser-local Ungrouped and flat-list drag persistence, hierarchy-free flat-row leading spacing, selected view indicators, expanded-section Workspace hit testing, an unclipped first insertion boundary, outside-list Workspace and Session drops, search collapse rules, and compact CSS dimensions.
|
||||
Domain and Host tests cover durable Workspace moves, no-op and invalid anchors, restart recovery, full-order RPC responses, order frames, and one Workspace snapshot per Host-stream baseline. Runtime tests cover optimistic order, frame/response precedence, overlapping rejection rollback to Host-confirmed order, reconnect baselines, and New Session target priority. UI tests cover five-row folding, transient expansion reset, pruning persisted state after Workspace removal, order-preserving mode switches, one-time recent-update and New Session promotion, Manual drag retention after the first prompt, browser-local Ungrouped and flat-list drag persistence, hierarchy-free flat-row leading spacing, selected view indicators, expanded-section Workspace hit testing, an unclipped first insertion boundary, outside-list Workspace and Session drops, search collapse rules, and compact CSS dimensions.
|
||||
|
||||
+4
-1
@@ -24,6 +24,8 @@ Workspace 注册表持有持久 `workspaceIds` 顺序,并提供采用 DOM `ins
|
||||
|
||||
组合视图菜单在分组和单列表呈现中都提供**手动排序**和**最近更新**,每个记账各自持有一份浏览器本地持久顺序。真实 Workspace 从 `WorkspaceView.sessionIds` 初始化;Ungrouped 和跨 Workspace 的单列表从最近更新时间顺序初始化,且没有 Host Session 记账。进入最近更新时会执行一次完整的时间排序;后续 user prompt 或 steer 会将对应 Session 置顶一次,拖拽仍可编辑所得顺序。返回手动排序会保留当前顺序,只停用后续活动置顶。真实 Workspace 在手动模式下的拖拽还会写入 Host Session 记账,而 Ungrouped 和单列表的拖拽与活动置顶保留在浏览器本地。单列表没有父级层次,因此不显示空的左侧状态槽;存在可见状态时仍保留该槽。
|
||||
|
||||
创建“新会话”并选中空白 Session 时,浏览器会在其分组记账和单列表记账中各置顶一次。这次明确的创建置顶不会推进 `updatedAt`;后续拖拽把空白 Session 当作普通 Session,首条提示词落地也不会撤销手动模式下的拖拽。
|
||||
|
||||
### 拖拽与紧凑界面
|
||||
|
||||
Workspace 命中测试使用完整渲染分组区段,包括可见 Session 行。前一分组的下半部与后一分组的上半部共享同一条插入边界,指示器是一条带有相连右向尖角且不影响布局的绝对定位横线。树主体覆盖层会在滚动裁切区外以相同的负偏移绘制第一条边界,因此左侧尖角保持可见,列表位置也不会改变。Workspace 或 Session 拖拽期间,文档级 `dragover` 与 `drop` 处理器会接受原生操作;若在 Workspace 列表外松手,`dragend` 会提交最后一个有效标记。
|
||||
@@ -48,9 +50,10 @@ Workspace 命中测试使用完整渲染分组区段,包括可见 Session 行
|
||||
|
||||
- Workspace 顺序通过 Host 持久并共享;分组方式、打开状态、每个记账的 Session 视图顺序和查询状态仍是浏览器本地呈现偏好。Ungrouped 和单列表支持相同的拖拽与置顶规则,但因没有单一 Workspace 记账,其顺序只保存在浏览器本地。
|
||||
- 最近更新模式会在进入时执行完整时间排序,随后保持手动调整,直到 user prompt 或 steer 推进某条 Session 并将其置顶。返回手动排序会保留所有当前位置。
|
||||
- 新选中的空白“新会话”行会在分组和单列表顺序中各置顶一次,之后遵循与其他 Session 相同的拖拽和活动规则。
|
||||
- 未执行明确的**展开其余**手势时,打开 Workspace 最多显示五条 Session;关闭分组只重置这项临时手势。
|
||||
- Host Session 记账继续采用[会话列表浏览与 Workspace 手动排序](2026-07-25-session-list-browsing-and-manual-order.md)确立的手动顺序含义。
|
||||
|
||||
## 测试
|
||||
|
||||
领域与 Host 测试覆盖持久 Workspace 移动、无操作与无效锚点、重启恢复、完整顺序 RPC 响应、顺序帧以及每条 Host stream 基线只读取一份 Workspace 快照。运行时测试覆盖乐观顺序、帧/响应优先级、重叠拒绝后恢复 Host 已确认顺序、重连基线以及 New Session 目标优先级。UI 测试覆盖五行折叠、临时展开重置、Workspace 移除后清理持久状态、保持顺序的模式切换、一次性最近更新置顶、浏览器本地 Ungrouped 与单列表拖拽持久化、无层级单列表行左侧间距、当前视图标记、展开区段的 Workspace 命中、未裁切的第一条插入边界、列表外 Workspace 与 Session 松手、搜索收起规则和紧凑 CSS 尺寸。
|
||||
领域与 Host 测试覆盖持久 Workspace 移动、无操作与无效锚点、重启恢复、完整顺序 RPC 响应、顺序帧以及每条 Host stream 基线只读取一份 Workspace 快照。运行时测试覆盖乐观顺序、帧/响应优先级、重叠拒绝后恢复 Host 已确认顺序、重连基线以及 New Session 目标优先级。UI 测试覆盖五行折叠、临时展开重置、Workspace 移除后清理持久状态、保持顺序的模式切换、一次性最近更新与“新会话”置顶、首条提示词落地后保留手动拖拽、浏览器本地 Ungrouped 与单列表拖拽持久化、无层级单列表行左侧间距、当前视图标记、展开区段的 Workspace 命中、未裁切的第一条插入边界、列表外 Workspace 与 Session 松手、搜索收起规则和紧凑 CSS 尺寸。
|
||||
|
||||
@@ -777,6 +777,31 @@ export function WorkspaceBrowser({
|
||||
const groupExpansion = useStore(s => s.groupExpansion)
|
||||
const sessionOrderByAccount = useStore(s => s.sessionOrderByAccount)
|
||||
const sessionUpdatedAtByAccount = useStore(s => s.sessionUpdatedAtByAccount)
|
||||
const currentBlankSessionId = useSessions((state) => {
|
||||
const current = state.current
|
||||
return current !== undefined && state.byId[current]?.blank === true ? current : undefined
|
||||
})
|
||||
const currentBlankAccount = currentBlankSessionId === undefined
|
||||
? undefined
|
||||
: (workspaces.find(workspace => workspace.sessionIds.includes(currentBlankSessionId))
|
||||
?.workspaceId as string | undefined) ?? UNGROUPED_KEY
|
||||
const promotedBlank = useRef<{ sessionId: SessionId; accountKey: string } | undefined>(undefined)
|
||||
useEffect(() => {
|
||||
if (currentBlankSessionId === undefined || currentBlankAccount === undefined) {
|
||||
promotedBlank.current = undefined
|
||||
return
|
||||
}
|
||||
if (promotedBlank.current?.sessionId === currentBlankSessionId
|
||||
&& promotedBlank.current.accountKey === currentBlankAccount) return
|
||||
promotedBlank.current = { sessionId: currentBlankSessionId, accountKey: currentBlankAccount }
|
||||
for (const accountKey of new Set([currentBlankAccount, FLAT_SESSION_ORDER_KEY])) {
|
||||
const previous = sessionOrderByAccount[accountKey] ?? []
|
||||
actions.setSessionOrder(accountKey, [
|
||||
currentBlankSessionId,
|
||||
...previous.filter(id => id !== currentBlankSessionId),
|
||||
])
|
||||
}
|
||||
}, [actions.setSessionOrder, currentBlankAccount, currentBlankSessionId, sessionOrderByAccount])
|
||||
useEffect(() => {
|
||||
if (workspacePhase !== 'ready') return
|
||||
actions.retainAccountKeys([
|
||||
|
||||
@@ -468,6 +468,72 @@ describe('WorkspaceBrowser', () => {
|
||||
expect(screen.queryByText('新会话')).toBeNull()
|
||||
})
|
||||
|
||||
it('promotes the blank selected by New Session in its grouped and flat orders', async () => {
|
||||
const items = [
|
||||
summary('old', 100),
|
||||
summary('blank', 150, { blank: true }),
|
||||
summary('mid', 200),
|
||||
]
|
||||
const startSession = vi.fn()
|
||||
const b = mount({
|
||||
useSessions: hook(sessionState(items)),
|
||||
useWorkspaces: hook(workspaceState([workspace('alpha', ['old', 'blank', 'mid'])])),
|
||||
startSession,
|
||||
})
|
||||
await waitFor(() => {
|
||||
expect(b.store.getSnapshot().sessionOrderByAccount.alpha).toEqual(['old', 'blank', 'mid'])
|
||||
})
|
||||
startSession.mockImplementation(() => {
|
||||
rerender(b, { useSessions: hook(sessionState(items, { current: sid('blank') })) })
|
||||
})
|
||||
fireEvent.click(screen.getByRole('button', { name: '在“alpha”中新建会话' }))
|
||||
expect(startSession).toHaveBeenCalledWith(wid('alpha'))
|
||||
await waitFor(() => {
|
||||
expect(b.store.getSnapshot().sessionOrderByAccount.alpha).toEqual(['blank', 'old', 'mid'])
|
||||
expect(b.store.getSnapshot().sessionOrderByAccount[FLAT_SESSION_ORDER_KEY]).toEqual(['blank'])
|
||||
})
|
||||
b.store.actions.setGroupBy('flat')
|
||||
await waitFor(() => {
|
||||
expect(b.store.getSnapshot().sessionOrderByAccount[FLAT_SESSION_ORDER_KEY]).toEqual(['blank', 'mid', 'old'])
|
||||
})
|
||||
})
|
||||
|
||||
it('does not repeat blank promotion after a manual drag or the first prompt', async () => {
|
||||
const insertSessionBefore = vi.fn(async () => {})
|
||||
const b = mount({
|
||||
useSessions: hook(sessionState([
|
||||
summary('old', 100),
|
||||
summary('blank', 150, { blank: true }),
|
||||
summary('mid', 200),
|
||||
], { current: sid('blank') })),
|
||||
useWorkspaces: hook(workspaceState([workspace('alpha', ['old', 'blank', 'mid'])])),
|
||||
insertSessionBefore,
|
||||
})
|
||||
await waitFor(() => {
|
||||
expect(b.store.getSnapshot().sessionOrderByAccount.alpha).toEqual(['blank', 'old', 'mid'])
|
||||
})
|
||||
const blank = screen.getByText('新会话').closest('[role="treeitem"]') as HTMLElement
|
||||
const mid = screen.getByText('mid').closest('[role="treeitem"]') as HTMLElement
|
||||
mid.getBoundingClientRect = () => ({
|
||||
top: 150, bottom: 184, left: 0, right: 200, width: 200, height: 34, x: 0, y: 150, toJSON: () => ({}),
|
||||
})
|
||||
fireEvent.dragStart(blank, { dataTransfer: dragData() })
|
||||
fireDrag(mid, 'drop', 180)
|
||||
expect(b.store.getSnapshot().sessionOrderByAccount.alpha).toEqual(['old', 'mid', 'blank'])
|
||||
expect(insertSessionBefore).toHaveBeenCalledWith(wid('alpha'), sid('blank'), undefined)
|
||||
|
||||
rerender(b, {
|
||||
useSessions: hook(sessionState([
|
||||
summary('old', 100),
|
||||
summary('blank', 150),
|
||||
summary('mid', 200),
|
||||
], { current: sid('blank') })),
|
||||
})
|
||||
await waitFor(() => {
|
||||
expect(b.store.getSnapshot().sessionOrderByAccount.alpha).toEqual(['old', 'mid', 'blank'])
|
||||
})
|
||||
})
|
||||
|
||||
it('shows local metadata matches immediately, then clears back to the grouped tree', async () => {
|
||||
vi.useFakeTimers()
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user