@burdenoff/microfe-timecampus 2026.1030.3 → 2026.1031.1

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.
@@ -3,98 +3,101 @@ import { formatDuration as t, formatTime as n } from "../../utils/helpers.js";
3
3
  import { StatCard as r } from "../../components/StatCard.js";
4
4
  import { LoadingSkeleton as i } from "../../components/LoadingSkeleton.js";
5
5
  import { EmptyState as a } from "../../components/EmptyState.js";
6
- import { useGetTimeCampusTimelineQuery as o, useListProjectsQuery as s, useRecategorizeTimeCampusCaptureEventMutation as c } from "../../../generated/wspace-operations.js";
7
- import { PageLayout as l } from "../../components/PageLayout.js";
8
- import { calendarHoldLabel as u } from "../focus/focusHelpers.js";
9
- import { driftLabel as d, focusStatusLabel as f, plannedDrift as p, protectedPercent as m } from "./timelineFocus.js";
10
- import { useMemo as h, useState as g } from "react";
11
- import { Activity as _, Brain as v, Calendar as y, CalendarClock as b, Coffee as x, FolderOpen as S, Github as C, GripVertical as w, MessageSquare as T, Shield as E, Users as D, Zap as O } from "lucide-react";
12
- import { jsx as k, jsxs as A } from "react/jsx-runtime";
13
- import { GlassCard as j } from "@burdenoff/fe-libs/ui";
14
- import { DndContext as M, DragOverlay as N, KeyboardSensor as P, PointerSensor as F, useDraggable as I, useDroppable as L, useSensor as R, useSensors as z } from "@dnd-kit/core";
6
+ import { useAcceptTimeCampusCaptureEventSuggestionMutation as o, useGetTimeCampusTimelineQuery as s, useListProjectsQuery as c, useRecategorizeTimeCampusCaptureEventMutation as l, useRejectTimeCampusCaptureEventSuggestionMutation as u, useSetTimeCampusCaptureEventProjectMutation as d, useSuggestTimeCampusCaptureEventProjectMutation as f } from "../../../generated/wspace-operations.js";
7
+ import { PageLayout as ee } from "../../components/PageLayout.js";
8
+ import { ToastContainer as te, useToast as p } from "../../components/Toast.js";
9
+ import { calendarHoldLabel as m } from "../focus/focusHelpers.js";
10
+ import { hasAiCategorizedSegment as h, segmentProvenance as g } from "./timelineProvenance.js";
11
+ import { driftLabel as _, focusStatusLabel as ne, plannedDrift as v, protectedPercent as re } from "./timelineFocus.js";
12
+ import { pendingSuggestion as ie, pendingSuggestions as ae } from "./timelineSuggestions.js";
13
+ import { useMemo as y, useState as b } from "react";
14
+ import { Activity as x, Brain as S, Calendar as oe, CalendarClock as C, Check as w, Coffee as T, FolderOpen as se, Github as ce, GripVertical as le, MessageSquare as E, Shield as D, Sparkles as O, Users as k, X as A, Zap as j } from "lucide-react";
15
+ import { jsx as M, jsxs as N } from "react/jsx-runtime";
16
+ import { GlassCard as P } from "@burdenoff/fe-libs/ui";
17
+ import { DndContext as ue, DragOverlay as de, KeyboardSensor as fe, PointerSensor as pe, useDraggable as F, useDroppable as I, useSensor as L, useSensors as me } from "@dnd-kit/core";
15
18
  //#region src/timecampus/pages/timeline/TimelinePage.tsx
