feat(web): sort the workspace picker by recent use and make it searchable
The chat sidebar's workspace picker listed rows in daemon order, which says nothing about where the user was last. It now orders by recent use and filters as you type. - new `features/chat/workspace-order.ts`: recency = browser-local stamp (`pi2-workspace-recency`, written whenever a workspace becomes active) > daemon `lastActiveAt` > name/id, so the order is deterministic and stable; search matches name, alias, cwd, directory name and id, whitespace-split terms all required - `WorkspaceSwitch` becomes a filterable listbox: fixed search field on top (focused on open, cleared on close), scrolling row list, empty state, arrow/Home/End focus, Enter takes the first match, Esc returns focus to the trigger; rows are `role=option` + `aria-selected` - pages/chat.tsx stamps whichever workspace is active (deep link, picker, default), styles and en/zh strings for the search field - tests for ordering, matching, persistence and the keyboard/selection paths; the B5 UI e2e scenario follows the ARIA change and asserts the filter
This commit is contained in:
1 parent
00c81a56f4
commit
3a797ac3f7
10 files changed
+651
-54
No files matched your search
@@ -158,26 +158,82 @@
|
||||
right: 8px;
|
||||
top: 42px;
|
||||
z-index: 12;
|
||||
padding: 4px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: var(--popover);
|
||||
color: var(--popover-foreground);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow-lg);
|
||||
max-height: min(50vh, 22rem);
|
||||
overflow-y: auto;
|
||||
overflow: hidden;
|
||||
}
|
||||
.ws-menu[hidden] {
|
||||
display: none;
|
||||
}
|
||||
.ws-menu__label {
|
||||
padding: 6px 8px 4px;
|
||||
font-size: var(--fs-2xs);
|
||||
font-weight: 650;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
/* 搜索框固定在顶部,只有下面的列表滚动 */
|
||||
.ws-menu__search {
|
||||
display: flex;
|
||||
flex: none;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 0 8px;
|
||||
border-bottom: 1px solid var(--border-subtle);
|
||||
}
|
||||
.ws-menu__search svg {
|
||||
flex: none;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
color: var(--faint);
|
||||
}
|
||||
.ws-menu__input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
height: 34px;
|
||||
min-height: 34px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: var(--foreground);
|
||||
font-size: var(--fs-sm);
|
||||
appearance: none;
|
||||
outline: none;
|
||||
}
|
||||
.ws-menu__input::-webkit-search-cancel-button {
|
||||
appearance: none;
|
||||
}
|
||||
.ws-menu__input::placeholder {
|
||||
color: var(--faint);
|
||||
}
|
||||
.ws-menu__clear {
|
||||
display: inline-flex;
|
||||
flex: none;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border-radius: var(--radius-sm);
|
||||
color: var(--faint);
|
||||
}
|
||||
.ws-menu__clear:hover {
|
||||
background: var(--surface-2);
|
||||
color: var(--foreground);
|
||||
}
|
||||
.ws-menu__clear svg {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
}
|
||||
.ws-menu__list {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
padding: 4px;
|
||||
}
|
||||
.ws-menu__empty {
|
||||
padding: 10px 8px;
|
||||
color: var(--faint);
|
||||
font-size: var(--fs-sm);
|
||||
}
|
||||
.ws-menu__item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -191,7 +247,8 @@
|
||||
color: var(--secondary-foreground);
|
||||
}
|
||||
.ws-menu__item:hover,
|
||||
.ws-menu__item:focus-visible {
|
||||
.ws-menu__item:focus-visible,
|
||||
.ws-menu__item:focus {
|
||||
background: var(--surface-2);
|
||||
color: var(--foreground);
|
||||
outline: none;
|
||||
|
||||
Reference in new issue
Block a user