claude-code-hud 0.3.12 → 0.3.13
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/tui/hud.tsx +28 -30
package/package.json
CHANGED
package/tui/hud.tsx
CHANGED
|
@@ -219,9 +219,8 @@ async function readSessionTimeline(cwd: string): Promise<TimelineEntry[]> {
|
|
|
219
219
|
if (!fs.existsSync(projectsDir)) return [];
|
|
220
220
|
|
|
221
221
|
const targetDirName = cwd.replace(/\//g, '-');
|
|
222
|
+
const allFiles: string[] = [];
|
|
222
223
|
|
|
223
|
-
let latestFile: string | null = null;
|
|
224
|
-
let latestMtime = 0;
|
|
225
224
|
try {
|
|
226
225
|
for (const projectHash of fs.readdirSync(projectsDir)) {
|
|
227
226
|
if (projectHash !== targetDirName) continue;
|
|
@@ -229,44 +228,43 @@ async function readSessionTimeline(cwd: string): Promise<TimelineEntry[]> {
|
|
|
229
228
|
if (!fs.statSync(sessionDir).isDirectory()) continue;
|
|
230
229
|
for (const file of fs.readdirSync(sessionDir)) {
|
|
231
230
|
if (!file.endsWith('.jsonl')) continue;
|
|
232
|
-
|
|
233
|
-
try {
|
|
234
|
-
const mtime = fs.statSync(filePath).mtimeMs;
|
|
235
|
-
if (mtime > latestMtime) { latestMtime = mtime; latestFile = filePath; }
|
|
236
|
-
} catch {}
|
|
231
|
+
allFiles.push(join(sessionDir, file));
|
|
237
232
|
}
|
|
238
233
|
}
|
|
239
234
|
} catch {}
|
|
240
235
|
|
|
241
|
-
if (
|
|
236
|
+
if (allFiles.length === 0) return [];
|
|
242
237
|
|
|
243
|
-
const
|
|
244
|
-
const entries: TimelineEntry[] = [];
|
|
238
|
+
const entries: (TimelineEntry & { ts: number })[] = [];
|
|
245
239
|
|
|
246
|
-
for (const
|
|
240
|
+
for (const filePath of allFiles) {
|
|
247
241
|
try {
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
242
|
+
const lines = fs.readFileSync(filePath, 'utf-8').split('\n').filter(Boolean);
|
|
243
|
+
for (const line of lines) {
|
|
244
|
+
try {
|
|
245
|
+
const obj = JSON.parse(line);
|
|
246
|
+
if (obj.type !== 'user') continue;
|
|
247
|
+
const content = obj.message?.content;
|
|
248
|
+
if (Array.isArray(content) && content.some((b: any) => b.type === 'tool_result')) continue;
|
|
249
|
+
const textBlock = Array.isArray(content)
|
|
250
|
+
? content.find((b: any) => b.type === 'text')
|
|
251
|
+
: null;
|
|
252
|
+
const text: string = textBlock?.text ?? (typeof content === 'string' ? content : '');
|
|
253
|
+
if (!text.trim()) continue;
|
|
254
|
+
|
|
255
|
+
const tsStr: string = obj.timestamp ?? '';
|
|
256
|
+
const tsNum = tsStr ? new Date(tsStr).getTime() : 0;
|
|
257
|
+
const time = tsStr ? new Date(tsStr).toTimeString().slice(0, 5) : '';
|
|
258
|
+
|
|
259
|
+
entries.push({ ts: tsNum, time, text: text.replace(/\n/g, ' ').slice(0, 80) });
|
|
260
|
+
} catch {}
|
|
263
261
|
}
|
|
264
|
-
|
|
265
|
-
entries.push({ time, text: text.replace(/\n/g, ' ').slice(0, 80) });
|
|
266
262
|
} catch {}
|
|
267
263
|
}
|
|
268
264
|
|
|
269
|
-
return
|
|
265
|
+
// Sort all sessions by time, return last 50
|
|
266
|
+
entries.sort((a, b) => a.ts - b.ts);
|
|
267
|
+
return entries.slice(-50).map(({ time, text }) => ({ time, text }));
|
|
270
268
|
}
|
|
271
269
|
|
|
272
270
|
// ── UI Components ──────────────────────────────────────────────────────────
|
|
@@ -845,7 +843,7 @@ function App() {
|
|
|
845
843
|
let debounceTimer: ReturnType<typeof setTimeout> | null = null;
|
|
846
844
|
watcher.on('change', () => {
|
|
847
845
|
if (debounceTimer) clearTimeout(debounceTimer);
|
|
848
|
-
debounceTimer = setTimeout(refresh,
|
|
846
|
+
debounceTimer = setTimeout(refresh, 2000);
|
|
849
847
|
});
|
|
850
848
|
});
|
|
851
849
|
}
|