iskills 0.2.49 → 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.
Files changed (184) hide show
  1. package/README.md +2 -2
  2. package/README.zh-CN.md +2 -2
  3. package/dist/src/cli.js +4 -0
  4. package/dist/src/cli.js.map +1 -1
  5. package/dist/src/commands/browser-actions.d.ts +2 -0
  6. package/dist/src/commands/browser-actions.js +44 -10
  7. package/dist/src/commands/browser-actions.js.map +1 -1
  8. package/dist/src/commands/config.d.ts +3 -2
  9. package/dist/src/commands/config.js +19 -2
  10. package/dist/src/commands/config.js.map +1 -1
  11. package/dist/src/commands/index.js +1 -0
  12. package/dist/src/commands/index.js.map +1 -1
  13. package/dist/src/commands/library.d.ts +5 -0
  14. package/dist/src/commands/library.js +45 -7
  15. package/dist/src/commands/library.js.map +1 -1
  16. package/dist/src/commands/mcp.d.ts +4 -0
  17. package/dist/src/commands/mcp.js +244 -0
  18. package/dist/src/commands/mcp.js.map +1 -0
  19. package/dist/src/domain/core.d.ts +6 -0
  20. package/dist/src/domain/core.js +64 -19
  21. package/dist/src/domain/core.js.map +1 -1
  22. package/dist/src/domain/git.d.ts +8 -0
  23. package/dist/src/domain/git.js +45 -11
  24. package/dist/src/domain/git.js.map +1 -1
  25. package/dist/src/domain/mcp/collection.d.ts +10 -0
  26. package/dist/src/domain/mcp/collection.js +107 -0
  27. package/dist/src/domain/mcp/collection.js.map +1 -0
  28. package/dist/src/domain/mcp/dialects.d.ts +23 -0
  29. package/dist/src/domain/mcp/dialects.js +536 -0
  30. package/dist/src/domain/mcp/dialects.js.map +1 -0
  31. package/dist/src/domain/mcp/headers.d.ts +9 -0
  32. package/dist/src/domain/mcp/headers.js +50 -0
  33. package/dist/src/domain/mcp/headers.js.map +1 -0
  34. package/dist/src/domain/mcp/identity.d.ts +13 -0
  35. package/dist/src/domain/mcp/identity.js +121 -0
  36. package/dist/src/domain/mcp/identity.js.map +1 -0
  37. package/dist/src/domain/mcp/index.d.ts +8 -0
  38. package/dist/src/domain/mcp/index.js +8 -0
  39. package/dist/src/domain/mcp/index.js.map +1 -0
  40. package/dist/src/domain/mcp/io.d.ts +7 -0
  41. package/dist/src/domain/mcp/io.js +55 -0
  42. package/dist/src/domain/mcp/io.js.map +1 -0
  43. package/dist/src/domain/mcp/probe.d.ts +7 -0
  44. package/dist/src/domain/mcp/probe.js +35 -0
  45. package/dist/src/domain/mcp/probe.js.map +1 -0
  46. package/dist/src/domain/mcp/recipe.d.ts +12 -0
  47. package/dist/src/domain/mcp/recipe.js +172 -0
  48. package/dist/src/domain/mcp/recipe.js.map +1 -0
  49. package/dist/src/domain/mcp/secrets.d.ts +12 -0
  50. package/dist/src/domain/mcp/secrets.js +133 -0
  51. package/dist/src/domain/mcp/secrets.js.map +1 -0
  52. package/dist/src/domain/mcp/types.d.ts +82 -0
  53. package/dist/src/domain/mcp/types.js +2 -0
  54. package/dist/src/domain/mcp/types.js.map +1 -0
  55. package/dist/src/domain/mcp/write.d.ts +30 -0
  56. package/dist/src/domain/mcp/write.js +229 -0
  57. package/dist/src/domain/mcp/write.js.map +1 -0
  58. package/dist/src/domain/user-config.d.ts +2 -0
  59. package/dist/src/domain/user-config.js +5 -2
  60. package/dist/src/domain/user-config.js.map +1 -1
  61. package/dist/src/i18n/en.js +99 -3
  62. package/dist/src/i18n/en.js.map +1 -1
  63. package/dist/src/i18n/zh.d.ts +98 -2
  64. package/dist/src/i18n/zh.js +99 -3
  65. package/dist/src/i18n/zh.js.map +1 -1
  66. package/dist/src/ui/browser/browse-capabilities.d.ts +2 -2
  67. package/dist/src/ui/browser/browse-capabilities.js +10 -14
  68. package/dist/src/ui/browser/browse-capabilities.js.map +1 -1
  69. package/dist/src/ui/browser/browse-nav.d.ts +42 -0
  70. package/dist/src/ui/browser/browse-nav.js +106 -0
  71. package/dist/src/ui/browser/browse-nav.js.map +1 -0
  72. package/dist/src/ui/browser/browse-session.d.ts +94 -0
  73. package/dist/src/ui/browser/browse-session.js +310 -0
  74. package/dist/src/ui/browser/browse-session.js.map +1 -0
  75. package/dist/src/ui/browser/browser.js +190 -444
  76. package/dist/src/ui/browser/browser.js.map +1 -1
  77. package/dist/src/ui/browser/detail.d.ts +1 -1
  78. package/dist/src/ui/browser/detail.js +13 -2
  79. package/dist/src/ui/browser/detail.js.map +1 -1
  80. package/dist/src/ui/browser/footer.d.ts +1 -1
  81. package/dist/src/ui/browser/footer.js +20 -7
  82. package/dist/src/ui/browser/footer.js.map +1 -1
  83. package/dist/src/ui/browser/format.d.ts +47 -12
  84. package/dist/src/ui/browser/format.js +191 -49
  85. package/dist/src/ui/browser/format.js.map +1 -1
  86. package/dist/src/ui/browser/index.js +12 -2
  87. package/dist/src/ui/browser/index.js.map +1 -1
  88. package/dist/src/ui/browser/panes.d.ts +107 -0
  89. package/dist/src/ui/browser/panes.js +212 -0
  90. package/dist/src/ui/browser/panes.js.map +1 -0
  91. package/dist/src/ui/browser/shortcut-help.d.ts +3 -1
  92. package/dist/src/ui/browser/shortcut-help.js +6 -6
  93. package/dist/src/ui/browser/shortcut-help.js.map +1 -1
  94. package/dist/src/ui/browser/store.d.ts +5 -1
  95. package/dist/src/ui/browser/store.js +2 -0
  96. package/dist/src/ui/browser/store.js.map +1 -1
  97. package/dist/src/ui/browser/types.d.ts +9 -4
  98. package/dist/src/ui/components/colors.d.ts +9 -9
  99. package/dist/src/ui/components/colors.js +14 -14
  100. package/dist/src/ui/components/colors.js.map +1 -1
  101. package/dist/src/ui/components/framed-panel.js +6 -6
  102. package/dist/src/ui/components/framed-panel.js.map +1 -1
  103. package/dist/src/ui/components/modal-panel.d.ts +1 -1
  104. package/dist/src/ui/components/modal-panel.js +3 -3
  105. package/dist/src/ui/components/modal-panel.js.map +1 -1
  106. package/dist/src/ui/components/mouse/clickable.js +3 -3
  107. package/dist/src/ui/components/mouse/clickable.js.map +1 -1
  108. package/dist/src/ui/components/mouse/provider.d.ts +3 -3
  109. package/dist/src/ui/components/mouse/provider.js +3 -3
  110. package/dist/src/ui/components/mouse/provider.js.map +1 -1
  111. package/dist/src/ui/components/multi-select.js +6 -6
  112. package/dist/src/ui/components/multi-select.js.map +1 -1
  113. package/dist/src/ui/components/options.d.ts +2 -0
  114. package/dist/src/ui/components/options.js +6 -0
  115. package/dist/src/ui/components/options.js.map +1 -1
  116. package/dist/src/ui/components/select.js +4 -4
  117. package/dist/src/ui/components/select.js.map +1 -1
  118. package/dist/src/ui/components/tag-editor.js +5 -5
  119. package/dist/src/ui/components/tag-editor.js.map +1 -1
  120. package/dist/src/ui/components/termcn.d.ts +1 -1
  121. package/dist/src/ui/components/termcn.js +1 -1
  122. package/dist/src/ui/components/terminal-layout.d.ts +2 -0
  123. package/dist/src/ui/components/terminal-layout.js +10 -0
  124. package/dist/src/ui/components/terminal-layout.js.map +1 -1
  125. package/dist/src/ui/components/text-input-ctrl-c.d.ts +21 -0
  126. package/dist/src/ui/components/text-input-ctrl-c.js +61 -0
  127. package/dist/src/ui/components/text-input-ctrl-c.js.map +1 -0
  128. package/dist/src/ui/components/text-input.d.ts +8 -1
  129. package/dist/src/ui/components/text-input.js +35 -12
  130. package/dist/src/ui/components/text-input.js.map +1 -1
  131. package/dist/src/ui/components/use-input.d.ts +3 -1
  132. package/dist/src/ui/components/use-input.js +2 -1
  133. package/dist/src/ui/components/use-input.js.map +1 -1
  134. package/dist/src/ui/config/index.d.ts +4 -0
  135. package/dist/src/ui/config/index.js +6 -3
  136. package/dist/src/ui/config/index.js.map +1 -1
  137. package/dist/src/ui/config/settings.d.ts +8 -4
  138. package/dist/src/ui/config/settings.js +115 -30
  139. package/dist/src/ui/config/settings.js.map +1 -1
  140. package/dist/src/ui/footer/resolve-footer.d.ts +2 -0
  141. package/dist/src/ui/footer/resolve-footer.js +52 -25
  142. package/dist/src/ui/footer/resolve-footer.js.map +1 -1
  143. package/dist/src/ui/footer/types.d.ts +7 -5
  144. package/dist/src/ui/import/review.js +7 -7
  145. package/dist/src/ui/import/review.js.map +1 -1
  146. package/dist/src/ui/import/skill-select.js +34 -14
  147. package/dist/src/ui/import/skill-select.js.map +1 -1
  148. package/dist/src/ui/install/review.js +4 -4
  149. package/dist/src/ui/install/review.js.map +1 -1
  150. package/dist/src/ui/mcp/browse-capabilities.d.ts +22 -0
  151. package/dist/src/ui/mcp/browse-capabilities.js +36 -0
  152. package/dist/src/ui/mcp/browse-capabilities.js.map +1 -0
  153. package/dist/src/ui/mcp/browser.d.ts +25 -0
  154. package/dist/src/ui/mcp/browser.js +310 -0
  155. package/dist/src/ui/mcp/browser.js.map +1 -0
  156. package/dist/src/ui/mcp/footer.d.ts +16 -0
  157. package/dist/src/ui/mcp/footer.js +30 -0
  158. package/dist/src/ui/mcp/footer.js.map +1 -0
  159. package/dist/src/ui/mcp/format.d.ts +24 -0
  160. package/dist/src/ui/mcp/format.js +218 -0
  161. package/dist/src/ui/mcp/format.js.map +1 -0
  162. package/dist/src/ui/mcp/index.d.ts +8 -0
  163. package/dist/src/ui/mcp/index.js +212 -0
  164. package/dist/src/ui/mcp/index.js.map +1 -0
  165. package/dist/src/ui/overlay/host.d.ts +3 -3
  166. package/dist/src/ui/overlay/host.js +4 -4
  167. package/dist/src/ui/overlay/host.js.map +1 -1
  168. package/dist/src/ui/prompts/present.d.ts +6 -2
  169. package/dist/src/ui/prompts/present.js +7 -3
  170. package/dist/src/ui/prompts/present.js.map +1 -1
  171. package/dist/src/ui/search/index.js +4 -4
  172. package/dist/src/ui/search/index.js.map +1 -1
  173. package/dist/src/ui/shell/app-shell.d.ts +7 -6
  174. package/dist/src/ui/shell/app-shell.js +35 -8
  175. package/dist/src/ui/shell/app-shell.js.map +1 -1
  176. package/dist/src/ui/shell/footer.js +4 -4
  177. package/dist/src/ui/shell/footer.js.map +1 -1
  178. package/dist/src/ui/shell/run.js +3 -0
  179. package/dist/src/ui/shell/run.js.map +1 -1
  180. package/dist/src/ui/tui/hooks.d.ts +2 -2
  181. package/dist/src/ui/tui/hooks.js +3 -3
  182. package/dist/src/ui/tui/index.d.ts +1 -1
  183. package/dist/src/ui/tui/index.js +1 -1
  184. package/package.json +3 -2
