iskills 0.2.48 → 0.2.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/README.zh-CN.md +2 -2
- package/dist/src/cli.js +7 -5
- package/dist/src/cli.js.map +1 -1
- package/dist/src/commands/browser-actions.d.ts +2 -0
- package/dist/src/commands/browser-actions.js +68 -13
- package/dist/src/commands/browser-actions.js.map +1 -1
- package/dist/src/commands/config.d.ts +3 -2
- package/dist/src/commands/config.js +19 -2
- package/dist/src/commands/config.js.map +1 -1
- package/dist/src/commands/index.js +1 -0
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/commands/library.d.ts +5 -0
- package/dist/src/commands/library.js +45 -7
- package/dist/src/commands/library.js.map +1 -1
- package/dist/src/commands/mcp.d.ts +4 -0
- package/dist/src/commands/mcp.js +244 -0
- package/dist/src/commands/mcp.js.map +1 -0
- package/dist/src/domain/collection-health.d.ts +22 -0
- package/dist/src/domain/collection-health.js +86 -0
- package/dist/src/domain/collection-health.js.map +1 -0
- package/dist/src/domain/core.d.ts +9 -1
- package/dist/src/domain/core.js +93 -19
- package/dist/src/domain/core.js.map +1 -1
- package/dist/src/domain/git.d.ts +9 -0
- package/dist/src/domain/git.js +159 -64
- package/dist/src/domain/git.js.map +1 -1
- package/dist/src/domain/mcp/collection.d.ts +10 -0
- package/dist/src/domain/mcp/collection.js +107 -0
- package/dist/src/domain/mcp/collection.js.map +1 -0
- package/dist/src/domain/mcp/dialects.d.ts +23 -0
- package/dist/src/domain/mcp/dialects.js +536 -0
- package/dist/src/domain/mcp/dialects.js.map +1 -0
- package/dist/src/domain/mcp/headers.d.ts +9 -0
- package/dist/src/domain/mcp/headers.js +50 -0
- package/dist/src/domain/mcp/headers.js.map +1 -0
- package/dist/src/domain/mcp/identity.d.ts +13 -0
- package/dist/src/domain/mcp/identity.js +121 -0
- package/dist/src/domain/mcp/identity.js.map +1 -0
- package/dist/src/domain/mcp/index.d.ts +8 -0
- package/dist/src/domain/mcp/index.js +8 -0
- package/dist/src/domain/mcp/index.js.map +1 -0
- package/dist/src/domain/mcp/io.d.ts +7 -0
- package/dist/src/domain/mcp/io.js +55 -0
- package/dist/src/domain/mcp/io.js.map +1 -0
- package/dist/src/domain/mcp/probe.d.ts +7 -0
- package/dist/src/domain/mcp/probe.js +35 -0
- package/dist/src/domain/mcp/probe.js.map +1 -0
- package/dist/src/domain/mcp/recipe.d.ts +12 -0
- package/dist/src/domain/mcp/recipe.js +172 -0
- package/dist/src/domain/mcp/recipe.js.map +1 -0
- package/dist/src/domain/mcp/secrets.d.ts +12 -0
- package/dist/src/domain/mcp/secrets.js +133 -0
- package/dist/src/domain/mcp/secrets.js.map +1 -0
- package/dist/src/domain/mcp/types.d.ts +82 -0
- package/dist/src/domain/mcp/types.js +2 -0
- package/dist/src/domain/mcp/types.js.map +1 -0
- package/dist/src/domain/mcp/write.d.ts +30 -0
- package/dist/src/domain/mcp/write.js +229 -0
- package/dist/src/domain/mcp/write.js.map +1 -0
- package/dist/src/domain/user-config.d.ts +2 -0
- package/dist/src/domain/user-config.js +5 -2
- package/dist/src/domain/user-config.js.map +1 -1
- package/dist/src/i18n/en.js +115 -7
- package/dist/src/i18n/en.js.map +1 -1
- package/dist/src/i18n/zh.d.ts +113 -6
- package/dist/src/i18n/zh.js +115 -7
- package/dist/src/i18n/zh.js.map +1 -1
- package/dist/src/ui/browser/browse-capabilities.d.ts +2 -2
- package/dist/src/ui/browser/browse-capabilities.js +13 -16
- package/dist/src/ui/browser/browse-capabilities.js.map +1 -1
- package/dist/src/ui/browser/browse-nav.d.ts +42 -0
- package/dist/src/ui/browser/browse-nav.js +106 -0
- package/dist/src/ui/browser/browse-nav.js.map +1 -0
- package/dist/src/ui/browser/browse-session.d.ts +94 -0
- package/dist/src/ui/browser/browse-session.js +310 -0
- package/dist/src/ui/browser/browse-session.js.map +1 -0
- package/dist/src/ui/browser/browser.d.ts +1 -1
- package/dist/src/ui/browser/browser.js +207 -474
- package/dist/src/ui/browser/browser.js.map +1 -1
- package/dist/src/ui/browser/detail.d.ts +1 -1
- package/dist/src/ui/browser/detail.js +13 -2
- package/dist/src/ui/browser/detail.js.map +1 -1
- package/dist/src/ui/browser/footer.d.ts +1 -1
- package/dist/src/ui/browser/footer.js +26 -6
- package/dist/src/ui/browser/footer.js.map +1 -1
- package/dist/src/ui/browser/format.d.ts +47 -12
- package/dist/src/ui/browser/format.js +191 -49
- package/dist/src/ui/browser/format.js.map +1 -1
- package/dist/src/ui/browser/health.d.ts +13 -0
- package/dist/src/ui/browser/health.js +69 -0
- package/dist/src/ui/browser/health.js.map +1 -0
- package/dist/src/ui/browser/index.js +40 -12
- package/dist/src/ui/browser/index.js.map +1 -1
- package/dist/src/ui/browser/panes.d.ts +107 -0
- package/dist/src/ui/browser/panes.js +212 -0
- package/dist/src/ui/browser/panes.js.map +1 -0
- package/dist/src/ui/browser/shortcut-help.d.ts +3 -1
- package/dist/src/ui/browser/shortcut-help.js +6 -6
- package/dist/src/ui/browser/shortcut-help.js.map +1 -1
- package/dist/src/ui/browser/store.d.ts +12 -1
- package/dist/src/ui/browser/store.js +10 -0
- package/dist/src/ui/browser/store.js.map +1 -1
- package/dist/src/ui/browser/types.d.ts +9 -4
- package/dist/src/ui/components/colors.d.ts +9 -9
- package/dist/src/ui/components/colors.js +14 -14
- package/dist/src/ui/components/colors.js.map +1 -1
- package/dist/src/ui/components/framed-panel.js +6 -6
- package/dist/src/ui/components/framed-panel.js.map +1 -1
- package/dist/src/ui/components/modal-panel.d.ts +1 -1
- package/dist/src/ui/components/modal-panel.js +3 -3
- package/dist/src/ui/components/modal-panel.js.map +1 -1
- package/dist/src/ui/components/mouse/clickable.js +3 -3
- package/dist/src/ui/components/mouse/clickable.js.map +1 -1
- package/dist/src/ui/components/mouse/provider.d.ts +3 -3
- package/dist/src/ui/components/mouse/provider.js +3 -3
- package/dist/src/ui/components/mouse/provider.js.map +1 -1
- package/dist/src/ui/components/multi-select.js +6 -6
- package/dist/src/ui/components/multi-select.js.map +1 -1
- package/dist/src/ui/components/options.d.ts +2 -0
- package/dist/src/ui/components/options.js +6 -0
- package/dist/src/ui/components/options.js.map +1 -1
- package/dist/src/ui/components/select.js +4 -4
- package/dist/src/ui/components/select.js.map +1 -1
- package/dist/src/ui/components/tag-editor.js +5 -5
- package/dist/src/ui/components/tag-editor.js.map +1 -1
- package/dist/src/ui/components/termcn.d.ts +1 -1
- package/dist/src/ui/components/termcn.js +1 -1
- package/dist/src/ui/components/terminal-layout.d.ts +2 -0
- package/dist/src/ui/components/terminal-layout.js +10 -0
- package/dist/src/ui/components/terminal-layout.js.map +1 -1
- package/dist/src/ui/components/text-input-ctrl-c.d.ts +21 -0
- package/dist/src/ui/components/text-input-ctrl-c.js +61 -0
- package/dist/src/ui/components/text-input-ctrl-c.js.map +1 -0
- package/dist/src/ui/components/text-input.d.ts +8 -1
- package/dist/src/ui/components/text-input.js +35 -12
- package/dist/src/ui/components/text-input.js.map +1 -1
- package/dist/src/ui/components/use-input.d.ts +3 -1
- package/dist/src/ui/components/use-input.js +2 -1
- package/dist/src/ui/components/use-input.js.map +1 -1
- package/dist/src/ui/config/index.d.ts +4 -0
- package/dist/src/ui/config/index.js +6 -3
- package/dist/src/ui/config/index.js.map +1 -1
- package/dist/src/ui/config/settings.d.ts +8 -4
- package/dist/src/ui/config/settings.js +115 -30
- package/dist/src/ui/config/settings.js.map +1 -1
- package/dist/src/ui/footer/resolve-footer.d.ts +2 -0
- package/dist/src/ui/footer/resolve-footer.js +73 -25
- package/dist/src/ui/footer/resolve-footer.js.map +1 -1
- package/dist/src/ui/footer/types.d.ts +15 -3
- package/dist/src/ui/import/review.js +7 -7
- package/dist/src/ui/import/review.js.map +1 -1
- package/dist/src/ui/import/skill-select.js +34 -14
- package/dist/src/ui/import/skill-select.js.map +1 -1
- package/dist/src/ui/install/review.js +4 -4
- package/dist/src/ui/install/review.js.map +1 -1
- package/dist/src/ui/mcp/browse-capabilities.d.ts +22 -0
- package/dist/src/ui/mcp/browse-capabilities.js +36 -0
- package/dist/src/ui/mcp/browse-capabilities.js.map +1 -0
- package/dist/src/ui/mcp/browser.d.ts +25 -0
- package/dist/src/ui/mcp/browser.js +310 -0
- package/dist/src/ui/mcp/browser.js.map +1 -0
- package/dist/src/ui/mcp/footer.d.ts +16 -0
- package/dist/src/ui/mcp/footer.js +30 -0
- package/dist/src/ui/mcp/footer.js.map +1 -0
- package/dist/src/ui/mcp/format.d.ts +24 -0
- package/dist/src/ui/mcp/format.js +218 -0
- package/dist/src/ui/mcp/format.js.map +1 -0
- package/dist/src/ui/mcp/index.d.ts +8 -0
- package/dist/src/ui/mcp/index.js +212 -0
- package/dist/src/ui/mcp/index.js.map +1 -0
- package/dist/src/ui/overlay/host.d.ts +3 -3
- package/dist/src/ui/overlay/host.js +4 -4
- package/dist/src/ui/overlay/host.js.map +1 -1
- package/dist/src/ui/prompts/present.d.ts +6 -2
- package/dist/src/ui/prompts/present.js +7 -3
- package/dist/src/ui/prompts/present.js.map +1 -1
- package/dist/src/ui/search/index.js +4 -4
- package/dist/src/ui/search/index.js.map +1 -1
- package/dist/src/ui/shell/app-shell.d.ts +7 -6
- package/dist/src/ui/shell/app-shell.js +35 -8
- package/dist/src/ui/shell/app-shell.js.map +1 -1
- package/dist/src/ui/shell/footer.d.ts +5 -1
- package/dist/src/ui/shell/footer.js +10 -5
- package/dist/src/ui/shell/footer.js.map +1 -1
- package/dist/src/ui/shell/run.js +3 -0
- package/dist/src/ui/shell/run.js.map +1 -1
- package/dist/src/ui/tui/hooks.d.ts +2 -2
- package/dist/src/ui/tui/hooks.js +3 -3
- package/dist/src/ui/tui/index.d.ts +1 -1
- package/dist/src/ui/tui/index.js +1 -1
- package/package.json +3 -2
|
@@ -1,20 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@opentui/react/jsx-runtime";
|
|
2
|
+
import { useStdout } from '../tui/index.js';
|
|
3
3
|
import { useInput } from '../components/use-input.js';
|
|
4
|
-
import { useAtom,
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { useAtom, useSetAtom, useStore } from 'jotai';
|
|
5
|
+
import { useEffect, useMemo, useRef, useState, } from 'react';
|
|
6
|
+
import { presentHealthAlerts } from './health.js';
|
|
7
|
+
import { browserDetailFieldAtom, browserFilterAtom, browserGroupJumpAtom, browserHealthAtom, browserNavigationAtom, browserSelectionAtom, browserTagFilterAtom, browserUpdateCheckAtom, } from './store.js';
|
|
8
|
+
import { browserFrameDimensions, masterDetailLayout, masterDetailViewportHeight, masterDetailWidths, } from './layout.js';
|
|
8
9
|
import { isCrossAgentInstallable } from '../../domain/cross-agent-install.js';
|
|
9
10
|
import { browseSelectionSets, projectActionSkills, } from './browse-capabilities.js';
|
|
10
|
-
import {
|
|
11
|
+
import { browseDetailRows, collectionListColumnLines, detailEditableFields, detailEntryFieldIndex, flatRows, groupedRows, selectableSkills, skillsForTagFilter, tagFilterOptions, visibleAgentGroups, } from './format.js';
|
|
11
12
|
import { t } from '../../i18n/index.js';
|
|
12
13
|
import { useModal, useOverlayBusy } from '../overlay/host.js';
|
|
13
14
|
import { FramedPanel } from '../components/framed-panel.js';
|
|
14
|
-
import { Select, Tabs,
|
|
15
|
-
import { Clickable } from '../components/mouse/clickable.js';
|
|
16
|
-
import { padColumns, sliceColumns } from '../components/terminal-layout.js';
|
|
15
|
+
import { Select, Tabs, useSpinnerFrame, } from '../components/termcn.js';
|
|
17
16
|
import { ShortcutHelpPanel } from './shortcut-help.js';
|
|
17
|
+
import { AgentTabs, BrowseHomePane, SkillPane } from './panes.js';
|
|
18
|
+
import { applyBrowseSessionPatch, browseSessionClickDetail, browseSessionClickList, browseSessionClickTag, browseSessionScrollList, reduceBrowseSessionKey, useBrowseSessionEffects, } from './browse-session.js';
|
|
19
|
+
const EMPTY_SKILLS = [];
|
|
20
|
+
function sameNavigation(left, right) {
|
|
21
|
+
if (left === right)
|
|
22
|
+
return true;
|
|
23
|
+
if (!left || !right)
|
|
24
|
+
return false;
|
|
25
|
+
return (left.tab === right.tab &&
|
|
26
|
+
left.focus === right.focus &&
|
|
27
|
+
left.agent === right.agent &&
|
|
28
|
+
left.cursor === right.cursor &&
|
|
29
|
+
left.query === right.query);
|
|
30
|
+
}
|
|
18
31
|
/** Framed more-actions picker when multiple m-actions are available. */
|
|
19
32
|
function MoreActionsPanel({ scope, items, onSelect, onCancel, }) {
|
|
20
33
|
const [cursor, setCursor] = useState(0);
|
|
@@ -41,179 +54,30 @@ function MoreActionsPanel({ scope, items, onSelect, onCancel, }) {
|
|
|
41
54
|
}
|
|
42
55
|
} }));
|
|
43
56
|
}
|
|
44
|
-
function masterDetailBlankRow(tagWidth, listWidth, peekWidth) {
|
|
45
|
-
const divider = '│';
|
|
46
|
-
return (_jsxs("box", { flexDirection: "row", children: [_jsxs("box", { width: tagWidth + 1, flexDirection: "row", children: [_jsx(Text, { wrap: "truncate-end", children: padColumns('', tagWidth) }), _jsx(Text, { color: termcnColors.border, children: divider })] }), _jsxs("box", { width: listWidth + 1, flexDirection: "row", children: [_jsx(Text, { wrap: "truncate-end", children: padColumns('', listWidth) }), _jsx(Text, { color: termcnColors.border, children: divider })] }), _jsx("box", { flexDirection: "row", width: peekWidth, children: _jsx(Text, { wrap: "truncate-end", children: padColumns('', peekWidth) }) })] }));
|
|
47
|
-
}
|
|
48
|
-
function SkillPane({ rows, cursor, isActive, preferNote = false, compact = false, layout = 'default', columnWidth, showPagination = true, showSource = false, showReferences = false, showGroup = false, updates = new Set(), updatingSkillName, viewportHeight, onRowClick, onCursorDelta, }) {
|
|
49
|
-
const { stdout } = useStdout();
|
|
50
|
-
const selected = useAtomValue(browserSelectionAtom);
|
|
51
|
-
const paneHeight = viewportHeight ?? Math.max(3, (stdout.rows ?? 24) - 8);
|
|
52
|
-
const height = rows.length > paneHeight ? Math.max(3, paneHeight - (showPagination ? 1 : 0)) : paneHeight;
|
|
53
|
-
const active = Math.max(0, Math.min(cursor, rows.length - 1));
|
|
54
|
-
const offset = Math.max(0, Math.min(active - Math.floor(height / 2), rows.length - height));
|
|
55
|
-
const visible = rows.slice(offset, offset + height);
|
|
56
|
-
const paneWidth = columnWidth ?? Math.max(20, (stdout.columns ?? 80) - 4);
|
|
57
|
-
const summaryWidth = Math.max(8, paneWidth - 4);
|
|
58
|
-
const onMouseScroll = useCallback((event) => {
|
|
59
|
-
const info = event.scroll;
|
|
60
|
-
if (!info || !onCursorDelta)
|
|
61
|
-
return;
|
|
62
|
-
const steps = Math.max(1, Math.abs(info.delta) || 1);
|
|
63
|
-
if (info.direction === 'up')
|
|
64
|
-
onCursorDelta(-steps);
|
|
65
|
-
else if (info.direction === 'down')
|
|
66
|
-
onCursorDelta(steps);
|
|
67
|
-
event.stopPropagation();
|
|
68
|
-
}, [onCursorDelta]);
|
|
69
|
-
const renderRow = (row, index) => {
|
|
70
|
-
if (row.type === 'group') {
|
|
71
|
-
const groupSkills = row.skills;
|
|
72
|
-
const count = groupSkills.filter((skill) => selected.has(skill.path)).length;
|
|
73
|
-
const marker = count === 0 ? '○' : count === groupSkills.length && groupSkills.length ? '●' : '◐';
|
|
74
|
-
const body = (_jsx(Text, { bold: true, ...(isActive && index === active ? { color: termcnColors.primary } : {}), children: `${isActive && index === active ? '›' : ' '} ${marker} ${row.name} (${row.skills.length})` }));
|
|
75
|
-
if (!onRowClick)
|
|
76
|
-
return _jsx("box", { flexDirection: "row", children: body }, `group:${row.name}:${index}`);
|
|
77
|
-
return (_jsx(Clickable, { onClick: () => onRowClick(index), children: body }, `group:${row.name}:${index}`));
|
|
78
|
-
}
|
|
79
|
-
const skill = row.skill;
|
|
80
|
-
const current = isActive && index === active;
|
|
81
|
-
const summary = compact || layout === 'master'
|
|
82
|
-
? ''
|
|
83
|
-
: listSkillSummary(skill, preferNote, summaryWidth);
|
|
84
|
-
const inlineSummary = summary;
|
|
85
|
-
const selectionMarker = selected.has(skill.path) ? '●' : '○';
|
|
86
|
-
const nameLine = (_jsxs(_Fragment, { children: [` ${current ? '›' : ' '} ${selectionMarker} `, showGroup && row.group && (_jsxs(Text, { color: termcnColors.muted, children: [row.group, " / "] })), showReferences && skill.isReference ? (_jsxs(_Fragment, { children: [_jsx(Text, { color: termcnColors.muted, children: t('browser.referencePrefix') }), _jsx(Text, { bold: current, children: skill.name })] })) : showSource && !skill.fromCollection ? (t('browser.localSkill', { name: skill.name })) : (_jsx(Text, { bold: current, children: skill.name })), updatingSkillName === skill.name ? (_jsx(WorkingSpinner, {})) : updates.has(skill.name) ? (_jsx(Text, { color: termcnColors.primary, children: " \u2191" })) : null, inlineSummary && (_jsxs(Text, { color: termcnColors.muted, children: [" \u2014 ", inlineSummary] }))] }));
|
|
87
|
-
const body = (_jsx(Text, { wrap: "truncate-end", ...(current
|
|
88
|
-
? {
|
|
89
|
-
color: termcnColors.selectionFg,
|
|
90
|
-
backgroundColor: termcnColors.selectionBg,
|
|
91
|
-
bold: true,
|
|
92
|
-
}
|
|
93
|
-
: {}), children: nameLine }));
|
|
94
|
-
if (!onRowClick) {
|
|
95
|
-
return (_jsx("box", { flexDirection: "row", children: body }, `${row.group}:${skill.path}:${index}`));
|
|
96
|
-
}
|
|
97
|
-
return (_jsx(Clickable, { onClick: () => onRowClick(index), children: body }, `${row.group}:${skill.path}:${index}`));
|
|
98
|
-
};
|
|
99
|
-
return (_jsxs("box", { flexDirection: "column", minHeight: 3, onMouseScroll: onMouseScroll, children: [rows.length ? (visible.map((row, visibleIndex) => renderRow(row, offset + visibleIndex))) : (_jsx(Text, { color: termcnColors.muted, children: t('browser.noMatchingSkills') })), showPagination && rows.length > height && (_jsxs(Text, { color: termcnColors.muted, children: [offset + 1, "\u2013", Math.min(offset + height, rows.length), " / ", rows.length] }))] }));
|
|
100
|
-
}
|
|
101
|
-
function AgentTabs({ groups, agent, focused, onSelect, }) {
|
|
102
|
-
return (_jsx("box", { flexDirection: "row", paddingLeft: 1, gap: 2, children: groups.map((group) => {
|
|
103
|
-
const active = group.agent === agent;
|
|
104
|
-
// Current agent always uses primary (visible after mouse click without
|
|
105
|
-
// forcing keyboard focus onto the agents row). Keyboard-on-agents adds
|
|
106
|
-
// selection chrome so the focus ladder is still obvious.
|
|
107
|
-
const keyboardHere = focused && active;
|
|
108
|
-
return (_jsx(Clickable, { onClick: () => onSelect(group.agent), children: _jsx(Text, { color: keyboardHere
|
|
109
|
-
? termcnColors.selectionFg
|
|
110
|
-
: active
|
|
111
|
-
? termcnColors.primary
|
|
112
|
-
: termcnColors.muted, ...(keyboardHere
|
|
113
|
-
? { backgroundColor: termcnColors.selectionBg, bold: true }
|
|
114
|
-
: active
|
|
115
|
-
? { bold: true, underline: true }
|
|
116
|
-
: {}), children: `${group.agent} ${group.skills.length}` }) }, group.agent));
|
|
117
|
-
}) }));
|
|
118
|
-
}
|
|
119
|
-
function masterDetailColumnText(line, width, options = {}) {
|
|
120
|
-
const padded = padColumns(sliceColumns(line, 0, width), width);
|
|
121
|
-
if (options.selected) {
|
|
122
|
-
return (_jsx(Text, { wrap: "truncate-end", color: termcnColors.selectionFg, backgroundColor: termcnColors.selectionBg, bold: true, children: padded }));
|
|
123
|
-
}
|
|
124
|
-
return (_jsx(Text, { wrap: "truncate-end", ...(options.muted
|
|
125
|
-
? { color: termcnColors.muted }
|
|
126
|
-
: options.color
|
|
127
|
-
? { color: options.color }
|
|
128
|
-
: {}), ...(options.bold ? { bold: true } : {}), children: padded }));
|
|
129
|
-
}
|
|
130
|
-
/** Right-pane detail row: muted labels, normal/muted values, optional bold title. */
|
|
131
|
-
function DetailColumnRow({ row, width, selected = false, }) {
|
|
132
|
-
if (selected) {
|
|
133
|
-
return (_jsx(Text, { wrap: "truncate-end", color: termcnColors.selectionFg, backgroundColor: termcnColors.selectionBg, bold: true, children: padColumns(sliceColumns(row.label !== undefined
|
|
134
|
-
? `${padColumns(row.label, detailLabelWidth())}${row.text}`
|
|
135
|
-
: row.text, 0, width), width) }));
|
|
136
|
-
}
|
|
137
|
-
if (row.label !== undefined) {
|
|
138
|
-
const valueWidth = Math.max(1, width - detailLabelWidth());
|
|
139
|
-
return (_jsxs(Text, { wrap: "truncate-end", children: [_jsx(Text, { color: termcnColors.muted, children: padColumns(row.label, detailLabelWidth()) }), _jsx(Text, { ...(row.muted ? { color: termcnColors.muted } : {}), ...(row.bold ? { bold: true } : {}), ...(row.primary ? { color: termcnColors.primary } : {}), children: padColumns(sliceColumns(row.text, 0, valueWidth), valueWidth) })] }));
|
|
140
|
-
}
|
|
141
|
-
return (_jsx(Text, { wrap: "truncate-end", ...(row.primary ? { color: termcnColors.primary } : {}), ...(row.muted ? { color: termcnColors.muted } : {}), ...(row.bold ? { bold: true } : {}), children: padColumns(sliceColumns(row.text, 0, width), width) }));
|
|
142
|
-
}
|
|
143
|
-
function MasterDetailBody({ tagLines, listLines, peekLines, tagWidth, listWidth, peekWidth, tagActive, listActive, detailActive = false, detailActiveField, collectionHome = false, listActiveLineIndexes, listSelectedLineIndexes, detailRows, onTagLineClick, onListLineClick, onDetailLineClick, onListScroll, }) {
|
|
144
|
-
const rows = Math.max(tagLines.length, listLines.length, peekLines.length, detailRows?.length ?? 0);
|
|
145
|
-
const divided = collectionHome;
|
|
146
|
-
const divider = divided ? '│' : '';
|
|
147
|
-
const tagColumnWidth = tagWidth + (divider ? 1 : 0);
|
|
148
|
-
const listColumnWidth = listWidth + (divider ? 1 : 0);
|
|
149
|
-
// Only the skill column (2nd) owns list wheel scrolling. Detail (3rd) must not
|
|
150
|
-
// move the list when the pointer is over it — attach scroll handler only there.
|
|
151
|
-
const onListColumnScroll = useCallback((event) => {
|
|
152
|
-
const info = event.scroll;
|
|
153
|
-
if (!info || !onListScroll)
|
|
154
|
-
return;
|
|
155
|
-
const steps = Math.max(1, Math.abs(info.delta) || 1);
|
|
156
|
-
if (info.direction === 'up')
|
|
157
|
-
onListScroll(-steps);
|
|
158
|
-
else if (info.direction === 'down')
|
|
159
|
-
onListScroll(steps);
|
|
160
|
-
event.stopPropagation();
|
|
161
|
-
}, [onListScroll]);
|
|
162
|
-
const swallowScroll = useCallback((event) => {
|
|
163
|
-
// Keep wheel over detail/tag from bubbling to a parent list scroller.
|
|
164
|
-
if (event.scroll)
|
|
165
|
-
event.stopPropagation();
|
|
166
|
-
}, []);
|
|
167
|
-
return (_jsx("box", { flexDirection: "column", children: Array.from({ length: rows }, (_, index) => {
|
|
168
|
-
const tagCell = masterDetailColumnText(tagLines[index] ?? '', tagWidth, {
|
|
169
|
-
...(tagActive && tagLines[index]?.startsWith('›')
|
|
170
|
-
? collectionHome
|
|
171
|
-
? { selected: true }
|
|
172
|
-
: { color: termcnColors.primary, bold: true }
|
|
173
|
-
: {}),
|
|
174
|
-
});
|
|
175
|
-
const listCell = masterDetailColumnText(listLines[index] ?? '', listWidth, {
|
|
176
|
-
...(listActiveLineIndexes?.has(index)
|
|
177
|
-
? { selected: true }
|
|
178
|
-
: listSelectedLineIndexes?.has(index)
|
|
179
|
-
? { color: termcnColors.primary, bold: true }
|
|
180
|
-
: listActive && listLines[index]?.startsWith('›')
|
|
181
|
-
? { color: termcnColors.primary, bold: true }
|
|
182
|
-
: index % 2 === 1 && listLines[index]?.trim()
|
|
183
|
-
? { muted: true }
|
|
184
|
-
: {}),
|
|
185
|
-
});
|
|
186
|
-
const tagInteractive = onTagLineClick && (tagLines[index] ?? '').trim().length > 0;
|
|
187
|
-
const listInteractive = onListLineClick && (listLines[index] ?? '').trim().length > 0;
|
|
188
|
-
return (_jsxs("box", { flexDirection: "row", children: [_jsxs("box", { width: tagColumnWidth, flexDirection: "row", onMouseScroll: swallowScroll, children: [tagInteractive ? (_jsx(Clickable, { onClick: () => onTagLineClick(index), children: tagCell })) : (tagCell), divider ? _jsx(Text, { color: termcnColors.border, children: divider }) : null] }), _jsxs("box", { width: listColumnWidth, flexDirection: "row", onMouseScroll: onListColumnScroll, children: [listInteractive ? (_jsx(Clickable, { onClick: () => onListLineClick(index), children: listCell })) : (listCell), divider ? _jsx(Text, { color: termcnColors.border, children: divider }) : null] }), _jsx("box", { flexDirection: "row", width: peekWidth, onMouseScroll: swallowScroll, children: detailRows?.[index] ? ((() => {
|
|
189
|
-
const detailRow = detailRows[index];
|
|
190
|
-
const fieldSelected = detailActive &&
|
|
191
|
-
detailRow.field !== undefined &&
|
|
192
|
-
detailRow.field === detailActiveField;
|
|
193
|
-
const cell = (_jsx(DetailColumnRow, { row: detailRow, width: peekWidth, selected: fieldSelected }));
|
|
194
|
-
return onDetailLineClick && detailRow.field ? (_jsx(Clickable, { onClick: () => onDetailLineClick(index), children: cell })) : (cell);
|
|
195
|
-
})()) : (_jsx(Text, { wrap: "truncate-end", color: index === 0 && peekLines[index] !== t('browser.selectSkillToView') ? termcnColors.primary : termcnColors.muted, bold: index === 0 && peekLines[index] !== t('browser.selectSkillToView'), children: padColumns(sliceColumns(peekLines[index] ?? '', 0, peekWidth), peekWidth) })) })] }, `master-detail-row:${index}`));
|
|
196
|
-
}) }));
|
|
197
|
-
}
|
|
198
57
|
/**
|
|
199
58
|
* Browser list view. Navigation/selection live in the parent Jotai Provider
|
|
200
59
|
* (BrowserApp store). Does not create a nested store.
|
|
201
60
|
* Overlays (? / more-actions) go through {@link useModal}.
|
|
202
61
|
*/
|
|
203
|
-
export function Browser({ projectGroups, collection, globalGroups, canSync, checkUpdates, updatingSkillName, finish, }) {
|
|
62
|
+
export function Browser({ projectGroups, collection, globalGroups, canSync, checkUpdates, updatingSkillName, workingAction, finish, }) {
|
|
204
63
|
const modal = useModal();
|
|
205
64
|
const shellBusy = useOverlayBusy();
|
|
206
65
|
const store = useStore();
|
|
66
|
+
// Block list input while a long action runs (update/materialize skill row or collection sync).
|
|
67
|
+
const actionBusy = Boolean(updatingSkillName) || Boolean(workingAction);
|
|
207
68
|
// Local braille spinner only while a skill is updating (not a global busy overlay).
|
|
208
69
|
const updatingFrame = useSpinnerFrame(Boolean(updatingSkillName));
|
|
209
70
|
const [navigation, setNavigationState] = useAtom(browserNavigationAtom);
|
|
210
71
|
const [selected, setSelected] = useAtom(browserSelectionAtom);
|
|
72
|
+
const setDetailField = useSetAtom(browserDetailFieldAtom);
|
|
211
73
|
const navigationRef = useRef(navigation);
|
|
212
74
|
navigationRef.current = navigation;
|
|
213
75
|
/** Keep ref in lockstep so multi-key stdin never reads a stale focus/tab. */
|
|
214
76
|
const setNavigation = (value) => {
|
|
215
77
|
setNavigationState((current) => {
|
|
216
78
|
const next = typeof value === 'function' ? value(current) : value;
|
|
79
|
+
if (sameNavigation(current, next))
|
|
80
|
+
return current;
|
|
217
81
|
navigationRef.current = next;
|
|
218
82
|
return next;
|
|
219
83
|
});
|
|
@@ -246,22 +110,24 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
|
|
|
246
110
|
const cursorRef = useRef(cursor);
|
|
247
111
|
cursorRef.current = cursor;
|
|
248
112
|
const setTab = (value) => {
|
|
249
|
-
setNavigation((current) => (current ? { ...current, tab: value } : current));
|
|
113
|
+
setNavigation((current) => (current && current.tab !== value ? { ...current, tab: value } : current));
|
|
250
114
|
};
|
|
251
115
|
const setQuery = (value) => {
|
|
252
|
-
setNavigation((current) =>
|
|
116
|
+
setNavigation((current) => current && current.query !== value ? { ...current, query: value } : current);
|
|
253
117
|
};
|
|
254
118
|
const setAgent = (value) => {
|
|
255
|
-
setNavigation((current) =>
|
|
119
|
+
setNavigation((current) => current && current.agent !== value ? { ...current, agent: value } : current);
|
|
256
120
|
};
|
|
257
121
|
const setFocus = (value) => {
|
|
258
|
-
setNavigation((current) =>
|
|
122
|
+
setNavigation((current) => current && current.focus !== value ? { ...current, focus: value } : current);
|
|
259
123
|
};
|
|
260
124
|
const setCursor = (value) => {
|
|
261
125
|
setNavigation((current) => {
|
|
262
126
|
if (!current)
|
|
263
127
|
return current;
|
|
264
128
|
const nextCursor = typeof value === 'function' ? value(current.cursor) : value;
|
|
129
|
+
if (nextCursor === current.cursor)
|
|
130
|
+
return current;
|
|
265
131
|
cursorRef.current = nextCursor;
|
|
266
132
|
return { ...current, cursor: nextCursor };
|
|
267
133
|
});
|
|
@@ -273,7 +139,7 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
|
|
|
273
139
|
const { selectedCollection, selectedProject, selectedGlobal, selectedProjectLocal, selectedGlobalLocal, } = browseSelectionSets(selected, { collection, projectGroups, globalGroups });
|
|
274
140
|
const selectedUpdates = selectedCollection.filter((skill) => updateCheck.updates.has(skill.name));
|
|
275
141
|
const { stdout } = useStdout();
|
|
276
|
-
// Wide terminals keep the 3-column master-detail
|
|
142
|
+
// Wide terminals keep the 3-column master-detail panes even while filtering;
|
|
277
143
|
// list rows still apply `query` inside the skill column.
|
|
278
144
|
const useBrowseHome = masterDetailLayout(stdout.columns, stdout.rows);
|
|
279
145
|
const useMasterDetail = useBrowseHome;
|
|
@@ -282,14 +148,26 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
|
|
|
282
148
|
const tabSkills = tab === 'collection'
|
|
283
149
|
? collection
|
|
284
150
|
: tab === 'project'
|
|
285
|
-
? projectGroup?.skills ??
|
|
151
|
+
? projectGroup?.skills ?? EMPTY_SKILLS
|
|
286
152
|
: tab === 'global'
|
|
287
|
-
? globalGroup?.skills ??
|
|
288
|
-
:
|
|
153
|
+
? globalGroup?.skills ?? EMPTY_SKILLS
|
|
154
|
+
: EMPTY_SKILLS;
|
|
289
155
|
const groupRows = useMemo(() => groupedRows(tabSkills, ''), [tabSkills]);
|
|
290
|
-
const groups = groupRows.filter((row) => row.type === 'group');
|
|
156
|
+
const groups = useMemo(() => groupRows.filter((row) => row.type === 'group'), [groupRows]);
|
|
291
157
|
const tagOptions = useMemo(() => tagFilterOptions(tabSkills, groups), [groups, tabSkills]);
|
|
292
|
-
const [tagFilter,
|
|
158
|
+
const [tagFilter, setTagFilterState] = useAtom(browserTagFilterAtom);
|
|
159
|
+
const setTagFilter = (value) => {
|
|
160
|
+
setTagFilterState((current) => (current === value ? current : value));
|
|
161
|
+
};
|
|
162
|
+
const setSelectedIfChanged = (next) => {
|
|
163
|
+
setSelected((current) => {
|
|
164
|
+
if (current === next)
|
|
165
|
+
return current;
|
|
166
|
+
if (current.size === next.size && [...next].every((id) => current.has(id)))
|
|
167
|
+
return current;
|
|
168
|
+
return next;
|
|
169
|
+
});
|
|
170
|
+
};
|
|
293
171
|
const [tagCursor, setTagCursor] = useState(0);
|
|
294
172
|
const tagCursorRef = useRef(tagCursor);
|
|
295
173
|
tagCursorRef.current = tagCursor;
|
|
@@ -302,40 +180,45 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
|
|
|
302
180
|
const listRows = useMasterDetail ? masterDetailRows : rows;
|
|
303
181
|
const currentRow = listRows[cursor];
|
|
304
182
|
const actionSkills = projectActionSkills(tab, tab === 'global' ? selectedGlobal : selectedProject, currentRow?.type === 'skill' ? currentRow.skill : undefined);
|
|
305
|
-
const canMaterialize = !
|
|
183
|
+
const canMaterialize = !actionBusy &&
|
|
306
184
|
focus === 'list' &&
|
|
307
185
|
tab === 'project' &&
|
|
308
186
|
actionSkills.length > 0 &&
|
|
309
187
|
actionSkills.every((skill) => skill.isReference);
|
|
310
|
-
const canInstallToAgents = !
|
|
188
|
+
const canInstallToAgents = !actionBusy &&
|
|
311
189
|
focus === 'list' &&
|
|
312
190
|
(tab === 'project' || tab === 'global') &&
|
|
313
191
|
actionSkills.length > 0 &&
|
|
314
192
|
actionSkills.every((skill) => isCrossAgentInstallable(skill));
|
|
315
193
|
const canOpenActions = canMaterialize || canInstallToAgents;
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
194
|
+
useBrowseSessionEffects({
|
|
195
|
+
tab,
|
|
196
|
+
agent,
|
|
197
|
+
focus,
|
|
198
|
+
cursor,
|
|
199
|
+
listLength: listRows.length,
|
|
200
|
+
hasAgents: hasAgentTabs,
|
|
201
|
+
masterDetail: useMasterDetail,
|
|
202
|
+
currentIsItem: currentRow?.type === 'skill',
|
|
203
|
+
setFocus,
|
|
204
|
+
setCursor,
|
|
205
|
+
setSelected: setSelectedIfChanged,
|
|
206
|
+
setTagFilter,
|
|
207
|
+
setTagCursor,
|
|
208
|
+
});
|
|
209
|
+
const applySession = (patch) => {
|
|
210
|
+
applyBrowseSessionPatch(patch, {
|
|
211
|
+
setNav: (nav) => setNavigation(nav),
|
|
212
|
+
setTagFilter,
|
|
213
|
+
setTagCursor,
|
|
214
|
+
setSelected: setSelectedIfChanged,
|
|
215
|
+
setDetailFieldIndex,
|
|
216
|
+
setChoosingGroup,
|
|
217
|
+
tagCursorRef,
|
|
218
|
+
detailFieldIndexRef,
|
|
219
|
+
cursorRef,
|
|
220
|
+
});
|
|
221
|
+
};
|
|
339
222
|
useEffect(() => {
|
|
340
223
|
if (tab !== 'collection')
|
|
341
224
|
return;
|
|
@@ -372,7 +255,7 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
|
|
|
372
255
|
hasGlobalAgents: visibleGlobalGroups.length > 0,
|
|
373
256
|
});
|
|
374
257
|
const openDetail = (skill, collection) => {
|
|
375
|
-
// Master-detail
|
|
258
|
+
// Master-detail panes fills the terminal; browserFrameDimensions still
|
|
376
259
|
// sizes by list row count and can be only a few lines on a short list.
|
|
377
260
|
// Full-screen detail must use the terminal viewport, not that stub height.
|
|
378
261
|
const frameHeight = useBrowseHome
|
|
@@ -396,6 +279,9 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
|
|
|
396
279
|
: withAgents
|
|
397
280
|
? agentPaneViewportHeight
|
|
398
281
|
: collectionPaneViewportHeight;
|
|
282
|
+
const tabBodyMinHeight = useMasterDetail
|
|
283
|
+
? Math.max(8, (stdout.rows ?? 24) - 2)
|
|
284
|
+
: frame.frameHeight - 1;
|
|
399
285
|
const masterListVisibleHeight = Math.max(1, Math.floor(masterDetailBrowseHeight(false) / 2));
|
|
400
286
|
const masterListOffset = useMasterDetail
|
|
401
287
|
? Math.max(0, Math.min(cursor - Math.floor(masterListVisibleHeight / 2), Math.max(0, listRows.length - masterListVisibleHeight)))
|
|
@@ -403,10 +289,14 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
|
|
|
403
289
|
const peekSkill = (focus === 'list' || focus === 'detail') && currentRow?.type === 'skill'
|
|
404
290
|
? currentRow.skill
|
|
405
291
|
: undefined;
|
|
406
|
-
const
|
|
292
|
+
const detailSkill = currentRow?.type === 'skill' ? currentRow.skill : undefined;
|
|
293
|
+
const detailFields = detailEditableFields(tab === 'collection', detailSkill);
|
|
407
294
|
const activeDetailField = focus === 'detail' && detailFields.length
|
|
408
295
|
? detailFields[Math.max(0, Math.min(detailFieldIndex, detailFields.length - 1))]
|
|
409
296
|
: undefined;
|
|
297
|
+
useEffect(() => {
|
|
298
|
+
setDetailField(focus === 'detail' ? activeDetailField : undefined);
|
|
299
|
+
}, [focus, activeDetailField, setDetailField]);
|
|
410
300
|
useEffect(() => {
|
|
411
301
|
if ((focus === 'detail' || focus === 'tags') && !useMasterDetail)
|
|
412
302
|
setFocus('list');
|
|
@@ -440,6 +330,11 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
|
|
|
440
330
|
});
|
|
441
331
|
return;
|
|
442
332
|
}
|
|
333
|
+
// Health alerts panel (demo seed via browserHealthAtom).
|
|
334
|
+
if (input === '!') {
|
|
335
|
+
void presentHealthAlerts(store.get(browserHealthAtom));
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
443
338
|
if (key.escape || input === 'q')
|
|
444
339
|
return finish({ type: 'quit' });
|
|
445
340
|
if (input === '/') {
|
|
@@ -451,148 +346,60 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
|
|
|
451
346
|
});
|
|
452
347
|
return;
|
|
453
348
|
}
|
|
454
|
-
if (input === 'g' && groups.length) {
|
|
455
|
-
return setChoosingGroup(true);
|
|
456
|
-
}
|
|
457
349
|
if (input === 's' && liveTab === 'collection' && canSync) {
|
|
458
350
|
return finish({ type: 'sync' });
|
|
459
351
|
}
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
setNavigation((current) => {
|
|
466
|
-
if (!current)
|
|
467
|
-
return current;
|
|
468
|
-
const groups = current.tab === 'project'
|
|
469
|
-
? visibleProjectGroups
|
|
470
|
-
: current.tab === 'global'
|
|
471
|
-
? visibleGlobalGroups
|
|
472
|
-
: [];
|
|
473
|
-
const hasAgents = groups.length > 0;
|
|
474
|
-
const names = groups.map((group) => group.agent);
|
|
475
|
-
if (current.focus === 'tabs') {
|
|
476
|
-
if (key.downArrow) {
|
|
477
|
-
return {
|
|
478
|
-
...current,
|
|
479
|
-
focus: focusAfterDownFromTabs(hasAgents, useMasterDetail),
|
|
480
|
-
};
|
|
481
|
-
}
|
|
482
|
-
if (key.leftArrow || key.rightArrow) {
|
|
483
|
-
const next = nextMainTab(current.tab, direction);
|
|
484
|
-
return next ? { ...current, tab: next } : current;
|
|
485
|
-
}
|
|
486
|
-
return current;
|
|
487
|
-
}
|
|
488
|
-
if (current.focus === 'agents') {
|
|
489
|
-
if (key.upArrow)
|
|
490
|
-
return { ...current, focus: 'tabs' };
|
|
491
|
-
if (key.downArrow) {
|
|
492
|
-
return {
|
|
493
|
-
...current,
|
|
494
|
-
focus: focusAfterDownFromAgents(useMasterDetail),
|
|
495
|
-
};
|
|
496
|
-
}
|
|
497
|
-
if (key.leftArrow || key.rightArrow) {
|
|
498
|
-
const next = nextAgent(names, current.agent || names[0] || '', direction);
|
|
499
|
-
return next ? { ...current, agent: next } : current;
|
|
500
|
-
}
|
|
501
|
-
return current;
|
|
502
|
-
}
|
|
503
|
-
if (current.focus === 'tags') {
|
|
504
|
-
// ↑/↓ move among tag rows (handled below). Only ←/→ change the focus ladder here.
|
|
505
|
-
if (key.leftArrow)
|
|
506
|
-
return { ...current, focus: focusAfterUpFromTags(hasAgents) };
|
|
507
|
-
if (key.rightArrow)
|
|
508
|
-
return { ...current, focus: 'list' };
|
|
509
|
-
return current;
|
|
510
|
-
}
|
|
511
|
-
return current;
|
|
512
|
-
});
|
|
513
|
-
// Tag index moves stay on the tags-local path below when still on tags.
|
|
514
|
-
if (liveFocus !== 'tags' || key.leftArrow || key.rightArrow)
|
|
515
|
-
return;
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
if (liveFocus === 'tabs' || liveFocus === 'agents') {
|
|
519
|
-
return;
|
|
352
|
+
if ((key.return || input.includes('\r') || input.includes('\n')) &&
|
|
353
|
+
liveFocus === 'list' &&
|
|
354
|
+
liveTab === 'collection' &&
|
|
355
|
+
selectedCollection.length) {
|
|
356
|
+
return finish({ type: 'add', skills: selectedCollection });
|
|
520
357
|
}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
const tagOption = tagOptions[liveTagCursor];
|
|
551
|
-
if (input === ' ' && tagOption) {
|
|
552
|
-
const paths = tagOption.skills.map((skill) => skill.path);
|
|
553
|
-
return setSelected((previous) => {
|
|
554
|
-
const next = new Set(previous);
|
|
555
|
-
const allSelected = paths.every((path) => previous.has(path));
|
|
556
|
-
for (const path of paths)
|
|
557
|
-
allSelected ? next.delete(path) : next.add(path);
|
|
558
|
-
return next;
|
|
559
|
-
});
|
|
560
|
-
}
|
|
561
|
-
if (key.return || input.includes('\r') || input.includes('\n')) {
|
|
562
|
-
selectTag(liveTagCursor);
|
|
563
|
-
return setFocus('list');
|
|
564
|
-
}
|
|
358
|
+
const liveNav = live ?? {
|
|
359
|
+
tab: liveTab,
|
|
360
|
+
focus: liveFocus,
|
|
361
|
+
agent,
|
|
362
|
+
cursor: cursorRef.current,
|
|
363
|
+
query,
|
|
364
|
+
};
|
|
365
|
+
const liveRow = listRows[liveNav.cursor];
|
|
366
|
+
const session = reduceBrowseSessionKey({
|
|
367
|
+
nav: liveNav,
|
|
368
|
+
tagFilter,
|
|
369
|
+
tagCursor: tagCursorRef.current,
|
|
370
|
+
selected,
|
|
371
|
+
detailFieldIndex: detailFieldIndexRef.current,
|
|
372
|
+
}, input, key, {
|
|
373
|
+
hasAgents: hasAgentTabs,
|
|
374
|
+
masterDetail: useMasterDetail,
|
|
375
|
+
projectAgentNames: visibleProjectGroups.map((group) => group.agent),
|
|
376
|
+
globalAgentNames: visibleGlobalGroups.map((group) => group.agent),
|
|
377
|
+
tagOptions,
|
|
378
|
+
listLength: listRows.length,
|
|
379
|
+
currentItemIds: liveRow ? selectableSkills(liveRow).map((skill) => skill.path) : [],
|
|
380
|
+
currentIsItem: liveRow?.type === 'skill',
|
|
381
|
+
allowNarrowGroupJump: groups.length > 0,
|
|
382
|
+
detailFieldCount: detailEditableFields(liveNav.tab === 'collection', liveRow?.type === 'skill' ? liveRow.skill : undefined).length,
|
|
383
|
+
detailEntryFieldIndex: detailEntryFieldIndex(detailEditableFields(liveNav.tab === 'collection', liveRow?.type === 'skill' ? liveRow.skill : undefined)),
|
|
384
|
+
});
|
|
385
|
+
if (session.handled) {
|
|
386
|
+
applySession(session.patch);
|
|
565
387
|
return;
|
|
566
388
|
}
|
|
567
|
-
|
|
568
|
-
if (liveFocus === 'detail' || focus === 'detail') {
|
|
389
|
+
if (liveNav.focus === 'detail') {
|
|
569
390
|
const detailRow = listRows[cursorRef.current];
|
|
570
391
|
const skill = detailRow?.type === 'skill' ? detailRow.skill : undefined;
|
|
571
|
-
const fields = detailEditableFields(tab === 'collection');
|
|
572
|
-
if (key.leftArrow)
|
|
573
|
-
return setFocus('list');
|
|
574
|
-
if (key.upArrow) {
|
|
575
|
-
if (!fields.length)
|
|
576
|
-
return;
|
|
577
|
-
setDetailFieldIndex((index) => Math.max(0, index - 1));
|
|
578
|
-
return;
|
|
579
|
-
}
|
|
580
|
-
if (key.downArrow) {
|
|
581
|
-
if (!fields.length)
|
|
582
|
-
return;
|
|
583
|
-
setDetailFieldIndex((index) => Math.min(fields.length - 1, index + 1));
|
|
584
|
-
return;
|
|
585
|
-
}
|
|
586
|
-
if (key.rightArrow)
|
|
587
|
-
return;
|
|
392
|
+
const fields = detailEditableFields(liveNav.tab === 'collection', skill);
|
|
588
393
|
const field = fields[detailFieldIndexRef.current] ?? fields[0];
|
|
589
394
|
if (skill && field && (key.return || input.includes('\r') || input.includes('\n'))) {
|
|
395
|
+
if (field === 'source')
|
|
396
|
+
return finish({ type: 'openSource', skill });
|
|
590
397
|
if (field === 'tags')
|
|
591
398
|
return finish({ type: 'editTags', skill });
|
|
592
399
|
if (field === 'note')
|
|
593
400
|
return finish({ type: 'editNote', skill });
|
|
594
401
|
}
|
|
595
|
-
if (skill && tab === 'collection') {
|
|
402
|
+
if (skill && liveNav.tab === 'collection') {
|
|
596
403
|
if (input === 't')
|
|
597
404
|
return finish({ type: 'editTags', skill });
|
|
598
405
|
if (input === 'n')
|
|
@@ -600,7 +407,7 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
|
|
|
600
407
|
}
|
|
601
408
|
return;
|
|
602
409
|
}
|
|
603
|
-
if (
|
|
410
|
+
if (liveNav.focus !== 'list')
|
|
604
411
|
return;
|
|
605
412
|
const row = listRows[cursorRef.current];
|
|
606
413
|
if (input === 'm' && canOpenActions) {
|
|
@@ -736,55 +543,19 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
|
|
|
736
543
|
});
|
|
737
544
|
return;
|
|
738
545
|
}
|
|
739
|
-
if (key.
|
|
740
|
-
return
|
|
741
|
-
if (key.upArrow) {
|
|
742
|
-
if (cursorRef.current === 0) {
|
|
743
|
-
return setFocus(focusAfterUpFromList(useMasterDetail, hasAgentTabs));
|
|
744
|
-
}
|
|
745
|
-
return setCursor((index) => index - 1);
|
|
746
|
-
}
|
|
747
|
-
if (key.downArrow) {
|
|
748
|
-
return setCursor((index) => Math.min(Math.max(0, listRows.length - 1), index + 1));
|
|
749
|
-
}
|
|
750
|
-
if (input === ' ' && row) {
|
|
751
|
-
const paths = selectableSkills(row).map((skill) => skill.path);
|
|
752
|
-
if (!paths.length)
|
|
753
|
-
return;
|
|
754
|
-
return setSelected((previous) => {
|
|
755
|
-
const next = new Set(previous);
|
|
756
|
-
const allSelected = paths.every((path) => previous.has(path));
|
|
757
|
-
for (const path of paths)
|
|
758
|
-
allSelected ? next.delete(path) : next.add(path);
|
|
759
|
-
return next;
|
|
760
|
-
});
|
|
761
|
-
}
|
|
762
|
-
// Collection only: wide → focuses detail column; narrow → opens fullscreen detail.
|
|
763
|
-
// Project / global: right pane is preview only — no → focus/open detail.
|
|
764
|
-
if (key.rightArrow && row?.type === 'skill' && tab === 'collection') {
|
|
765
|
-
if (useMasterDetail) {
|
|
766
|
-
setDetailFieldIndex(0);
|
|
767
|
-
return setFocus('detail');
|
|
768
|
-
}
|
|
769
|
-
if (!useBrowseHome) {
|
|
770
|
-
return openDetail(row.skill, true);
|
|
771
|
-
}
|
|
546
|
+
if (key.rightArrow && row?.type === 'skill' && tab === 'collection' && !useMasterDetail) {
|
|
547
|
+
return openDetail(row.skill, true);
|
|
772
548
|
}
|
|
773
549
|
if (key.return || input.includes('\r') || input.includes('\n')) {
|
|
774
550
|
if (tab === 'collection' && selectedCollection.length) {
|
|
775
551
|
return finish({ type: 'add', skills: selectedCollection });
|
|
776
552
|
}
|
|
777
|
-
if (
|
|
778
|
-
return;
|
|
779
|
-
if (tab === 'collection' && row?.type === 'skill') {
|
|
780
|
-
return openDetail(row.skill, true);
|
|
781
|
-
}
|
|
782
|
-
if (tab !== 'collection' && row?.type === 'skill') {
|
|
783
|
-
return openDetail(row.skill, false);
|
|
553
|
+
if (row?.type === 'skill') {
|
|
554
|
+
return openDetail(row.skill, tab === 'collection');
|
|
784
555
|
}
|
|
785
556
|
}
|
|
786
557
|
}, {
|
|
787
|
-
isActive: !shellBusy && !searching && !choosingGroup && !
|
|
558
|
+
isActive: !shellBusy && !searching && !choosingGroup && !actionBusy,
|
|
788
559
|
});
|
|
789
560
|
useInput((input, key) => {
|
|
790
561
|
if (key.escape || input === 'q') {
|
|
@@ -813,142 +584,104 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
|
|
|
813
584
|
const renderBrowsePane = (paneRows, viewportHeight, options = {}) => {
|
|
814
585
|
if (useBrowseHome) {
|
|
815
586
|
const { tagWidth, listWidth, peekWidth } = masterDetailColumns;
|
|
816
|
-
const
|
|
817
|
-
const tagActiveIndex = Math.max(0, Math.min(tagCursor, tagOptions.length - 1));
|
|
818
|
-
const tagOffset = Math.max(0, Math.min(tagActiveIndex - Math.floor(viewportHeight / 2), Math.max(0, tagOptions.length - viewportHeight)));
|
|
819
|
-
const tagLines = collectionCategoryLines(tagOptions, tagCursor, focus === 'tags', tagWidth, viewportHeight);
|
|
820
|
-
const { lines: listLines, skillOffset, activeLineIndexes: listActiveLineIndexes, selectedLineIndexes: listSelectedLineIndexes, } = collectionListColumnLines(paneRows, cursor, focus === 'list', options.preferNote ?? false, listWidth, viewportHeight, selectedPaths, options.updates ?? new Set(), options.updatingSkillName, updatingFrame);
|
|
587
|
+
const { lines: listLines, skillOffset, activeLineIndexes: listActiveLineIndexes, selectedLineIndexes: listSelectedLineIndexes, } = collectionListColumnLines(paneRows, cursor, focus === 'list', options.preferNote ?? false, listWidth, viewportHeight, selected, options.updates ?? new Set(), options.updatingSkillName, updatingFrame);
|
|
821
588
|
const detailRows = browseDetailRows(peekSkill, peekWidth, viewportHeight, options.collection ?? false, options.updates ?? new Set(), options.updatingSkillName, updatingFrame);
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
}
|
|
856
|
-
return next;
|
|
857
|
-
});
|
|
858
|
-
}, onDetailLineClick: (visibleIndex) => {
|
|
859
|
-
const row = detailRows[visibleIndex];
|
|
860
|
-
if (!row?.field)
|
|
861
|
-
return;
|
|
862
|
-
const index = detailFields.indexOf(row.field);
|
|
863
|
-
if (index < 0)
|
|
864
|
-
return;
|
|
865
|
-
setDetailFieldIndex(index);
|
|
866
|
-
setFocus('detail');
|
|
867
|
-
}, onListScroll: (delta) => {
|
|
868
|
-
setFocus('list');
|
|
869
|
-
setCursor((index) => Math.max(0, Math.min(Math.max(0, paneRows.length - 1), index + delta)));
|
|
870
|
-
} }), _jsx(Text, { color: termcnColors.border, wrap: "truncate-end", children: masterDetailSeparator(tagWidth, listWidth, peekWidth, 'bottom', true) })] }));
|
|
589
|
+
return (_jsx(BrowseHomePane, { tagOptions: tagOptions, tagCursor: tagCursor, listLines: listLines, skillOffset: skillOffset, listLength: paneRows.length, ...(listActiveLineIndexes ? { listActiveLineIndexes } : {}), ...(listSelectedLineIndexes ? { listSelectedLineIndexes } : {}), detailRows: detailRows, ...(activeDetailField ? { detailActiveField: activeDetailField } : {}), tagWidth: tagWidth, listWidth: listWidth, peekWidth: peekWidth, viewportHeight: viewportHeight, tagActive: focus === 'tags', listActive: focus === 'list', detailActive: focus === 'detail', onTagIndex: (index) => {
|
|
590
|
+
const liveNav = navigationRef.current;
|
|
591
|
+
if (!liveNav)
|
|
592
|
+
return;
|
|
593
|
+
const patch = browseSessionClickTag(liveNav, tagOptions, index);
|
|
594
|
+
if (patch)
|
|
595
|
+
applySession(patch);
|
|
596
|
+
}, onListIndex: (index) => {
|
|
597
|
+
const liveNav = navigationRef.current;
|
|
598
|
+
if (!liveNav)
|
|
599
|
+
return;
|
|
600
|
+
applySession(browseSessionClickList(liveNav, index));
|
|
601
|
+
}, onDetailLine: (visibleIndex) => {
|
|
602
|
+
const row = detailRows[visibleIndex];
|
|
603
|
+
if (!row?.field)
|
|
604
|
+
return;
|
|
605
|
+
const index = detailFields.indexOf(row.field);
|
|
606
|
+
if (index < 0)
|
|
607
|
+
return;
|
|
608
|
+
if (row.field === 'source' && peekSkill) {
|
|
609
|
+
finish({ type: 'openSource', skill: peekSkill });
|
|
610
|
+
return;
|
|
611
|
+
}
|
|
612
|
+
const liveNav = navigationRef.current;
|
|
613
|
+
if (!liveNav)
|
|
614
|
+
return;
|
|
615
|
+
applySession(browseSessionClickDetail(liveNav, index));
|
|
616
|
+
}, onListScroll: (delta) => {
|
|
617
|
+
const liveNav = navigationRef.current;
|
|
618
|
+
if (!liveNav)
|
|
619
|
+
return;
|
|
620
|
+
applySession(browseSessionScrollList(liveNav, delta, paneRows.length));
|
|
621
|
+
} }));
|
|
871
622
|
}
|
|
872
|
-
return (_jsx(SkillPane, { rows: paneRows, cursor: cursor, isActive: focus === 'list', viewportHeight: viewportHeight, onRowClick: (index) => {
|
|
623
|
+
return (_jsx(SkillPane, { rows: paneRows, cursor: cursor, isActive: focus === 'list', selected: selected, viewportHeight: viewportHeight, onRowClick: (index) => {
|
|
624
|
+
// Click focuses the row only; Space toggles multi-select.
|
|
873
625
|
setCursor(index);
|
|
874
626
|
setFocus('list');
|
|
875
|
-
const row = paneRows[index];
|
|
876
|
-
if (!row)
|
|
877
|
-
return;
|
|
878
|
-
const paths = selectableSkills(row).map((skill) => skill.path);
|
|
879
|
-
if (!paths.length)
|
|
880
|
-
return;
|
|
881
|
-
setSelected((previous) => {
|
|
882
|
-
const next = new Set(previous);
|
|
883
|
-
const allSelected = paths.every((path) => previous.has(path));
|
|
884
|
-
for (const path of paths) {
|
|
885
|
-
if (allSelected)
|
|
886
|
-
next.delete(path);
|
|
887
|
-
else
|
|
888
|
-
next.add(path);
|
|
889
|
-
}
|
|
890
|
-
return next;
|
|
891
|
-
});
|
|
892
627
|
}, onCursorDelta: (delta) => {
|
|
893
628
|
setFocus('list');
|
|
894
629
|
setCursor((index) => Math.max(0, Math.min(Math.max(0, paneRows.length - 1), index + delta)));
|
|
895
630
|
}, ...options }));
|
|
896
631
|
};
|
|
632
|
+
const activeBrowsePane = tab === 'collection'
|
|
633
|
+
? renderBrowsePane(listRows, browseViewportHeight(false), {
|
|
634
|
+
preferNote: true,
|
|
635
|
+
collection: true,
|
|
636
|
+
showGroup: Boolean(query.trim()),
|
|
637
|
+
updates: updateCheck.updates,
|
|
638
|
+
updatingSkillName,
|
|
639
|
+
})
|
|
640
|
+
: renderBrowsePane(listRows, browseViewportHeight(true), {
|
|
641
|
+
showSource: true,
|
|
642
|
+
showReferences: tab === 'project',
|
|
643
|
+
showGroup: Boolean(query.trim()),
|
|
644
|
+
});
|
|
897
645
|
const tabs = [
|
|
898
646
|
{
|
|
899
647
|
key: 'project',
|
|
900
648
|
label: t('browser.tabProject', { count: project.length }),
|
|
901
|
-
content: (_jsxs("box", { flexDirection: "column", minHeight:
|
|
649
|
+
content: tab === 'project' ? (_jsxs("box", { flexDirection: "column", minHeight: tabBodyMinHeight, children: [_jsx(AgentTabs, { groups: visibleProjectGroups.map((group) => ({
|
|
650
|
+
agent: group.agent,
|
|
651
|
+
count: group.skills.length,
|
|
652
|
+
})), agent: activeProjectAgent, focused: !shellBusy && !searching && focus === 'agents', onSelect: (name) => {
|
|
902
653
|
setAgent(name);
|
|
903
654
|
setCursor(0);
|
|
904
|
-
} }),
|
|
905
|
-
showSource: true,
|
|
906
|
-
showReferences: true,
|
|
907
|
-
showGroup: Boolean(query.trim()),
|
|
908
|
-
})] })),
|
|
655
|
+
} }), activeBrowsePane] })) : null,
|
|
909
656
|
},
|
|
910
657
|
{
|
|
911
658
|
key: 'global',
|
|
912
659
|
label: t('browser.tabGlobal', { count: globalGroups.reduce((count, group) => count + group.skills.length, 0) }),
|
|
913
|
-
content: (_jsxs("box", { flexDirection: "column", minHeight:
|
|
660
|
+
content: tab === 'global' ? (_jsxs("box", { flexDirection: "column", minHeight: tabBodyMinHeight, children: [_jsx(AgentTabs, { groups: visibleGlobalGroups.map((group) => ({
|
|
661
|
+
agent: group.agent,
|
|
662
|
+
count: group.skills.length,
|
|
663
|
+
})), agent: activeGlobalAgent, focused: !shellBusy && !searching && focus === 'agents', onSelect: (name) => {
|
|
914
664
|
setAgent(name);
|
|
915
665
|
setCursor(0);
|
|
916
|
-
} }),
|
|
917
|
-
showSource: true,
|
|
918
|
-
showGroup: Boolean(query.trim()),
|
|
919
|
-
})] })),
|
|
666
|
+
} }), activeBrowsePane] })) : null,
|
|
920
667
|
},
|
|
921
668
|
{
|
|
922
669
|
key: 'collection',
|
|
923
670
|
label: t('browser.tabCollection', { count: collection.length }),
|
|
924
|
-
content: (_jsx("box", { flexDirection: "column", minHeight:
|
|
925
|
-
preferNote: true,
|
|
926
|
-
collection: true,
|
|
927
|
-
showGroup: Boolean(query.trim()),
|
|
928
|
-
updates: updateCheck.updates,
|
|
929
|
-
updatingSkillName,
|
|
930
|
-
}) })),
|
|
671
|
+
content: tab === 'collection' ? (_jsx("box", { flexDirection: "column", minHeight: tabBodyMinHeight, children: activeBrowsePane })) : null,
|
|
931
672
|
},
|
|
932
673
|
];
|
|
674
|
+
// Narrow layout only — wide layout focuses the tag column instead of this Select.
|
|
933
675
|
if (choosingGroup) {
|
|
934
676
|
return (_jsx(Select, { label: t('browser.jumpToGroup'), numbered: true, options: groups.map((group) => ({
|
|
935
677
|
label: `${group.name} (${group.skills.length})`,
|
|
936
678
|
value: group.name,
|
|
937
679
|
})), onSubmit: (name) => {
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
setTagCursor(Math.max(0, index));
|
|
942
|
-
setCursor(0);
|
|
943
|
-
setFocus('list');
|
|
944
|
-
}
|
|
945
|
-
else {
|
|
946
|
-
setQuery('');
|
|
947
|
-
setCursor(groupRows.findIndex((row) => row.type === 'group' && row.name === name));
|
|
948
|
-
setFocus('list');
|
|
949
|
-
}
|
|
680
|
+
setQuery('');
|
|
681
|
+
setCursor(groupRows.findIndex((row) => row.type === 'group' && row.name === name));
|
|
682
|
+
setFocus('list');
|
|
950
683
|
setChoosingGroup(false);
|
|
951
|
-
} }));
|
|
684
|
+
}, onCancel: () => setChoosingGroup(false) }));
|
|
952
685
|
}
|
|
953
686
|
return (_jsx("box", { flexDirection: "column", children: _jsx(Tabs, { tabs: tabs, activeTab: tab, onTabChange: (key) => setTab(key), isActive: !shellBusy && !searching && focus === 'tabs', enableArrowNav: false, focused: !shellBusy && !searching && focus === 'tabs', width: frame.frameWidth, bordered: false, chip: useBrowseHome }) }));
|
|
954
687
|
}
|