@codemem/server 0.33.0-alpha.3 → 0.33.0

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
@@ -2653,6 +2653,7 @@ function legacySharedReviewSummary(store) {
2653
2653
  if (isOwnedBySelf) existing.reassignable_memory_count += 1;
2654
2654
  else existing.peer_owned_memory_count += 1;
2655
2655
  if (rowUpdatedAt && (!existing.last_updated_at || rowUpdatedAt > existing.last_updated_at)) existing.last_updated_at = rowUpdatedAt;
2656
+ if (existing.memory_samples.length < LEGACY_SHARED_REVIEW_SAMPLE_LIMIT) existing.memory_samples.push(legacySharedReviewMemorySample(row, isOwnedBySelf));
2656
2657
  continue;
2657
2658
  }
2658
2659
  groupsByIdentity.set(identity.value, {
@@ -2663,6 +2664,7 @@ function legacySharedReviewSummary(store) {
2663
2664
  reassignable_memory_count: isOwnedBySelf ? 1 : 0,
2664
2665
  peer_owned_memory_count: isOwnedBySelf ? 0 : 1,
2665
2666
  last_updated_at: rowUpdatedAt,
2667
+ memory_samples: [legacySharedReviewMemorySample(row, isOwnedBySelf)],
2666
2668
  suggested_scope_id: suggestedScope ?? null,
2667
2669
  suggestion_reason: suggestedScope ? candidate?.suggestion_reason ?? "Existing project mapping can be reviewed as a destination, but legacy data is not promoted automatically." : null
2668
2670
  });
@@ -2684,13 +2686,38 @@ function legacySharedReviewSummary(store) {
2684
2686
  target_scopes: targetScopes
2685
2687
  };
2686
2688
  }
2689
+ var LEGACY_SHARED_REVIEW_SAMPLE_LIMIT = 3;
2690
+ var LEGACY_SHARED_REVIEW_BODY_PREVIEW_SQL_LIMIT = 360;
2691
+ function previewText(value, limit = 180) {
2692
+ const normalized = value?.replace(/\s+/g, " ").trim();
2693
+ if (!normalized) return null;
2694
+ return normalized.length > limit ? `${normalized.slice(0, limit - 1)}…` : normalized;
2695
+ }
2696
+ function legacySharedReviewMemorySample(row, isOwnedBySelf) {
2697
+ return {
2698
+ id: row.id,
2699
+ kind: row.kind,
2700
+ title: previewText(row.title, 120) ?? `Memory ${row.id}`,
2701
+ body_preview: previewText(row.body_text),
2702
+ created_at: row.created_at ?? null,
2703
+ updated_at: row.updated_at ?? null,
2704
+ ownership: isOwnedBySelf ? "local" : "peer",
2705
+ project: row.project ?? null,
2706
+ cwd: row.cwd ?? null,
2707
+ git_remote: row.git_remote ?? null
2708
+ };
2709
+ }
2687
2710
  function legacySharedReviewRows(store) {
2688
2711
  return store.db.prepare(`SELECT m.id,
2689
2712
  m.rev,
2690
2713
  m.active,
2691
2714
  m.deleted_at,
2715
+ m.created_at,
2692
2716
  m.updated_at,
2693
2717
  m.scope_id,
2718
+ m.kind,
2719
+ m.title,
2720
+ substr(m.body_text, 1, ?) AS body_text,
2694
2721
  s.project,
2695
2722
  s.cwd,
2696
2723
  s.git_remote,
@@ -2703,7 +2730,8 @@ function legacySharedReviewRows(store) {
2703
2730
  LEFT JOIN sessions s ON s.id = m.session_id
2704
2731
  WHERE m.scope_id = ?
2705
2732
  AND m.active = 1
2706
- AND m.deleted_at IS NULL`).all(LEGACY_SHARED_REVIEW_SCOPE_ID);
2733
+ AND m.deleted_at IS NULL
2734
+ ORDER BY COALESCE(m.updated_at, m.created_at, '') DESC, m.id DESC`).all(LEGACY_SHARED_REVIEW_BODY_PREVIEW_SQL_LIMIT, LEGACY_SHARED_REVIEW_SCOPE_ID);
2707
2735
  }
2708
2736
  function legacySharedReviewConfirmationToken(input) {
2709
2737
  const ownedBySelf = input.store.buildOwnershipPredicate();