Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✨ feat(acceptance): pin the list rail on wide screens and add shift/cmd multi-select (#19559)

Innei4c94aee97b43
diff --git a/apps/desktop/scripts/__tests__/devOrchestrator.test.mjs b/apps/desktop/scripts/__tests__/devOrchestrator.test.mjs
index 8e3d5b0194a..b74d5faf79a 100644
--- a/apps/desktop/scripts/__tests__/devOrchestrator.test.mjs
+++ b/apps/desktop/scripts/__tests__/devOrchestrator.test.mjs
@@ -11,7 +11,7 @@ class FakeChild extends EventEmitter {
const createHarness = (overrides = {}) => {
const spawned = [];
const watchers = [];
- const state = { bundlesExist: false, mtime: 1, portReady: false };
+ const state = { bundlesExist: false, mtime: Date.now() + 1, portReady: false };
const options = {
checkPort: vi.fn(async () => state.portReady),
@@ -22,6 +22,7 @@ const createHarness = (overrides = {}) => {
log: vi.fn(),
logError: vi.fn(),
nodeBin: '/bin/node',
+ rmSync: vi.fn(),
spawn: vi.fn((bin, args, opts) => {
const child = new FakeChild();
spawned.push({ args, bin, child, opts });
@@ -84,6 +85,19 @@ describe('createDevOrchestrator', () => {
]);
});
+ it('wipes the stale dist before spawning the watch builds', () => {
+ const h = createHarness();
+ h.orchestrator.start();
+
+ expect(h.options.rmSync).toHaveBeenCalledWith('/repo/apps/desktop/dist', {
+ force: true,
+ recursive: true,
+ });
+ expect(h.options.rmSync.mock.invocationCallOrder[0]).toBeLessThan(
+ h.options.spawn.mock.invocationCallOrder[0],
+ );
+ });
+
it('shuts everything down when a vite child exits early', () => {
const h = createHarness();
h.orchestrator.start();
@@ -123,7 +137,7 @@ describe('createDevOrchestrator', () => {
h.state.portReady = true;
await vi.advanceTimersByTimeAsync(600);
- h.state.mtime = 2;
+ h.state.mtime += 1;
await vi.advanceTimersByTimeAsync(600);
expect(h.electronSpawns()).toHaveLength(0);
@@ -131,6 +145,21 @@ describe('createDevOrchestrator', () => {
expect(h.electronSpawns()).toHaveLength(1);
});
+ it('ignores bundles left over from a previous run until the watch build rewrites them', async () => {
+ const h = createHarness();
+ h.state.mtime = Date.now() - 1;
+ h.orchestrator.start();
+ h.state.bundlesExist = true;
+ h.state.portReady = true;
+
+ await vi.advanceTimersByTimeAsync(3000);
+ expect(h.electronSpawns()).toHaveLength(0);
+
+ h.state.mtime = Date.now();
+ await vi.advanceTimersByTimeAsync(2000);
+ expect(h.electronSpawns()).toHaveLength(1);
+ });
+
it('passes extra CLI args through to electron', async () => {
const h = createHarness({ electronArgs: ['--remote-debugging-port=9223', '--foo'] });
h.orchestrator.start();
diff --git a/apps/desktop/scripts/devOrchestrator.mjs b/apps/desktop/scripts/devOrchestrator.mjs
index bf60cafa4af..00b21bae1fa 100644
--- a/apps/desktop/scripts/devOrchestrator.mjs
+++ b/apps/desktop/scripts/devOrchestrator.mjs
@@ -1,6 +1,7 @@
import { spawn as nodeSpawn } from 'node:child_process';
import {
existsSync as nodeExistsSync,
+ rmSync as nodeRmSync,
statSync as nodeStatSync,
watch as nodeWatch,
} from 'node:fs';
@@ -29,6 +30,7 @@ export function createDevOrchestrator({
restartDebounceMs = 400,
spawn = nodeSpawn,
existsSync = nodeExistsSync,
+ rmSync = nodeRmSync,
statSync = nodeStatSync,
watch = nodeWatch,
checkPort = defaultCheckPort,
@@ -113,6 +115,7 @@ export function createDevOrchestrator({
}
function start() {
+ rmSync(path.join(desktopRoot, 'dist'), { force: true, recursive: true });
children.push(
spawnVite(['--config', 'vite.renderer.config.ts']),
spawnVite(['build', '--watch', '--mode', 'development', '--config', 'vite.main.config.ts']),
@@ -135,6 +138,9 @@ export function createDevOrchestrator({
// The two build configs `emptyOutDir` on startup and finish at different times,
// so wait until the renderer server accepts connections and both bundles exist
// and have been quiet for a second before launching electron or attaching watchers.
+ // Bundles left over from a previous run look "quiet" too, so ignore anything
+ // written before this run started — otherwise electron boots on the stale dist
+ // right as the watch build empties it.
const started = Date.now();
let lastChange = Date.now();
let lastSignature = '';
@@ -151,7 +157,9 @@ export function createDevOrchestrator({
return;
}
if (!existsSync(MAIN_BUNDLE) || !existsSync(PRELOAD_BUNDLE)) return;
- const signature = [MAIN_BUNDLE, PRELOAD_BUNDLE].map((f) => statSync(f).mtimeMs).join(':');
+ const mtimes = [MAIN_BUNDLE, PRELOAD_BUNDLE].map((f) => statSync(f).mtimeMs);
+ if (mtimes.some((mtime) => mtime < started)) return;
+ const signature = mtimes.join(':');
if (signature !== lastSignature) {
lastSignature = signature;
lastChange = Date.now();
diff --git a/locales/en-US/verify.json b/locales/en-US/verify.json
index f23844287e0..afad393817e 100644
--- a/locales/en-US/verify.json
+++ b/locales/en-US/verify.json
@@ -766,6 +766,7 @@
"workspace.loadError": "Something went wrong while loading your reports.",
"workspace.loadErrorTitle": "Couldn’t load reports",
"workspace.loadMoreError": "Couldn’t load more reports",
+ "workspace.pin": "Pin report list",
"workspace.renameEmpty": "Report title cannot be empty",
"workspace.renameError": "Failed to rename report",
"workspace.renameSuccess": "Report renamed",
diff --git a/locales/zh-CN/verify.json b/locales/zh-CN/verify.json
index 1f6bba4c654..be4171153f9 100644
--- a/locales/zh-CN/verify.json
+++ b/locales/zh-CN/verify.json
@@ -766,6 +766,7 @@
"workspace.loadError": "加载报告时出错了。",
"workspace.loadErrorTitle": "报告加载失败",
"workspace.loadMoreError": "加载更多失败",
+ "workspace.pin": "固定报告列表",
"workspace.renameEmpty": "报告标题不能为空",
"workspace.renameError": "报告重命名失败",
"workspace.renameSuccess": "报告已重命名",
diff --git a/packages/locales/src/default/verify.ts b/packages/locales/src/default/verify.ts
index 8142dc1c405..d579eb3f43c 100644
--- a/packages/locales/src/default/verify.ts
+++ b/packages/locales/src/default/verify.ts
@@ -860,6 +860,7 @@ export default {
'Pick a verification report from the list to see its verdict, checks, and evidence.',
'workspace.emptyDetail.title': 'No report selected',
'workspace.expand': 'Show report list',
+ 'workspace.pin': 'Pin report list',
'workspace.listEmpty':
'Reports appear here after a checker run finishes or a report is ingested.',
'workspace.listEmptyTitle': 'No reports yet',
diff --git a/src/features/Acceptance/Workspace/AcceptanceListPanel.tsx b/src/features/Acceptance/Workspace/AcceptanceListPanel.tsx
index f103e089ccf..aea5bf1b9ae 100644
--- a/src/features/Acceptance/Workspace/AcceptanceListPanel.tsx
+++ b/src/features/Acceptance/Workspace/AcceptanceListPanel.tsx
@@ -61,6 +61,7 @@ import {
acceptanceSelectAllState,
chunkAcceptanceBatch,
nextAcceptanceSelectAll,
+ rangeAcceptanceSelection,
toggleAcceptanceSelection,
visibleAcceptanceSelection,
} from './batchSelection';
@@ -375,6 +376,7 @@ const AcceptanceListPanel = memo<AcceptanceListPanelProps>(
const [selecting, setSelecting] = useState(false);
const [selected, setSelected] = useState<string[]>([]);
+ const [anchorId, setAnchorId] = useState<string | null>(null);
const [batchPending, setBatchPending] = useState(false);
const selectedVisible = visibleAcceptanceSelection(selected, items);
const selectAllState = acceptanceSelectAllState(items.length, selectedVisible.length);
@@ -382,6 +384,7 @@ const AcceptanceListPanel = memo<AcceptanceListPanelProps>(
const leaveSelecting = () => {
setSelecting(false);
setSelected([]);
+ setAnchorId(null);
};
/**
@@ -582,15 +585,34 @@ const AcceptanceListPanel = memo<AcceptanceListPanelProps>(
// to carry it on the row or the affiliation is simply not on screen.
const showRowProject = groupMode !== 'project';
- const rowSelectionProps = (id: string) =>
- selecting
- ? {
- selectable: true,
- selected: selectedVisible.includes(id),
- onToggleSelect: () =>
- setSelected((previous) => toggleAcceptanceSelection(previous, id)),
- }
- : undefined;
+ const orderedIds = (showGroups ? groups.flatMap((group) => group.items) : items).map(
+ (item) => item.id,
+ );
+
+ // Shift/⌘-click on a row while browsing enters selection on the spot: a
+ // shift range starts from the open record, a ⌘ pick from nothing.
+ const pickRow = (id: string, shift: boolean) => {
+ if (!selecting) {
+ setSelecting(true);
+ setSelected(
+ shift ? rangeAcceptanceSelection(orderedIds, acceptanceId ?? null, id, []) : [id],
+ );
+ setAnchorId(id);
+ return;
+ }
+ if (shift) {
+ setSelected((previous) => rangeAcceptanceSelection(orderedIds, anchorId, id, previous));
+ return;
+ }
+ setSelected((previous) => toggleAcceptanceSelection(previous, id));
+ setAnchorId(id);
+ };
+
+ const rowSelectionProps = (id: string) => ({
+ selectable: selecting,
+ selected: selecting && selectedVisible.includes(id),
+ onToggleSelect: (shift: boolean) => pickRow(id, shift),
+ });
// Grouping shares the filter's popover rather than taking a fourth icon in a
// 260px header: both answer "what does this list show me", and one of them
@@ -796,7 +818,7 @@ const AcceptanceListPanel = memo<AcceptanceListPanelProps>(
</Center>
)
) : (
- <div className={styles.list}>
+ <div className={styles.list} style={selecting ? { userSelect: 'none' } : undefined}>
{showGroups ? (
<Accordion
gap={4}
diff --git a/src/features/Acceptance/Workspace/AcceptanceRow.tsx b/src/features/Acceptance/Workspace/AcceptanceRow.tsx
index e14f9852a83..5c674588bcb 100644
--- a/src/features/Acceptance/Workspace/AcceptanceRow.tsx
+++ b/src/features/Acceptance/Workspace/AcceptanceRow.tsx
@@ -114,7 +114,7 @@ const AcceptanceRow = memo<{
/** Multi-select is running: the row picks instead of navigating. */
selectable?: boolean;
selected?: boolean;
- onToggleSelect?: () => void;
+ onToggleSelect?: (shift: boolean) => void;
}>(({ active, item, onChanged, onToggleSelect, selectable, selected, showProject }) => {
const { t } = useTranslation('verify');
const navigate = useNavigate();
@@ -379,7 +379,13 @@ const AcceptanceRow = memo<{
}
: undefined
}
- onClick={() => (selectable ? onToggleSelect?.() : navigate(`/acceptance/${item.id}`))}
+ onClick={(e) => {
+ if (selectable || e.shiftKey || e.metaKey || e.ctrlKey) {
+ onToggleSelect?.(e.shiftKey);
+ return;
+ }
+ navigate(`/acceptance/${item.id}`);
+ }}
/>
);
});
diff --git a/src/features/Acceptance/Workspace/batchSelection.test.ts b/src/features/Acceptance/Workspace/batchSelection.test.ts
index 7a81ea848a3..13e95c983cf 100644
--- a/src/features/Acceptance/Workspace/batchSelection.test.ts
+++ b/src/features/Acceptance/Workspace/batchSelection.test.ts
@@ -9,6 +9,7 @@ import {
acceptanceSelectAllState,
chunkAcceptanceBatch,
nextAcceptanceSelectAll,
+ rangeAcceptanceSelection,
toggleAcceptanceSelection,
visibleAcceptanceSelection,
} from './batchSelection';
@@ -29,6 +30,20 @@ describe('toggleAcceptanceSelection', () => {
});
});
+describe('rangeAcceptanceSelection', () => {
+ const order = ['a', 'b', 'c', 'd', 'e'];
+
+ it('selects everything between anchor and target in either direction', () => {
+ expect(rangeAcceptanceSelection(order, 'b', 'd', [])).toEqual(['b', 'c', 'd']);
+ expect(rangeAcceptanceSelection(order, 'd', 'b', ['e'])).toEqual(['e', 'b', 'c', 'd']);
+ });
+
+ it('falls back to a single pick when the anchor is missing or out of order', () => {
+ expect(rangeAcceptanceSelection(order, null, 'c', ['a'])).toEqual(['a', 'c']);
+ expect(rangeAcceptanceSelection(order, 'gone', 'c', [])).toEqual(['c']);
+ });
+});
+
describe('visibleAcceptanceSelection', () => {
it('drops picks the active filter no longer shows', () => {
// A sweep must act on exactly the ticked boxes on screen — never on a row
diff --git a/src/features/Acceptance/Workspace/batchSelection.ts b/src/features/Acceptance/Workspace/batchSelection.ts
index 074e6055627..23b74e5e2a9 100644
--- a/src/features/Acceptance/Workspace/batchSelection.ts
+++ b/src/features/Acceptance/Workspace/batchSelection.ts
@@ -9,6 +9,29 @@ export type AcceptanceSelectAllState = 'all' | 'none' | 'partial';
export const toggleAcceptanceSelection = (selected: string[], id: string): string[] =>
selected.includes(id) ? selected.filter((entry) => entry !== id) : [...selected, id];
+/**
+ * Shift-click: every row between the anchor and the target in VISUAL order,
+ * collapsed groups included — the batch bar count shows what was swept. An
+ * anchor that has scrolled out of the visible order degrades to a single pick.
+ */
+export const rangeAcceptanceSelection = (
+ orderedIds: string[],
+ anchor: string | null,
+ target: string,
+ selected: string[],
+): string[] => {
+ const from = anchor ? orderedIds.indexOf(anchor) : -1;
+ const to = orderedIds.indexOf(target);
+ const range =
+ from === -1 || to === -1
+ ? [target]
+ : orderedIds.slice(Math.min(from, to), Math.max(from, to) + 1);
+
+ const merged = new Set(selected);
+ for (const id of range) merged.add(id);
+ return [...merged];
+};
+
/**
* The selection as the user can currently SEE it.
*
diff --git a/src/features/Acceptance/Workspace/index.tsx b/src/features/Acceptance/Workspace/index.tsx
index 27a4e7b7e29..22450a06ae9 100644
--- a/src/features/Acceptance/Workspace/index.tsx
+++ b/src/features/Acceptance/Workspace/index.tsx
@@ -3,7 +3,7 @@
import { Flexbox, Icon } from '@lobehub/ui';
import { ActionIcon, Drawer } from '@lobehub/ui/base-ui';
import { createStaticStyles, cssVar } from 'antd-style';
-import { Menu, PanelLeftOpen } from 'lucide-react';
+import { Menu, PanelLeftOpen, Pin } from 'lucide-react';
import { memo, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Outlet, useNavigate, useParams, useSearchParams } from 'react-router';
@@ -89,19 +89,22 @@ const AcceptanceWorkspace = memo<AcceptanceWorkspaceProps>(({ projectId }) => {
/**
* Inside a project the workspace is already wearing the `(main)` shell's
- * chrome, so it keeps its inline rail. Only the standalone `/acceptance`
- * route — registered outside `(main)`, with nothing above it — grows a top
- * bar of its own, and there the list becomes a drawer so a record can own
- * the full width without the collection having to disappear to give it.
+ * chrome, so it keeps its inline rail. The standalone `/acceptance` route —
+ * registered outside `(main)`, with nothing above it — grows a top bar of
+ * its own and keeps the list in a drawer, so a record can own the full width
+ * without the collection disappearing. On a wide viewport the drawer can be
+ * pinned into that same rail (its header then carries back + title);
+ * collapsing the rail hands the list back to the drawer.
*/
const standalone = !projectId;
const showList = !hasFocusedCheck;
+ const listInDrawer = standalone && (panel.isNarrow || !panel.pinned);
const [listOpen, setListOpen] = useState(false);
- // Picking a row is what the drawer was opened to cause; once the route has
- // changed the drawer has nothing left to do.
+ // Picking a row is what the drawer was opened for; once the route has moved
+ // on (or the rail has taken over) the drawer has nothing left to do.
useEffect(() => {
setListOpen(false);
- }, [acceptanceId]);
+ }, [acceptanceId, listInDrawer]);
const {
data: allAcceptances,
@@ -123,12 +126,22 @@ const AcceptanceWorkspace = memo<AcceptanceWorkspaceProps>(({ projectId }) => {
<ShellTopBar
title={t('acceptance.workspace.title')}
titleExtra={
- <ActionIcon
- icon={Menu}
- size={'small'}
- title={t('acceptance.shell.menu')}
- onClick={() => setListOpen(true)}
- />
+ <>
+ <ActionIcon
+ icon={Menu}
+ size={'small'}
+ title={t('acceptance.shell.menu')}
+ onClick={() => setListOpen(true)}
+ />
+ {!panel.isNarrow && (
+ <ActionIcon
+ icon={Pin}
+ size={'small'}
+ title={t('workspace.pin')}
+ onClick={() => panel.setExpand(true)}
+ />
+ )}
+ </>
}
onBack={() => navigate(acceptanceHomePath())}
/>
@@ -149,7 +162,7 @@ const AcceptanceWorkspace = memo<AcceptanceWorkspaceProps>(({ projectId }) => {
);
}
- if (!standalone)
+ if (!listInDrawer)
return (
<Flexbox horizontal height={'100dvh'} style={{ overflow: 'hidden' }} width={'100%'}>
<RouteMetaBridge />
diff --git a/src/features/Acceptance/Workspace/useReportPanelExpand.ts b/src/features/Acceptance/Workspace/useReportPanelExpand.ts
index fd322c1f8ea..1dec95c9c5f 100644
--- a/src/features/Acceptance/Workspace/useReportPanelExpand.ts
+++ b/src/features/Acceptance/Workspace/useReportPanelExpand.ts
@@ -10,6 +10,8 @@ export interface ReportPanelExpand {
expand: boolean;
/** Below the breakpoint the panel floats over the report instead of shrinking it. */
isNarrow: boolean;
+ /** The wide-layout preference itself, regardless of the current viewport. */
+ pinned: boolean;
setExpand: (expand: boolean) => void;
}
@@ -61,5 +63,5 @@ export const useReportPanelExpand = (): ReportPanelExpand => {
}));
};
- return { expand: isNarrow ? floatOpen : showPanel, isNarrow, setExpand };
+ return { expand: isNarrow ? floatOpen : showPanel, isNarrow, pinned: showPanel, setExpand };
};