@jxtools/promptline 1.3.2 → 1.3.3

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.2",
3
+ "version": "1.3.3",
4
4
  "type": "module",
5
5
  "license": "ISC",
6
6
  "bin": {
package/src/api/client.ts CHANGED
@@ -30,6 +30,9 @@ export const api = {
30
30
  deleteSession: (project: string, sessionId: string) =>
31
31
  request<{ deleted: string }>(sessionUrl(project, sessionId), { method: 'DELETE' }),
32
32
 
33
+ clearPrompts: (project: string, sessionId: string) =>
34
+ request<{ cleared: number }>(`${sessionUrl(project, sessionId)}/prompts`, { method: 'DELETE' }),
35
+
33
36
  addPrompt: (project: string, sessionId: string, text: string) =>
34
37
  request<Prompt>(`${sessionUrl(project, sessionId)}/prompts`, {
35
38
  method: 'POST',
@@ -150,6 +150,11 @@ export function deletePrompt(session: SessionQueue, promptId: string): Prompt |
150
150
  return session.prompts.splice(idx, 1)[0];
151
151
  }
152
152
 
153
+ export function clearPrompts(session: SessionQueue): Prompt[] {
154
+ const removed = session.prompts.splice(0);
155
+ return removed;
156
+ }
157
+
153
158
  export function reorderPrompts(session: SessionQueue, order: string[]): string | null {
154
159
  const promptMap = new Map(session.prompts.map(p => [p.id, p]));
155
160
  for (const id of order) {
@@ -35,10 +35,10 @@ export function SessionSection({ session, project, onMutate, defaultExpanded = t
35
35
  const [draggingId, setDraggingId] = useState<string | null>(null);
36
36
  const dragSourceRef = useRef<string | null>(null);
37
37
 
38
- async function handleDeleteSession(e: React.MouseEvent) {
38
+ async function handleClearPrompts(e: React.MouseEvent) {
39
39
  e.stopPropagation();
40
40
  try {
41
- await api.deleteSession(project, session.sessionId);
41
+ await api.clearPrompts(project, session.sessionId);
42
42
  onMutate();
43
43
  } catch {
44
44
  // Silent fail
@@ -148,18 +148,20 @@ export function SessionSection({ session, project, onMutate, defaultExpanded = t
148
148
 
149
149
  </span>
150
150
  </button>
151
- <button
152
- type="button"
153
- onClick={handleDeleteSession}
154
- className={[
155
- 'absolute right-2 top-1/2 -translate-y-1/2 p-1.5 rounded cursor-pointer',
156
- 'text-[var(--color-muted)]/40 hover:text-red-400 hover:bg-red-400/10',
157
- 'transition-all duration-100 focus:outline-none',
158
- ].join(' ')}
159
- aria-label="Delete session"
160
- >
161
- <TrashIcon />
162
- </button>
151
+ {session.prompts.length > 0 && (
152
+ <button
153
+ type="button"
154
+ onClick={handleClearPrompts}
155
+ className={[
156
+ 'absolute right-2 top-1/2 -translate-y-1/2 p-1.5 rounded cursor-pointer',
157
+ 'text-[var(--color-muted)]/40 hover:text-red-400 hover:bg-red-400/10',
158
+ 'transition-all duration-100 focus:outline-none',
159
+ ].join(' ')}
160
+ aria-label="Clear prompts"
161
+ >
162
+ <TrashIcon />
163
+ </button>
164
+ )}
163
165
  </div>
164
166
 
165
167
  {/* Session content */}
@@ -17,6 +17,7 @@ import {
17
17
  addPrompt,
18
18
  updatePrompt,
19
19
  deletePrompt,
20
+ clearPrompts,
20
21
  reorderPrompts,
21
22
  } from './src/backend/queue-store.ts';
22
23
 
@@ -283,6 +284,21 @@ async function handleApi(
283
284
  return jsonError(res, 405, `Method ${method} not allowed`);
284
285
  }
285
286
 
287
+ // DELETE /api/projects/:project/sessions/:sessionId/prompts
288
+ if (
289
+ segments[0] === 'projects' && segments[2] === 'sessions' &&
290
+ segments[4] === 'prompts' && segments.length === 5 && method === 'DELETE'
291
+ ) {
292
+ const project = segments[1];
293
+ const sessionId = segments[3];
294
+ const session = readSession(QUEUES_DIR, project, sessionId);
295
+ if (!session) return jsonError(res, 404, 'Session not found');
296
+
297
+ const removed = clearPrompts(session);
298
+ writeSession(QUEUES_DIR, project, session);
299
+ return json(res, 200, { cleared: removed.length });
300
+ }
301
+
286
302
  // /api/projects/:project/sessions/:sessionId/prompts
287
303
  if (
288
304
  segments[0] === 'projects' && segments[2] === 'sessions' &&