@@ -1,21 +1,33 @@
1
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "@opentui/react/jsx-runtime";
2
- import { Text, useStdout } from '../tui/index.js';
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, useAtomValue, useStore } from 'jotai';
5
- import { useCallback, useEffect, useMemo, useRef, useState, } from 'react';
4
+ import { useAtom, useSetAtom, useStore } from 'jotai';
5
+ import { useEffect, useMemo, useRef, useState, } from 'react';
6
6
  import { presentHealthAlerts } from './health.js';
7
- import { browserFilterAtom, browserGroupJumpAtom, browserHealthAtom, browserNavigationAtom, browserSelectionAtom, browserTagFilterAtom, browserUpdateCheckAtom, } from './store.js';
8
- import { browserFrameDimensions, masterDetailLayout, masterDetailSeparator, masterDetailViewportHeight, masterDetailWidths, } from './layout.js';
7
+ import { browserDetailFieldAtom, browserFilterAtom, browserGroupJumpAtom, browserHealthAtom, browserNavigationAtom, browserSelectionAtom, browserTagFilterAtom, browserUpdateCheckAtom, } from './store.js';
8
+ import { browserFrameDimensions, masterDetailLayout, masterDetailViewportHeight, masterDetailWidths, } from './layout.js';
9
9
  import { isCrossAgentInstallable } from '../../domain/cross-agent-install.js';
