mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-19 02:17:09 +00:00
feat(analyze): add filtered token summary bar to Web UI
Shows always-loaded, on-demand, and total token sums for the current search/filter result set using mini stat chips with icon + label + value. Appears only when a filter is active. Search matches on path (relPath) to support group filtering. Lint filter badge shows readable rule name.
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
||||
FileText,
|
||||
HelpCircle,
|
||||
ExternalLink,
|
||||
Filter,
|
||||
} from 'lucide-react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { api } from '../api/client';
|
||||
@@ -478,6 +479,52 @@ function LintSummary({ skills, onRuleClick }: LintSummaryProps) {
|
||||
);
|
||||
}
|
||||
|
||||
/* ──────────────────────────────────────────────────────────────────────
|
||||
* Filtered Summary Bar
|
||||
* ────────────────────────────────────────────────────────────────────── */
|
||||
|
||||
function FilteredSummaryBar({ filtered, total }: { filtered: AnalyzeSkill[]; total: number }) {
|
||||
const summary = useMemo(() => {
|
||||
let descTokens = 0;
|
||||
let bodyTokens = 0;
|
||||
for (const s of filtered) {
|
||||
descTokens += s.description_tokens;
|
||||
bodyTokens += s.body_tokens;
|
||||
}
|
||||
return { descTokens, bodyTokens, totalTokens: descTokens + bodyTokens };
|
||||
}, [filtered]);
|
||||
|
||||
if (filtered.length === total) return null;
|
||||
|
||||
const stats = [
|
||||
{ label: 'Always', value: formatTokens(summary.descTokens), icon: <Zap size={14} strokeWidth={2.5} />, colorClass: 'text-info', bgClass: 'bg-info-light border-info' },
|
||||
{ label: 'On-demand', value: formatTokens(summary.bodyTokens), icon: <ToggleRight size={14} strokeWidth={2.5} />, colorClass: 'text-pencil', bgClass: 'bg-paper border-muted-dark' },
|
||||
{ label: 'Total', value: formatTokens(summary.totalTokens), icon: <Package size={14} strokeWidth={2.5} />, colorClass: 'text-success', bgClass: 'bg-success-light border-success' },
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="flex flex-wrap items-center gap-3 mb-4">
|
||||
<div className="flex items-center gap-1.5 mr-1">
|
||||
<Filter size={16} className="text-pencil shrink-0" />
|
||||
<span className="text-sm font-medium text-pencil">
|
||||
{filtered.length}<span className="text-pencil-light font-normal">/{total}</span>
|
||||
</span>
|
||||
</div>
|
||||
{stats.map((s) => (
|
||||
<div
|
||||
key={s.label}
|
||||
className={`inline-flex items-center gap-1.5 px-2.5 py-1.5 border-2 ${s.bgClass} text-xs`}
|
||||
style={{ borderRadius: radius.sm }}
|
||||
>
|
||||
<span className={s.colorClass}>{s.icon}</span>
|
||||
<span className="text-pencil-light">{s.label}</span>
|
||||
<span className={`font-mono font-bold ${s.colorClass}`}>{s.value}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/* ──────────────────────────────────────────────────────────────────────
|
||||
* Full Skill Table
|
||||
* ────────────────────────────────────────────────────────────────────── */
|
||||
@@ -511,7 +558,10 @@ function SkillTable({
|
||||
// Search filter
|
||||
if (search) {
|
||||
const q = search.toLowerCase();
|
||||
result = result.filter((s) => s.name.toLowerCase().includes(q));
|
||||
result = result.filter((s) => {
|
||||
const searchField = s.path || s.name;
|
||||
return searchField.toLowerCase().includes(q);
|
||||
});
|
||||
}
|
||||
|
||||
// Lint rule filter
|
||||
@@ -580,7 +630,7 @@ function SkillTable({
|
||||
onClick={() => onLintFilterChange(null)}
|
||||
>
|
||||
<Badge variant="warning" size="md">
|
||||
{lintFilter}
|
||||
{readableRule(lintFilter)}
|
||||
<X size={12} strokeWidth={2.5} className="ml-1" />
|
||||
</Badge>
|
||||
</span>
|
||||
@@ -596,6 +646,9 @@ function SkillTable({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Filtered summary */}
|
||||
<FilteredSummaryBar filtered={filtered} total={skills.length} />
|
||||
|
||||
{/* Table */}
|
||||
<div className="overflow-auto max-h-[calc(100vh-320px)]">
|
||||
<table className="w-full text-left table-fixed">
|
||||
|
||||
@@ -139,6 +139,16 @@ Passing a target name automatically enables verbose output:
|
||||
skillshare analyze claude
|
||||
```
|
||||
|
||||
### Filter by Group
|
||||
|
||||
```bash
|
||||
# See total token cost of all frontend skills
|
||||
skillshare analyze claude --json --filter frontend
|
||||
|
||||
# Pre-populate the search box in TUI
|
||||
skillshare analyze --filter marketing
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
| Flag | Description |
|
||||
@@ -148,6 +158,7 @@ skillshare analyze claude
|
||||
| `--no-tui` | Disable interactive TUI, print plain text |
|
||||
| `--project`, `-p` | Analyze project-level skills (`.skillshare/`) |
|
||||
| `--global`, `-g` | Analyze global skills (`~/.config/skillshare`) |
|
||||
| `--filter <text>` | Filter skills by name/path substring |
|
||||
| `--json` | Output as JSON (for scripting/CI) |
|
||||
| `--help`, `-h` | Show help |
|
||||
|
||||
@@ -208,6 +219,35 @@ skillshare analyze -p claude # Single target details
|
||||
skillshare analyze -p --json # JSON output
|
||||
```
|
||||
|
||||
## Filtering
|
||||
|
||||
Use `--filter` to narrow results to a subset of skills. The filter performs a case-insensitive
|
||||
substring match on the skill's relative path (which includes the group directory).
|
||||
|
||||
For example, if you installed skills with `--into frontend`:
|
||||
- `--filter frontend` matches all skills in the `frontend/` group
|
||||
- `--filter react` matches any skill with "react" in its path
|
||||
|
||||
In TUI mode, `--filter` pre-populates the filter input. You can also use the `/` key to start filtering interactively.
|
||||
|
||||
In JSON mode, the output includes a `filtered_summary` with aggregated token counts:
|
||||
|
||||
```json
|
||||
{
|
||||
"filter": "frontend",
|
||||
"matched_count": 5,
|
||||
"total_count": 50,
|
||||
"filtered_summary": {
|
||||
"always_loaded": { "chars": 2400, "tokens": 600 },
|
||||
"on_demand": { "chars": 8000, "tokens": 2000 },
|
||||
"total": { "chars": 10400, "tokens": 2600 }
|
||||
},
|
||||
"skills": [...]
|
||||
}
|
||||
```
|
||||
|
||||
The Web UI also shows a dynamic token summary bar when search or filter is active.
|
||||
|
||||
## See Also
|
||||
|
||||
- [list](/docs/reference/commands/list) — View installed skills
|
||||
|
||||
Reference in New Issue
Block a user