@sentry/junior-dashboard 0.270.0 → 0.272.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.
Files changed (48) hide show
  1. package/dist/app.js +44 -3
  2. package/dist/client.js +77 -77
  3. package/dist/index.js +40 -3
  4. package/dist/tailwind.css +1 -1
  5. package/package.json +4 -4
  6. package/src/app.ts +2 -0
  7. package/src/client/App.tsx +89 -61
  8. package/src/client/components/ProfileMenu.tsx +0 -24
  9. package/src/client/components/UserInputForm.tsx +38 -7
  10. package/src/client/components/layout/PageHeader.tsx +25 -10
  11. package/src/client/conversations/ConversationPage.tsx +55 -8
  12. package/src/client/conversations/ConversationTranscript.tsx +74 -5
  13. package/src/client/conversations/TranscriptRows.tsx +23 -0
  14. package/src/client/conversations/TranscriptView.tsx +22 -0
  15. package/src/client/conversations/conversationRoutes.ts +30 -3
  16. package/src/client/conversations/queries.ts +30 -5
  17. package/src/client/conversations/transcriptBottomPinning.ts +84 -13
  18. package/src/client/conversations/transcriptReadPosition.ts +267 -0
  19. package/src/client/conversations/transcriptRenderModel.ts +16 -2
  20. package/src/client/pages/automations/AutomationActions.tsx +2 -3
  21. package/src/client/pages/automations/AutomationEditor.tsx +18 -30
  22. package/src/client/pages/automations/AutomationOverview.tsx +2 -2
  23. package/src/client/pages/automations/AutomationVersionsTab.tsx +1 -1
  24. package/src/client/pages/settings/ConnectionsPage.tsx +198 -0
  25. package/src/client/pages/settings/McpSettingsPage.tsx +77 -0
  26. package/src/client/pages/settings/PersonalTokensPage.tsx +198 -0
  27. package/src/client/pages/{SettingsPage.tsx → settings/SettingsPage.tsx} +115 -61
  28. package/src/client/pages/settings/SettingsPageLayout.tsx +45 -0
  29. package/src/client/primaryNav.ts +1 -1
  30. package/src/client/review-desk/ReviewDeskPage.tsx +185 -242
  31. package/src/client/review-desk/ReviewDeskSidebar.tsx +259 -0
  32. package/src/client/review-desk/ReviewItemActions.tsx +1 -10
  33. package/src/client/review-desk/ReviewItemContext.tsx +108 -0
  34. package/src/client/review-desk/ReviewItemDetails.tsx +153 -0
  35. package/src/client/review-desk/ReviewItemView.tsx +159 -0
  36. package/src/client/review-desk/queries.ts +3 -3
  37. package/src/client/review-desk/reviewItemFormat.ts +52 -0
  38. package/src/mock-reporting/read-positions.ts +39 -0
  39. package/src/mock-reporting/routes.ts +26 -1
  40. package/src/tailwind.css +1 -1
  41. package/src/client/components/AGENTS.md +0 -65
  42. package/src/client/components/charts/AGENTS.md +0 -15
  43. package/src/client/conversations/AGENTS.md +0 -38
  44. package/src/client/pages/ConnectionsPage.tsx +0 -207
  45. package/src/client/pages/PersonalTokensPage.tsx +0 -205
  46. package/src/client/pages/automations/AGENTS.md +0 -34
  47. package/src/client/pages/system/AGENTS.md +0 -12
  48. package/src/client/review-desk/ReviewItemDetail.tsx +0 -123