16
- var B = {
19
+ var R = {
17
20
  DEEP_WORK: {
18
21
  label: "Deep work",
19
- icon: v,
22
+ icon: S,
20
23
  dot: "bg-status-success-bg",
21
24
  chip: "bg-status-success-bg text-status-success-text"
22
25
  },
23
26
  MEETING: {
24
27
  label: "Meeting",
25
- icon: D,
28
+ icon: k,
26
29
  dot: "bg-status-info-bg",
27
30
  chip: "bg-status-info-bg text-status-info-text"
28
31
  },
29
32
  COMMUNICATION: {
30
33
  label: "Communication",
31
- icon: T,
34
+ icon: E,
32
35
  dot: "bg-status-warning-bg",
33
36
  chip: "bg-status-warning-bg text-status-warning-text"
34
37
  },
35
38
  BREAK: {
36
39
  label: "Break",
37
- icon: x,
40
+ icon: T,
38
41
  dot: "bg-bg-sunken",
39
42
  chip: "bg-bg-sunken text-text-secondary"
40
43
  },
41
44
  OTHER: {
42
45
  label: "Other",
43
- icon: _,
46
+ icon: x,
44
47
  dot: "bg-bg-sunken",
45
48
  chip: "bg-bg-sunken text-text-secondary"
46
49
  }
47
- }, V = {
48
- TIME_ENTRY: O,
49
- MEETING: D,
50
- POMODORO: v,
51
- EMAIL: T,
52
- CAPTURE: C,
53
- FOCUS_SESSION: E,
54
- FOCUS_BLOCK: b
50
+ }, z = {
51
+ TIME_ENTRY: j,
52
+ MEETING: k,
53
+ POMODORO: S,
54
+ EMAIL: E,
55
+ CAPTURE: ce,
56
+ FOCUS_SESSION: D,
57
+ FOCUS_BLOCK: C
55
58
  };
56
- function H(e) {
59
+ function he(e) {
57
60
  return e.source === "FOCUS_SESSION" || e.source === "FOCUS_BLOCK";
58
61
  }
59
- function U({ segment: e }) {
62
+ function ge({ segment: e }) {
60
63
  let r = e.focus;
61
64
  if (!r) return null;
62
- let i = e.isPlanned, a = i ? b : E, o = f(i, r, e.endTime), s = i ? null : m(r), c = i ? null : p(e.startTime, e.endTime, r), l = u(r.calendarHoldStatus);
63
- return /* @__PURE__ */ A("li", {
65
+ let i = e.isPlanned, a = i ? C : D, o = ne(i, r, e.endTime), s = i ? null : re(r), c = i ? null : v(e.startTime, e.endTime, r), l = m(r.calendarHoldStatus);
66
+ return /* @__PURE__ */ N("li", {
64
67
  className: `flex items-start gap-3 p-4 ${i ? "bg-bg-sunken/30" : ""}`,
65
68
  "data-testid": i ? "timeline-focus-block" : "timeline-focus-session",
66
69
  children: [
67
- /* @__PURE__ */ A("div", {
70
+ /* @__PURE__ */ N("div", {
68
71
  className: "flex w-16 shrink-0 flex-col items-end pt-0.5 text-xs tabular-nums text-text-secondary",
69
- children: [/* @__PURE__ */ k("span", { children: n(e.startTime) }), /* @__PURE__ */ k("span", {
72
+ children: [/* @__PURE__ */ M("span", { children: n(e.startTime) }), /* @__PURE__ */ M("span", {
70
73
  className: "text-text-tertiary",
71
74
  children: t(e.durationSeconds)
72
75
  })]
73
76
  }),
74
- /* @__PURE__ */ k("div", {
77
+ /* @__PURE__ */ M("div", {
75
78
  className: `mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg ${i ? "border border-dashed border-status-success-text/60 text-status-success-text" : "bg-status-success-bg text-status-success-text"}`,
76
- children: /* @__PURE__ */ k(a, { className: "h-4 w-4" })
79
+ children: /* @__PURE__ */ M(a, { className: "h-4 w-4" })
77
80
  }),
78
- /* @__PURE__ */ A("div", {
81
+ /* @__PURE__ */ N("div", {
79
82
  className: "min-w-0 flex-1",
80
83
  children: [
81
- /* @__PURE__ */ k("p", {
84
+ /* @__PURE__ */ M("p", {
82
85
  className: "truncate text-sm font-medium text-text-primary",
83
86
  children: e.title || (i ? "Planned focus block" : "Focus session")
84
87
  }),
85
- /* @__PURE__ */ A("div", {
88
+ /* @__PURE__ */ N("div", {
86
89
  className: "mt-1 flex flex-wrap items-center gap-2",
87
90
  children: [
88
- /* @__PURE__ */ k("span", {
91
+ /* @__PURE__ */ M("span", {
89
92
  className: `inline-flex rounded-full px-2 py-0.5 text-xs font-medium ${i ? "border border-dashed border-border-seam text-text-secondary" : "bg-status-success-bg text-status-success-text"}`,
90
93
  "data-testid": "timeline-focus-status",
91
94
  children: o
92
95
  }),
93
- r.protectionLevel === "STRICT" && /* @__PURE__ */ k("span", {
96
+ r.protectionLevel === "STRICT" && /* @__PURE__ */ M("span", {
94
97
  className: "text-xs text-text-secondary",
95
98
  children: "Strict"
96
99
  }),
97
- r.plannedStartTime && r.plannedEndTime && /* @__PURE__ */ A("span", {
100
+ r.plannedStartTime && r.plannedEndTime && /* @__PURE__ */ N("span", {
98
101
  className: "text-xs tabular-nums text-text-secondary",
99
102
  children: [
100
103
  "Planned ",
@@ -104,7 +107,7 @@ function U({ segment: e }) {
104
107
  n(r.plannedEndTime)
105
108
  ]
106
109
  }),
107
- !i && e.endTime && /* @__PURE__ */ A("span", {
110
+ !i && e.endTime && /* @__PURE__ */ N("span", {
108
111
  className: "text-xs tabular-nums text-text-secondary",
109
112
  children: [
110
113
  "Actual ",
@@ -114,35 +117,35 @@ function U({ segment: e }) {
114
117
  n(e.endTime)
115
118
  ]
116
119
  }),
117
- c && /* @__PURE__ */ A("span", {
120
+ c && /* @__PURE__ */ N("span", {
118
121
  className: "text-xs text-text-tertiary",
119
122
  children: [
120
123
  "Started ",
121
- d(c.startMinutes),
122
- c.endMinutes !== null && `, ended ${d(c.endMinutes, "over", "short")}`
124
+ _(c.startMinutes),
125
+ c.endMinutes !== null && `, ended ${_(c.endMinutes, "over", "short")}`
123
126
  ]
124
127
  }),
125
- l && /* @__PURE__ */ k("span", {
128
+ l && /* @__PURE__ */ M("span", {
126
129
  className: "text-xs text-text-tertiary",
127
130
  children: l
128
131
  })
129
132
  ]
130
133
  }),
131
- !i && /* @__PURE__ */ A("div", {
134
+ !i && /* @__PURE__ */ N("div", {
132
135
  className: "mt-2",
133
136
  "data-testid": "timeline-focus-protection",
134
- children: [/* @__PURE__ */ A("div", {
137
+ children: [/* @__PURE__ */ N("div", {
135
138
  className: "flex h-1.5 w-full max-w-xs overflow-hidden rounded-full bg-bg-sunken",
136
139
  role: "img",
137
140
  "aria-label": `${s ?? 0}% of this session stayed protected`,
138
- children: [/* @__PURE__ */ k("span", {
141
+ children: [/* @__PURE__ */ M("span", {
139
142
  className: "h-full bg-status-success-text",
140
143
  style: { width: `${s ?? 0}%` }
141
- }), /* @__PURE__ */ k("span", {
144
+ }), /* @__PURE__ */ M("span", {
142
145
  className: "h-full bg-status-warning-text",
143
146
  style: { width: `${s === null ? 0 : 100 - s}%` }
144
147
  })]
145
- }), /* @__PURE__ */ A("p", {
148
+ }), /* @__PURE__ */ N("p", {
146
149
  className: "mt-1 text-xs tabular-nums text-text-secondary",
147
150
  children: [
148
151
  "Protected ",
@@ -159,7 +162,7 @@ function U({ segment: e }) {
159
162
  ]
160
163
  })]
161
164
  }),
162
- i && /* @__PURE__ */ k("p", {
165
+ i && /* @__PURE__ */ M("p", {
163
166
  className: "mt-1 text-xs text-text-tertiary",
164
167
  children: "Not counted in the day's totals until you run it."
165
168
  })
@@ -168,258 +171,427 @@ function U({ segment: e }) {
168
171
  ]
169
172
  });
170
173
  }
171
- var W = [
174
+ var B = [
172
175
  "DEEP_WORK",
173
176
  "MEETING",
174
177
  "COMMUNICATION",
175
178
  "BREAK",
176
179
  "OTHER"
177
- ], G = {
178
- auto: "Auto-categorized",
179
- user: "You set this",
180
- channel: "From channel rules"
181
- };
182
- function K(e) {
183
- return e ? G[e.toLowerCase()] ?? e : null;
180
+ ];
181
+ function V({ suggestion: e, busy: t, onAccept: n, onReject: r }) {
182
+ return /* @__PURE__ */ N("div", {
183
+ className: "mt-2 flex flex-wrap items-center gap-2 rounded-lg border border-dashed border-border-seam bg-bg-sunken/40 px-2.5 py-1.5",
184
+ "data-testid": "timeline-project-suggestion",
185
+ children: [
186
+ /* @__PURE__ */ M(O, {
187
+ className: "h-3.5 w-3.5 shrink-0 text-primary",
188
+ "aria-hidden": !0
189
+ }),
190
+ /* @__PURE__ */ N("span", {
191
+ className: "text-xs text-text-secondary",
192
+ children: [
193
+ "Suggested project",
194
+ " ",
195
+ /* @__PURE__ */ M("span", {
196
+ className: "font-medium text-text-primary",
197
+ children: e.projectName
198
+ }),
199
+ " ",
200
+ "· ",
201
+ e.confidencePercent,
202
+ "% · ",
203
+ e.reason
204
+ ]
205
+ }),
206
+ /* @__PURE__ */ N("span", {
207
+ className: "ml-auto flex items-center gap-1",
208
+ children: [/* @__PURE__ */ N("button", {
209
+ type: "button",
210
+ disabled: t,
211
+ onClick: () => n(e),
212
+ "aria-label": `Accept project ${e.projectName}`,
213
+ className: "inline-flex items-center gap-1 rounded-md bg-action-primary-bg px-2 py-0.5 text-xs font-medium text-action-primary-text hover:bg-action-primary-bg/90 disabled:opacity-50",
214
+ children: [/* @__PURE__ */ M(w, { className: "h-3 w-3" }), "Accept"]
215
+ }), /* @__PURE__ */ N("button", {
216
+ type: "button",
217
+ disabled: t,
218
+ onClick: () => r(e),
219
+ "aria-label": `Dismiss suggested project ${e.projectName}`,
220
+ className: "inline-flex items-center gap-1 rounded-md border border-border-seam bg-bg-surface px-2 py-0.5 text-xs font-medium text-text-secondary hover:bg-bg-sunken disabled:opacity-50",
221
+ children: [/* @__PURE__ */ M(A, { className: "h-3 w-3" }), "Dismiss"]
222
+ })]
223
+ })
224
+ ]
225
+ });
184
226
  }
185
- function q({ category: e, label: n, dotClassName: r, totalSeconds: i }) {
186
- let { isOver: a, setNodeRef: o } = L({ id: `category:${e}` });
187
- return /* @__PURE__ */ A("div", {
227
+ function _e({ category: e, label: n, dotClassName: r, totalSeconds: i }) {
228
+ let { isOver: a, setNodeRef: o } = I({ id: `category:${e}` });
229
+ return /* @__PURE__ */ N("div", {
188
230
  ref: o,
189
231
  className: `flex items-center gap-2 rounded-lg border px-3 py-2 transition-colors ${a ? "border-action-primary-bg bg-action-primary-bg/10" : "border-border-seam bg-bg-surface"}`,
190
232
  children: [
191
- /* @__PURE__ */ k("span", {
233
+ /* @__PURE__ */ M("span", {
192
234
  className: `inline-block h-2.5 w-2.5 rounded-full ${r}`,
193
235
  "aria-hidden": !0
194
236
  }),
195
- /* @__PURE__ */ k("span", {
237
+ /* @__PURE__ */ M("span", {
196
238
  className: "text-sm font-medium text-text-primary",
197
239
  children: n
198
240
  }),
199
- /* @__PURE__ */ k("span", {
241
+ /* @__PURE__ */ M("span", {
200
242
  className: "text-sm tabular-nums text-text-secondary",
201
243
  children: t(i)
202
244
  }),
203
- a && /* @__PURE__ */ k("span", {
245
+ a && /* @__PURE__ */ M("span", {
204
246
  className: "text-xs font-medium text-primary",
205
247
  children: "Drop here"
206
248
  })
207
249
  ]
208
250
  });
209
251
  }
210
- function J({ segment: e, category: r, projectName: i, recategorizing: a, onRecategorize: o }) {
211
- let s = B[r] ?? B.OTHER, c = V[e.source] ?? _, l = K(e.categorySource), { attributes: u, listeners: d, setNodeRef: f, isDragging: p } = I({
252
+ function ve({ segment: e, category: r, projectName: i, suggestion: a, recategorizing: o, onRecategorize: s, projectActions: c }) {
253
+ let l = R[r] ?? R.OTHER, u = z[e.source] ?? x, d = g(e), f = e.source === "CAPTURE", ee = f && !e.projectId && !a && c.projects.length > 0, { attributes: te, listeners: p, setNodeRef: m, isDragging: h } = F({
212
254
  id: e.id,
213
255
  data: { segment: e },
214
256
  disabled: !e.isRecategorizable
215
257
  });
216
- return /* @__PURE__ */ A("li", {
217
- ref: f,
218
- className: `flex items-start gap-3 p-4 transition-colors hover:bg-bg-sunken/50 ${p ? "opacity-40" : ""}`,
258
+ return /* @__PURE__ */ N("li", {
259
+ ref: m,
260
+ className: `flex items-start gap-3 p-4 transition-colors hover:bg-bg-sunken/50 ${h ? "opacity-40" : ""}`,
219
261
  children: [
220
- /* @__PURE__ */ A("div", {
262
+ /* @__PURE__ */ N("div", {
221
263
  className: "flex w-16 shrink-0 flex-col items-end pt-0.5 text-xs tabular-nums text-text-secondary",
222
- children: [/* @__PURE__ */ k("span", { children: n(e.startTime) }), /* @__PURE__ */ k("span", {
264
+ children: [/* @__PURE__ */ M("span", { children: n(e.startTime) }), /* @__PURE__ */ M("span", {
223
265
  className: "text-text-tertiary",
224
266
  children: t(e.durationSeconds)
225
267
  })]
226
268
  }),
227
- e.isRecategorizable && /* @__PURE__ */ k("button", {
269
+ e.isRecategorizable && /* @__PURE__ */ M("button", {
228
270
  type: "button",
229
- "aria-label": `Drag to recategorize ${e.title || s.label}`,
271
+ "aria-label": `Drag to recategorize ${e.title || l.label}`,
230
272
  className: "mt-1.5 shrink-0 cursor-grab touch-none text-text-tertiary hover:text-text-secondary active:cursor-grabbing",
231
- ...u,
232
- ...d,
233
- children: /* @__PURE__ */ k(w, { className: "h-4 w-4" })
273
+ ...te,
274
+ ...p,
275
+ children: /* @__PURE__ */ M(le, { className: "h-4 w-4" })
234
276
  }),
235
- /* @__PURE__ */ k("div", {
236
- className: `mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg ${s.chip}`,
237
- children: /* @__PURE__ */ k(c, { className: "h-4 w-4" })
277
+ /* @__PURE__ */ M("div", {
278
+ className: `mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg ${l.chip}`,
279
+ children: /* @__PURE__ */ M(u, { className: "h-4 w-4" })
238
280
  }),
239
- /* @__PURE__ */ A("div", {
281
+ /* @__PURE__ */ N("div", {
240
282
  className: "min-w-0 flex-1",
241
- children: [/* @__PURE__ */ k("p", {
242
- className: "truncate text-sm font-medium text-text-primary",
243
- children: e.title || s.label
244
- }), /* @__PURE__ */ A("div", {
245
- className: "mt-1 flex flex-wrap items-center gap-2",
246
- children: [
247
- /* @__PURE__ */ k("span", {
248
- className: `inline-flex rounded-full px-2 py-0.5 text-xs font-medium ${s.chip}`,
249
- children: s.label
250
- }),
251
- i !== void 0 && /* @__PURE__ */ A("span", {
252
- className: "inline-flex max-w-[12rem] items-center gap-1 rounded-full bg-bg-sunken px-2 py-0.5 text-xs font-medium text-text-secondary",
253
- children: [/* @__PURE__ */ k(S, { className: "h-3 w-3 shrink-0" }), /* @__PURE__ */ k("span", {
254
- className: "truncate",
255
- children: i
256
- })]
257
- }),
258
- e.app && /* @__PURE__ */ k("span", {
259
- className: "text-xs text-text-secondary",
260
- children: e.app
261
- }),
262
- l && /* @__PURE__ */ k("span", {
263
- className: "text-xs text-text-tertiary",
264
- children: l
265
- })
266
- ]
267
- })]
283
+ children: [
284
+ /* @__PURE__ */ M("p", {
285
+ className: "truncate text-sm font-medium text-text-primary",
286
+ children: e.title || l.label
287
+ }),
288
+ /* @__PURE__ */ N("div", {
289
+ className: "mt-1 flex flex-wrap items-center gap-2",
290
+ children: [
291
+ /* @__PURE__ */ M("span", {
292
+ className: `inline-flex rounded-full px-2 py-0.5 text-xs font-medium ${l.chip}`,
293
+ children: l.label
294
+ }),
295
+ i !== void 0 && /* @__PURE__ */ N("span", {
296
+ className: "inline-flex max-w-[12rem] items-center gap-1 rounded-full bg-bg-sunken px-2 py-0.5 text-xs font-medium text-text-secondary",
297
+ children: [/* @__PURE__ */ M(se, { className: "h-3 w-3 shrink-0" }), /* @__PURE__ */ M("span", {
298
+ className: "truncate",
299
+ children: i
300
+ })]
301
+ }),
302
+ e.app && /* @__PURE__ */ M("span", {
303
+ className: "text-xs text-text-secondary",
304
+ children: e.app
305
+ }),
306
+ d && (d.isAi ? /* @__PURE__ */ N("span", {
307
+ className: "inline-flex items-center gap-1 rounded-full bg-bg-sunken px-2 py-0.5 text-xs font-medium text-text-secondary",
308
+ title: d.detail,
309
+ "data-testid": "timeline-ai-provenance",
310
+ children: [
311
+ /* @__PURE__ */ M(O, {
312
+ className: "h-3 w-3 shrink-0",
313
+ "aria-hidden": !0
314
+ }),
315
+ d.label,
316
+ /* @__PURE__ */ N("span", {
317
+ className: "sr-only",
318
+ children: [". ", d.detail]
319
+ })
320
+ ]
321
+ }) : /* @__PURE__ */ M("span", {
322
+ className: "text-xs text-text-tertiary",
323
+ title: d.detail,
324
+ children: d.label
325
+ }))
326
+ ]
327
+ }),
328
+ a && /* @__PURE__ */ M(V, {
329
+ suggestion: a,
330
+ busy: c.busy,
331
+ onAccept: c.onAccept,
332
+ onReject: c.onReject
333
+ })
334
+ ]
268
335
  }),
269
- e.isRecategorizable && /* @__PURE__ */ k("select", {
270
- "aria-label": "Recategorize activity",
271
- disabled: a,
272
- value: r,
273
- onChange: (t) => o(e, t.target.value),
274
- className: "shrink-0 rounded-md border border-border-seam bg-bg-surface px-2 py-1 text-xs text-text-secondary focus:outline-none focus:ring-2 focus:ring-action-primary-bg/40",
275
- children: W.map((e) => /* @__PURE__ */ k("option", {
276
- value: e,
277
- children: B[e].label
278
- }, e))
336
+ /* @__PURE__ */ N("div", {
337
+ className: "flex shrink-0 flex-col items-end gap-1.5",
338
+ children: [
339
+ e.isRecategorizable && /* @__PURE__ */ M("select", {
340
+ "aria-label": "Recategorize activity",
341
+ disabled: o,
342
+ value: r,
343
+ onChange: (t) => s(e, t.target.value),
344
+ className: "rounded-md border border-border-seam bg-bg-surface px-2 py-1 text-xs text-text-secondary focus:outline-none focus:ring-2 focus:ring-action-primary-bg/40",
345
+ children: B.map((e) => /* @__PURE__ */ M("option", {
346
+ value: e,
347
+ children: R[e].label
348
+ }, e))
349
+ }),
350
+ f && c.projects.length > 0 && /* @__PURE__ */ N("select", {
351
+ "aria-label": "Assign project",
352
+ disabled: c.busy,
353
+ value: e.projectId ?? "",
354
+ onChange: (t) => c.onSetProject(e, t.target.value || null),
355
+ className: "max-w-[10rem] rounded-md border border-border-seam bg-bg-surface px-2 py-1 text-xs text-text-secondary focus:outline-none focus:ring-2 focus:ring-action-primary-bg/40",
356
+ children: [/* @__PURE__ */ M("option", {
357
+ value: "",
358
+ children: "No project"
359
+ }), c.projects.map((e) => /* @__PURE__ */ M("option", {
360
+ value: e.id,
361
+ children: e.name
362
+ }, e.id))]
363
+ }),
364
+ ee && /* @__PURE__ */ N("button", {
365
+ type: "button",
366
+ disabled: c.busy,
367
+ onClick: () => c.onSuggest(e),
368
+ className: "inline-flex items-center gap-1 text-xs font-medium text-primary hover:underline disabled:opacity-50",
369
+ children: [/* @__PURE__ */ M(O, { className: "h-3 w-3" }), "Suggest project"]
370
+ })
371
+ ]
279
372
  })
280
373
  ]
281
374
  });
282
375
  }
283
- function Y(e) {
376
+ function H(e) {
377
+ return e instanceof Error ? e.message : "Something went wrong";
378
+ }
379
+ function U(e) {
284
380
  let t = e.getTimezoneOffset();
285
381
  return (/* @__PURE__ */ new Date(e.getTime() - t * 60 * 1e3)).toISOString().slice(0, 10);
286
382
  }
287
- var X = 14;
288
- function ee() {
383
+ var ye = 14;
384
+ function be() {
289
385
  let e = /* @__PURE__ */ new Date();
290
- return e.setDate(e.getDate() + X), Y(e);
386
+ return e.setDate(e.getDate() + ye), U(e);
291
387
  }
292
- function te(e) {
388
+ function xe(e) {
293
389
  let t = /* @__PURE__ */ new Date(`${e}T00:00:00`), n = /* @__PURE__ */ new Date(`${e}T23:59:59.999`);
294
390
  return {
295
391
  from: t.toISOString(),
296
392
  to: n.toISOString()
297
393
  };
298
394
  }
299
- function Z() {
300
- let { workspaceId: u = "" } = e(), [d, f] = g(() => Y(/* @__PURE__ */ new Date())), [p, m] = g(null), { from: b, to: x } = h(() => te(d), [d]), { data: S, loading: C, error: T, refetch: E } = o({
395
+ function W() {
396
+ let { workspaceId: m = "" } = e(), { toasts: g, addToast: _, dismissToast: ne } = p(), [v, re] = b(() => U(/* @__PURE__ */ new Date())), [C, T] = b(null), { from: se, to: ce } = y(() => xe(v), [v]), { data: E, loading: D, error: k, refetch: A } = s({
301
397
  variables: {
302
- from: b,
303
- to: x
398
+ from: se,
399
+ to: ce
304
400
  },
305
- skip: !u,
401
+ skip: !m,
306
402
  fetchPolicy: "cache-and-network"
307
- }), { data: D } = s({
403
+ }), { data: F } = c({
308
404
  variables: { pagination: { limit: 200 } },
309
- skip: !u
310
- }), [I, { loading: L }] = c(), V = z(R(F, { activationConstraint: { distance: 6 } }), R(P)), G = S?.timeCampusTimeline, K = G?.segments ?? [], X = G?.summary, Z = h(() => {
405
+ skip: !m
406
+ }), [I, { loading: z }] = l(), [V, { loading: ye }] = o(), [W, { loading: Se }] = u(), [Ce, { loading: we }] = d(), [Te, { loading: Ee }] = f(), G = ye || Se || we || Ee, De = me(L(pe, { activationConstraint: { distance: 6 } }), L(fe)), K = E?.timeCampusTimeline, q = y(() => K?.segments ?? [], [K]), J = K?.summary, Y = y(() => {
311
407
  let e = /* @__PURE__ */ new Map();
312
- for (let t of D?.projects?.items ?? []) e.set(t.id, t.name);
408
+ for (let t of F?.projects?.items ?? []) e.set(t.id, t.name);
313
409
  return e;
314
- }, [D?.projects?.items]), ne = h(() => {
410
+ }, [F?.projects?.items]), Oe = y(() => Array.from(Y, ([e, t]) => ({
411
+ id: e,
412
+ name: t
413
+ })), [Y]), X = y(() => ae(q, Y), [q, Y]), ke = y(() => {
315
414
  let e = /* @__PURE__ */ new Map();
316
- for (let t of X?.byCategory ?? []) e.set(t.category, {
415
+ for (let t of J?.byCategory ?? []) e.set(t.category, {
317
416
  totalSeconds: t.totalSeconds,
318
417
  segmentCount: t.segmentCount
319
418
  });
320
419
  return e;
321
- }, [X]), Q = async (e, t) => {
420
+ }, [J]), Z = async (e, t) => {
322
421
  !e.isRecategorizable || e.category === t || (await I({ variables: {
323
422
  id: e.sourceId,
324
423
  category: t
325
- } }), await E());
326
- }, re = (e) => {
424
+ } }), await A());
425
+ }, Q = async (e, t) => {
426
+ try {
427
+ await e(), await A(), _({
428
+ title: t,
429
+ variant: "success"
430
+ });
431
+ } catch (e) {
432
+ _({
433
+ title: H(e),
434
+ variant: "error"
435
+ });
436
+ }
437
+ }, Ae = (e) => Q(() => V({ variables: { id: e.captureEventId } }), `Assigned to ${e.projectName}`), je = (e) => Q(() => W({ variables: { id: e.captureEventId } }), "Suggestion dismissed"), Me = (e, t) => {
438
+ if ((e.projectId ?? null) === t) return;
439
+ let n = t ? Y.get(t) : void 0;
440
+ return Q(() => Ce({ variables: {
441
+ id: e.sourceId,
442
+ projectId: t
443
+ } }), n ? `Assigned to ${n}` : "Project removed");
444
+ }, Ne = async (e) => {
445
+ try {
446
+ let t = (await Te({ variables: { id: e.sourceId } })).data?.suggestTimeCampusCaptureEventCategory;
447
+ await A(), _(t?.suggestedProjectId ? {
448
+ title: `Suggested ${t.suggestedProjectName ?? "a project"}`,
449
+ description: "Accept or dismiss it on the activity.",
450
+ variant: "info"
451
+ } : {
452
+ title: "No confident project match",
453
+ description: "Pick a project from the list instead.",
454
+ variant: "info"
455
+ });
456
+ } catch (e) {
457
+ _({
458
+ title: H(e),
459
+ variant: "error"
460
+ });
461
+ }
462
+ }, Pe = async () => {
463
+ let e = 0;
464
+ try {
465
+ for (let t of X) await V({ variables: { id: t.captureEventId } }), e++;
466
+ _({
467
+ title: `Accepted ${e} project ${e === 1 ? "suggestion" : "suggestions"}`,
468
+ variant: "success"
469
+ });
470
+ } catch (t) {
471
+ _({
472
+ title: `Accepted ${e} of ${X.length}`,
473
+ description: H(t),
474
+ variant: "error"
475
+ });
476
+ } finally {
477
+ await A();
478
+ }
479
+ }, Fe = {
480
+ projects: Oe,
481
+ busy: G,
482
+ onAccept: (e) => void Ae(e),
483
+ onReject: (e) => void je(e),
484
+ onSetProject: (e, t) => void Me(e, t),
485
+ onSuggest: (e) => void Ne(e)
486
+ }, Ie = (e) => {
327
487
  let t = e.active.data.current?.segment;
328
- m(t ?? null);
329
- }, ie = (e) => {
488
+ T(t ?? null);
489
+ }, Le = (e) => {
330
490
  let t = e.active.data.current?.segment;
331
- m(null);
491
+ T(null);
332
492
  let n = e.over?.id;
333
493
  if (!t || typeof n != "string") return;
334
494
  let r = n.replace(/^category:/, "");
335
- W.includes(r) && Q(t, r);
336
- }, ae = X && X.focusRatio != null ? Math.round(X.focusRatio * 100) : 0, $ = X?.firstActivityAt && X?.lastActivityAt ? `${n(X.firstActivityAt)} – ${n(X.lastActivityAt)}` : null;
337
- return /* @__PURE__ */ k(l, {
495
+ B.includes(r) && Z(t, r);
496
+ }, Re = J && J.focusRatio != null ? Math.round(J.focusRatio * 100) : 0, $ = J?.firstActivityAt && J?.lastActivityAt ? `${n(J.firstActivityAt)} – ${n(J.lastActivityAt)}` : null;
497
+ return /* @__PURE__ */ N(ee, {
338
498
  title: "Timeline",
339
499
  description: "Your day, assembled automatically",
340
500
  purpose: "See where your time actually went — meetings, deep work, communication and breaks stitched into one honest, chronological view from everything TimeCampus captures, so you can spot the patterns worth changing.",
341
- actions: /* @__PURE__ */ A("div", {
501
+ actions: /* @__PURE__ */ N("div", {
342
502
  className: "flex flex-wrap items-center gap-3",
343
- children: [$ && /* @__PURE__ */ A("span", {
503
+ children: [$ && /* @__PURE__ */ N("span", {
344
504
  className: "inline-flex items-center gap-1.5 rounded-full bg-bg-sunken px-2.5 py-1 text-xs font-medium tabular-nums text-text-secondary",
345
- children: [/* @__PURE__ */ k(_, { className: "h-3.5 w-3.5" }), $]
346
- }), /* @__PURE__ */ A("label", {
505
+ children: [/* @__PURE__ */ M(x, { className: "h-3.5 w-3.5" }), $]
506
+ }), /* @__PURE__ */ N("label", {
347
507
  className: "flex items-center gap-2 text-sm text-text-secondary",
348
- children: [/* @__PURE__ */ k(y, { className: "h-4 w-4" }), /* @__PURE__ */ k("input", {
508
+ children: [/* @__PURE__ */ M(oe, { className: "h-4 w-4" }), /* @__PURE__ */ M("input", {
349
509
  type: "date",
350
- value: d,
351
- max: ee(),
352
- onChange: (e) => f(e.target.value),
510
+ value: v,
511
+ max: be(),
512
+ onChange: (e) => re(e.target.value),
353
513
  className: "rounded-md border border-border-seam bg-bg-surface px-3 py-1.5 text-sm text-text-primary focus:outline-none focus:ring-2 focus:ring-action-primary-bg/40"
354
514
  })]
355
515
  })]
356
516
  }),
357
- children: C && !G ? /* @__PURE__ */ A("div", {
517
+ children: [D && !K ? /* @__PURE__ */ N("div", {
358
518
  className: "space-y-6",
359
- children: [/* @__PURE__ */ k(i, {
519
+ children: [/* @__PURE__ */ M(i, {
360
520
  variant: "card",
361
521
  count: 4
362
- }), /* @__PURE__ */ k(i, {
522
+ }), /* @__PURE__ */ M(i, {
363
523
  variant: "list",
364
524
  count: 6
365
525
  })]
366
- }) : T ? /* @__PURE__ */ k("div", {
526
+ }) : k ? /* @__PURE__ */ M("div", {
367
527
  className: "rounded-lg border border-status-error-bg/40 bg-status-error-bg p-4 text-sm text-status-error-text",
368
528
  children: "Failed to load your timeline. Please try again later."
369
- }) : /* @__PURE__ */ A(M, {
370
- sensors: V,
371
- onDragStart: re,
372
- onDragEnd: ie,
373
- children: [/* @__PURE__ */ A("div", {
529
+ }) : /* @__PURE__ */ N(ue, {
530
+ sensors: De,
531
+ onDragStart: Ie,
532
+ onDragEnd: Le,
533
+ children: [/* @__PURE__ */ N("div", {
374
534
  className: "space-y-6",
375
535
  children: [
376
- /* @__PURE__ */ A("div", {
536
+ /* @__PURE__ */ N("div", {
377
537
  className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",
378
538
  children: [
379
- /* @__PURE__ */ k(r, {
539
+ /* @__PURE__ */ M(r, {
380
540
  featured: !0,
381
541
  title: "Tracked time",
382
- value: t(X?.totalTrackedSeconds ?? 0),
383
- icon: /* @__PURE__ */ k(_, { className: "h-5 w-5" }),
542
+ value: t(J?.totalTrackedSeconds ?? 0),
543
+ icon: /* @__PURE__ */ M(x, { className: "h-5 w-5" }),
384
544
  description: "Total activity across the day"
385
545
  }),
386
- /* @__PURE__ */ k(r, {
546
+ /* @__PURE__ */ M(r, {
387
547
  title: "Focus ratio",
388
- value: `${ae}%`,
389
- icon: /* @__PURE__ */ k(v, { className: "h-5 w-5" }),
548
+ value: `${Re}%`,
549
+ icon: /* @__PURE__ */ M(S, { className: "h-5 w-5" }),
390
550
  description: "Share of time in deep work"
391
551
  }),
392
- /* @__PURE__ */ k(r, {
552
+ /* @__PURE__ */ M(r, {
393
553
  title: "Context switches",
394
- value: X?.contextSwitches ?? 0,
395
- icon: /* @__PURE__ */ k(O, { className: "h-5 w-5" }),
554
+ value: J?.contextSwitches ?? 0,
555
+ icon: /* @__PURE__ */ M(j, { className: "h-5 w-5" }),
396
556
  description: "Category changes through the day"
397
557
  }),
398
- /* @__PURE__ */ k(r, {
558
+ /* @__PURE__ */ M(r, {
399
559
  title: "Longest focus block",
400
- value: t(X?.longestFocusBlockSeconds ?? 0),
401
- icon: /* @__PURE__ */ k(v, { className: "h-5 w-5" }),
560
+ value: t(J?.longestFocusBlockSeconds ?? 0),
561
+ icon: /* @__PURE__ */ M(S, { className: "h-5 w-5" }),
402
562
  description: "Your deepest uninterrupted stretch"
403
563
  })
404
564
  ]
405
565
  }),
406
- K.length > 0 && /* @__PURE__ */ A(j, {
566
+ q.length > 0 && /* @__PURE__ */ N(P, {
407
567
  treatment: "glass",
408
568
  className: "p-4 sm:p-6",
409
569
  children: [
410
- /* @__PURE__ */ k("h2", {
570
+ /* @__PURE__ */ M("h2", {
411
571
  className: "mb-1 text-sm font-semibold text-text-primary",
412
572
  children: "Where the time went"
413
573
  }),
414
- /* @__PURE__ */ k("p", {
574
+ /* @__PURE__ */ M("p", {
415
575
  className: "mb-4 text-xs text-text-secondary",
416
576
  children: "Drag a segment from the timeline below onto a category to recategorize it — or use its dropdown."
417
577
  }),
418
- /* @__PURE__ */ k("div", {
578
+ h(q) && /* @__PURE__ */ N("p", {
579
+ className: "mb-4 flex items-start gap-1.5 text-xs text-text-secondary",
580
+ "data-testid": "timeline-ai-disclaimer",
581
+ children: [/* @__PURE__ */ M(O, {
582
+ className: "mt-0.5 h-3 w-3 shrink-0",
583
+ "aria-hidden": !0
584
+ }), /* @__PURE__ */ N("span", { children: [
585
+ "Some activities here were categorized by AI.",
586
+ " ",
587
+ "AI can get this wrong. Pick another category to correct it, and TimeCampus will use your choice for this app from now on."
588
+ ] })]
589
+ }),
590
+ /* @__PURE__ */ M("div", {
419
591
  className: "flex flex-wrap gap-4",
420
- children: W.map((e) => {
421
- let t = B[e], n = ne.get(e);
422
- return /* @__PURE__ */ k(q, {
592
+ children: B.map((e) => {
593
+ let t = R[e], n = ke.get(e);
594
+ return /* @__PURE__ */ M(_e, {
423
595
  category: e,
424
596
  label: t.label,
425
597
  dotClassName: t.dot,
@@ -429,37 +601,72 @@ function Z() {
429
601
  })
430
602
  ]
431
603
  }),
432
- K.length === 0 ? /* @__PURE__ */ k(a, {
604
+ X.length > 0 && /* @__PURE__ */ N("div", {
605
+ className: "flex flex-wrap items-center gap-3 rounded-lg border border-border-seam bg-bg-sunken/40 px-4 py-3",
606
+ "data-testid": "timeline-suggestions-banner",
607
+ children: [
608
+ /* @__PURE__ */ M(O, { className: "h-4 w-4 shrink-0 text-primary" }),
609
+ /* @__PURE__ */ N("p", {
610
+ className: "text-sm text-text-secondary",
611
+ children: [
612
+ /* @__PURE__ */ N("span", {
613
+ className: "font-medium text-text-primary",
614
+ children: [
615
+ X.length,
616
+ " project",
617
+ " ",
618
+ X.length === 1 ? "suggestion" : "suggestions"
619
+ ]
620
+ }),
621
+ " ",
622
+ "waiting for review. Nothing is assigned until you accept."
623
+ ]
624
+ }),
625
+ /* @__PURE__ */ N("button", {
626
+ type: "button",
627
+ disabled: G,
628
+ onClick: () => void Pe(),
629
+ className: "ml-auto inline-flex items-center gap-1 rounded-md bg-action-primary-bg px-3 py-1 text-xs font-medium text-action-primary-text hover:bg-action-primary-bg/90 disabled:opacity-50",
630
+ children: [/* @__PURE__ */ M(w, { className: "h-3.5 w-3.5" }), "Accept all"]
631
+ })
632
+ ]
633
+ }),
634
+ q.length === 0 ? /* @__PURE__ */ M(a, {
433
635
  illustration: "empty-generic",
434
636
  title: "No activity captured for this day",
435
637
  description: "As you track time, hold meetings, run focus sessions, and connect shared integrations, your day assembles here automatically — categorized and in order."
436
- }) : /* @__PURE__ */ k(j, {
638
+ }) : /* @__PURE__ */ M(P, {
437
639
  treatment: "glass",
438
640
  glow: !0,
439
641
  className: "overflow-hidden",
440
- children: /* @__PURE__ */ k("ol", {
642
+ children: /* @__PURE__ */ M("ol", {
441
643
  className: "divide-y divide-border-seam",
442
- children: K.map((e) => H(e) ? /* @__PURE__ */ k(U, { segment: e }, e.id) : /* @__PURE__ */ k(J, {
644
+ children: q.map((e) => he(e) ? /* @__PURE__ */ M(ge, { segment: e }, e.id) : /* @__PURE__ */ M(ve, {
443
645
  segment: e,
444
646
  category: e.category ?? "OTHER",
445
- projectName: e.projectId ? Z.get(e.projectId) : void 0,
446
- recategorizing: L,
447
- onRecategorize: Q
647
+ projectName: e.projectId ? Y.get(e.projectId) : void 0,
648
+ suggestion: ie(e, Y),
649
+ recategorizing: z,
650
+ onRecategorize: Z,
651
+ projectActions: Fe
448
652
  }, e.id))
449
653
  })
450
654
  })
451
655
  ]
452
- }), /* @__PURE__ */ k(N, { children: p && /* @__PURE__ */ A("div", {
656
+ }), /* @__PURE__ */ M(de, { children: C && /* @__PURE__ */ N("div", {
453
657
  className: "flex items-center gap-2 rounded-lg border border-border-seam bg-bg-surface px-3 py-2 shadow-pop",
454
- children: [/* @__PURE__ */ k(w, { className: "h-4 w-4 text-text-tertiary" }), /* @__PURE__ */ k("span", {
658
+ children: [/* @__PURE__ */ M(le, { className: "h-4 w-4 text-text-tertiary" }), /* @__PURE__ */ M("span", {
455
659
  className: "text-sm font-medium text-text-primary",
456
- children: p.title || B[p.category ?? "OTHER"].label
660
+ children: C.title || R[C.category ?? "OTHER"].label
457
661
  })]
458
662
  }) })]
459
- })
663
+ }), /* @__PURE__ */ M(te, {
664
+ toasts: g,
665
+ onDismiss: ne
666
+ })]
460
667
  });
461
668
  }
462
669
  //#endregion
463
- export { Z as TimelinePage };
670
+ export { W as TimelinePage };
464
671
 
465
672
  //# sourceMappingURL=TimelinePage.js.map