10
10
  import { browseSelectionSets, projectActionSkills, } from './browse-capabilities.js';
11
- import { TAG_FILTER_ALL, browseDetailRows, collectionCategoryLines, collectionListColumnLines, detailEditableFields, detailLabelWidth, flatRows, focusAfterDownFromAgents, focusAfterDownFromTabs, focusAfterUpFromList, focusAfterUpFromTags, groupedRows, listSkillSummary, nextAgent, nextMainTab, selectableSkills, skillsForTagFilter, tagFilterOptions, visibleAgentGroups, } from './format.js';
11
+ import { browseDetailRows, collectionListColumnLines, detailEditableFields, detailEntryFieldIndex, flatRows, groupedRows, selectableSkills, skillsForTagFilter, tagFilterOptions, visibleAgentGroups, } from './format.js';
12
12
  import { t } from '../../i18n/index.js';
13
13
  import { useModal, useOverlayBusy } from '../overlay/host.js';
14
14
  import { FramedPanel } from '../components/framed-panel.js';
15
- import { Select, Tabs, termcnColors, WorkingSpinner, useSpinnerFrame, } from '../components/termcn.js';
16
- import { Clickable } from '../components/mouse/clickable.js';
17
- import { padColumns, sliceColumns } from '../components/terminal-layout.js';
15
+ import { Select, Tabs, useSpinnerFrame, } from '../components/termcn.js';
18
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
+ }
19
31
  /** Framed more-actions picker when multiple m-actions are available. */
20
32
  function MoreActionsPanel({ scope, items, onSelect, onCancel, }) {
21
33
  const [cursor, setCursor] = useState(0);
@@ -42,160 +54,6 @@ function MoreActionsPanel({ scope, items, onSelect, onCancel, }) {
42
54
  }
43
55
  } }));
44
56
  }
