tycono 0.3.14 → 0.3.15
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/package.json +1 -1
- package/src/tui/components/PanelMode.tsx +103 -28
package/package.json
CHANGED
|
@@ -100,6 +100,8 @@ const PanelModeInner: React.FC<PanelModeProps> = ({
|
|
|
100
100
|
const [termHeight, setTermHeight] = useState(process.stdout.rows || 30);
|
|
101
101
|
const [rightTab, setRightTab] = useState<RightTab>('stream');
|
|
102
102
|
const [docsIndex, setDocsIndex] = useState(0);
|
|
103
|
+
const [docsFilter, setDocsFilter] = useState<'all' | 'wave' | 'kb' | 'projects'>('all');
|
|
104
|
+
const [docsPreview, setDocsPreview] = useState(false); // true = file preview mode
|
|
103
105
|
|
|
104
106
|
useEffect(() => {
|
|
105
107
|
const fn = () => setTermHeight(process.stdout.rows || 30);
|
|
@@ -119,7 +121,10 @@ const PanelModeInner: React.FC<PanelModeProps> = ({
|
|
|
119
121
|
|
|
120
122
|
// Key handling
|
|
121
123
|
useInput((input, key) => {
|
|
122
|
-
if (key.escape) {
|
|
124
|
+
if (key.escape) {
|
|
125
|
+
if (docsPreview) { setDocsPreview(false); return; }
|
|
126
|
+
onEscape(); return;
|
|
127
|
+
}
|
|
123
128
|
if (input === 'h' || key.leftArrow) {
|
|
124
129
|
const tabs: RightTab[] = ['stream', 'docs', 'info'];
|
|
125
130
|
const idx = tabs.indexOf(rightTab);
|
|
@@ -145,18 +150,37 @@ const PanelModeInner: React.FC<PanelModeProps> = ({
|
|
|
145
150
|
}
|
|
146
151
|
if (key.return) {
|
|
147
152
|
if (rightTab === 'docs' && selectedDocPath) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
153
|
+
if (docsPreview) {
|
|
154
|
+
// In preview → open in vim
|
|
155
|
+
try {
|
|
156
|
+
const editor = process.env.EDITOR || 'vim';
|
|
157
|
+
execSync(`${editor} "${selectedDocPath}"`, { stdio: 'inherit' });
|
|
158
|
+
} catch { /* ignore */ }
|
|
159
|
+
setDocsPreview(false);
|
|
160
|
+
} else {
|
|
161
|
+
// In list → toggle preview
|
|
162
|
+
setDocsPreview(true);
|
|
163
|
+
}
|
|
164
|
+
return;
|
|
152
165
|
} else {
|
|
153
166
|
onSelect();
|
|
154
167
|
}
|
|
155
168
|
return;
|
|
156
169
|
}
|
|
157
|
-
//
|
|
170
|
+
// Docs filter 1-4
|
|
171
|
+
if (rightTab === 'docs') {
|
|
172
|
+
const filters = ['all', 'wave', 'kb', 'projects'] as const;
|
|
173
|
+
const fi = parseInt(input, 10);
|
|
174
|
+
if (fi >= 1 && fi <= 4) {
|
|
175
|
+
setDocsFilter(filters[fi - 1]);
|
|
176
|
+
setDocsIndex(0);
|
|
177
|
+
setDocsPreview(false);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
// Wave switch 1-9 (not in docs filter mode)
|
|
158
182
|
const num = parseInt(input, 10);
|
|
159
|
-
if (num >= 1 && num <= 9 && num <= waves.length) {
|
|
183
|
+
if (rightTab !== 'docs' && num >= 1 && num <= 9 && num <= waves.length) {
|
|
160
184
|
onFocusWave(waves[num - 1].waveId);
|
|
161
185
|
}
|
|
162
186
|
});
|
|
@@ -217,40 +241,91 @@ const PanelModeInner: React.FC<PanelModeProps> = ({
|
|
|
217
241
|
rightContentLines.push(`Sessions: ${waveSessionCount} Events: ${events.length}`);
|
|
218
242
|
rightContentLines.push(`Stream: ${streamStatus}`);
|
|
219
243
|
} else if (rightTab === 'docs') {
|
|
220
|
-
// Docs: scan
|
|
244
|
+
// Docs: scan + filter + ★ wave artifacts + preview
|
|
221
245
|
try {
|
|
222
|
-
const
|
|
223
|
-
const
|
|
224
|
-
const mdPaths: string[] = []; // full paths for vim
|
|
246
|
+
const skipDirs = new Set(['.git', 'node_modules', '.tycono', '.worktrees', 'dist', '.claude', '.obsidian']);
|
|
247
|
+
const allMdFiles: Array<{ rel: string; full: string }> = [];
|
|
225
248
|
const walk = (dir: string, depth: number) => {
|
|
226
|
-
if (depth > 3 ||
|
|
249
|
+
if (depth > 3 || allMdFiles.length > 300) return;
|
|
227
250
|
try {
|
|
228
251
|
for (const e of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
229
|
-
if (
|
|
252
|
+
if (skipDirs.has(e.name)) continue;
|
|
230
253
|
const full = path.join(dir, e.name);
|
|
231
254
|
if (e.isDirectory()) walk(full, depth + 1);
|
|
232
255
|
else if (e.name.endsWith('.md')) {
|
|
233
|
-
|
|
234
|
-
mdPaths.push(full);
|
|
256
|
+
allMdFiles.push({ rel: full.replace(companyRoot + '/', ''), full });
|
|
235
257
|
}
|
|
236
258
|
}
|
|
237
259
|
} catch {}
|
|
238
260
|
};
|
|
239
261
|
walk(companyRoot, 0);
|
|
240
|
-
|
|
241
|
-
|
|
262
|
+
allMdFiles.sort((a, b) => a.rel.localeCompare(b.rel));
|
|
263
|
+
|
|
264
|
+
// Wave artifact files (from SSE events)
|
|
265
|
+
const waveFiles = new Set<string>();
|
|
266
|
+
for (const ev of events) {
|
|
267
|
+
if (ev.type === 'tool:start') {
|
|
268
|
+
const name = (ev.data.name as string) ?? '';
|
|
269
|
+
const inp = ev.data.input as Record<string, unknown> | undefined;
|
|
270
|
+
if (['Write', 'Edit', 'NotebookEdit'].includes(name) && inp?.file_path) {
|
|
271
|
+
waveFiles.add(String(inp.file_path));
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// Apply filter
|
|
277
|
+
const filtered = allMdFiles.filter(f => {
|
|
278
|
+
if (docsFilter === 'wave') return waveFiles.has(f.full);
|
|
279
|
+
if (docsFilter === 'kb') return f.rel.startsWith('knowledge/');
|
|
280
|
+
if (docsFilter === 'projects') return f.rel.startsWith('projects/');
|
|
281
|
+
return true; // 'all'
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
// Sort: wave files first
|
|
285
|
+
filtered.sort((a, b) => {
|
|
286
|
+
const aw = waveFiles.has(a.full) ? 0 : 1;
|
|
287
|
+
const bw = waveFiles.has(b.full) ? 0 : 1;
|
|
288
|
+
if (aw !== bw) return aw - bw;
|
|
289
|
+
return a.rel.localeCompare(b.rel);
|
|
290
|
+
});
|
|
291
|
+
|
|
242
292
|
// Cap docsIndex
|
|
243
|
-
const cappedIdx = Math.min(docsIndex,
|
|
244
|
-
if (cappedIdx !== docsIndex) setDocsIndex(
|
|
245
|
-
selectedDocPath =
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
293
|
+
const cappedIdx = Math.min(docsIndex, Math.max(0, filtered.length - 1));
|
|
294
|
+
if (cappedIdx !== docsIndex) setDocsIndex(cappedIdx);
|
|
295
|
+
selectedDocPath = filtered[cappedIdx]?.full ?? null;
|
|
296
|
+
|
|
297
|
+
if (docsPreview && selectedDocPath) {
|
|
298
|
+
// === Preview mode ===
|
|
299
|
+
const previewLines: string[] = [];
|
|
300
|
+
try {
|
|
301
|
+
const content = fs.readFileSync(selectedDocPath, 'utf-8');
|
|
302
|
+
previewLines.push(...content.split('\n').slice(0, contentHeight - 3));
|
|
303
|
+
} catch { previewLines.push('(cannot read)'); }
|
|
304
|
+
const shortName = selectedDocPath.split('/').slice(-2).join('/');
|
|
305
|
+
rightContentLines.push(`${waveFiles.has(selectedDocPath) ? '\u2605 ' : ''}${shortName} [Esc] back [Enter] ${process.env.EDITOR || 'vim'}`);
|
|
306
|
+
rightContentLines.push('\u2500'.repeat(Math.min(50, rightWidth)));
|
|
307
|
+
for (const pl of previewLines) {
|
|
308
|
+
if (rightContentLines.length >= contentHeight) break;
|
|
309
|
+
rightContentLines.push(pl.slice(0, rightWidth));
|
|
310
|
+
}
|
|
311
|
+
} else {
|
|
312
|
+
// === List mode ===
|
|
313
|
+
const filterLabels = ['1:All', '2:\u2605Wave', '3:KB', '4:Projects'];
|
|
314
|
+
const filterBar = filterLabels.map((f, i) => {
|
|
315
|
+
const key = ['all', 'wave', 'kb', 'projects'][i];
|
|
316
|
+
return key === docsFilter ? `[${f}]` : ` ${f} `;
|
|
317
|
+
}).join(' ');
|
|
318
|
+
rightContentLines.push(`${filterBar} ${filtered.length} docs [j/k] browse [Enter] preview`);
|
|
319
|
+
|
|
320
|
+
const maxVisible = Math.max(5, contentHeight - 3);
|
|
321
|
+
const scrollStart = Math.max(0, Math.min(cappedIdx - 3, filtered.length - maxVisible));
|
|
322
|
+
for (let i = scrollStart; i < Math.min(scrollStart + maxVisible, filtered.length); i++) {
|
|
323
|
+
const selected = i === cappedIdx;
|
|
324
|
+
const isWave = waveFiles.has(filtered[i].full);
|
|
325
|
+
const prefix = selected ? '\u25B6 ' : ' ';
|
|
326
|
+
const star = isWave ? '\u2605' : ' ';
|
|
327
|
+
rightContentLines.push(`${prefix}${star} ${filtered[i].rel.slice(0, rightWidth - 6)}`);
|
|
328
|
+
}
|
|
254
329
|
}
|
|
255
330
|
} catch {
|
|
256
331
|
rightContentLines.push('Cannot scan documents');
|