@@ -0,0 +1,259 @@
1
+ import type { ReactNode } from "react";
2
+ import { Link } from "react-router";
3
+ import type {
4
+ AutomationSummary,
5
+ ReviewItemPayload,
6
+ } from "@sentry/junior/api/schema";
7
+
8
+ import { InlineError } from "../components/InlineError";
9
+ import { SearchInput } from "../components/SearchInput";
10
+ import { Skeleton } from "../components/ui/skeleton";
11
+ import { ConversationSectionHeading } from "../conversations/ConversationSectionHeading";
12
+ import { automationPath, formatRelativeTime } from "../format";
13
+ import { pathWithSearch } from "../searchParams";
14
+ import { cn } from "../styles";
15
+ import { reviewItemPath, reviewItemStatusLabel } from "./reviewItemFormat";
16
+
17
+ /** A sidebar group key. The page owns which groups are collapsed. */
18
+ export type InboxGroupKey = "blocked" | "fyi" | "needs-you";
19
+
20
+ type Dot = "accent" | "muted" | "warning" | "closed";
21
+
22
+ const dotClass: Record<Dot, string> = {
23
+ accent: "bg-dashboard-accent",
24
+ closed: "border border-dashboard-text-faint",
25
+ muted: "bg-dashboard-text-faint",
26
+ warning: "bg-amber-300",
27
+ };
28
+
29
+ const rowClass =
30
+ "block min-w-0 rounded-lg px-3 py-2 text-inherit no-underline transition-colors hover:bg-dashboard-fill-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-dashboard-focus";
31
+
32
+ function InboxRow(props: {
33
+ dot: Dot;
34
+ meta: ReactNode;
35
+ selected?: "always" | "wide";
36
+ title: string;
37
+ to: string;
38
+ }) {
39
+ return (
40
+ <li>
41
+ <Link
42
+ aria-current={props.selected ? "page" : undefined}
43
+ className={cn(
44
+ rowClass,
45
+ props.selected === "always" && "bg-dashboard-surface-active",
46
+ props.selected === "wide" && "md:bg-dashboard-surface-active",
47
+ )}
48
+ to={props.to}
49
+ >
50
+ <div className="grid min-w-0 grid-cols-[auto_minmax(0,1fr)] items-start gap-x-2">
51
+ <span
52
+ aria-hidden="true"
53
+ className={cn(
54
+ "mt-[0.4rem] size-2 shrink-0 rounded-full",
55
+ dotClass[props.dot],
56
+ )}
57
+ />
58
+ <span
59
+ className={cn(
60
+ "truncate font-sans text-sm font-medium leading-snug",
61
+ props.dot === "closed"
62
+ ? "text-dashboard-text-muted"
63
+ : "text-dashboard-text",
64
+ )}
65
+ >
66
+ {props.title}
67
+ </span>
68
+ <span className="col-start-2 mt-1 truncate font-sans text-xs leading-tight text-dashboard-text-muted">
69
+ {props.meta}
70
+ </span>
71
+ </div>
72
+ </Link>
73
+ </li>
74
+ );
75
+ }
76
+
77
+ function InboxGroup(props: {
78
+ children: ReactNode;
79
+ collapsed: boolean;
80
+ count: number;
81
+ first: boolean;
82
+ label: string;
83
+ onToggle(): void;
84
+ }) {
85
+ if (props.count === 0) return null;
86
+ return (
87
+ <section aria-label={props.label}>
88
+ <ConversationSectionHeading
89
+ className={cn("px-3 pb-1", props.first ? "pt-1" : "pt-3")}
90
+ collapsed={props.collapsed}
91
+ count={props.count}
92
+ label={props.label}
93
+ onToggle={props.onToggle}
94
+ />
95
+ {props.collapsed ? null : (
96
+ <ul className="m-0 grid list-none gap-0.5 p-0">{props.children}</ul>
97
+ )}
98
+ </section>
99
+ );
100
+ }
101
+
102
+ function InboxRowsLoading() {
103
+ return (
104
+ <div
105
+ aria-busy="true"
106
+ aria-live="polite"
107
+ className="grid gap-0.5"
108
+ role="status"
109
+ >
110
+ <span className="sr-only">Loading review items</span>
111
+ <Skeleton className="mb-1 ml-3 mt-1.5 h-2.5 w-16" />
112
+ {[0, 1, 2, 3, 4].map((row) => (
113
+ <div className="grid gap-1 rounded-lg px-3 py-2" key={row}>
114
+ <Skeleton className={cn("h-4", row % 2 ? "w-3/5" : "w-4/5")} />
115
+ <Skeleton className="h-3 w-2/5 opacity-70" />
116
+ </div>
117
+ ))}
118
+ </div>
119
+ );
120
+ }
121
+
122
+ /**
123
+ * List the inbox: open items that need the viewer, notices, and blocked
124
+ * Automations, each in a group that collapses. A search shows one list of
125
+ * open and archived matches instead.
126
+ */
127
+ export function ReviewDeskSidebar(props: {
128
+ blocked: AutomationSummary[];
129
+ collapsed: ReadonlySet<InboxGroupKey>;
130
+ /** Shown under the groups, such as an empty state or load more. */
131
+ footer?: ReactNode;
132
+ error: boolean;
133
+ fyi: ReviewItemPayload[];
134
+ loading: boolean;
135
+ needsYou: ReviewItemPayload[];
136
+ onSearchChange(value: string): void;
137
+ onToggle(key: InboxGroupKey): void;
138
+ /** Search matches in API order. Set while a search is active. */
139
+ results?: ReviewItemPayload[];
140
+ search: string;
141
+ searchParams: URLSearchParams;
142
+ selectedId?: string;
143
+ /** False while small screens show the list instead of the selected item. */
144
+ selectedShown: boolean;
145
+ /** The title of the Conversation that added an item, when it is known. */
146
+ sourceTitle(item: ReviewItemPayload): string | undefined;
147
+ }) {
148
+ const groups = [
149
+ { items: props.needsYou, key: "needs-you", label: "Needs you" },
150
+ { items: props.fyi, key: "fyi", label: "FYI" },
151
+ ] as const;
152
+ const shown = [
153
+ ...groups.map((group) => group.items.length),
154
+ props.blocked.length,
155
+ ];
156
+ const firstKey = (index: number) =>
157
+ shown.slice(0, index).every((count) => count === 0);
158
+ const itemRow = (item: ReviewItemPayload) => {
159
+ const open = item.status === "open";
160
+ const source = item.automationId ? "Automation" : props.sourceTitle(item);
161
+ const meta = [
162
+ open ? undefined : reviewItemStatusLabel(item),
163
+ source,
164
+ formatRelativeTime(open ? item.createdAt : item.closedAt),
165
+ ];
166
+ return (
167
+ <InboxRow
168
+ dot={open ? (item.kind === "action" ? "accent" : "muted") : "closed"}
169
+ key={item.id}
170
+ meta={meta.filter(Boolean).join(" · ")}
171
+ selected={
172
+ item.id !== props.selectedId
173
+ ? undefined
174
+ : props.selectedShown
175
+ ? "always"
176
+ : "wide"
177
+ }
178
+ title={item.title}
179
+ to={pathWithSearch(reviewItemPath(item.id), props.searchParams)}
180
+ />
181
+ );
182
+ };
183
+
184
+ return (
185
+ <aside className="grid h-full min-h-0 grid-rows-[auto_auto_minmax(0,1fr)] overflow-hidden border-r border-dashboard-border bg-dashboard-surface-panel">
186
+ <div className="px-5 py-3">
187
+ <h2 className="m-0 font-display text-lg font-medium leading-tight text-dashboard-text">
188
+ Inbox
189
+ </h2>
190
+ </div>
191
+ <div className="px-4 pb-2">
192
+ <SearchInput
193
+ label="Search review items"
194
+ onChange={props.onSearchChange}
195
+ placeholder="Search items…"
196
+ size="compact"
197
+ value={props.search}
198
+ />
199
+ </div>
200
+ <nav
201
+ aria-label="Review items"
202
+ className="min-h-0 overflow-y-auto overscroll-contain px-3 pb-[max(0.5rem,env(safe-area-inset-bottom))]"
203
+ >
204
+ {props.error ? (
205
+ <InlineError className="px-3 py-2">
206
+ Could not load review items.
207
+ </InlineError>
208
+ ) : props.loading ? (
209
+ <InboxRowsLoading />
210
+ ) : props.results ? (
211
+ <>
212
+ {props.results.length > 0 ? (
213
+ <ul
214
+ aria-label="Search results"
215
+ className="m-0 grid list-none gap-0.5 p-0 pt-1"
216
+ >
217
+ {props.results.map(itemRow)}
218
+ </ul>
219
+ ) : null}
220
+ {props.footer}
221
+ </>
222
+ ) : (
223
+ <>
224
+ {groups.map((group, index) => (
225
+ <InboxGroup
226
+ collapsed={props.collapsed.has(group.key)}
227
+ count={group.items.length}
228
+ first={firstKey(index)}
229
+ key={group.key}
230
+ label={group.label}
231
+ onToggle={() => props.onToggle(group.key)}
232
+ >
233
+ {group.items.map(itemRow)}
234
+ </InboxGroup>
235
+ ))}
236
+ <InboxGroup
237
+ collapsed={props.collapsed.has("blocked")}
238
+ count={props.blocked.length}
239
+ first={firstKey(2)}
240
+ label="Blocked automations"
241
+ onToggle={() => props.onToggle("blocked")}
242
+ >
243
+ {props.blocked.map((automation) => (
244
+ <InboxRow
245
+ dot="warning"
246
+ key={automation.id}
247
+ meta={automation.statusReason ?? "Blocked"}
248
+ title={automation.title}
249
+ to={automationPath(automation.id)}
250
+ />
251
+ ))}
252
+ </InboxGroup>
253
+ {props.footer}
254
+ </>
255
+ )}
256
+ </nav>
257
+ </aside>
258
+ );
259
+ }
@@ -102,7 +102,7 @@ export function ReviewItemActions(props: { item: ReviewItemPayload }) {
102
102
  }