45
- function masterDetailBlankRow(tagWidth, listWidth, peekWidth) {
46
- const divider = '│';
47
- 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) }) })] }));
48
- }
49
- 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, }) {
50
- const { stdout } = useStdout();
51
- const selected = useAtomValue(browserSelectionAtom);
52
- const paneHeight = viewportHeight ?? Math.max(3, (stdout.rows ?? 24) - 8);
53
- const height = rows.length > paneHeight ? Math.max(3, paneHeight - (showPagination ? 1 : 0)) : paneHeight;
54
- const active = Math.max(0, Math.min(cursor, rows.length - 1));
55
- const offset = Math.max(0, Math.min(active - Math.floor(height / 2), rows.length - height));
56
- const visible = rows.slice(offset, offset + height);
57
- const paneWidth = columnWidth ?? Math.max(20, (stdout.columns ?? 80) - 4);
58
- const summaryWidth = Math.max(8, paneWidth - 4);
59
- const onMouseScroll = useCallback((event) => {
60
- const info = event.scroll;
61
- if (!info || !onCursorDelta)
62
- return;
63
- const steps = Math.max(1, Math.abs(info.delta) || 1);
64
- if (info.direction === 'up')
65
- onCursorDelta(-steps);
66
- else if (info.direction === 'down')
67
- onCursorDelta(steps);
68
- event.stopPropagation();
69
- }, [onCursorDelta]);
70
- const renderRow = (row, index) => {
71
- if (row.type === 'group') {
72
- const groupSkills = row.skills;
73
- const count = groupSkills.filter((skill) => selected.has(skill.path)).length;
74
- const marker = count === 0 ? '○' : count === groupSkills.length && groupSkills.length ? '●' : '◐';
75
- const body = (_jsx(Text, { bold: true, ...(isActive && index === active ? { color: termcnColors.primary } : {}), children: `${isActive && index === active ? '›' : ' '} ${marker} ${row.name} (${row.skills.length})` }));
76
- if (!onRowClick)
77
- return _jsx("box", { flexDirection: "row", children: body }, `group:${row.name}:${index}`);
78
- return (_jsx(Clickable, { onClick: () => onRowClick(index), children: body }, `group:${row.name}:${index}`));
79
- }
80
- const skill = row.skill;
81
- const current = isActive && index === active;
82
- const summary = compact || layout === 'master'
83
- ? ''
84
- : listSkillSummary(skill, preferNote, summaryWidth);
85
- const inlineSummary = summary;
86
- const selectionMarker = selected.has(skill.path) ? '●' : '○';
87
- 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] }))] }));
88
- const body = (_jsx(Text, { wrap: "truncate-end", ...(current
89
- ? {
90
- color: termcnColors.selectionFg,
91
- backgroundColor: termcnColors.selectionBg,
92
- bold: true,
93
- }
94
- : {}), children: nameLine }));
95
- if (!onRowClick) {
96
- return (_jsx("box", { flexDirection: "row", children: body }, `${row.group}:${skill.path}:${index}`));
97
- }
98
- return (_jsx(Clickable, { onClick: () => onRowClick(index), children: body }, `${row.group}:${skill.path}:${index}`));
99
- };
100
- 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] }))] }));
101
- }
102
- function AgentTabs({ groups, agent, focused, onSelect, }) {
103
- return (_jsx("box", { flexDirection: "row", paddingLeft: 1, gap: 2, children: groups.map((group) => {
104
- const active = group.agent === agent;
105
- // Current agent always uses primary (visible after mouse click without
106
- // forcing keyboard focus onto the agents row). Keyboard-on-agents adds
107
- // selection chrome so the focus ladder is still obvious.
108
- const keyboardHere = focused && active;
109
- return (_jsx(Clickable, { onClick: () => onSelect(group.agent), children: _jsx(Text, { color: keyboardHere
110
- ? termcnColors.selectionFg
111
- : active
112
- ? termcnColors.primary
113
- : termcnColors.muted, ...(keyboardHere
114
- ? { backgroundColor: termcnColors.selectionBg, bold: true }
115
- : active
116
- ? { bold: true, underline: true }
117
- : {}), children: `${group.agent} ${group.skills.length}` }) }, group.agent));
118
- }) }));
119
- }
120
- function masterDetailColumnText(line, width, options = {}) {
121
- const padded = padColumns(sliceColumns(line, 0, width), width);
122
- if (options.selected) {
123
- return (_jsx(Text, { wrap: "truncate-end", color: termcnColors.selectionFg, backgroundColor: termcnColors.selectionBg, bold: true, children: padded }));
124
- }
125
- return (_jsx(Text, { wrap: "truncate-end", ...(options.muted
126
- ? { color: termcnColors.muted }
127
- : options.color
128
- ? { color: options.color }
129
- : {}), ...(options.bold ? { bold: true } : {}), children: padded }));
130
- }
131
- /** Right-pane detail row: muted labels, normal/muted values, optional bold title. */
132
- function DetailColumnRow({ row, width, selected = false, }) {
133
- if (selected) {
134
- return (_jsx(Text, { wrap: "truncate-end", color: termcnColors.selectionFg, backgroundColor: termcnColors.selectionBg, bold: true, children: padColumns(sliceColumns(row.label !== undefined
135
- ? `${padColumns(row.label, detailLabelWidth())}${row.text}`
136
- : row.text, 0, width), width) }));
137
- }
138
- if (row.label !== undefined) {
139
- const valueWidth = Math.max(1, width - detailLabelWidth());
140
- 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) })] }));
141
- }
142
- 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) }));
143
- }
144
- function MasterDetailBody({ tagLines, listLines, peekLines, tagWidth, listWidth, peekWidth, tagActive, listActive, detailActive = false, detailActiveField, collectionHome = false, listActiveLineIndexes, listSelectedLineIndexes, detailRows, onTagLineClick, onListLineClick, onDetailLineClick, onListScroll, }) {
145
- const rows = Math.max(tagLines.length, listLines.length, peekLines.length, detailRows?.length ?? 0);
146
- const divided = collectionHome;
147
- const divider = divided ? '│' : '';
148
- const tagColumnWidth = tagWidth + (divider ? 1 : 0);
149
- const listColumnWidth = listWidth + (divider ? 1 : 0);
150
- // Only the skill column (2nd) owns list wheel scrolling. Detail (3rd) must not
151
- // move the list when the pointer is over it — attach scroll handler only there.
152
- const onListColumnScroll = useCallback((event) => {
153
- const info = event.scroll;
154
- if (!info || !onListScroll)
155
- return;
156
- const steps = Math.max(1, Math.abs(info.delta) || 1);
157
- if (info.direction === 'up')
158
- onListScroll(-steps);
159
- else if (info.direction === 'down')
160
- onListScroll(steps);
161
- event.stopPropagation();
162
- }, [onListScroll]);
163
- const swallowScroll = useCallback((event) => {
164
- // Keep wheel over detail/tag from bubbling to a parent list scroller.
165
- if (event.scroll)
166
- event.stopPropagation();
167
- }, []);
168
- return (_jsx("box", { flexDirection: "column", children: Array.from({ length: rows }, (_, index) => {
169
- const tagCell = masterDetailColumnText(tagLines[index] ?? '', tagWidth, {
170
- ...(tagActive && tagLines[index]?.startsWith('›')
171
- ? collectionHome
172
- ? { selected: true }
173
- : { color: termcnColors.primary, bold: true }
174
- : {}),
175
- });
176
- const listCell = masterDetailColumnText(listLines[index] ?? '', listWidth, {
177
- ...(listActiveLineIndexes?.has(index)
178
- ? { selected: true }
179
- : listSelectedLineIndexes?.has(index)
180
- ? { color: termcnColors.primary, bold: true }
181
- : listActive && listLines[index]?.startsWith('›')
182
- ? { color: termcnColors.primary, bold: true }
183
- : index % 2 === 1 && listLines[index]?.trim()
184
- ? { muted: true }
185
- : {}),
186
- });
187
- const tagInteractive = onTagLineClick && (tagLines[index] ?? '').trim().length > 0;
188
- const listInteractive = onListLineClick && (listLines[index] ?? '').trim().length > 0;
189
- 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] ? ((() => {
190
- const detailRow = detailRows[index];
191
- const fieldSelected = detailActive &&
192
- detailRow.field !== undefined &&
193
- detailRow.field === detailActiveField;
194
- const cell = (_jsx(DetailColumnRow, { row: detailRow, width: peekWidth, selected: fieldSelected }));
195
- return onDetailLineClick && detailRow.field ? (_jsx(Clickable, { onClick: () => onDetailLineClick(index), children: cell })) : (cell);
196
- })()) : (_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}`));
197
- }) }));
198
- }
199
57
  /**
200
58
  * Browser list view. Navigation/selection live in the parent Jotai Provider
201
59
  * (BrowserApp store). Does not create a nested store.
@@ -206,17 +64,20 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
206
64
  const shellBusy = useOverlayBusy();
207
65
  const store = useStore();
208
66
  // Block list input while a long action runs (update/materialize skill row or collection sync).
209
- const actionBusy = Boolean(updatingSkillName) || workingAction === 'sync';
67
+ const actionBusy = Boolean(updatingSkillName) || Boolean(workingAction);
210
68
  // Local braille spinner only while a skill is updating (not a global busy overlay).
211
69
  const updatingFrame = useSpinnerFrame(Boolean(updatingSkillName));
212
70
  const [navigation, setNavigationState] = useAtom(browserNavigationAtom);
213
71
  const [selected, setSelected] = useAtom(browserSelectionAtom);
72
+ const setDetailField = useSetAtom(browserDetailFieldAtom);
214
73
  const navigationRef = useRef(navigation);
215
74
  navigationRef.current = navigation;
216
75
  /** Keep ref in lockstep so multi-key stdin never reads a stale focus/tab. */
217
76
  const setNavigation = (value) => {
218
77
  setNavigationState((current) => {
219
78
  const next = typeof value === 'function' ? value(current) : value;
79
+ if (sameNavigation(current, next))
80
+ return current;
220
81
  navigationRef.current = next;
221
82
  return next;
222
83
  });
@@ -249,22 +110,24 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
249
110
  const cursorRef = useRef(cursor);
250
111
  cursorRef.current = cursor;
251
112
  const setTab = (value) => {
252
- setNavigation((current) => (current ? { ...current, tab: value } : current));
113
+ setNavigation((current) => (current && current.tab !== value ? { ...current, tab: value } : current));
253
114
  };
254
115
  const setQuery = (value) => {
255
- setNavigation((current) => (current ? { ...current, query: value } : current));
116
+ setNavigation((current) => current && current.query !== value ? { ...current, query: value } : current);
256
117
  };
257
118
  const setAgent = (value) => {
258
- setNavigation((current) => (current ? { ...current, agent: value } : current));
119
+ setNavigation((current) => current && current.agent !== value ? { ...current, agent: value } : current);
259
120
  };
260
121
  const setFocus = (value) => {
261
- setNavigation((current) => (current ? { ...current, focus: value } : current));
122
+ setNavigation((current) => current && current.focus !== value ? { ...current, focus: value } : current);
262
123
  };
263
124
  const setCursor = (value) => {
264
125
  setNavigation((current) => {
265
126
  if (!current)
266
127
  return current;
267
128
  const nextCursor = typeof value === 'function' ? value(current.cursor) : value;
129
+ if (nextCursor === current.cursor)
130
+ return current;
268
131
  cursorRef.current = nextCursor;
269
132
  return { ...current, cursor: nextCursor };
270
133
  });
@@ -276,7 +139,7 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
276
139
  const { selectedCollection, selectedProject, selectedGlobal, selectedProjectLocal, selectedGlobalLocal, } = browseSelectionSets(selected, { collection, projectGroups, globalGroups });
277
140
  const selectedUpdates = selectedCollection.filter((skill) => updateCheck.updates.has(skill.name));
278
141
  const { stdout } = useStdout();
279
- // Wide terminals keep the 3-column master-detail chrome even while filtering;
142
+ // Wide terminals keep the 3-column master-detail panes even while filtering;
280
143
  // list rows still apply `query` inside the skill column.
281
144
  const useBrowseHome = masterDetailLayout(stdout.columns, stdout.rows);
282
145
  const useMasterDetail = useBrowseHome;
@@ -285,14 +148,26 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
285
148
  const tabSkills = tab === 'collection'
286
149
  ? collection
287
150
  : tab === 'project'
288
- ? projectGroup?.skills ?? []
151
+ ? projectGroup?.skills ?? EMPTY_SKILLS
289
152
  : tab === 'global'
290
- ? globalGroup?.skills ?? []
291
- : [];
153
+ ? globalGroup?.skills ?? EMPTY_SKILLS
154
+ : EMPTY_SKILLS;
292
155
  const groupRows = useMemo(() => groupedRows(tabSkills, ''), [tabSkills]);
293
- const groups = groupRows.filter((row) => row.type === 'group');
156
+ const groups = useMemo(() => groupRows.filter((row) => row.type === 'group'), [groupRows]);
294
157
  const tagOptions = useMemo(() => tagFilterOptions(tabSkills, groups), [groups, tabSkills]);
295
- const [tagFilter, setTagFilter] = useAtom(browserTagFilterAtom);
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
+ };
296
171
  const [tagCursor, setTagCursor] = useState(0);
297
172
  const tagCursorRef = useRef(tagCursor);
298
173
  tagCursorRef.current = tagCursor;
@@ -316,29 +191,34 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
316
191
  actionSkills.length > 0 &&
317
192
  actionSkills.every((skill) => isCrossAgentInstallable(skill));
318
193
  const canOpenActions = canMaterialize || canInstallToAgents;
319
- const previousTab = useRef(tab);
320
- useEffect(() => {
321
- if (previousTab.current !== tab) {
322
- setCursor(0);
323
- setSelected(new Set());
324
- setTagFilter(TAG_FILTER_ALL);
325
- setTagCursor(0);
326
- previousTab.current = tab;
327
- }
328
- }, [tab]);
329
- const previousAgent = useRef(agent);
330
- useEffect(() => {
331
- if (previousAgent.current !== agent) {
332
- setCursor(0);
333
- setTagFilter(TAG_FILTER_ALL);
334
- setTagCursor(0);
335
- previousAgent.current = agent;
336
- }
337
- }, [agent]);
338
- useEffect(() => {
339
- if (focus === 'agents' && !hasAgentTabs)
340
- setFocus(useMasterDetail ? 'tags' : 'list');
341
- }, [focus, hasAgentTabs, useMasterDetail]);
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
+ };
342
222
  useEffect(() => {
343
223
  if (tab !== 'collection')
344
224
  return;
@@ -375,7 +255,7 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
375
255
  hasGlobalAgents: visibleGlobalGroups.length > 0,
376
256
  });
377
257
  const openDetail = (skill, collection) => {
378
- // Master-detail chrome fills the terminal; browserFrameDimensions still
258
+ // Master-detail panes fills the terminal; browserFrameDimensions still
379
259
  // sizes by list row count and can be only a few lines on a short list.
380
260
  // Full-screen detail must use the terminal viewport, not that stub height.
381
261
  const frameHeight = useBrowseHome
@@ -399,6 +279,9 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
399
279
  : withAgents
400
280
  ? agentPaneViewportHeight
401
281
  : collectionPaneViewportHeight;
282
+ const tabBodyMinHeight = useMasterDetail
283
+ ? Math.max(8, (stdout.rows ?? 24) - 2)
284
+ : frame.frameHeight - 1;
402
285
  const masterListVisibleHeight = Math.max(1, Math.floor(masterDetailBrowseHeight(false) / 2));
403
286
  const masterListOffset = useMasterDetail
404
287
  ? Math.max(0, Math.min(cursor - Math.floor(masterListVisibleHeight / 2), Math.max(0, listRows.length - masterListVisibleHeight)))
@@ -406,10 +289,14 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
406
289
  const peekSkill = (focus === 'list' || focus === 'detail') && currentRow?.type === 'skill'
407
290
  ? currentRow.skill
408
291
  : undefined;
409
- const detailFields = detailEditableFields(tab === 'collection');
292
+ const detailSkill = currentRow?.type === 'skill' ? currentRow.skill : undefined;
293
+ const detailFields = detailEditableFields(tab === 'collection', detailSkill);
410
294
  const activeDetailField = focus === 'detail' && detailFields.length
411
295
  ? detailFields[Math.max(0, Math.min(detailFieldIndex, detailFields.length - 1))]
412
296
  : undefined;
297
+ useEffect(() => {
298
+ setDetailField(focus === 'detail' ? activeDetailField : undefined);
299
+ }, [focus, activeDetailField, setDetailField]);
413
300
  useEffect(() => {
414
301
  if ((focus === 'detail' || focus === 'tags') && !useMasterDetail)
415
302
  setFocus('list');
@@ -459,160 +346,60 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
459
346
  });
460
347
  return;
461
348
  }
462
- // Jump tags: wide master-detail already has a tag column — focus it (no popup).
463
- // Narrow layout still uses a full-content Select over group headers.
464
- if (input === 'g') {
465
- if (useMasterDetail && tagOptions.length > 0) {
466
- const index = Math.max(0, tagOptions.findIndex((option) => option.key === tagFilter));
467
- setTagCursor(index);
468
- tagCursorRef.current = index;
469
- setFocus('tags');
470
- return;
471
- }
472
- if (groups.length) {
473
- setChoosingGroup(true);
474
- }
475
- return;
476
- }
477
349
  if (input === 's' && liveTab === 'collection' && canSync) {
478
350
  return finish({ type: 'sync' });
479
351
  }
480
- // Focus ladder + tab/agent switching: always branch on the live ref so
481
- // multi-key stdin batches each advance from the latest navigation.
482
- if (key.downArrow || key.upArrow || key.leftArrow || key.rightArrow) {
483
- if (liveFocus === 'tabs' || liveFocus === 'agents' || liveFocus === 'tags') {
484
- const direction = key.leftArrow ? -1 : key.rightArrow ? 1 : 0;
485
- setNavigation((current) => {
486
- if (!current)
487
- return current;
488
- const groups = current.tab === 'project'
489
- ? visibleProjectGroups
490
- : current.tab === 'global'
491
- ? visibleGlobalGroups
492
- : [];
493
- const hasAgents = groups.length > 0;
494
- const names = groups.map((group) => group.agent);
495
- if (current.focus === 'tabs') {
496
- if (key.downArrow) {
497
- return {
498
- ...current,
499
- focus: focusAfterDownFromTabs(hasAgents, useMasterDetail),
500
- };
501
- }
502
- if (key.leftArrow || key.rightArrow) {
503
- const next = nextMainTab(current.tab, direction);
504
- return next ? { ...current, tab: next } : current;
505
- }
506
- return current;
507
- }
508
- if (current.focus === 'agents') {
509
- if (key.upArrow)
510
- return { ...current, focus: 'tabs' };
511
- if (key.downArrow) {
512
- return {
513
- ...current,
514
- focus: focusAfterDownFromAgents(useMasterDetail),
515
- };
516
- }
517
- if (key.leftArrow || key.rightArrow) {
518
- const next = nextAgent(names, current.agent || names[0] || '', direction);
519
- return next ? { ...current, agent: next } : current;
520
- }
521
- return current;
522
- }
523
- if (current.focus === 'tags') {
524
- // ↑/↓ move among tag rows (handled below). Only ←/→ change the focus ladder here.
525
- if (key.leftArrow)
526
- return { ...current, focus: focusAfterUpFromTags(hasAgents) };
527
- if (key.rightArrow)
528
- return { ...current, focus: 'list' };
529
- return current;
530
- }
531
- return current;
532
- });
533
- // Tag index moves stay on the tags-local path below when still on tags.
534
- if (liveFocus !== 'tags' || key.leftArrow || key.rightArrow)
535
- return;
536
- }
537
- }
538
- if (liveFocus === 'tabs' || liveFocus === 'agents') {
539
- 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 });
540
357
  }
541
- if (liveFocus === 'tags' || focus === 'tags') {
542
- const selectTag = (index) => {
543
- const option = tagOptions[index];
544
- if (!option)
545
- return;
546
- setTagFilter(option.key);
547
- tagCursorRef.current = index;
548
- setTagCursor(index);
549
- setCursor(0);
550
- };
551
- const liveTagCursor = tagCursorRef.current;
552
- if (key.upArrow) {
553
- if (liveTagCursor === 0)
554
- return setFocus(focusAfterUpFromTags(hasAgentTabs));
555
- selectTag(liveTagCursor - 1);
556
- return;
557
- }
558
- if (key.downArrow) {
559
- if (liveTagCursor >= tagOptions.length - 1)
560
- return setFocus('list');
561
- selectTag(liveTagCursor + 1);
562
- return;
563
- }
564
- if (key.leftArrow)
565
- return setFocus(focusAfterUpFromTags(hasAgentTabs));
566
- if (key.rightArrow) {
567
- selectTag(liveTagCursor);
568
- return setFocus('list');
569
- }
570
- const tagOption = tagOptions[liveTagCursor];
571
- if (input === ' ' && tagOption) {
572
- const paths = tagOption.skills.map((skill) => skill.path);
573
- return setSelected((previous) => {
574
- const next = new Set(previous);
575
- const allSelected = paths.every((path) => previous.has(path));
576
- for (const path of paths)
577
- allSelected ? next.delete(path) : next.add(path);
578
- return next;
579
- });
580
- }
581
- if (key.return || input.includes('\r') || input.includes('\n')) {
582
- selectTag(liveTagCursor);
583
- return setFocus('list');
584
- }
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);
585
387
  return;
586
388
  }
587
- // Right column: move among editable fields (标签 / 备注); Enter opens editor.
588
- if (liveFocus === 'detail' || focus === 'detail') {
389
+ if (liveNav.focus === 'detail') {
589
390
  const detailRow = listRows[cursorRef.current];
590
391
  const skill = detailRow?.type === 'skill' ? detailRow.skill : undefined;
591
- const fields = detailEditableFields(tab === 'collection');
592
- if (key.leftArrow)
593
- return setFocus('list');
594
- if (key.upArrow) {
595
- if (!fields.length)
596
- return;
597
- setDetailFieldIndex((index) => Math.max(0, index - 1));
598
- return;
599
- }
600
- if (key.downArrow) {
601
- if (!fields.length)
602
- return;
603
- setDetailFieldIndex((index) => Math.min(fields.length - 1, index + 1));
604
- return;
605
- }
606
- if (key.rightArrow)
607
- return;
392
+ const fields = detailEditableFields(liveNav.tab === 'collection', skill);
608
393
  const field = fields[detailFieldIndexRef.current] ?? fields[0];
609
394
  if (skill && field && (key.return || input.includes('\r') || input.includes('\n'))) {
395
+ if (field === 'source')
396
+ return finish({ type: 'openSource', skill });
610
397
  if (field === 'tags')
611
398
  return finish({ type: 'editTags', skill });
612
399
  if (field === 'note')
613
400
  return finish({ type: 'editNote', skill });
614
401
  }
615
- if (skill && tab === 'collection') {
402
+ if (skill && liveNav.tab === 'collection') {
616
403
  if (input === 't')
617
404
  return finish({ type: 'editTags', skill });
618
405
  if (input === 'n')
@@ -620,7 +407,7 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
620
407
  }
621
408
  return;
622
409
  }
623
- if ((navigationRef.current?.focus ?? focus) !== 'list')
410
+ if (liveNav.focus !== 'list')
624
411
  return;
625
412
  const row = listRows[cursorRef.current];
626
413
  if (input === 'm' && canOpenActions) {
@@ -756,58 +543,15 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
756
543
  });
757
544
  return;
758
545
  }
759
- if (key.leftArrow && useMasterDetail)
760
- return setFocus('tags');
761
- if (key.upArrow) {
762
- if (cursorRef.current === 0) {
763
- return setFocus(focusAfterUpFromList(useMasterDetail, hasAgentTabs));
764
- }
765
- return setCursor((index) => index - 1);
766
- }
767
- if (key.downArrow) {
768
- return setCursor((index) => Math.min(Math.max(0, listRows.length - 1), index + 1));
769
- }
770
- if (input === ' ' && row) {
771
- const paths = selectableSkills(row).map((skill) => skill.path);
772
- if (!paths.length)
773
- return;
774
- return setSelected((previous) => {
775
- const next = new Set(previous);
776
- const allSelected = paths.every((path) => previous.has(path));
777
- for (const path of paths)
778
- allSelected ? next.delete(path) : next.add(path);
779
- return next;
780
- });
781
- }
782
- // Collection only: wide → focuses detail column; narrow → opens fullscreen detail.
783
- // Project / global: right pane is preview only — no → focus/open detail.
784
- if (key.rightArrow && row?.type === 'skill' && tab === 'collection') {
785
- if (useMasterDetail) {
786
- setDetailFieldIndex(0);
787
- return setFocus('detail');
788
- }
789
- if (!useBrowseHome) {
790
- return openDetail(row.skill, true);
791
- }
546
+ if (key.rightArrow && row?.type === 'skill' && tab === 'collection' && !useMasterDetail) {
547
+ return openDetail(row.skill, true);
792
548
  }
793
549
  if (key.return || input.includes('\r') || input.includes('\n')) {
794
550
  if (tab === 'collection' && selectedCollection.length) {
795
551
  return finish({ type: 'add', skills: selectedCollection });
796
552
  }
797
- // Master-detail collection: Enter focuses detail column (never silent no-op).
798
- // Project/global master-detail: peek-only — no Enter open.
799
- if (useMasterDetail) {
800
- if (tab === 'collection' && row?.type === 'skill') {
801
- setDetailFieldIndex(0);
802
- return setFocus('detail');
803
- }
804
- return;
805
- }
806
- if (tab === 'collection' && row?.type === 'skill') {
807
- return openDetail(row.skill, true);
808
- }
809
- if (tab !== 'collection' && row?.type === 'skill') {
810
- return openDetail(row.skill, false);
553
+ if (row?.type === 'skill') {
554
+ return openDetail(row.skill, tab === 'collection');
811
555
  }
812
556
  }
813
557
  }, {
@@ -840,47 +584,43 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
840
584
  const renderBrowsePane = (paneRows, viewportHeight, options = {}) => {
841
585
  if (useBrowseHome) {
842
586
  const { tagWidth, listWidth, peekWidth } = masterDetailColumns;
843
- const selectedPaths = selected;
844
- const tagActiveIndex = Math.max(0, Math.min(tagCursor, tagOptions.length - 1));
845
- const tagOffset = Math.max(0, Math.min(tagActiveIndex - Math.floor(viewportHeight / 2), Math.max(0, tagOptions.length - viewportHeight)));
846
- const tagLines = collectionCategoryLines(tagOptions, tagCursor, focus === 'tags', tagWidth, viewportHeight);
847
- 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);
848
588
  const detailRows = browseDetailRows(peekSkill, peekWidth, viewportHeight, options.collection ?? false, options.updates ?? new Set(), options.updatingSkillName, updatingFrame);
849
- const headerLine = (left, middle, right) => (_jsxs("box", { flexDirection: "row", children: [_jsxs("box", { width: tagWidth + 1, flexDirection: "row", children: [_jsx(Text, { bold: true, color: termcnColors.muted, wrap: "truncate-end", children: padColumns(left, tagWidth) }), _jsx(Text, { color: termcnColors.border, children: "\u2502" })] }), _jsxs("box", { width: listWidth + 1, flexDirection: "row", children: [_jsx(Text, { bold: true, color: termcnColors.muted, wrap: "truncate-end", children: padColumns(middle, listWidth) }), _jsx(Text, { color: termcnColors.border, children: "\u2502" })] }), _jsx("box", { flexDirection: "row", width: peekWidth, children: _jsx(Text, { bold: true, color: termcnColors.muted, wrap: "truncate-end", children: padColumns(right, peekWidth) }) })] }));
850
- return (_jsxs("box", { flexDirection: "column", children: [_jsx(Text, { color: termcnColors.border, wrap: "truncate-end", children: masterDetailSeparator(tagWidth, listWidth, peekWidth, 'top', true) }), headerLine(t('common.tags'), t('common.skill'), t('common.detail')), masterDetailBlankRow(tagWidth, listWidth, peekWidth), _jsx(MasterDetailBody, { tagLines: tagLines, listLines: listLines, peekLines: [], tagWidth: tagWidth, listWidth: listWidth, peekWidth: peekWidth, tagActive: focus === 'tags', listActive: focus === 'list', detailActive: focus === 'detail', ...(activeDetailField ? { detailActiveField: activeDetailField } : {}), collectionHome: true, ...(listActiveLineIndexes ? { listActiveLineIndexes } : {}), ...(listSelectedLineIndexes ? { listSelectedLineIndexes } : {}), detailRows: detailRows, onTagLineClick: (visibleIndex) => {
851
- const absolute = tagOffset + visibleIndex;
852
- if (absolute < 0 || absolute >= tagOptions.length)
853
- return;
854
- const option = tagOptions[absolute];
855
- if (!option)
856
- return;
857
- setTagFilter(option.key);
858
- setTagCursor(absolute);
859
- setCursor(0);
860
- setFocus('tags');
861
- }, onListLineClick: (visibleIndex) => {
862
- // Paired name/summary lines → skill index.
863
- // Click focuses the row only; Space toggles multi-select.
864
- const skillIndex = skillOffset + Math.floor(visibleIndex / 2);
865
- if (skillIndex < 0 || skillIndex >= paneRows.length)
866
- return;
867
- setCursor(skillIndex);
868
- setFocus('list');
869
- }, onDetailLineClick: (visibleIndex) => {
870
- const row = detailRows[visibleIndex];
871
- if (!row?.field)
872
- return;
873
- const index = detailFields.indexOf(row.field);
874
- if (index < 0)
875
- return;
876
- setDetailFieldIndex(index);
877
- setFocus('detail');
878
- }, onListScroll: (delta) => {
879
- setFocus('list');
880
- setCursor((index) => Math.max(0, Math.min(Math.max(0, paneRows.length - 1), index + delta)));
881
- } }), _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
+ } }));
882
622
  }
883
- 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) => {
884
624
  // Click focuses the row only; Space toggles multi-select.
885
625
  setCursor(index);
886
626
  setFocus('list');
@@ -889,40 +629,46 @@ export function Browser({ projectGroups, collection, globalGroups, canSync, chec
889
629
  setCursor((index) => Math.max(0, Math.min(Math.max(0, paneRows.length - 1), index + delta)));
890
630
  }, ...options }));
891
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
+ });
892
645
  const tabs = [
893
646
  {
894
647
  key: 'project',
895
648
  label: t('browser.tabProject', { count: project.length }),
896
- content: (_jsxs("box", { flexDirection: "column", minHeight: frame.frameHeight - 1, children: [_jsx(AgentTabs, { groups: visibleProjectGroups, agent: activeProjectAgent, focused: !shellBusy && !searching && focus === 'agents', onSelect: (name) => {
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) => {
897
653
  setAgent(name);
898
654
  setCursor(0);
899
- } }), renderBrowsePane(listRows, browseViewportHeight(true), {
900
- showSource: true,
901
- showReferences: true,
902
- showGroup: Boolean(query.trim()),
903
- })] })),
655
+ } }), activeBrowsePane] })) : null,
904
656
  },
905
657
  {
906
658
  key: 'global',
907
659
  label: t('browser.tabGlobal', { count: globalGroups.reduce((count, group) => count + group.skills.length, 0) }),
908
- content: (_jsxs("box", { flexDirection: "column", minHeight: frame.frameHeight - 1, children: [_jsx(AgentTabs, { groups: visibleGlobalGroups, agent: activeGlobalAgent, focused: !shellBusy && !searching && focus === 'agents', onSelect: (name) => {
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) => {
909
664
  setAgent(name);
910
665
  setCursor(0);
911
- } }), renderBrowsePane(listRows, browseViewportHeight(true), {
912
- showSource: true,
913
- showGroup: Boolean(query.trim()),
914
- })] })),
666
+ } }), activeBrowsePane] })) : null,
915
667
  },
916
668
  {
917
669
  key: 'collection',
918
670
  label: t('browser.tabCollection', { count: collection.length }),
919
- content: (_jsx("box", { flexDirection: "column", minHeight: frame.frameHeight - 1, children: renderBrowsePane(listRows, browseViewportHeight(false), {
920
- preferNote: true,
921
- collection: true,
922
- showGroup: Boolean(query.trim()),
923
- updates: updateCheck.updates,
924
- updatingSkillName,
925
- }) })),
671
+ content: tab === 'collection' ? (_jsx("box", { flexDirection: "column", minHeight: tabBodyMinHeight, children: activeBrowsePane })) : null,
926
672
  },
927
673
  ];
928
674
  // Narrow layout only — wide layout focuses the tag column instead of this Select.