@codemem/server 0.33.0-alpha.2 → 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
@@ -2606,9 +2606,11 @@ function redactSyncAttemptError(error) {
2606
2606
  return "sync attempt failed; enable diagnostics for details";
2607
2607
  }
2608
2608
  function mapSyncAttemptRow(row, showDiag, addresses) {
2609
+ const redactedError = redactSyncAttemptError(row.error);
2609
2610
  return {
2610
2611
  ...row,
2611
- error: showDiag ? row.error : redactSyncAttemptError(row.error),
2612
+ error: showDiag ? row.error : redactedError,
2613
+ error_redacted: !showDiag && redactedError != null,
2612
2614
  status: attemptStatus(row),
2613
2615
  address: showDiag && addresses?.length ? addresses[0] : null
2614
2616
  };
@@ -2651,6 +2653,7 @@ function legacySharedReviewSummary(store) {
2651
2653
  if (isOwnedBySelf) existing.reassignable_memory_count += 1;
2652
2654
  else existing.peer_owned_memory_count += 1;
2653
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));
2654
2657
  continue;
2655
2658
  }
2656
2659
  groupsByIdentity.set(identity.value, {
@@ -2661,6 +2664,7 @@ function legacySharedReviewSummary(store) {
2661
2664
  reassignable_memory_count: isOwnedBySelf ? 1 : 0,
2662
2665
  peer_owned_memory_count: isOwnedBySelf ? 0 : 1,
2663
2666
  last_updated_at: rowUpdatedAt,
2667
+ memory_samples: [legacySharedReviewMemorySample(row, isOwnedBySelf)],
2664
2668
  suggested_scope_id: suggestedScope ?? null,
2665
2669
  suggestion_reason: suggestedScope ? candidate?.suggestion_reason ?? "Existing project mapping can be reviewed as a destination, but legacy data is not promoted automatically." : null
2666
2670
  });
@@ -2682,13 +2686,38 @@ function legacySharedReviewSummary(store) {
2682
2686
  target_scopes: targetScopes
2683
2687
  };
2684
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
+ }
2685
2710
  function legacySharedReviewRows(store) {
2686
2711
  return store.db.prepare(`SELECT m.id,
2687
2712
  m.rev,
2688
2713
  m.active,
2689
2714
  m.deleted_at,
2715
+ m.created_at,
2690
2716
  m.updated_at,
2691
2717
  m.scope_id,
2718
+ m.kind,
2719
+ m.title,
2720
+ substr(m.body_text, 1, ?) AS body_text,
2692
2721
  s.project,
2693
2722
  s.cwd,
2694
2723
  s.git_remote,
@@ -2701,7 +2730,8 @@ function legacySharedReviewRows(store) {
2701
2730
  LEFT JOIN sessions s ON s.id = m.session_id
2702
2731
  WHERE m.scope_id = ?
2703
2732
  AND m.active = 1
2704
- 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);
2705
2735
  }
2706
2736
  function legacySharedReviewConfirmationToken(input) {
2707
2737
  const ownedBySelf = input.store.buildOwnershipPredicate();
@@ -3602,7 +3632,9 @@ function syncRoutes(getStore, getSyncRuntimeStatus) {
3602
3632
  try {
3603
3633
  const workspaceIdentity = optionalViewerStrictString(body, "workspace_identity") ?? "";
3604
3634
  const project = optionalViewerStrictString(body, "project") ?? "";
3635
+ const [deviceId] = ensureDeviceIdentity(store.db, { keysDir: syncKeysDir() });
3605
3636
  const result = reassignProjectScopeInventoryProject(store.db, {
3637
+ deviceId,
3606
3638
  project,
3607
3639
  workspaceIdentity
3608
3640
  });