103
103
  }
104
104
 
105
- // Take and Dismiss are quiet, so the answer or Done stays the main action.
105
+ // Take and Dismiss are quiet, so the answer stays the main action.
106
106
  const secondaryActions = (
107
107
  <>
108
108
  {item.canTake ? (
@@ -149,15 +149,6 @@ export function ReviewItemActions(props: { item: ReviewItemPayload }) {
149
149
  </div>
150
150
  ) : (
151
151
  <div className="flex flex-wrap items-center gap-2">
152
- {item.kind === "notice" ? (
153
- <Button
154
- disabled={action.isPending}
155
- onClick={() => void run({ action: "complete" }).catch(() => {})}
156
- variant="primary"
157
- >
158
- Done
159
- </Button>
160
- ) : null}
161
152
  <div className="flex flex-wrap gap-1 sm:ml-auto">
162
153
  {secondaryActions}
163
154
  </div>
@@ -0,0 +1,108 @@
1
+ import { useEffect, useMemo, useRef, type ReactNode } from "react";
2
+ import type {
3
+ ConversationReportEvent,
4
+ ReviewItemPayload,
5
+ } from "@sentry/junior/api/schema";
6
+
7
+ import { getDashboardAgentName } from "../agentName";
8
+ import { ConversationTranscriptView } from "../conversations/ConversationTranscript";
9
+ import { TranscriptLoading } from "../conversations/TranscriptLoading";
10
+ import { useConversationData } from "../conversations/queries";
11
+ import type { ConversationTranscript } from "../types";
12
+
13
+ /** Messages before the item that the excerpt shows. */
14
+ const BEFORE_COUNT = 3;
15
+ /** Messages after the item that the excerpt shows, newest last. */
16
+ const AFTER_COUNT = 8;
17
+
18
+ /**
19
+ * Split the messages of a Conversation at the time an item was added. Only
20
+ * messages show: the tool call that added the item would repeat its card.
21
+ */
22
+ function conversationExcerpt(
23
+ events: readonly ConversationReportEvent[],
24
+ itemCreatedAt: string,
25
+ ): { after: ConversationReportEvent[]; before: ConversationReportEvent[] } {
26
+ const askedAt = Date.parse(itemCreatedAt);
27
+ const messages = events.filter(
28
+ (event) => event.data.type === "message" && event.data.role !== "system",
29
+ );
30
+ return {
31
+ after: messages
32
+ .filter((event) => Date.parse(event.createdAt) > askedAt)
33
+ .slice(-AFTER_COUNT),
34
+ before: messages
35
+ .filter((event) => Date.parse(event.createdAt) <= askedAt)
36
+ .slice(-BEFORE_COUNT),
37
+ };
38
+ }
39
+
40
+ function Excerpt(props: {
41
+ conversation: ConversationTranscript;
42
+ events: ConversationReportEvent[];
43
+ }) {
44
+ const conversation = useMemo(
45
+ () => ({ ...props.conversation, events: props.events }),
46
+ [props.conversation, props.events],
47
+ );
48
+ return <ConversationTranscriptView conversation={conversation} />;
49
+ }
50
+
51
+ /**
52
+ * Show the end of the Conversation that added an item, split where the agent
53
+ * asked. Returns `fallback` when the viewer cannot read its messages.
54
+ */
55
+ export function ReviewItemContext(props: {
56
+ fallback: ReactNode;
57
+ item: ReviewItemPayload;
58
+ }) {
59
+ const detail = useConversationData(props.item.addedByConversationId);
60
+ const data = detail.data;
61
+ const events = data?.events;
62
+ const excerpt = useMemo(
63
+ () =>
64
+ events ? conversationExcerpt(events, props.item.createdAt) : undefined,
65
+ [events, props.item.createdAt],
66
+ );
67
+ // The first page holds the newest events. Load earlier pages until the
68
+ // page reaches the time the item was added, or history ends.
69
+ const loadPreviousPageRef = useRef(detail.loadPreviousPage);
70
+ loadPreviousPageRef.current = detail.loadPreviousPage;
71
+ const oldest = events?.[0]?.createdAt;
72
+ const loadEarlier =
73
+ oldest !== undefined &&
74
+ Date.parse(oldest) > Date.parse(props.item.createdAt) &&
75
+ detail.hasPreviousPage &&
76
+ !detail.isLoadingPreviousPage &&
77
+ !detail.historyError;
78
+ useEffect(() => {
79
+ if (loadEarlier) loadPreviousPageRef.current();
80
+ }, [loadEarlier, oldest]);
81
+
82
+ if (detail.isPending) return <TranscriptLoading />;
83
+ if (
84
+ !data ||
85
+ !excerpt ||
86
+ data.eventHistory.status !== "available" ||
87
+ excerpt.before.length + excerpt.after.length === 0
88
+ ) {
89
+ return props.fallback;
90
+ }
91
+ return (
92
+ <div className="grid min-w-0 gap-2">
93
+ {excerpt.before.length > 0 ? (
94
+ <Excerpt conversation={data} events={excerpt.before} />
95
+ ) : null}
96
+ {excerpt.after.length > 0 ? (
97
+ <>
98
+ <div className="flex items-center gap-3 py-1 font-sans text-xs font-medium text-dashboard-accent-text">
99
+ <span className="h-px flex-1 bg-dashboard-accent/30" />
100
+ New since {getDashboardAgentName()} asked
101
+ <span className="h-px flex-1 bg-dashboard-accent/30" />
102
+ </div>
103
+ <Excerpt conversation={data} events={excerpt.after} />
104
+ </>
105
+ ) : null}
106
+ </div>
107
+ );
108
+ }
@@ -0,0 +1,153 @@
1
+ import type { ReactNode } from "react";
2
+ import { Link } from "react-router";
3
+ import type { ReviewItemPayload } from "@sentry/junior/api/schema";
4
+
5
+ import { DetailsPanel } from "../components/DetailsPanel";
6
+ import { StatusChip } from "../components/StatusChip";
7
+ import { DetailsCard } from "../conversations/DetailsList";
8
+ import { conversationPath } from "../conversations/conversationRoutes";
9
+ import { DisplayText } from "../display-text/DisplayText";
10
+ import { automationPath, formatRelativeTime } from "../format";
11
+ import { dashboardInlineLinkClass } from "../styles";
12
+ import { useLinkedConversationTitles } from "./queries";
13
+ import {
14
+ assigneeLabel,
15
+ reviewItemStatusLabel,
16
+ reviewItemSubjectHref,
17
+ } from "./reviewItemFormat";
18
+
19
+ function Fact(props: { children: ReactNode; label: string }) {
20
+ return (
21
+ <>
22
+ <dt className="text-dashboard-text-muted">{props.label}</dt>
23
+ <dd className="m-0 min-w-0 break-words text-dashboard-text">
24
+ {props.children}
25
+ </dd>
26
+ </>
27
+ );
28
+ }
29
+
30
+ /**
31
+ * Show the facts of one Review item beside it: its text, assignees, where
32
+ * it came from, and the Conversations linked to it.
33
+ */
34
+ export function ReviewItemDetails(props: {
35
+ item: ReviewItemPayload;
36
+ onClose(): void;
37
+ }) {
38
+ const { item } = props;
39
+ const subject = item.subject;
40
+ const subjectHref = subject?.url
41
+ ? reviewItemSubjectHref(subject.url)
42
+ : undefined;
43
+ const [addedByTitle, ...linkedTitles] = useLinkedConversationTitles([
44
+ item.addedByConversationId,
45
+ ...item.conversationIds,
46
+ ]);
47
+ const assigned = item.assignees.length > 0 || item.assignedToEveryone;
48
+ return (
49
+ <DetailsPanel
50
+ label="Review item details"
51
+ onClose={props.onClose}
52
+ title={
53
+ <h2 className="m-0 text-base font-semibold text-dashboard-text">
54
+ Details
55
+ </h2>
56
+ }
57
+ >
58
+ <div className="grid min-w-0 gap-3 p-4 pb-[max(1rem,env(safe-area-inset-bottom))]">
59
+ <div className="min-w-0 break-words px-1 pb-1 font-sans text-sm leading-relaxed text-dashboard-text-muted">
60
+ <DisplayText text={item.body} />
61
+ </div>
62
+ <DetailsCard title="Assignees">
63
+ {assigned ? (
64
+ <span className="text-sm text-dashboard-text">
65
+ {assigneeLabel(item)}
66
+ </span>
67
+ ) : (
68
+ <StatusChip size="compact" tone="warning">
69
+ Unassigned
70
+ </StatusChip>
71
+ )}
72
+ </DetailsCard>
73
+ <DetailsCard>
74
+ <dl className="m-0 grid grid-cols-[auto_minmax(0,1fr)] gap-x-4 gap-y-1.5">
75
+ <Fact label="Status">{reviewItemStatusLabel(item)}</Fact>
76
+ <Fact label="Added">{formatRelativeTime(item.createdAt)}</Fact>
77
+ <Fact label="Added by">
78
+ <Link
79
+ className={dashboardInlineLinkClass}
80
+ title={item.addedByConversationId}
81
+ to={conversationPath(item.addedByConversationId, {
82
+ turnId: item.addedByTurnId,
83
+ })}
84
+ >
85
+ {addedByTitle ?? "Conversation"}
86
+ </Link>
87
+ {item.automationId ? (
88
+ <>
89
+ {" · "}
90
+ <Link
91
+ className={dashboardInlineLinkClass}
92
+ to={automationPath(item.automationId)}
93
+ >
94
+ Automation
95
+ </Link>
96
+ </>
97
+ ) : null}
98
+ </Fact>
99
+ <Fact label="Visibility">
100
+ {item.visibility === "private" ? "Private" : "Public"}
101
+ </Fact>
102
+ </dl>
103
+ </DetailsCard>
104
+ {subject ? (
105
+ <DetailsCard title="Subject">
106
+ <span className="text-sm">
107
+ {subjectHref ? (
108
+ <a
109
+ className={dashboardInlineLinkClass}
110
+ href={subjectHref}
111
+ rel="noreferrer"
112
+ target="_blank"
113
+ >
114
+ {subject.title ?? subjectHref}
115
+ </a>
116
+ ) : (
117
+ (subject.title ?? subject.id)
118
+ )}
119
+ </span>
120
+ </DetailsCard>
121
+ ) : null}
122
+ {item.conversationIds.length > 0 ? (
123
+ <DetailsCard
124
+ count={item.conversationIds.length}
125
+ title="Linked conversations"
126
+ >
127
+ <ul className="m-0 grid list-none gap-1 p-0 text-sm">
128
+ {item.conversationIds.map((conversationId, index) => {
129
+ const title = linkedTitles[index];
130
+ return (
131
+ <li
132
+ className={
133
+ title ? "truncate" : "truncate font-mono text-xs"
134
+ }
135
+ key={conversationId}
136
+ >
137
+ <Link
138
+ className={dashboardInlineLinkClass}
139
+ title={conversationId}
140
+ to={conversationPath(conversationId)}
141
+ >
142
+ {title ?? conversationId}
143
+ </Link>
144
+ </li>
145
+ );
146
+ })}
147
+ </ul>
148
+ </DetailsCard>
149
+ ) : null}
150
+ </div>
151
+ </DetailsPanel>
152
+ );
153
+ }