@sentry/junior-memory 0.124.1 → 0.124.2

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/src/user-pages.ts CHANGED
@@ -1,7 +1,10 @@
1
- /** Project viewer-owned memories into Junior's core-rendered user page. */
1
+ /** Project viewer-visible memories into Junior's core-rendered user page. */
2
2
  import type { PluginUserPageDefinition } from "@sentry/junior-plugin-api";
3
3
  import { createViewerMemories } from "./personal";
4
- import type { PersonalMemoryRecord } from "./personal-store";
4
+ import type {
5
+ MemoryVisibility,
6
+ PersonalMemoryRecord,
7
+ } from "./personal-store";
5
8
  import type { MemoryDb } from "./store";
6
9
 
7
10
  function titleCase(value: string): string {
@@ -22,31 +25,33 @@ function originLabel(origin: PersonalMemoryRecord["origin"]): string {
22
25
  return "Other";
23
26
  }
24
27
 
28
+ function visibilityLabel(visibility: MemoryVisibility): string {
29
+ return visibility === "public" ? "Public" : "Private";
30
+ }
31
+
25
32
  function pageFilter(filter: string | undefined): {
26
- kind?: "preference";
27
- origin?: "automatic" | "explicit";
33
+ visibility?: MemoryVisibility;
28
34
  } {
29
- if (filter === "preferences") return { kind: "preference" };
30
- if (filter === "automatic") return { origin: "automatic" };
31
- if (filter === "explicit") return { origin: "explicit" };
35
+ if (filter === "private") return { visibility: "private" };
36
+ if (filter === "public") return { visibility: "public" };
32
37
  return {};
33
38
  }
34
39
 
35
40
  function pageEmptyText(input: { filter?: string; query?: string }): string {
36
41
  if (input.query) return "No memories matched your search.";
37
- if (input.filter === "preferences") return "No preferences yet.";
38
- if (input.filter === "automatic") return "No learned memories yet.";
39
- if (input.filter === "explicit") return "No saved memories yet.";
40
- return "No personal memories yet.";
42
+ if (input.filter === "private") return "No private memories yet.";
43
+ if (input.filter === "public") return "No public memories yet.";
44
+ return "No memories yet.";
41
45
  }
42
46
 
43
- /** Create the interactive personal Memories dashboard page. */
47
+ /** Create the interactive Memories dashboard page. */
44
48
  export function createMemoryUserPage(): PluginUserPageDefinition {
45
49
  return {
46
50
  id: "memories",
47
51
  label: "Memories",
48
52
  navigation: "primary",
49
- description: "Personal facts and preferences Junior remembers about you.",
53
+ description:
54
+ "Personal and public memories Junior can use across conversations.",
50
55
  async read(ctx, input) {
51
56
  const memories = createViewerMemories(
52
57
  ctx.db as MemoryDb,
@@ -64,22 +69,28 @@ export function createMemoryUserPage(): PluginUserPageDefinition {
64
69
  ...(page.nextCursor ? { nextCursor: page.nextCursor } : {}),
65
70
  searchPlaceholder: "Search memories",
66
71
  records: page.memories.map((memory) => ({
67
- actions: [
68
- {
69
- confirmation: "Forget this memory?",
70
- href: `/api/plugins/memory/memories/${encodeURIComponent(memory.id)}`,
71
- label: "Forget",
72
- method: "DELETE" as const,
73
- tone: "danger" as const,
74
- },
75
- ],
72
+ actions:
73
+ memory.visibility === "private"
74
+ ? [
75
+ {
76
+ confirmation: "Forget this memory?",
77
+ href: `/api/plugins/memory/memories/${encodeURIComponent(memory.id)}`,
78
+ label: "Forget",
79
+ method: "DELETE" as const,
80
+ tone: "danger" as const,
81
+ },
82
+ ]
83
+ : [],
76
84
  id: memory.id,
77
85
  title: memory.content,
78
86
  metadata: [
79
87
  { label: "Type", value: titleCase(memory.kind) },
80
88
  { label: "Learned", value: originLabel(memory.origin) },
81
89
  { label: "Source", value: titleCase(memory.sourcePlatform) },
82
- { label: "Visibility", value: "Only you" },
90
+ {
91
+ label: "Visibility",
92
+ value: visibilityLabel(memory.visibility),
93
+ },
83
94
  { label: "Remembered", value: rememberedDate(memory.createdAtMs) },
84
95
  { label: "Observed", value: rememberedDate(memory.observedAtMs) },
85
96
  {