promptcase 1.0.6 → 1.0.7

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/dist/index.js CHANGED
File without changes
@@ -287,7 +287,23 @@ export class ClaudeCaptureService {
287
287
  }
288
288
  /**
289
289
  * Get all prompts from all sources (project transcripts + history),
290
- * deduplicated by SHA-256 content hash, sorted newest first.
290
+ * deduplicated by SHA-256 content hash.
291
+ *
292
+ * Sort order depends on whether this is a backfill or an incremental sync:
293
+ *
294
+ * - **Backfill** (`since` is undefined): the daemon's first sync, with no
295
+ * prior cursor. We sort **OLDEST FIRST** so that the server inserts
296
+ * prompts in chronological order. Since the server's `created_at`
297
+ * column defaults to insert time and the dashboard sorts `created_at
298
+ * DESC`, the *most recent* prompt in the batch ends up at the top of
299
+ * the dashboard — matching the user's intuition that "latest shows
300
+ * first."
301
+ *
302
+ * - **Incremental** (`since` is a date): the daemon's subsequent syncs
303
+ * pick up only prompts newer than the cursor. We sort **NEWEST FIRST**
304
+ * so that when the cursor advances we always send the freshest
305
+ * prompts first (and the new cursor lands on the actual latest
306
+ * prompt, not a few-batch-behind one).
291
307
  */
292
308
  async getAllPrompts(since, limit = 100) {
293
309
  const sessions = await this.getSessions();
@@ -326,7 +342,14 @@ export class ClaudeCaptureService {
326
342
  seenHashes.add(prompt.hash);
327
343
  allPrompts.push(prompt);
328
344
  }
329
- allPrompts.sort((a, b) => b.timestamp.getTime() - a.timestamp.getTime());
345
+ // Backfill: oldest first (so newest ends up at top of dashboard).
346
+ // Incremental: newest first (so the cursor advances to actual latest).
347
+ if (since) {
348
+ allPrompts.sort((a, b) => b.timestamp.getTime() - a.timestamp.getTime());
349
+ }
350
+ else {
351
+ allPrompts.sort((a, b) => a.timestamp.getTime() - b.timestamp.getTime());
352
+ }
330
353
  return allPrompts.slice(0, limit);
331
354
  }
332
355
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "promptcase",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "CLI daemon to capture and sync AI prompts to PromptCase web app",
5
5
  "main": "dist/index.js",
6
6
  "bin": {