@jxtools/promptline 1.3.12 → 1.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jxtools/promptline",
3
- "version": "1.3.12",
3
+ "version": "1.3.13",
4
4
  "type": "module",
5
5
  "license": "ISC",
6
6
  "bin": {
@@ -33,7 +33,7 @@ else
33
33
  fi
34
34
 
35
35
  QUEUE_DIR="$(dirname "$QUEUE_FILE")"
36
- export QUEUE_FILE QUEUE_DIR SESSION_ID
36
+ export QUEUE_FILE QUEUE_DIR SESSION_ID QUEUES_BASE
37
37
 
38
38
  python3 << 'PYEOF'
39
39
  import json, os, glob, tempfile
@@ -68,21 +68,24 @@ try:
68
68
  except (json.JSONDecodeError, IOError, OSError):
69
69
  pass
70
70
 
71
- # Close orphaned sessions in the same project
72
- for path in glob.glob(os.path.join(queue_dir, "*.json")):
73
- if os.path.basename(path) == f"{session_id}.json":
71
+ queues_base = os.environ["QUEUES_BASE"]
72
+ for project_dir in glob.glob(os.path.join(queues_base, "*")):
73
+ if not os.path.isdir(project_dir):
74
74
  continue
75
- try:
76
- with open(path, "r") as f:
77
- data = json.load(f)
78
- if data.get("closedAt") is not None:
75
+ for path in glob.glob(os.path.join(project_dir, "*.json")):
76
+ if os.path.basename(path) == f"{session_id}.json":
79
77
  continue
80
- has_pending = any(p.get("status") in ("pending", "running") for p in data.get("prompts", []))
81
- if has_pending:
78
+ try:
79
+ with open(path, "r") as f:
80
+ data = json.load(f)
81
+ if data.get("closedAt") is not None:
82
+ continue
83
+ has_pending = any(p.get("status") in ("pending", "running") for p in data.get("prompts", []))
84
+ if has_pending:
85
+ continue
86
+ close_session(path, now)
87
+ except (json.JSONDecodeError, IOError, OSError):
82
88
  continue
83
- close_session(path, now)
84
- except (json.JSONDecodeError, IOError, OSError):
85
- continue
86
89
 
87
90
  PYEOF
88
91
 
@@ -3,6 +3,7 @@ import { join } from 'node:path';
3
3
  import type { SessionQueue, Prompt, PromptStatus, SessionStatus, QueueStatus, ProjectView, SessionWithStatus } from '../types/queue.ts';
4
4
 
5
5
  export const SESSION_ACTIVE_TIMEOUT_MS = 60_000;
6
+ export const SESSION_EMPTY_IDLE_TIMEOUT_MS = SESSION_ACTIVE_TIMEOUT_MS;
6
7
  export const SESSION_ABANDONED_TIMEOUT_MS = 24 * 60 * 60_000; // 24h safety net
7
8
  const LOCK_STALE_MS = 10_000;
8
9
 
@@ -91,6 +92,9 @@ export function withComputedStatus(session: SessionQueue): SessionQueue & { stat
91
92
  export function isSessionVisible(session: SessionQueue, now: number = Date.now()): boolean {
92
93
  if (hasPendingWork(session)) return true;
93
94
  if (session.closedAt != null) return false;
95
+ if (session.prompts.length === 0 && msSinceLastActivity(session, now) > SESSION_EMPTY_IDLE_TIMEOUT_MS) {
96
+ return false;
97
+ }
94
98
  const msSinceStart = now - new Date(session.startedAt).getTime();
95
99
  return msSinceStart <= SESSION_ABANDONED_TIMEOUT_MS;
96
100
  }