feat(ui): search the include/exclude preview list (#799)

* feat(ui): search the include/exclude preview list

With dozens of skills, finding one row in the filter preview meant
scrolling the whole list before a click could include or exclude it.
A search box above the preview narrows the rows by name, ignoring case,
and marks the matching text. It only narrows what is shown; the filters
and the summary still cover every row.

The preview is shared, so the search appears on the project page, the
target page, and the Extras edit-target dialog. Switching between skills
and agents clears it, since a skill name rarely means anything as an
agent search.

Closes #798

* fix(ui): hide the stray scrollbar on the skills tab bar

The tab bar scrolls sideways at phone width, and overflow-x: auto makes
the other axis auto too. In the Clean style each tab hangs 1px below the
bar to cover its underline, so the bar overflowed by 1px and Chrome drew
the app's 8px custom scrollbar as a small dark pill at its right end.
Clipping the vertical axis keeps the sideways scroll and the underline.
This commit is contained in:
Willie
2026-11-08 03:26:41 +08:00
committed by GitHub
parent 03f6f42aae
commit 228efb4fca
15 changed files with 101 additions and 9 deletions
+30 -7
View File
@@ -1,12 +1,12 @@
import { Fragment, useState, type ReactNode } from 'react';
import { Link } from 'react-router-dom';
import { ChevronDown, ChevronRight } from 'lucide-react';
import { ChevronDown, ChevronRight, Search } from 'lucide-react';
import type { SyncMatrixEntry } from '../../api/client';
import AgentIcon from '../AgentIcon';
import Spinner from '../Spinner';
import { useI18n, useT, plural } from '../../i18n';
import PatternInput from './PatternInput';
import { joinList, patternName, togglePatterns } from './targetView';
import { joinList, patternName, searchEntries, togglePatterns } from './targetView';
type Kind = 'skill' | 'agent' | 'file';
const MODES = ['merge', 'copy', 'symlink'] as const;
@@ -39,8 +39,22 @@ interface Props {
export default function FilterSection({ kind, mode, name, include, exclude, onChange, entries, loaded, loading, error, disabled, alsoReadBy = [], readsFrom = [], includeWarning }: Props) {
const { t, locale } = useI18n();
const [help, setHelp] = useState(false);
const [query, setQuery] = useState('');
// Switching between skills and agents starts a new search.
const [queryKind, setQueryKind] = useState(kind);
if (queryKind !== kind) {
setQueryKind(kind);
setQuery('');
}
const files = kind === 'file';
const synced = entries.filter((e) => e.status === 'synced').length;
const shown = searchEntries(entries, query);
/** Marks the searched text inside a row name. */
const hit = (name: string) => {
const q = query.trim();
const i = q ? name.toLowerCase().indexOf(q.toLowerCase()) : -1;
return i < 0 ? name : <>{name.slice(0, i)}<mark className="ss-hit">{name.slice(i, i + q.length)}</mark>{name.slice(i + q.length)}</>;
};
const reason = (e: SyncMatrixEntry) => {
switch (e.status) {
@@ -119,9 +133,17 @@ export default function FilterSection({ kind, mode, name, include, exclude, onCh
) : entries.length > 0 && (
// The result of the filters, set apart from the fields that shape it.
<div className="mt-2 flex flex-col gap-3 border-t border-line pt-5">
<div className="flex flex-col gap-0.5">
<h3 className="text-[14px] font-semibold">{t('targetDetail.previewCount', { count: entries.length })}</h3>
<p className="text-[13px] text-ink-3">{t(files ? 'targetDetail.clickHintFiles' : 'targetDetail.clickHint')}</p>
<div className="flex flex-wrap items-end justify-between gap-3">
<div className="flex flex-col gap-0.5">
<h3 className="text-[14px] font-semibold">
{query.trim() ? t('targetDetail.previewCountSearch', { shown: shown.length, count: entries.length }) : t('targetDetail.previewCount', { count: entries.length })}
</h3>
<p className="text-[13px] text-ink-3">{t(files ? 'targetDetail.clickHintFiles' : 'targetDetail.clickHint')}</p>
</div>
<label className="ss-inp h-[34px] w-full sm:w-[240px]">
<Search size={15} className="shrink-0 text-ink-3" />
<input type="search" value={query} onChange={(e) => setQuery(e.target.value)} placeholder={t(`targetDetail.search.${kind}s`)} aria-label={t(`targetDetail.search.${kind}s`)} />
</label>
</div>
<div className="ss-list !shadow-none">
<div className="ss-lh">
@@ -130,12 +152,13 @@ export default function FilterSection({ kind, mode, name, include, exclude, onCh
<span className="w-[96px]">{t('targetDetail.result')}</span>
</div>
<div className="max-h-[340px] overflow-y-auto">
{entries.map((e) => {
{shown.length === 0 && <p className="px-4 py-3 text-[13px] text-ink-3">{t('targetDetail.searchNoMatches', { query: query.trim() })}</p>}
{shown.map((e) => {
const next = togglePatterns(e, include, exclude);
const on = e.status === 'synced';
const cells = (
<>
<span className={`min-w-0 flex-1 truncate font-mono text-[13px] font-semibold ${on ? '' : 'text-ink-2'}`}>{patternName(e)}</span>
<span className={`min-w-0 flex-1 truncate font-mono text-[13px] font-semibold ${on ? '' : 'text-ink-2'}`}>{hit(patternName(e))}</span>
<span className="w-[170px] shrink-0 truncate font-mono text-[12px] text-ink-2" title={reason(e)}>{reason(e)}</span>
<span className="w-[96px] shrink-0"><span className={`ss-st ${on ? 'ok' : 'off'}`}>{t(on ? 'targetDetail.synced' : 'targetDetail.notSynced')}</span></span>
</>
+9 -1
View File
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';
import type { SyncMatrixEntry, Target } from '../../api/client';
import { joinList, targetHealth, targetSkipHints, targetWarning, togglePatterns } from './targetView';
import { joinList, searchEntries, targetHealth, targetSkipHints, targetWarning, togglePatterns } from './targetView';
const target = (over: Partial<Target>): Target => ({
name: 'claude', path: '~/.claude/skills', mode: 'merge', targetNaming: 'flat', status: 'merged',
@@ -27,6 +27,14 @@ describe('targetHealth', () => {
});
});
describe('searchEntries', () => {
it('matches part of a name in any case, and an agent by its name without the extension', () => {
const rows = [row('frontend/React-Doctor', 'synced'), row('react.md', 'synced', 'agent'), row('archify', 'excluded')];
expect(searchEntries(rows, ' react ').map((e) => e.skill)).toEqual(['frontend/React-Doctor', 'react.md']);
expect(searchEntries(rows, '.md')).toEqual([]);
});
});
describe('togglePatterns', () => {
it('round-trips a row that only syncs because of its own include', () => {
const on = togglePatterns(row('scratch', 'not_included'), ['core-*'], []);
+6
View File
@@ -31,6 +31,12 @@ export function targetHealth(target: Target): { state: TargetState; pending: num
/** Filter patterns match agent names without the .md extension. */
export const patternName = (entry: SyncMatrixEntry) => (entry.kind === 'agent' ? entry.skill.replace(/\.md$/, '') : entry.skill);
/** Preview rows whose pattern name contains the search text, ignoring case. */
export function searchEntries(entries: SyncMatrixEntry[], query: string) {
const q = query.trim().toLowerCase();
return q ? entries.filter((e) => patternName(e).toLowerCase().includes(q)) : entries;
}
/**
* The filter edit a click on a preview row makes, or null when naming the row can't change its result
* (a wildcard exclude, or a resource that declares its own targets).
+5
View File
@@ -1870,6 +1870,11 @@
"targetDetail.removePattern": "{pattern} entfernen",
"targetDetail.loadingPreview": "Vorschau wird geladen…",
"targetDetail.previewCount": "Vorschau · {count}",
"targetDetail.previewCountSearch": "Vorschau · {shown} von {count}",
"targetDetail.search.skills": "Skills suchen",
"targetDetail.search.agents": "Agents suchen",
"targetDetail.search.files": "Dateien suchen",
"targetDetail.searchNoMatches": "Nichts passt zu „{query}“.",
"targetDetail.becauseOf": "Grund",
"targetDetail.result": "Ergebnis",
"targetDetail.reason.included": "passt zu Einschließen",
+5
View File
@@ -1870,6 +1870,11 @@
"targetDetail.removePattern": "Remove {pattern}",
"targetDetail.loadingPreview": "Loading preview…",
"targetDetail.previewCount": "Preview · {count}",
"targetDetail.previewCountSearch": "Preview · {shown} of {count}",
"targetDetail.search.skills": "Search skills",
"targetDetail.search.agents": "Search agents",
"targetDetail.search.files": "Search files",
"targetDetail.searchNoMatches": "Nothing matches “{query}”.",
"targetDetail.becauseOf": "Because of",
"targetDetail.result": "Result",
"targetDetail.reason.included": "matches include",
+5
View File
@@ -1870,6 +1870,11 @@
"targetDetail.removePattern": "Quitar {pattern}",
"targetDetail.loadingPreview": "Cargando vista previa…",
"targetDetail.previewCount": "Vista previa · {count}",
"targetDetail.previewCountSearch": "Vista previa · {shown} de {count}",
"targetDetail.search.skills": "Buscar skills",
"targetDetail.search.agents": "Buscar agents",
"targetDetail.search.files": "Buscar archivos",
"targetDetail.searchNoMatches": "Nada coincide con «{query}».",
"targetDetail.becauseOf": "Motivo",
"targetDetail.result": "Resultado",
"targetDetail.reason.included": "coincide con incluir",
+5
View File
@@ -1870,6 +1870,11 @@
"targetDetail.removePattern": "حذف {pattern}",
"targetDetail.loadingPreview": "در حال بارگذاری پیش‌نمایش…",
"targetDetail.previewCount": "پیش‌نمایش · {count}",
"targetDetail.previewCountSearch": "پیش‌نمایش · {shown} از {count}",
"targetDetail.search.skills": "جستجوی اسکیل‌ها",
"targetDetail.search.agents": "جستجوی Agentها",
"targetDetail.search.files": "جستجوی فایل‌ها",
"targetDetail.searchNoMatches": "چیزی با «{query}» مطابقت ندارد.",
"targetDetail.becauseOf": "به دلیل",
"targetDetail.result": "نتیجه",
"targetDetail.reason.included": "مطابق شامل",
+5
View File
@@ -1870,6 +1870,11 @@
"targetDetail.removePattern": "Retirer {pattern}",
"targetDetail.loadingPreview": "Chargement de l’aperçu…",
"targetDetail.previewCount": "Aperçu · {count}",
"targetDetail.previewCountSearch": "Aperçu · {shown} sur {count}",
"targetDetail.search.skills": "Rechercher des skills",
"targetDetail.search.agents": "Rechercher des agents",
"targetDetail.search.files": "Rechercher des fichiers",
"targetDetail.searchNoMatches": "Aucun résultat pour « {query} ».",
"targetDetail.becauseOf": "Raison",
"targetDetail.result": "Résultat",
"targetDetail.reason.included": "correspond à l’inclusion",
+5
View File
@@ -1870,6 +1870,11 @@
"targetDetail.removePattern": "Hapus {pattern}",
"targetDetail.loadingPreview": "Memuat pratinjau…",
"targetDetail.previewCount": "Pratinjau · {count}",
"targetDetail.previewCountSearch": "Pratinjau · {shown} dari {count}",
"targetDetail.search.skills": "Cari skill",
"targetDetail.search.agents": "Cari agent",
"targetDetail.search.files": "Cari file",
"targetDetail.searchNoMatches": "Tidak ada yang cocok dengan “{query}”.",
"targetDetail.becauseOf": "Karena",
"targetDetail.result": "Hasil",
"targetDetail.reason.included": "cocok dengan sertakan",
+5
View File
@@ -1870,6 +1870,11 @@
"targetDetail.removePattern": "{pattern} を削除",
"targetDetail.loadingPreview": "プレビューを読み込み中…",
"targetDetail.previewCount": "プレビュー · {count} 件",
"targetDetail.previewCountSearch": "プレビュー · {count} 件中 {shown} 件",
"targetDetail.search.skills": "スキルを検索",
"targetDetail.search.agents": "Agent を検索",
"targetDetail.search.files": "ファイルを検索",
"targetDetail.searchNoMatches": "「{query}」に一致する項目はありません。",
"targetDetail.becauseOf": "理由",
"targetDetail.result": "結果",
"targetDetail.reason.included": "含める条件に一致",
+5
View File
@@ -1870,6 +1870,11 @@
"targetDetail.removePattern": "{pattern} 제거",
"targetDetail.loadingPreview": "미리보기 불러오는 중…",
"targetDetail.previewCount": "미리보기 · {count}개",
"targetDetail.previewCountSearch": "미리보기 · {count}개 중 {shown}개",
"targetDetail.search.skills": "skill 검색",
"targetDetail.search.agents": "agent 검색",
"targetDetail.search.files": "파일 검색",
"targetDetail.searchNoMatches": "“{query}”와 일치하는 항목이 없습니다.",
"targetDetail.becauseOf": "이유",
"targetDetail.result": "결과",
"targetDetail.reason.included": "포함과 일치",
+5
View File
@@ -1870,6 +1870,11 @@
"targetDetail.removePattern": "Remover {pattern}",
"targetDetail.loadingPreview": "Carregando prévia…",
"targetDetail.previewCount": "Prévia · {count}",
"targetDetail.previewCountSearch": "Prévia · {shown} de {count}",
"targetDetail.search.skills": "Buscar skills",
"targetDetail.search.agents": "Buscar agents",
"targetDetail.search.files": "Buscar arquivos",
"targetDetail.searchNoMatches": "Nada corresponde a “{query}”.",
"targetDetail.becauseOf": "Motivo",
"targetDetail.result": "Resultado",
"targetDetail.reason.included": "corresponde a incluir",
+5
View File
@@ -1870,6 +1870,11 @@
"targetDetail.removePattern": "移除 {pattern}",
"targetDetail.loadingPreview": "正在加载预览…",
"targetDetail.previewCount": "预览 · {count} 个",
"targetDetail.previewCountSearch": "预览 · {count} 个中的 {shown} 个",
"targetDetail.search.skills": "搜索 Skill",
"targetDetail.search.agents": "搜索 Agent",
"targetDetail.search.files": "搜索文件",
"targetDetail.searchNoMatches": "没有与“{query}”匹配的项目。",
"targetDetail.becauseOf": "原因",
"targetDetail.result": "结果",
"targetDetail.reason.included": "匹配包含",
+5
View File
@@ -1870,6 +1870,11 @@
"targetDetail.removePattern": "移除 {pattern}",
"targetDetail.loadingPreview": "正在載入預覽…",
"targetDetail.previewCount": "預覽 · {count} 個",
"targetDetail.previewCountSearch": "預覽 · {count} 個中的 {shown} 個",
"targetDetail.search.skills": "搜尋 Skills",
"targetDetail.search.agents": "搜尋 Agents",
"targetDetail.search.files": "搜尋檔案",
"targetDetail.searchNoMatches": "沒有符合「{query}」的項目。",
"targetDetail.becauseOf": "原因",
"targetDetail.result": "結果",
"targetDetail.reason.included": "符合包含",
+1 -1
View File
@@ -1027,7 +1027,7 @@ export default function ResourcesPage({ kind }: { kind: Kind }) {
)}
/>
<nav className="ss-tabs overflow-x-auto" aria-label={t(isAgent ? 'layout.nav.agents' : 'layout.nav.skills')} data-tour="skills-view">
<nav className="ss-tabs overflow-x-auto overflow-y-hidden" aria-label={t(isAgent ? 'layout.nav.agents' : 'layout.nav.skills')} data-tour="skills-view">
{([
['installed', '', t('resources.tab.installed'), items.length],
['updates', '?tab=updates', t('resources.tab.updates'), updateCount],