Skip to content

Commit 006650b

Browse files
committed
chat list: active-only by default; --stale opts into the stale section
1 parent ca1c9a4 commit 006650b

1 file changed

Lines changed: 26 additions & 23 deletions

File tree

‎bin/thatch‎

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ function usage(): never {
4949
Full conversation as OpenAI chat-completions JSONL
5050
thatch session search <query> [--session <id>] [--regex] [--limit N]
5151
JSONL of matching parts across sessions (decoded content)
52-
thatch chat list [--active] [--stale N|all]
53-
Registered chat sessions, grouped Active/Stale. --active
54-
shows only fresh sessions (no stale section):
55-
name, age, status, project, topic.
56-
--stale N (days) hides stale sessions
57-
older than N; default 1. --stale all
58-
shows every stale session.
52+
thatch chat list [--stale N|all] Registered chat sessions. Default shows
53+
only active (fresh-heartbeat) sessions:
54+
name, session id, age, status, project,
55+
topic. --stale adds the stale section:
56+
N bounds it to sessions seen in the
57+
last N days (default 1); all shows
58+
every stale session.
5959
thatch chat tail [--once] [--limit N|all] [--match RE]
6060
[--from NAME] [--to NAME] [--since DT] [--until DT]
6161
Follow cross-session chat as a JSONL
@@ -495,29 +495,32 @@ async function chatCommand(rest: string[]): Promise<void> {
495495
// sessions from burying the fresh signal. --stale all restores the
496496
// unbounded view. A bad value dies loudly rather than silently
497497
// shrinking the roster.
498-
const activeOnly = restArgs.includes("--active");
499-
const staleArg = flagValue(restArgs, "--stale");
498+
// Default: active sessions only. --stale [N|all] opts into the
499+
// stale section - bare --stale keeps the one-day display cap, N
500+
// bounds it, all removes it. The value is parsed by hand (not
501+
// flagValue) because bare --stale is meaningful.
502+
const showStale = restArgs.includes("--stale");
503+
const staleIdx = restArgs.indexOf("--stale");
504+
const staleNext = showStale ? restArgs[staleIdx + 1] : undefined;
500505
let staleCapMs: number | null = 24 * 60 * 60 * 1000;
501-
if (staleArg !== undefined) {
502-
if (staleArg === "all") staleCapMs = null;
503-
else if (!/^\d+(\.\d+)?$/.test(staleArg) || Number(staleArg) <= 0) {
504-
console.error(`error: --stale expects a positive number of days or "all", got "${staleArg}"`);
506+
if (staleNext !== undefined) {
507+
if (staleNext === "all") staleCapMs = null;
508+
else if (!/^\d+(\.\d+)?$/.test(staleNext) || Number(staleNext) <= 0) {
509+
console.error(`error: --stale expects a positive number of days or "all", got "${staleNext}"`);
505510
process.exit(1);
506-
} else staleCapMs = Number(staleArg) * 24 * 60 * 60 * 1000;
511+
} else staleCapMs = Number(staleNext) * 24 * 60 * 60 * 1000;
507512
}
508513
let sessions = db.listChatSessions();
509-
if (activeOnly) {
510-
// Vetting view: only the fresh rows, no stale section. The
511-
// boundary is the same heartbeat age the roster's Active section
512-
// uses, so this is exactly that section with the stale header
513-
// (and the --stale window) skipped.
514-
sessions = sessions.filter((r) => chatLiveness(r) === "fresh");
515-
}
514+
if (!showStale) sessions = sessions.filter((r) => chatLiveness(r) === "fresh");
516515
if (sessions.length === 0) {
517-
console.log(activeOnly ? "No active sessions." : "No sessions registered. Sessions join the directory automatically on their first idle (opencode), or via chat_register.");
516+
console.log(
517+
showStale
518+
? "No sessions registered. Sessions join the directory automatically on their first idle (opencode), or via chat_register."
519+
: "No active sessions. (Stale sessions are hidden; run with --stale to include them.)",
520+
);
518521
break;
519522
}
520-
console.log(formatChatRoster(sessions, activeOnly ? null : staleCapMs));
523+
console.log(formatChatRoster(sessions, showStale ? staleCapMs : null));
521524
break;
522525
}
523526

0 commit comments

Comments
 (0)