feat: dock the not-classified bucket above the default workspace
The 'not classified yet' bucket (???/???/???/???/???/Uncategorized) now leaves the scrolling tree and shares the bottom dock with the pinned Host default workspace, above a divider. It keeps its category row, children, menus and drag behaviour; the dock caps its height and scrolls it on its own, so a large bucket never swallows the tree. Search results never repeat the bucket (matches are shown in the dock instead), and the rail hides the dock.
This commit is contained in:
parent
f7a9f08ac4
commit
5544f82ccd
328
lib/client.js
328
lib/client.js
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -107,6 +107,8 @@ export interface GroupsTreeView {
|
||||||
}
|
}
|
||||||
/** Key of the uncategorized bucket (matches the config fallback label). */
|
/** Key of the uncategorized bucket (matches the config fallback label). */
|
||||||
export declare const UNCATEGORIZED_KEY = "\u672A\u5206\u7C7B";
|
export declare const UNCATEGORIZED_KEY = "\u672A\u5206\u7C7B";
|
||||||
|
/** Whether this category key names the "not yet classified" bucket. */
|
||||||
|
export declare function isDockedCategoryKey(key: string): boolean;
|
||||||
/** Directory display label: basename of the path (both separators accepted). */
|
/** Directory display label: basename of the path (both separators accepted). */
|
||||||
export declare function workspaceLabel(cwd: string | undefined): string;
|
export declare function workspaceLabel(cwd: string | undefined): string;
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ import {
|
||||||
type ManualGroups,
|
type ManualGroups,
|
||||||
} from '../core/types.ts'
|
} from '../core/types.ts'
|
||||||
import type { GroupsBrowserProps } from './contract.ts'
|
import type { GroupsBrowserProps } from './contract.ts'
|
||||||
import { deriveDefaultWorkspace, deriveGroups, deriveSearchGroups, deriveSearchMatches, deriveTopLevel, currentSessionId, folderKey, folderLabel, UNCATEGORIZED_KEY, type CategoryNode, type SearchMatchSet, type SearchTree, type WorkspaceGroupNode } from './tree.ts'
|
import { deriveDefaultWorkspace, deriveGroups, deriveSearchGroups, deriveSearchMatches, deriveTopLevel, currentSessionId, folderKey, folderLabel, isDockedCategoryKey, UNCATEGORIZED_KEY, type CategoryNode, type SearchMatchSet, type SearchTree, type WorkspaceGroupNode } from './tree.ts'
|
||||||
import { CategoryGlyph, CategoryRow, DND_CATEGORY_TYPE, DND_WORKSPACE_TYPE, FolderRow, hasPluginDragType, RowGroup, SessionRow, WorkspaceRow } from './rows.tsx'
|
import { CategoryGlyph, CategoryRow, DND_CATEGORY_TYPE, DND_WORKSPACE_TYPE, FolderRow, hasPluginDragType, RowGroup, SessionRow, WorkspaceRow } from './rows.tsx'
|
||||||
import type { WorkspaceGroupsKey } from './locales.ts'
|
import type { WorkspaceGroupsKey } from './locales.ts'
|
||||||
import { GROUP_EMOJI_ICONS, GROUP_ICON_LABELS } from './group-icon-labels.ts'
|
import { GROUP_EMOJI_ICONS, GROUP_ICON_LABELS } from './group-icon-labels.ts'
|
||||||
|
|
@ -152,6 +152,28 @@ function withoutSessions(node: WorkspaceGroupNode): WorkspaceGroupNode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Split the derived categories into the tree and the docked "not classified
|
||||||
|
* yet" bucket (see isDockedCategoryKey). The bucket keeps its own row and
|
||||||
|
* children, only its position moves to the bottom dock.
|
||||||
|
*/
|
||||||
|
function splitDockedCategory(categories: readonly CategoryNode[]): {
|
||||||
|
treeGroups: readonly CategoryNode[]
|
||||||
|
dockedCategory: CategoryNode | undefined
|
||||||
|
} {
|
||||||
|
const docked = categories.find(category => isDockedCategoryKey(category.key))
|
||||||
|
return {
|
||||||
|
treeGroups: docked === undefined ? categories : categories.filter(category => category !== docked),
|
||||||
|
dockedCategory: docked,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Whether a workspace node (or one of its folder rows) holds a matched session. */
|
||||||
|
function workspaceHasMatchedSession(workspace: WorkspaceGroupNode, matched: ReadonlySet<SessionId>): boolean {
|
||||||
|
if (workspace.sessions.some(session => matched.has(session.id))) return true
|
||||||
|
return workspace.folders?.some(folder => folder.sessions.some(session => matched.has(session.id))) ?? false
|
||||||
|
}
|
||||||
|
|
||||||
function sanitizeSearchQuery(value: string): string {
|
function sanitizeSearchQuery(value: string): string {
|
||||||
const withoutNul = value.replaceAll('\0', '')
|
const withoutNul = value.replaceAll('\0', '')
|
||||||
if (withoutNul.length <= SEARCH_QUERY_MAX_CODE_UNITS) return withoutNul
|
if (withoutNul.length <= SEARCH_QUERY_MAX_CODE_UNITS) return withoutNul
|
||||||
|
|
@ -493,6 +515,26 @@ export function GroupsBrowser({
|
||||||
: deriveSearchGroups(list, workspaces, config, searchMatches.matchedIds, archivedSessionIds, manual, searchMatches.snippetsBySession, statuses, foldersDoc)),
|
: deriveSearchGroups(list, workspaces, config, searchMatches.matchedIds, archivedSessionIds, manual, searchMatches.snippetsBySession, statuses, foldersDoc)),
|
||||||
[list, workspaces, config, searchMatches, archivedSessionIds, manual, statuses, foldersDoc],
|
[list, workspaces, config, searchMatches, archivedSessionIds, manual, statuses, foldersDoc],
|
||||||
)
|
)
|
||||||
|
// The "not classified yet" bucket leaves the tree and docks above the
|
||||||
|
// default-workspace bar, so unsorted projects never take a tree slot.
|
||||||
|
const { treeGroups, dockedCategory } = useMemo(() => splitDockedCategory(groups), [groups])
|
||||||
|
// Search keeps the dock too, but pruned to the matching rows: a bucket with no
|
||||||
|
// match is content, not a permanent anchor, so it simply does not show.
|
||||||
|
const searchDockCategory = useMemo<CategoryNode | undefined>(() => {
|
||||||
|
if (searchTree === undefined || searchMatches === undefined) return undefined
|
||||||
|
const docked = searchTree.categories.find(category => isDockedCategoryKey(category.key))
|
||||||
|
if (docked === undefined) return undefined
|
||||||
|
const workspaces = docked.workspaces.filter(workspace => workspaceHasMatchedSession(workspace, searchMatches.matchedIds))
|
||||||
|
return workspaces.length === 0 ? undefined : { ...docked, workspaces }
|
||||||
|
}, [searchTree, searchMatches])
|
||||||
|
// The results area must never repeat the docked bucket: drop it from the tree
|
||||||
|
// handed to SearchBody (the dock renders it instead).
|
||||||
|
const searchTreeForBody = useMemo<SearchTree | undefined>(
|
||||||
|
() => (searchTree === undefined
|
||||||
|
? undefined
|
||||||
|
: { ...searchTree, categories: searchTree.categories.filter(category => !isDockedCategoryKey(category.key)) }),
|
||||||
|
[searchTree],
|
||||||
|
)
|
||||||
// Quick panel (Ctrl+R): category label per grouped workspace id (the tree
|
// Quick panel (Ctrl+R): category label per grouped workspace id (the tree
|
||||||
// derivation already resolved grouping; top-level workspaces stay absent).
|
// derivation already resolved grouping; top-level workspaces stay absent).
|
||||||
const categoryByWorkspace = useMemo(() => {
|
const categoryByWorkspace = useMemo(() => {
|
||||||
|
|
@ -1314,6 +1356,83 @@ export function GroupsBrowser({
|
||||||
? defaultWorkspace
|
? defaultWorkspace
|
||||||
: (searchTree?.defaultWorkspace ?? withoutSessions(defaultWorkspace))
|
: (searchTree?.defaultWorkspace ?? withoutSessions(defaultWorkspace))
|
||||||
|
|
||||||
|
// Idle: the bucketed category as the tree derived it. Searching: the pruned
|
||||||
|
// bucket (matched rows only), absent when nothing matched.
|
||||||
|
const dockCategory = normalizedQuery === '' ? dockedCategory : searchDockCategory
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One category section with every tree callback bound. Extracted so the docked
|
||||||
|
* bucket is literally the same row/children component as a tree category —
|
||||||
|
* drag, menu, rename, appearance, folder management all behave identically.
|
||||||
|
*/
|
||||||
|
const categorySectionNode = (category: CategoryNode): JSX.Element => (
|
||||||
|
<CategorySection
|
||||||
|
key={category.key}
|
||||||
|
category={category}
|
||||||
|
current={current}
|
||||||
|
now={now}
|
||||||
|
t={t}
|
||||||
|
dragIndicator={dragIndicator}
|
||||||
|
onDragOverRow={onDragOverRow}
|
||||||
|
onDragLeaveRow={onDragLeaveRow}
|
||||||
|
onDropRow={onDropRow}
|
||||||
|
onDragStartCategory={onDragStartCategory(category.key)}
|
||||||
|
onDragStartWorkspace={onDragStartWorkspace}
|
||||||
|
onToggleCategory={() => { actions.setCategoryExpanded(category.key, !category.expanded) }}
|
||||||
|
onToggleWorkspace={(key) => { actions.setWorkspaceExpanded(key, !workspaceExpansion[key]) }}
|
||||||
|
onNewSession={startSessionAtRoot}
|
||||||
|
onOpen={open}
|
||||||
|
onToggleFolder={toggleFolder}
|
||||||
|
onFolderNewSession={startSessionInFolder}
|
||||||
|
onFolderSetRoot={setFolderRoot}
|
||||||
|
onFolderRemove={removeFolderFrom}
|
||||||
|
onOpenFolderPath={openFolderPath}
|
||||||
|
onManageFolders={(workspaceId) => { setFoldersTarget(workspaceId) }}
|
||||||
|
creatingFolderKey={creatingSessionIn}
|
||||||
|
onRenameRequest={(workspaceId, title) => {
|
||||||
|
setRenameTarget({ workspaceId, currentTitle: title })
|
||||||
|
setRenameDraft(title)
|
||||||
|
setRenameError(null)
|
||||||
|
}}
|
||||||
|
onDeleteRequest={(workspaceId, title) => {
|
||||||
|
setDeleteTarget({ workspaceId, title })
|
||||||
|
setDeleteError(null)
|
||||||
|
}}
|
||||||
|
onSessionRename={onSessionRename}
|
||||||
|
onSessionArchive={onSessionArchive}
|
||||||
|
onFork={forkSession}
|
||||||
|
onAddWorkspace={() => { void addWorkspace(category.key) }}
|
||||||
|
addingWorkspace={adding || manualSaving}
|
||||||
|
onGroupRename={() => {
|
||||||
|
setGroupDraft(category.key)
|
||||||
|
setGroupError(null)
|
||||||
|
setGroupDialog({ mode: 'rename', from: category.key })
|
||||||
|
}}
|
||||||
|
onGroupDelete={() => {
|
||||||
|
setGroupDeleteTarget(category.key)
|
||||||
|
setGroupDeleteError(null)
|
||||||
|
}}
|
||||||
|
onGroupTogglePin={() => { void toggleCategoryPinned(category.key) }}
|
||||||
|
onGroupAppearance={() => {
|
||||||
|
setAppearanceDraft(manual.appearance[category.key] ?? {})
|
||||||
|
setAppearanceError(null)
|
||||||
|
setAppearanceTarget(category.key)
|
||||||
|
}}
|
||||||
|
animate={dragging === null}
|
||||||
|
onMoveOut={(workspaceId) => { void moveWorkspaceTo(workspaceId, UNCATEGORIZED_KEY) }}
|
||||||
|
onOpenInFolder={openInFolder}
|
||||||
|
canMoveOut={(workspaceId) => {
|
||||||
|
// The menu "Move out of group" is offered for any project that
|
||||||
|
// currently sits inside a group (rule-classified or manual) —
|
||||||
|
// not just overridden ones. Top-level projects
|
||||||
|
// (resolveCategory === undefined) don't need it.
|
||||||
|
const workspace = workspaces.find(w => w.workspaceId === workspaceId)
|
||||||
|
return workspace !== undefined
|
||||||
|
&& resolveCategory(config, manual, workspace.workspaceId, workspace.path, workspace.title) !== undefined
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`wgRoot${wide ? '' : ' wgRail'}`}>
|
<div className={`wgRoot${wide ? '' : ' wgRail'}`}>
|
||||||
{/* The tab strip portals itself into the conversation column's head seat,
|
{/* The tab strip portals itself into the conversation column's head seat,
|
||||||
|
|
@ -1424,9 +1543,9 @@ export function GroupsBrowser({
|
||||||
{manualError !== null && (
|
{manualError !== null && (
|
||||||
<div className="wgSearchStatus wgManualError" role="alert">{t('manual.saveError')}: {manualError}</div>
|
<div className="wgSearchStatus wgManualError" role="alert">{t('manual.saveError')}: {manualError}</div>
|
||||||
)}
|
)}
|
||||||
{wide && normalizedQuery !== '' && searchTree !== undefined && searchMatches !== undefined ? (
|
{wide && normalizedQuery !== '' && searchTreeForBody !== undefined && searchMatches !== undefined ? (
|
||||||
<SearchBody
|
<SearchBody
|
||||||
tree={searchTree}
|
tree={searchTreeForBody}
|
||||||
matches={searchMatches}
|
matches={searchMatches}
|
||||||
status={activeRemoteSearch.status}
|
status={activeRemoteSearch.status}
|
||||||
current={current}
|
current={current}
|
||||||
|
|
@ -1441,78 +1560,12 @@ export function GroupsBrowser({
|
||||||
the index-based measurement). */
|
the index-based measurement). */
|
||||||
<div className="wgTreeWrap">
|
<div className="wgTreeWrap">
|
||||||
<div className="wgList" role="tree" aria-label={t('section.workspaces')}>
|
<div className="wgList" role="tree" aria-label={t('section.workspaces')}>
|
||||||
{/* The pinned default workspace sits in its own bottom bar, so a tree
|
{/* The docked bucket and the pinned default workspace sit outside the
|
||||||
holding nothing but that workspace is not "empty". */}
|
tree's scroll area, so a tree holding nothing but them is not "empty". */}
|
||||||
{groups.length === 0 && topLevel.length === 0 && !topLevelDropActive && defaultBarNode === undefined && (
|
{treeGroups.length === 0 && topLevel.length === 0 && !topLevelDropActive && defaultBarNode === undefined && dockCategory === undefined && (
|
||||||
<div className="wgEmpty">{workspacePhase === 'ready' ? t('empty.noWorkspaces') : t('empty.none')}</div>
|
<div className="wgEmpty">{workspacePhase === 'ready' ? t('empty.noWorkspaces') : t('empty.none')}</div>
|
||||||
)}
|
)}
|
||||||
{groups.map((category) => (
|
{treeGroups.map(categorySectionNode)}
|
||||||
<CategorySection
|
|
||||||
key={category.key}
|
|
||||||
category={category}
|
|
||||||
current={current}
|
|
||||||
now={now}
|
|
||||||
t={t}
|
|
||||||
dragIndicator={dragIndicator}
|
|
||||||
onDragOverRow={onDragOverRow}
|
|
||||||
onDragLeaveRow={onDragLeaveRow}
|
|
||||||
onDropRow={onDropRow}
|
|
||||||
onDragStartCategory={onDragStartCategory(category.key)}
|
|
||||||
onDragStartWorkspace={onDragStartWorkspace}
|
|
||||||
onToggleCategory={() => { actions.setCategoryExpanded(category.key, !category.expanded) }}
|
|
||||||
onToggleWorkspace={(key) => { actions.setWorkspaceExpanded(key, !workspaceExpansion[key]) }}
|
|
||||||
onNewSession={startSessionAtRoot}
|
|
||||||
onOpen={open}
|
|
||||||
onToggleFolder={toggleFolder}
|
|
||||||
onFolderNewSession={startSessionInFolder}
|
|
||||||
onFolderSetRoot={setFolderRoot}
|
|
||||||
onFolderRemove={removeFolderFrom}
|
|
||||||
onOpenFolderPath={openFolderPath}
|
|
||||||
onManageFolders={(workspaceId) => { setFoldersTarget(workspaceId) }}
|
|
||||||
creatingFolderKey={creatingSessionIn}
|
|
||||||
onRenameRequest={(workspaceId, title) => {
|
|
||||||
setRenameTarget({ workspaceId, currentTitle: title })
|
|
||||||
setRenameDraft(title)
|
|
||||||
setRenameError(null)
|
|
||||||
}}
|
|
||||||
onDeleteRequest={(workspaceId, title) => {
|
|
||||||
setDeleteTarget({ workspaceId, title })
|
|
||||||
setDeleteError(null)
|
|
||||||
}}
|
|
||||||
onSessionRename={onSessionRename}
|
|
||||||
onSessionArchive={onSessionArchive}
|
|
||||||
onFork={forkSession}
|
|
||||||
onAddWorkspace={() => { void addWorkspace(category.key) }}
|
|
||||||
addingWorkspace={adding || manualSaving}
|
|
||||||
onGroupRename={() => {
|
|
||||||
setGroupDraft(category.key)
|
|
||||||
setGroupError(null)
|
|
||||||
setGroupDialog({ mode: 'rename', from: category.key })
|
|
||||||
}}
|
|
||||||
onGroupDelete={() => {
|
|
||||||
setGroupDeleteTarget(category.key)
|
|
||||||
setGroupDeleteError(null)
|
|
||||||
}}
|
|
||||||
onGroupTogglePin={() => { void toggleCategoryPinned(category.key) }}
|
|
||||||
onGroupAppearance={() => {
|
|
||||||
setAppearanceDraft(manual.appearance[category.key] ?? {})
|
|
||||||
setAppearanceError(null)
|
|
||||||
setAppearanceTarget(category.key)
|
|
||||||
}}
|
|
||||||
animate={dragging === null}
|
|
||||||
onMoveOut={(workspaceId) => { void moveWorkspaceTo(workspaceId, UNCATEGORIZED_KEY) }}
|
|
||||||
onOpenInFolder={openInFolder}
|
|
||||||
canMoveOut={(workspaceId) => {
|
|
||||||
// The menu "Move out of group" is offered for any project that
|
|
||||||
// currently sits inside a group (rule-classified or manual) —
|
|
||||||
// not just overridden ones. Top-level projects
|
|
||||||
// (resolveCategory === undefined) don't need it.
|
|
||||||
const workspace = workspaces.find(w => w.workspaceId === workspaceId)
|
|
||||||
return workspace !== undefined
|
|
||||||
&& resolveCategory(config, manual, workspace.workspaceId, workspace.path, workspace.title) !== undefined
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
{/* Top-level (ungrouped) workspaces, rendered after the group
|
{/* Top-level (ungrouped) workspaces, rendered after the group
|
||||||
folders. While dragging a project the whole area is the
|
folders. While dragging a project the whole area is the
|
||||||
move-out landing spot (a line shows the insert position;
|
move-out landing spot (a line shows the insert position;
|
||||||
|
|
@ -1561,50 +1614,62 @@ export function GroupsBrowser({
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Pinned default workspace: a sibling of the tree's scroll area (not a
|
{/* Bottom dock: siblings of the tree's scroll area (not rows inside it), so
|
||||||
row inside it), above a divider, so a long session list can never
|
a long session list can never push them away or scroll them out.
|
||||||
push it away or scroll it out. It keeps the whole workspace-row
|
- the "not classified yet" bucket keeps its own category row and
|
||||||
behaviour — toggle, new session, rename, delete, ⋯ menu, folder
|
children (same component, same drag/menu behaviour), capped in height
|
||||||
management — and its sessions still highlight as usual. */}
|
with its own scroll so a big bucket cannot swallow the tree;
|
||||||
{wide && defaultBarNode !== undefined && (
|
- the Host default workspace keeps the whole workspace-row behaviour
|
||||||
<div className="wgDefaultWorkspaceBar" role="group" aria-label={t('section.defaultWorkspace')}>
|
(toggle, new session, rename, delete, ⋯ menu, folder management) and
|
||||||
<WorkspaceRow
|
its sessions still highlight as usual. */}
|
||||||
node={defaultBarNode}
|
{wide && (dockCategory !== undefined || defaultBarNode !== undefined) && (
|
||||||
t={t}
|
<div className="wgDock">
|
||||||
flat
|
{dockCategory !== undefined && (
|
||||||
onToggle={() => { actions.setWorkspaceExpanded(defaultBarNode.workspaceId as string, !workspaceExpansion[defaultBarNode.workspaceId]) }}
|
<div className="wgDockBucket" role="group" aria-label={dockCategory.label}>
|
||||||
onNewSession={() => { startSessionAtRoot(defaultBarNode.workspaceId) }}
|
{categorySectionNode(dockCategory)}
|
||||||
onRename={() => {
|
</div>
|
||||||
setRenameTarget({ workspaceId: defaultBarNode.workspaceId, currentTitle: defaultBarNode.label })
|
)}
|
||||||
setRenameDraft(defaultBarNode.label)
|
{defaultBarNode !== undefined && (
|
||||||
setRenameError(null)
|
<div className="wgDefaultWorkspaceBar" role="group" aria-label={t('section.defaultWorkspace')}>
|
||||||
}}
|
<WorkspaceRow
|
||||||
onDelete={() => {
|
node={defaultBarNode}
|
||||||
setDeleteTarget({ workspaceId: defaultBarNode.workspaceId, title: defaultBarNode.label })
|
t={t}
|
||||||
setDeleteError(null)
|
flat
|
||||||
}}
|
onToggle={() => { actions.setWorkspaceExpanded(defaultBarNode.workspaceId as string, !workspaceExpansion[defaultBarNode.workspaceId]) }}
|
||||||
{...(openInFolder !== undefined
|
onNewSession={() => { startSessionAtRoot(defaultBarNode.workspaceId) }}
|
||||||
? { onOpenInFolder: () => { openInFolder(defaultBarNode.workspaceId) } }
|
onRename={() => {
|
||||||
: {})}
|
setRenameTarget({ workspaceId: defaultBarNode.workspaceId, currentTitle: defaultBarNode.label })
|
||||||
onManageFolders={() => { setFoldersTarget(defaultBarNode.workspaceId) }}
|
setRenameDraft(defaultBarNode.label)
|
||||||
/>
|
setRenameError(null)
|
||||||
<WorkspaceSubtree
|
}}
|
||||||
workspace={defaultBarNode}
|
onDelete={() => {
|
||||||
current={current}
|
setDeleteTarget({ workspaceId: defaultBarNode.workspaceId, title: defaultBarNode.label })
|
||||||
now={now}
|
setDeleteError(null)
|
||||||
t={t}
|
}}
|
||||||
animate={dragging === null}
|
{...(openInFolder !== undefined
|
||||||
onOpen={open}
|
? { onOpenInFolder: () => { openInFolder(defaultBarNode.workspaceId) } }
|
||||||
onSessionRename={onSessionRename}
|
: {})}
|
||||||
onSessionArchive={onSessionArchive}
|
onManageFolders={() => { setFoldersTarget(defaultBarNode.workspaceId) }}
|
||||||
onFork={forkSession}
|
/>
|
||||||
onToggleFolder={toggleFolder}
|
<WorkspaceSubtree
|
||||||
onFolderNewSession={startSessionInFolder}
|
workspace={defaultBarNode}
|
||||||
onFolderSetRoot={setFolderRoot}
|
current={current}
|
||||||
onFolderRemove={removeFolderFrom}
|
now={now}
|
||||||
onOpenFolderPath={openFolderPath}
|
t={t}
|
||||||
creatingFolderKey={creatingSessionIn}
|
animate={dragging === null}
|
||||||
/>
|
onOpen={open}
|
||||||
|
onSessionRename={onSessionRename}
|
||||||
|
onSessionArchive={onSessionArchive}
|
||||||
|
onFork={forkSession}
|
||||||
|
onToggleFolder={toggleFolder}
|
||||||
|
onFolderNewSession={startSessionInFolder}
|
||||||
|
onFolderSetRoot={setFolderRoot}
|
||||||
|
onFolderRemove={removeFolderFrom}
|
||||||
|
onOpenFolderPath={openFolderPath}
|
||||||
|
creatingFolderKey={creatingSessionIn}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -91,11 +91,41 @@
|
||||||
/* Pinned default workspace: a sibling of the tree's scroll area, never inside
|
/* Pinned default workspace: a sibling of the tree's scroll area, never inside
|
||||||
it — a long session list scrolls above this bar and can neither push it away
|
it — a long session list scrolls above this bar and can neither push it away
|
||||||
nor scroll it out. The divider separates the two zones. */
|
nor scroll it out. The divider separates the two zones. */
|
||||||
|
/* Bottom dock: the "not classified yet" bucket and the Host default workspace
|
||||||
|
sit outside the tree's scroll area, so a long session list can never push
|
||||||
|
them away. The dock owns the divider against the tree; the default-workspace
|
||||||
|
bar adds a second one only when the bucket sits above it. */
|
||||||
|
.wgDock {
|
||||||
|
flex:none;
|
||||||
|
min-width:0;
|
||||||
|
display:flex;
|
||||||
|
flex-direction:column;
|
||||||
|
border-top:1px solid var(--dsw-alias-border-l2,#7f7f7f47);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The docked bucket scrolls on its own and never grows past a fixed share of
|
||||||
|
the sidebar: a big "not classified yet" pile must not swallow the tree. */
|
||||||
|
.wgDockBucket {
|
||||||
|
flex:none;
|
||||||
|
min-width:0;
|
||||||
|
max-height:min(240px,38vh);
|
||||||
|
padding:4px 8px 0;
|
||||||
|
overflow-x:hidden;
|
||||||
|
overflow-y:auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wgDockBucket + .wgDefaultWorkspaceBar {
|
||||||
|
border-top:1px solid var(--dsw-alias-border-l2,#7f7f7f47);
|
||||||
|
}
|
||||||
|
|
||||||
|
.wgRail .wgDock {
|
||||||
|
display:none;
|
||||||
|
}
|
||||||
|
|
||||||
.wgDefaultWorkspaceBar {
|
.wgDefaultWorkspaceBar {
|
||||||
flex:none;
|
flex:none;
|
||||||
min-width:0;
|
min-width:0;
|
||||||
padding:6px 8px 8px;
|
padding:6px 8px 8px;
|
||||||
border-top:1px solid var(--dsw-alias-border-l2,#7f7f7f47);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.wgDefaultWorkspaceBar .wgProjectRow {
|
.wgDefaultWorkspaceBar .wgProjectRow {
|
||||||
|
|
|
||||||
|
|
@ -156,6 +156,19 @@ export interface GroupsTreeView {
|
||||||
/** Key of the uncategorized bucket (matches the config fallback label). */
|
/** Key of the uncategorized bucket (matches the config fallback label). */
|
||||||
export const UNCATEGORIZED_KEY = UNCATEGORIZED_LABEL
|
export const UNCATEGORIZED_KEY = UNCATEGORIZED_LABEL
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Names the "not sorted yet" bucket commonly gets. A group whose key matches one
|
||||||
|
* of these is docked to the bottom of the sidebar (above the default-workspace
|
||||||
|
* row) instead of taking a slot in the tree, so the workspaces a user has not
|
||||||
|
* classified yet never push the classified tree around.
|
||||||
|
*/
|
||||||
|
const DOCKED_CATEGORY_PATTERN = /^(?:未归类|未分类|未分组|未排序|待归类|ungrouped|uncategorized|unsorted)$/iu
|
||||||
|
|
||||||
|
/** Whether this category key names the "not yet classified" bucket. */
|
||||||
|
export function isDockedCategoryKey(key: string): boolean {
|
||||||
|
return DOCKED_CATEGORY_PATTERN.test(key.trim())
|
||||||
|
}
|
||||||
|
|
||||||
/** Directory display label: basename of the path (both separators accepted). */
|
/** Directory display label: basename of the path (both separators accepted). */
|
||||||
export function workspaceLabel(cwd: string | undefined): string {
|
export function workspaceLabel(cwd: string | undefined): string {
|
||||||
if (cwd === undefined || cwd === '') return UNCATEGORIZED_LABEL
|
if (cwd === undefined || cwd === '') return UNCATEGORIZED_LABEL
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
/**
|
||||||
|
* Zero-dependency checks for the bottom dock (the "not classified yet" bucket
|
||||||
|
* and the pinned default workspace).
|
||||||
|
*
|
||||||
|
* Vitest cannot start in this checkout (missing @vitest/utils, std-env), so the
|
||||||
|
* equivalent assertions run here instead:
|
||||||
|
* 1. the dock predicate accepts the bucket names users actually type and
|
||||||
|
* rejects ordinary group names;
|
||||||
|
* 2. the browser component takes the bucket out of the tree and out of the
|
||||||
|
* search results, and paints it in the dock instead;
|
||||||
|
* 3. the stylesheet keeps the dock out of the tree's scroll area and caps the
|
||||||
|
* bucket height.
|
||||||
|
*
|
||||||
|
* Run from the package root: `node tools/verify-dock.mjs`.
|
||||||
|
*/
|
||||||
|
import assert from 'node:assert/strict'
|
||||||
|
import { readFileSync } from 'node:fs'
|
||||||
|
import { join } from 'node:path'
|
||||||
|
|
||||||
|
const root = process.cwd()
|
||||||
|
const read = (relative) => readFileSync(join(root, relative), 'utf8')
|
||||||
|
|
||||||
|
// Node ≥ 22.18 strips TypeScript types on import, which lets the shared
|
||||||
|
// predicate be tested directly instead of copied into this script.
|
||||||
|
const { isDockedCategoryKey } = await import('../src/client/tree.ts')
|
||||||
|
|
||||||
|
// 1. predicate ---------------------------------------------------------------
|
||||||
|
const docked = ['未归类', '未分类', '未分组', '未排序', '待归类', 'ungrouped', 'Uncategorized', 'UNSORTED', ' 未归类 ']
|
||||||
|
for (const key of docked) {
|
||||||
|
assert.equal(isDockedCategoryKey(key), true, `${JSON.stringify(key)} must dock`)
|
||||||
|
}
|
||||||
|
const notDocked = ['开发', '实验', '人生大事', '画图', 'default-workspace', '未归类的项目', 'grouping', '未', 'Uncategorized work']
|
||||||
|
for (const key of notDocked) {
|
||||||
|
assert.equal(isDockedCategoryKey(key), false, `${JSON.stringify(key)} must stay in the tree`)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. render wiring -----------------------------------------------------------
|
||||||
|
const browser = read('src/client/GroupsBrowser.tsx')
|
||||||
|
assert.match(browser, /splitDockedCategory\(groups\)/, 'the docked bucket is split out of the derived groups')
|
||||||
|
assert.match(browser, /\{treeGroups\.map\(categorySectionNode\)\}/, 'the tree renders the categories without the bucket')
|
||||||
|
assert.match(browser, /className="wgDock"/, 'the bottom dock container is rendered')
|
||||||
|
assert.match(browser, /className="wgDockBucket"/, 'the docked bucket has its own capped container')
|
||||||
|
assert.match(browser, /categorySectionNode\(dockCategory\)/, 'the docked bucket reuses the category section component')
|
||||||
|
assert.match(
|
||||||
|
browser,
|
||||||
|
/categories: searchTree\.categories\.filter\(category => !isDockedCategoryKey\(category\.key\)\)/,
|
||||||
|
'search results never repeat the docked bucket',
|
||||||
|
)
|
||||||
|
assert.match(browser, /tree=\{searchTreeForBody\}/, 'search results use the bucket-free tree')
|
||||||
|
assert.match(browser, /dockCategory === undefined && \(/, 'an empty tree that only holds the dock is not "no workspaces"')
|
||||||
|
|
||||||
|
// 3. stylesheet --------------------------------------------------------------
|
||||||
|
const css = read('src/client/styles.css')
|
||||||
|
const block = (selector) => {
|
||||||
|
const escaped = selector.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
||||||
|
const match = new RegExp(`(?:^|\\n)(${escaped} \\{)`).exec(css)
|
||||||
|
assert.ok(match !== null, `${selector} rule exists`)
|
||||||
|
const start = match.index + match[0].length - match[1].length
|
||||||
|
return css.slice(start, css.indexOf('}', start))
|
||||||
|
}
|
||||||
|
assert.match(block('.wgDock'), /border-top:1px solid/, 'the dock draws the divider against the tree')
|
||||||
|
assert.match(block('.wgDock'), /flex:none/, 'the dock never scrolls with the tree')
|
||||||
|
assert.match(block('.wgDockBucket'), /overflow-y:auto/, 'a long bucket scrolls on its own')
|
||||||
|
assert.match(block('.wgDockBucket'), /max-height:min\(240px,38vh\)/, 'the bucket is capped so it cannot swallow the tree')
|
||||||
|
assert.match(css, /\.wgDockBucket \+ \.wgDefaultWorkspaceBar \{[^}]*border-top:1px solid/, 'a separator sits between the bucket and the default-workspace row')
|
||||||
|
assert.match(css, /\.wgRail \.wgDock \{\s*display:none;/, 'the rail never shows the dock')
|
||||||
|
assert.doesNotMatch(block('.wgDefaultWorkspaceBar'), /border-top/, 'the bar itself no longer draws a duplicate divider')
|
||||||
|
|
||||||
|
console.log('Dock contracts passed: bucket predicate, render wiring and stylesheet.')
|
||||||
|
|
@ -9,7 +9,9 @@ const source = readFileSync(new URL('../src/client/styles.css', import.meta.url)
|
||||||
transform({ filename: 'styles.css', code: Buffer.from(source) })
|
transform({ filename: 'styles.css', code: Buffer.from(source) })
|
||||||
const rule = selector => {
|
const rule = selector => {
|
||||||
const escaped = selector.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
const escaped = selector.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
||||||
const result = source.match(new RegExp(`${escaped}\\s*\\{([^}]*)\\}`))
|
// Anchor at a line start so a selector that also appears inside a compound
|
||||||
|
// rule (".wgDockBucket + .wgDefaultWorkspaceBar") never shadows its own block.
|
||||||
|
const result = source.match(new RegExp(`(?:^|\\n)${escaped}\\s*\\{([^}]*)\\}`, 'm'))
|
||||||
assert.ok(result, `missing rule: ${selector}`)
|
assert.ok(result, `missing rule: ${selector}`)
|
||||||
return result[1].replace(/\s/g, '')
|
return result[1].replace(/\s/g, '')
|
||||||
}
|
}
|
||||||
|
|
@ -57,11 +59,15 @@ const sections = rule('.wgIconSections')
|
||||||
assert.ok(sections.includes('max-height:') && sections.includes('overflow-y:auto;'), 'icon picker is bounded, footer stays visible')
|
assert.ok(sections.includes('max-height:') && sections.includes('overflow-y:auto;'), 'icon picker is bounded, footer stays visible')
|
||||||
assert.ok(!rule('.wgIconGrid').includes('max-height:'), 'the scroll box moved from the grid to the section list')
|
assert.ok(!rule('.wgIconGrid').includes('max-height:'), 'the scroll box moved from the grid to the section list')
|
||||||
|
|
||||||
// D. The pinned default workspace is a sibling of the scrolling tree, so a long
|
// D. The bottom dock (not-classified bucket + pinned default workspace) is a
|
||||||
// session list can never scroll it away.
|
// sibling of the scrolling tree, so a long session list can never scroll it
|
||||||
const bar = rule('.wgDefaultWorkspaceBar')
|
// away. The dock owns the divider; the bucket scrolls inside a capped box.
|
||||||
assert.ok(bar.includes('border-top:'), 'the bar is separated from the tree')
|
const dock = rule('.wgDock')
|
||||||
assert.ok(bar.includes('flex:none;'), 'the bar must not be squeezed by the tree')
|
assert.ok(dock.includes('border-top:'), 'the dock is separated from the tree')
|
||||||
|
assert.ok(dock.includes('flex:none;'), 'the dock must not be squeezed by the tree')
|
||||||
|
const bucket = rule('.wgDockBucket')
|
||||||
|
assert.ok(bucket.includes('overflow-y:auto;') && bucket.includes('max-height:'), 'a long bucket scrolls on its own')
|
||||||
|
assert.ok(rule('.wgDefaultWorkspaceBar').includes('flex:none;'), 'the default-workspace row must not be squeezed by the tree')
|
||||||
|
|
||||||
// E. The markup backs the CSS: every row hands its rest-state label (member
|
// E. The markup backs the CSS: every row hands its rest-state label (member
|
||||||
// count or session time) AND its buttons to the one trailing slot, so both right
|
// count or session time) AND its buttons to the one trailing slot, so both right
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue