@burdenoff/microfe-timecampus 2026.1028.1 → 2026.1030.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.
- package/dist/generated/wspace-operations.d.ts +102 -0
- package/dist/generated/wspace-operations.d.ts.map +1 -1
- package/dist/generated/wspace-operations.js +477 -425
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/generated/wspace-types.d.ts +67 -3
- package/dist/generated/wspace-types.d.ts.map +1 -1
- package/dist/generated/wspace-types.js.map +1 -1
- package/dist/index.js +7 -7
- package/dist/timecampus/index.js +7 -7
- package/dist/timecampus/pages/focus/FocusProtectionPage.d.ts.map +1 -1
- package/dist/timecampus/pages/focus/FocusProtectionPage.js +341 -280
- package/dist/timecampus/pages/focus/FocusProtectionPage.js.map +1 -1
- package/dist/timecampus/pages/focus/focusHelpers.d.ts +19 -0
- package/dist/timecampus/pages/focus/focusHelpers.d.ts.map +1 -1
- package/dist/timecampus/pages/focus/focusHelpers.js +61 -1
- package/dist/timecampus/pages/focus/focusHelpers.js.map +1 -1
- package/dist/timecampus/pages/timeline/TimelinePage.d.ts.map +1 -1
- package/dist/timecampus/pages/timeline/TimelinePage.js +245 -120
- package/dist/timecampus/pages/timeline/TimelinePage.js.map +1 -1
- package/dist/timecampus/pages/timeline/timelineFocus.d.ts +33 -0
- package/dist/timecampus/pages/timeline/timelineFocus.d.ts.map +1 -0
- package/dist/timecampus/pages/timeline/timelineFocus.js +26 -0
- package/dist/timecampus/pages/timeline/timelineFocus.js.map +1 -0
- package/dist/utils/pageContext.d.ts.map +1 -1
- package/dist/utils/pageContext.js +12 -6
- package/dist/utils/pageContext.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimelinePage.js","names":[],"sources":["../../../../src/timecampus/pages/timeline/TimelinePage.tsx"],"sourcesContent":["import { useMemo, useState } from \"react\";\nimport {\n DndContext,\n DragOverlay,\n KeyboardSensor,\n PointerSensor,\n useDraggable,\n useDroppable,\n useSensor,\n useSensors,\n type DragEndEvent,\n type DragStartEvent,\n} from \"@dnd-kit/core\";\nimport {\n Activity,\n Brain,\n Calendar,\n Coffee,\n FolderOpen,\n Github,\n GripVertical,\n MessageSquare,\n Users,\n Zap,\n} from \"lucide-react\";\nimport { GlassCard } from \"@burdenoff/fe-libs/ui\";\nimport { PageLayout } from \"../../components/PageLayout\";\nimport { StatCard } from \"../../components/StatCard\";\nimport { EmptyState } from \"../../components/EmptyState\";\nimport { LoadingSkeleton } from \"../../components/LoadingSkeleton\";\nimport { formatDuration, formatTime } from \"../../utils/helpers\";\nimport { useTimeCampus } from \"../../providers/TimeCampusProvider\";\nimport {\n useGetTimeCampusTimelineQuery,\n useListProjectsQuery,\n useRecategorizeTimeCampusCaptureEventMutation,\n type TimelineSegmentFieldsFragment,\n} from \"@/generated/wspace-operations\";\n\ntype Category = \"MEETING\" | \"DEEP_WORK\" | \"COMMUNICATION\" | \"BREAK\" | \"OTHER\";\n\nconst CATEGORY_META: Record<\n Category,\n { label: string; icon: typeof Brain; dot: string; chip: string }\n> = {\n DEEP_WORK: {\n label: \"Deep work\",\n icon: Brain,\n dot: \"bg-status-success-bg\",\n chip: \"bg-status-success-bg text-status-success-text\",\n },\n MEETING: {\n label: \"Meeting\",\n icon: Users,\n dot: \"bg-status-info-bg\",\n chip: \"bg-status-info-bg text-status-info-text\",\n },\n COMMUNICATION: {\n label: \"Communication\",\n icon: MessageSquare,\n dot: \"bg-status-warning-bg\",\n chip: \"bg-status-warning-bg text-status-warning-text\",\n },\n BREAK: {\n label: \"Break\",\n icon: Coffee,\n dot: \"bg-bg-sunken\",\n chip: \"bg-bg-sunken text-text-secondary\",\n },\n OTHER: {\n label: \"Other\",\n icon: Activity,\n dot: \"bg-bg-sunken\",\n chip: \"bg-bg-sunken text-text-secondary\",\n },\n};\n\nconst SOURCE_ICON: Record<string, typeof Brain> = {\n TIME_ENTRY: Zap,\n MEETING: Users,\n POMODORO: Brain,\n EMAIL: MessageSquare,\n CAPTURE: Github,\n};\n\nconst CATEGORY_ORDER: Category[] = [\n \"DEEP_WORK\",\n \"MEETING\",\n \"COMMUNICATION\",\n \"BREAK\",\n \"OTHER\",\n];\n\n/**\n * How a segment came by its category. The service writes these lowercase\n * (`timeline.service.ts` → 'auto' | 'user' | 'channel'), so normalise before\n * matching rather than trusting the string's casing.\n */\nconst CATEGORY_SOURCE_LABEL: Record<string, string> = {\n auto: \"Auto-categorized\",\n user: \"You set this\",\n channel: \"From channel rules\",\n};\n\nfunction categorySourceLabel(source: string | null | undefined): string | null {\n if (!source) return null;\n return CATEGORY_SOURCE_LABEL[source.toLowerCase()] ?? source;\n}\n\n/** Droppable target: a category chip in the \"Where the time went\" summary. */\nfunction DroppableCategoryChip({\n category,\n label,\n dotClassName,\n totalSeconds,\n}: {\n category: Category;\n label: string;\n dotClassName: string;\n totalSeconds: number;\n}) {\n const { isOver, setNodeRef } = useDroppable({ id: `category:${category}` });\n return (\n <div\n ref={setNodeRef}\n className={`flex items-center gap-2 rounded-lg border px-3 py-2 transition-colors ${\n isOver\n ? \"border-action-primary-bg bg-action-primary-bg/10\"\n : \"border-border-seam bg-bg-surface\"\n }`}\n >\n <span\n className={`inline-block h-2.5 w-2.5 rounded-full ${dotClassName}`}\n aria-hidden\n />\n <span className=\"text-sm font-medium text-text-primary\">{label}</span>\n <span className=\"text-sm tabular-nums text-text-secondary\">\n {formatDuration(totalSeconds)}\n </span>\n {isOver && (\n <span className=\"text-xs font-medium text-primary\">Drop here</span>\n )}\n </div>\n );\n}\n\n/** Draggable row for a single timeline segment, with the existing dropdown kept as an accessible fallback. */\nfunction DraggableSegmentRow({\n segment,\n category,\n projectName,\n recategorizing,\n onRecategorize,\n}: {\n segment: TimelineSegmentFieldsFragment;\n category: Category;\n /** Resolved name for `segment.projectId`; undefined when it carries none. */\n projectName: string | undefined;\n recategorizing: boolean;\n onRecategorize: (\n segment: TimelineSegmentFieldsFragment,\n category: Category,\n ) => void;\n}) {\n const meta = CATEGORY_META[category] ?? CATEGORY_META.OTHER;\n const SourceIcon = SOURCE_ICON[segment.source] ?? Activity;\n const provenance = categorySourceLabel(segment.categorySource);\n const { attributes, listeners, setNodeRef, isDragging } = useDraggable({\n id: segment.id,\n data: { segment },\n disabled: !segment.isRecategorizable,\n });\n\n return (\n <li\n ref={setNodeRef}\n className={`flex items-start gap-3 p-4 transition-colors hover:bg-bg-sunken/50 ${\n isDragging ? \"opacity-40\" : \"\"\n }`}\n >\n <div className=\"flex w-16 shrink-0 flex-col items-end pt-0.5 text-xs tabular-nums text-text-secondary\">\n <span>{formatTime(segment.startTime)}</span>\n <span className=\"text-text-tertiary\">\n {formatDuration(segment.durationSeconds)}\n </span>\n </div>\n {segment.isRecategorizable && (\n <button\n type=\"button\"\n aria-label={`Drag to recategorize ${segment.title || meta.label}`}\n className=\"mt-1.5 shrink-0 cursor-grab touch-none text-text-tertiary hover:text-text-secondary active:cursor-grabbing\"\n {...attributes}\n {...listeners}\n >\n <GripVertical className=\"h-4 w-4\" />\n </button>\n )}\n <div\n className={`mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg ${meta.chip}`}\n >\n <SourceIcon className=\"h-4 w-4\" />\n </div>\n <div className=\"min-w-0 flex-1\">\n <p className=\"truncate text-sm font-medium text-text-primary\">\n {segment.title || meta.label}\n </p>\n <div className=\"mt-1 flex flex-wrap items-center gap-2\">\n <span\n className={`inline-flex rounded-full px-2 py-0.5 text-xs font-medium ${meta.chip}`}\n >\n {meta.label}\n </span>\n {projectName !== undefined && (\n <span 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\">\n <FolderOpen className=\"h-3 w-3 shrink-0\" />\n <span className=\"truncate\">{projectName}</span>\n </span>\n )}\n {segment.app && (\n <span className=\"text-xs text-text-secondary\">{segment.app}</span>\n )}\n {provenance && (\n <span className=\"text-xs text-text-tertiary\">{provenance}</span>\n )}\n </div>\n </div>\n {segment.isRecategorizable && (\n <select\n aria-label=\"Recategorize activity\"\n disabled={recategorizing}\n value={category}\n onChange={(e) => onRecategorize(segment, e.target.value as Category)}\n 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\"\n >\n {CATEGORY_ORDER.map((c) => (\n <option key={c} value={c}>\n {CATEGORY_META[c].label}\n </option>\n ))}\n </select>\n )}\n </li>\n );\n}\n\nfunction toLocalDateInput(date: Date): string {\n const offset = date.getTimezoneOffset();\n const local = new Date(date.getTime() - offset * 60 * 1000);\n return local.toISOString().slice(0, 10);\n}\n\nfunction dayBounds(dateStr: string): { from: string; to: string } {\n const start = new Date(`${dateStr}T00:00:00`);\n const end = new Date(`${dateStr}T23:59:59.999`);\n return { from: start.toISOString(), to: end.toISOString() };\n}\n\nexport function TimelinePage() {\n const { workspaceId = \"\" } = useTimeCampus();\n const [dateStr, setDateStr] = useState(() => toLocalDateInput(new Date()));\n const [draggingSegment, setDraggingSegment] =\n useState<TimelineSegmentFieldsFragment | null>(null);\n\n const { from, to } = useMemo(() => dayBounds(dateStr), [dateStr]);\n\n const { data, loading, error, refetch } = useGetTimeCampusTimelineQuery({\n variables: { from, to },\n skip: !workspaceId,\n fetchPolicy: \"cache-and-network\",\n });\n\n // Segments carry a `projectId` only; the workspace's projects supply the\n // name to show next to them. A segment whose id isn't in this list simply\n // keeps no project chip — it is never labelled from a guess.\n const { data: projectsData } = useListProjectsQuery({\n variables: { pagination: { limit: 200 } },\n skip: !workspaceId,\n });\n\n const [recategorize, { loading: recategorizing }] =\n useRecategorizeTimeCampusCaptureEventMutation();\n\n const sensors = useSensors(\n useSensor(PointerSensor, { activationConstraint: { distance: 6 } }),\n useSensor(KeyboardSensor),\n );\n\n const timeline = data?.timeCampusTimeline;\n const segments = timeline?.segments ?? [];\n const summary = timeline?.summary;\n\n const projectNameById = useMemo(() => {\n const map = new Map<string, string>();\n for (const project of projectsData?.projects?.items ?? []) {\n map.set(project.id, project.name);\n }\n return map;\n }, [projectsData?.projects?.items]);\n\n const totalsByCategory = useMemo(() => {\n const map = new Map<\n string,\n { totalSeconds: number; segmentCount: number }\n >();\n for (const t of summary?.byCategory ?? []) {\n map.set(t.category, {\n totalSeconds: t.totalSeconds,\n segmentCount: t.segmentCount,\n });\n }\n return map;\n }, [summary]);\n\n const handleRecategorize = async (\n segment: TimelineSegmentFieldsFragment,\n category: Category,\n ) => {\n if (!segment.isRecategorizable || segment.category === category) return;\n await recategorize({\n variables: { id: segment.sourceId, category },\n });\n await refetch();\n };\n\n const handleDragStart = (event: DragStartEvent) => {\n const segment = event.active.data.current?.segment as\n TimelineSegmentFieldsFragment | undefined;\n setDraggingSegment(segment ?? null);\n };\n\n const handleDragEnd = (event: DragEndEvent) => {\n const segment = event.active.data.current?.segment as\n TimelineSegmentFieldsFragment | undefined;\n setDraggingSegment(null);\n const overId = event.over?.id;\n if (!segment || typeof overId !== \"string\") return;\n const category = overId.replace(/^category:/, \"\") as Category;\n if (!CATEGORY_ORDER.includes(category)) return;\n void handleRecategorize(segment, category);\n };\n\n const focusPct =\n summary && summary.focusRatio != null\n ? Math.round(summary.focusRatio * 100)\n : 0;\n\n // The real span of the day, straight off the summary — not inferred from the\n // segment list, which may be paginated or filtered differently.\n const daySpan =\n summary?.firstActivityAt && summary?.lastActivityAt\n ? `${formatTime(summary.firstActivityAt)} – ${formatTime(summary.lastActivityAt)}`\n : null;\n\n return (\n <PageLayout\n title=\"Timeline\"\n description=\"Your day, assembled automatically\"\n 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.\"\n actions={\n <div className=\"flex flex-wrap items-center gap-3\">\n {daySpan && (\n <span 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\">\n <Activity className=\"h-3.5 w-3.5\" />\n {daySpan}\n </span>\n )}\n <label className=\"flex items-center gap-2 text-sm text-text-secondary\">\n <Calendar className=\"h-4 w-4\" />\n <input\n type=\"date\"\n value={dateStr}\n max={toLocalDateInput(new Date())}\n onChange={(e) => setDateStr(e.target.value)}\n 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\"\n />\n </label>\n </div>\n }\n >\n {loading && !timeline ? (\n <div className=\"space-y-6\">\n <LoadingSkeleton variant=\"card\" count={4} />\n <LoadingSkeleton variant=\"list\" count={6} />\n </div>\n ) : error ? (\n <div className=\"rounded-lg border border-status-error-bg/40 bg-status-error-bg p-4 text-sm text-status-error-text\">\n Failed to load your timeline. Please try again later.\n </div>\n ) : (\n <DndContext\n sensors={sensors}\n onDragStart={handleDragStart}\n onDragEnd={handleDragEnd}\n >\n <div className=\"space-y-6\">\n {/* Summary */}\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4\">\n <StatCard\n featured\n title=\"Tracked time\"\n value={formatDuration(summary?.totalTrackedSeconds ?? 0)}\n icon={<Activity className=\"h-5 w-5\" />}\n description=\"Total activity across the day\"\n />\n <StatCard\n title=\"Focus ratio\"\n value={`${focusPct}%`}\n icon={<Brain className=\"h-5 w-5\" />}\n description=\"Share of time in deep work\"\n />\n <StatCard\n title=\"Context switches\"\n value={summary?.contextSwitches ?? 0}\n icon={<Zap className=\"h-5 w-5\" />}\n description=\"Category changes through the day\"\n />\n <StatCard\n title=\"Longest focus block\"\n value={formatDuration(summary?.longestFocusBlockSeconds ?? 0)}\n icon={<Brain className=\"h-5 w-5\" />}\n description=\"Your deepest uninterrupted stretch\"\n />\n </div>\n\n {/* Category breakdown — also the drop targets for drag-to-recategorize */}\n {segments.length > 0 && (\n <GlassCard treatment=\"glass\" className=\"p-4 sm:p-6\">\n <h2 className=\"mb-1 text-sm font-semibold text-text-primary\">\n Where the time went\n </h2>\n <p className=\"mb-4 text-xs text-text-secondary\">\n Drag a segment from the timeline below onto a category to\n recategorize it — or use its dropdown.\n </p>\n <div className=\"flex flex-wrap gap-4\">\n {CATEGORY_ORDER.map((category) => {\n const meta = CATEGORY_META[category];\n const total = totalsByCategory.get(category);\n return (\n <DroppableCategoryChip\n key={category}\n category={category}\n label={meta.label}\n dotClassName={meta.dot}\n totalSeconds={total?.totalSeconds ?? 0}\n />\n );\n })}\n </div>\n </GlassCard>\n )}\n\n {/* Chronological timeline */}\n {segments.length === 0 ? (\n <EmptyState\n illustration=\"empty-generic\"\n title=\"No activity captured for this day\"\n description=\"As you track time, hold meetings, run focus sessions, and connect shared integrations, your day assembles here automatically — categorized and in order.\"\n />\n ) : (\n <GlassCard treatment=\"glass\" glow className=\"overflow-hidden\">\n <ol className=\"divide-y divide-border-seam\">\n {segments.map((segment: TimelineSegmentFieldsFragment) => (\n <DraggableSegmentRow\n key={segment.id}\n segment={segment}\n category={(segment.category as Category) ?? \"OTHER\"}\n projectName={\n segment.projectId\n ? projectNameById.get(segment.projectId)\n : undefined\n }\n recategorizing={recategorizing}\n onRecategorize={handleRecategorize}\n />\n ))}\n </ol>\n </GlassCard>\n )}\n </div>\n\n <DragOverlay>\n {draggingSegment && (\n <div className=\"flex items-center gap-2 rounded-lg border border-border-seam bg-bg-surface px-3 py-2 shadow-pop\">\n <GripVertical className=\"h-4 w-4 text-text-tertiary\" />\n <span className=\"text-sm font-medium text-text-primary\">\n {draggingSegment.title ||\n CATEGORY_META[\n (draggingSegment.category as Category) ?? \"OTHER\"\n ].label}\n </span>\n </div>\n )}\n </DragOverlay>\n </DndContext>\n )}\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAyCA,IAAM,IAGF;CACF,WAAW;EACT,OAAO;EACP,MAAM;EACN,KAAK;EACL,MAAM;CACR;CACA,SAAS;EACP,OAAO;EACP,MAAM;EACN,KAAK;EACL,MAAM;CACR;CACA,eAAe;EACb,OAAO;EACP,MAAM;EACN,KAAK;EACL,MAAM;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QAA+C,UAAA;OAEzD,CAAA;OACJ,kBAAC,KAAD;QAAG,WAAU;QAAmC,UAAA;OAG7C,CAAA;OACH,kBAAC,OAAD;QAAK,WAAU;QACZ,UAAA,EAAe,KAAK,MAAa;SAChC,IAAM,IAAO,EAAc,IACrB,IAAQ,EAAiB,IAAI,CAAQ;SAC3C,OACE,kBAAC,GAAD;UAEY;UACV,OAAO,EAAK;UACZ,cAAc,EAAK;UACnB,cAAc,GAAO,gBAAgB;SACtC,GALM,CAKN;QAEL,CAAC;OACE,CAAA;MACI;;KAIZ,EAAS,WAAW,IACnB,kBAAC,GAAD;MACE,cAAa;MACb,OAAM;MACN,aAAY;KACb,CAAA,IAED,kBAAC,GAAD;MAAW,WAAU;MAAQ,MAAA;MAAK,WAAU;MAC1C,UAAA,kBAAC,MAAD;OAAI,WAAU;OACX,UAAA,EAAS,KAAK,MACb,kBAAC,GAAD;QAEW;QACT,UAAW,EAAQ,YAAyB;QAC5C,aACE,EAAQ,YACJ,EAAgB,IAAI,EAAQ,SAAS,IACrC,KAAA;QAEU;QAChB,gBAAgB;OACjB,GAVM,EAAQ,EAUd,CACF;MACC,CAAA;KACK,CAAA;IAEV;GAEL,CAAA,GAAA,kBAAC,GAAD,EAAA,UACG,KACC,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,kBAAC,GAAD,EAAc,WAAU,6BAA8B,CAAA,GACtD,kBAAC,QAAD;KAAM,WAAU;KACb,UAAA,EAAgB,SACf,EACG,EAAgB,YAAyB,QAC3C,CAAC;IACA,CAAA,CACH;GAEI,CAAA,EAAA,CAAA,CACH;;CAEJ,CAAA;AAEhB"}
|
|
1
|
+
{"version":3,"file":"TimelinePage.js","names":[],"sources":["../../../../src/timecampus/pages/timeline/TimelinePage.tsx"],"sourcesContent":["import { useMemo, useState } from \"react\";\nimport {\n DndContext,\n DragOverlay,\n KeyboardSensor,\n PointerSensor,\n useDraggable,\n useDroppable,\n useSensor,\n useSensors,\n type DragEndEvent,\n type DragStartEvent,\n} from \"@dnd-kit/core\";\nimport {\n Activity,\n Brain,\n Calendar,\n CalendarClock,\n Coffee,\n FolderOpen,\n Github,\n GripVertical,\n MessageSquare,\n Shield,\n Users,\n Zap,\n} from \"lucide-react\";\nimport { GlassCard } from \"@burdenoff/fe-libs/ui\";\nimport { PageLayout } from \"../../components/PageLayout\";\nimport { StatCard } from \"../../components/StatCard\";\nimport { EmptyState } from \"../../components/EmptyState\";\nimport { LoadingSkeleton } from \"../../components/LoadingSkeleton\";\nimport { formatDuration, formatTime } from \"../../utils/helpers\";\nimport { calendarHoldLabel } from \"../focus/focusHelpers\";\nimport {\n driftLabel,\n focusStatusLabel,\n plannedDrift,\n protectedPercent,\n} from \"./timelineFocus\";\nimport { useTimeCampus } from \"../../providers/TimeCampusProvider\";\nimport {\n useGetTimeCampusTimelineQuery,\n useListProjectsQuery,\n useRecategorizeTimeCampusCaptureEventMutation,\n type TimelineSegmentFieldsFragment,\n} from \"@/generated/wspace-operations\";\n\ntype Category = \"MEETING\" | \"DEEP_WORK\" | \"COMMUNICATION\" | \"BREAK\" | \"OTHER\";\n\nconst CATEGORY_META: Record<\n Category,\n { label: string; icon: typeof Brain; dot: string; chip: string }\n> = {\n DEEP_WORK: {\n label: \"Deep work\",\n icon: Brain,\n dot: \"bg-status-success-bg\",\n chip: \"bg-status-success-bg text-status-success-text\",\n },\n MEETING: {\n label: \"Meeting\",\n icon: Users,\n dot: \"bg-status-info-bg\",\n chip: \"bg-status-info-bg text-status-info-text\",\n },\n COMMUNICATION: {\n label: \"Communication\",\n icon: MessageSquare,\n dot: \"bg-status-warning-bg\",\n chip: \"bg-status-warning-bg text-status-warning-text\",\n },\n BREAK: {\n label: \"Break\",\n icon: Coffee,\n dot: \"bg-bg-sunken\",\n chip: \"bg-bg-sunken text-text-secondary\",\n },\n OTHER: {\n label: \"Other\",\n icon: Activity,\n dot: \"bg-bg-sunken\",\n chip: \"bg-bg-sunken text-text-secondary\",\n },\n};\n\nconst SOURCE_ICON: Record<string, typeof Brain> = {\n TIME_ENTRY: Zap,\n MEETING: Users,\n POMODORO: Brain,\n EMAIL: MessageSquare,\n CAPTURE: Github,\n FOCUS_SESSION: Shield,\n FOCUS_BLOCK: CalendarClock,\n};\n\n/** Focus sessions and planned focus blocks get their own row (BOFF-9678). */\nfunction isFocusSegment(segment: TimelineSegmentFieldsFragment): boolean {\n return segment.source === \"FOCUS_SESSION\" || segment.source === \"FOCUS_BLOCK\";\n}\n\n/**\n * A focus session (what happened) or a planned focus block: planned vs\n * actual window, and protected vs interrupted time. Planned blocks are drawn\n * dashed and are not counted in the day's totals.\n */\nfunction FocusSegmentRow({\n segment,\n}: {\n segment: TimelineSegmentFieldsFragment;\n}) {\n const focus = segment.focus;\n if (!focus) return null;\n const planned = segment.isPlanned;\n const Icon = planned ? CalendarClock : Shield;\n const status = focusStatusLabel(planned, focus, segment.endTime);\n const percent = planned ? null : protectedPercent(focus);\n const drift = planned\n ? null\n : plannedDrift(segment.startTime, segment.endTime, focus);\n const hold = calendarHoldLabel(focus.calendarHoldStatus);\n\n return (\n <li\n className={`flex items-start gap-3 p-4 ${\n planned ? \"bg-bg-sunken/30\" : \"\"\n }`}\n data-testid={planned ? \"timeline-focus-block\" : \"timeline-focus-session\"}\n >\n <div className=\"flex w-16 shrink-0 flex-col items-end pt-0.5 text-xs tabular-nums text-text-secondary\">\n <span>{formatTime(segment.startTime)}</span>\n <span className=\"text-text-tertiary\">\n {formatDuration(segment.durationSeconds)}\n </span>\n </div>\n <div\n className={`mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg ${\n planned\n ? \"border border-dashed border-status-success-text/60 text-status-success-text\"\n : \"bg-status-success-bg text-status-success-text\"\n }`}\n >\n <Icon className=\"h-4 w-4\" />\n </div>\n <div className=\"min-w-0 flex-1\">\n <p className=\"truncate text-sm font-medium text-text-primary\">\n {segment.title || (planned ? \"Planned focus block\" : \"Focus session\")}\n </p>\n <div className=\"mt-1 flex flex-wrap items-center gap-2\">\n <span\n className={`inline-flex rounded-full px-2 py-0.5 text-xs font-medium ${\n planned\n ? \"border border-dashed border-border-seam text-text-secondary\"\n : \"bg-status-success-bg text-status-success-text\"\n }`}\n data-testid=\"timeline-focus-status\"\n >\n {status}\n </span>\n {focus.protectionLevel === \"STRICT\" && (\n <span className=\"text-xs text-text-secondary\">Strict</span>\n )}\n {focus.plannedStartTime && focus.plannedEndTime && (\n <span className=\"text-xs tabular-nums text-text-secondary\">\n Planned {formatTime(focus.plannedStartTime)} –{\" \"}\n {formatTime(focus.plannedEndTime)}\n </span>\n )}\n {!planned && segment.endTime && (\n <span className=\"text-xs tabular-nums text-text-secondary\">\n Actual {formatTime(segment.startTime)} –{\" \"}\n {formatTime(segment.endTime)}\n </span>\n )}\n {drift && (\n <span className=\"text-xs text-text-tertiary\">\n Started {driftLabel(drift.startMinutes)}\n {drift.endMinutes !== null &&\n `, ended ${driftLabel(drift.endMinutes, \"over\", \"short\")}`}\n </span>\n )}\n {hold && <span className=\"text-xs text-text-tertiary\">{hold}</span>}\n </div>\n {!planned && (\n <div className=\"mt-2\" data-testid=\"timeline-focus-protection\">\n <div\n className=\"flex h-1.5 w-full max-w-xs overflow-hidden rounded-full bg-bg-sunken\"\n role=\"img\"\n aria-label={`${percent ?? 0}% of this session stayed protected`}\n >\n <span\n className=\"h-full bg-status-success-text\"\n style={{ width: `${percent ?? 0}%` }}\n />\n <span\n className=\"h-full bg-status-warning-text\"\n style={{ width: `${percent === null ? 0 : 100 - percent}%` }}\n />\n </div>\n <p className=\"mt-1 text-xs tabular-nums text-text-secondary\">\n Protected {formatDuration(focus.protectedSeconds)} · Interrupted{\" \"}\n {formatDuration(focus.interruptedSeconds)} ·{\" \"}\n {focus.interruptionCount} interruption\n {focus.interruptionCount === 1 ? \"\" : \"s\"}\n {focus.blockedAttemptCount > 0 &&\n ` · ${focus.blockedAttemptCount} distraction${\n focus.blockedAttemptCount === 1 ? \"\" : \"s\"\n } blocked`}\n </p>\n </div>\n )}\n {planned && (\n <p className=\"mt-1 text-xs text-text-tertiary\">\n Not counted in the day's totals until you run it.\n </p>\n )}\n </div>\n </li>\n );\n}\n\nconst CATEGORY_ORDER: Category[] = [\n \"DEEP_WORK\",\n \"MEETING\",\n \"COMMUNICATION\",\n \"BREAK\",\n \"OTHER\",\n];\n\n/**\n * How a segment came by its category. The service writes these lowercase\n * (`timeline.service.ts` → 'auto' | 'user' | 'channel'), so normalise before\n * matching rather than trusting the string's casing.\n */\nconst CATEGORY_SOURCE_LABEL: Record<string, string> = {\n auto: \"Auto-categorized\",\n user: \"You set this\",\n channel: \"From channel rules\",\n};\n\nfunction categorySourceLabel(source: string | null | undefined): string | null {\n if (!source) return null;\n return CATEGORY_SOURCE_LABEL[source.toLowerCase()] ?? source;\n}\n\n/** Droppable target: a category chip in the \"Where the time went\" summary. */\nfunction DroppableCategoryChip({\n category,\n label,\n dotClassName,\n totalSeconds,\n}: {\n category: Category;\n label: string;\n dotClassName: string;\n totalSeconds: number;\n}) {\n const { isOver, setNodeRef } = useDroppable({ id: `category:${category}` });\n return (\n <div\n ref={setNodeRef}\n className={`flex items-center gap-2 rounded-lg border px-3 py-2 transition-colors ${\n isOver\n ? \"border-action-primary-bg bg-action-primary-bg/10\"\n : \"border-border-seam bg-bg-surface\"\n }`}\n >\n <span\n className={`inline-block h-2.5 w-2.5 rounded-full ${dotClassName}`}\n aria-hidden\n />\n <span className=\"text-sm font-medium text-text-primary\">{label}</span>\n <span className=\"text-sm tabular-nums text-text-secondary\">\n {formatDuration(totalSeconds)}\n </span>\n {isOver && (\n <span className=\"text-xs font-medium text-primary\">Drop here</span>\n )}\n </div>\n );\n}\n\n/** Draggable row for a single timeline segment, with the existing dropdown kept as an accessible fallback. */\nfunction DraggableSegmentRow({\n segment,\n category,\n projectName,\n recategorizing,\n onRecategorize,\n}: {\n segment: TimelineSegmentFieldsFragment;\n category: Category;\n /** Resolved name for `segment.projectId`; undefined when it carries none. */\n projectName: string | undefined;\n recategorizing: boolean;\n onRecategorize: (\n segment: TimelineSegmentFieldsFragment,\n category: Category,\n ) => void;\n}) {\n const meta = CATEGORY_META[category] ?? CATEGORY_META.OTHER;\n const SourceIcon = SOURCE_ICON[segment.source] ?? Activity;\n const provenance = categorySourceLabel(segment.categorySource);\n const { attributes, listeners, setNodeRef, isDragging } = useDraggable({\n id: segment.id,\n data: { segment },\n disabled: !segment.isRecategorizable,\n });\n\n return (\n <li\n ref={setNodeRef}\n className={`flex items-start gap-3 p-4 transition-colors hover:bg-bg-sunken/50 ${\n isDragging ? \"opacity-40\" : \"\"\n }`}\n >\n <div className=\"flex w-16 shrink-0 flex-col items-end pt-0.5 text-xs tabular-nums text-text-secondary\">\n <span>{formatTime(segment.startTime)}</span>\n <span className=\"text-text-tertiary\">\n {formatDuration(segment.durationSeconds)}\n </span>\n </div>\n {segment.isRecategorizable && (\n <button\n type=\"button\"\n aria-label={`Drag to recategorize ${segment.title || meta.label}`}\n className=\"mt-1.5 shrink-0 cursor-grab touch-none text-text-tertiary hover:text-text-secondary active:cursor-grabbing\"\n {...attributes}\n {...listeners}\n >\n <GripVertical className=\"h-4 w-4\" />\n </button>\n )}\n <div\n className={`mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg ${meta.chip}`}\n >\n <SourceIcon className=\"h-4 w-4\" />\n </div>\n <div className=\"min-w-0 flex-1\">\n <p className=\"truncate text-sm font-medium text-text-primary\">\n {segment.title || meta.label}\n </p>\n <div className=\"mt-1 flex flex-wrap items-center gap-2\">\n <span\n className={`inline-flex rounded-full px-2 py-0.5 text-xs font-medium ${meta.chip}`}\n >\n {meta.label}\n </span>\n {projectName !== undefined && (\n <span 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\">\n <FolderOpen className=\"h-3 w-3 shrink-0\" />\n <span className=\"truncate\">{projectName}</span>\n </span>\n )}\n {segment.app && (\n <span className=\"text-xs text-text-secondary\">{segment.app}</span>\n )}\n {provenance && (\n <span className=\"text-xs text-text-tertiary\">{provenance}</span>\n )}\n </div>\n </div>\n {segment.isRecategorizable && (\n <select\n aria-label=\"Recategorize activity\"\n disabled={recategorizing}\n value={category}\n onChange={(e) => onRecategorize(segment, e.target.value as Category)}\n 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\"\n >\n {CATEGORY_ORDER.map((c) => (\n <option key={c} value={c}>\n {CATEGORY_META[c].label}\n </option>\n ))}\n </select>\n )}\n </li>\n );\n}\n\nfunction toLocalDateInput(date: Date): string {\n const offset = date.getTimezoneOffset();\n const local = new Date(date.getTime() - offset * 60 * 1000);\n return local.toISOString().slice(0, 10);\n}\n\n/** Latest day the picker offers: planned focus blocks can be up to two weeks ahead. */\nconst MAX_DAYS_AHEAD = 14;\n\nfunction maxPickableDate(): string {\n const d = new Date();\n d.setDate(d.getDate() + MAX_DAYS_AHEAD);\n return toLocalDateInput(d);\n}\n\nfunction dayBounds(dateStr: string): { from: string; to: string } {\n const start = new Date(`${dateStr}T00:00:00`);\n const end = new Date(`${dateStr}T23:59:59.999`);\n return { from: start.toISOString(), to: end.toISOString() };\n}\n\nexport function TimelinePage() {\n const { workspaceId = \"\" } = useTimeCampus();\n const [dateStr, setDateStr] = useState(() => toLocalDateInput(new Date()));\n const [draggingSegment, setDraggingSegment] =\n useState<TimelineSegmentFieldsFragment | null>(null);\n\n const { from, to } = useMemo(() => dayBounds(dateStr), [dateStr]);\n\n const { data, loading, error, refetch } = useGetTimeCampusTimelineQuery({\n variables: { from, to },\n skip: !workspaceId,\n fetchPolicy: \"cache-and-network\",\n });\n\n // Segments carry a `projectId` only; the workspace's projects supply the\n // name to show next to them. A segment whose id isn't in this list simply\n // keeps no project chip — it is never labelled from a guess.\n const { data: projectsData } = useListProjectsQuery({\n variables: { pagination: { limit: 200 } },\n skip: !workspaceId,\n });\n\n const [recategorize, { loading: recategorizing }] =\n useRecategorizeTimeCampusCaptureEventMutation();\n\n const sensors = useSensors(\n useSensor(PointerSensor, { activationConstraint: { distance: 6 } }),\n useSensor(KeyboardSensor),\n );\n\n const timeline = data?.timeCampusTimeline;\n const segments = timeline?.segments ?? [];\n const summary = timeline?.summary;\n\n const projectNameById = useMemo(() => {\n const map = new Map<string, string>();\n for (const project of projectsData?.projects?.items ?? []) {\n map.set(project.id, project.name);\n }\n return map;\n }, [projectsData?.projects?.items]);\n\n const totalsByCategory = useMemo(() => {\n const map = new Map<\n string,\n { totalSeconds: number; segmentCount: number }\n >();\n for (const t of summary?.byCategory ?? []) {\n map.set(t.category, {\n totalSeconds: t.totalSeconds,\n segmentCount: t.segmentCount,\n });\n }\n return map;\n }, [summary]);\n\n const handleRecategorize = async (\n segment: TimelineSegmentFieldsFragment,\n category: Category,\n ) => {\n if (!segment.isRecategorizable || segment.category === category) return;\n await recategorize({\n variables: { id: segment.sourceId, category },\n });\n await refetch();\n };\n\n const handleDragStart = (event: DragStartEvent) => {\n const segment = event.active.data.current?.segment as\n TimelineSegmentFieldsFragment | undefined;\n setDraggingSegment(segment ?? null);\n };\n\n const handleDragEnd = (event: DragEndEvent) => {\n const segment = event.active.data.current?.segment as\n TimelineSegmentFieldsFragment | undefined;\n setDraggingSegment(null);\n const overId = event.over?.id;\n if (!segment || typeof overId !== \"string\") return;\n const category = overId.replace(/^category:/, \"\") as Category;\n if (!CATEGORY_ORDER.includes(category)) return;\n void handleRecategorize(segment, category);\n };\n\n const focusPct =\n summary && summary.focusRatio != null\n ? Math.round(summary.focusRatio * 100)\n : 0;\n\n // The real span of the day, straight off the summary — not inferred from the\n // segment list, which may be paginated or filtered differently.\n const daySpan =\n summary?.firstActivityAt && summary?.lastActivityAt\n ? `${formatTime(summary.firstActivityAt)} – ${formatTime(summary.lastActivityAt)}`\n : null;\n\n return (\n <PageLayout\n title=\"Timeline\"\n description=\"Your day, assembled automatically\"\n 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.\"\n actions={\n <div className=\"flex flex-wrap items-center gap-3\">\n {daySpan && (\n <span 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\">\n <Activity className=\"h-3.5 w-3.5\" />\n {daySpan}\n </span>\n )}\n <label className=\"flex items-center gap-2 text-sm text-text-secondary\">\n <Calendar className=\"h-4 w-4\" />\n <input\n type=\"date\"\n value={dateStr}\n max={maxPickableDate()}\n onChange={(e) => setDateStr(e.target.value)}\n 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\"\n />\n </label>\n </div>\n }\n >\n {loading && !timeline ? (\n <div className=\"space-y-6\">\n <LoadingSkeleton variant=\"card\" count={4} />\n <LoadingSkeleton variant=\"list\" count={6} />\n </div>\n ) : error ? (\n <div className=\"rounded-lg border border-status-error-bg/40 bg-status-error-bg p-4 text-sm text-status-error-text\">\n Failed to load your timeline. Please try again later.\n </div>\n ) : (\n <DndContext\n sensors={sensors}\n onDragStart={handleDragStart}\n onDragEnd={handleDragEnd}\n >\n <div className=\"space-y-6\">\n {/* Summary */}\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4\">\n <StatCard\n featured\n title=\"Tracked time\"\n value={formatDuration(summary?.totalTrackedSeconds ?? 0)}\n icon={<Activity className=\"h-5 w-5\" />}\n description=\"Total activity across the day\"\n />\n <StatCard\n title=\"Focus ratio\"\n value={`${focusPct}%`}\n icon={<Brain className=\"h-5 w-5\" />}\n description=\"Share of time in deep work\"\n />\n <StatCard\n title=\"Context switches\"\n value={summary?.contextSwitches ?? 0}\n icon={<Zap className=\"h-5 w-5\" />}\n description=\"Category changes through the day\"\n />\n <StatCard\n title=\"Longest focus block\"\n value={formatDuration(summary?.longestFocusBlockSeconds ?? 0)}\n icon={<Brain className=\"h-5 w-5\" />}\n description=\"Your deepest uninterrupted stretch\"\n />\n </div>\n\n {/* Category breakdown — also the drop targets for drag-to-recategorize */}\n {segments.length > 0 && (\n <GlassCard treatment=\"glass\" className=\"p-4 sm:p-6\">\n <h2 className=\"mb-1 text-sm font-semibold text-text-primary\">\n Where the time went\n </h2>\n <p className=\"mb-4 text-xs text-text-secondary\">\n Drag a segment from the timeline below onto a category to\n recategorize it — or use its dropdown.\n </p>\n <div className=\"flex flex-wrap gap-4\">\n {CATEGORY_ORDER.map((category) => {\n const meta = CATEGORY_META[category];\n const total = totalsByCategory.get(category);\n return (\n <DroppableCategoryChip\n key={category}\n category={category}\n label={meta.label}\n dotClassName={meta.dot}\n totalSeconds={total?.totalSeconds ?? 0}\n />\n );\n })}\n </div>\n </GlassCard>\n )}\n\n {/* Chronological timeline */}\n {segments.length === 0 ? (\n <EmptyState\n illustration=\"empty-generic\"\n title=\"No activity captured for this day\"\n description=\"As you track time, hold meetings, run focus sessions, and connect shared integrations, your day assembles here automatically — categorized and in order.\"\n />\n ) : (\n <GlassCard treatment=\"glass\" glow className=\"overflow-hidden\">\n <ol className=\"divide-y divide-border-seam\">\n {segments.map((segment: TimelineSegmentFieldsFragment) =>\n isFocusSegment(segment) ? (\n <FocusSegmentRow key={segment.id} segment={segment} />\n ) : (\n <DraggableSegmentRow\n key={segment.id}\n segment={segment}\n category={(segment.category as Category) ?? \"OTHER\"}\n projectName={\n segment.projectId\n ? projectNameById.get(segment.projectId)\n : undefined\n }\n recategorizing={recategorizing}\n onRecategorize={handleRecategorize}\n />\n ),\n )}\n </ol>\n </GlassCard>\n )}\n </div>\n\n <DragOverlay>\n {draggingSegment && (\n <div className=\"flex items-center gap-2 rounded-lg border border-border-seam bg-bg-surface px-3 py-2 shadow-pop\">\n <GripVertical className=\"h-4 w-4 text-text-tertiary\" />\n <span className=\"text-sm font-medium text-text-primary\">\n {draggingSegment.title ||\n CATEGORY_META[\n (draggingSegment.category as Category) ?? \"OTHER\"\n ].label}\n </span>\n </div>\n )}\n </Drag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AA8B,CAAA,GACtD,kBAAC,QAAD;KAAM,WAAU;KACb,UAAA,EAAgB,SACf,EACG,EAAgB,YAAyB,QAC3C,CAAC;IACA,CAAA,CACH;GAEI,CAAA,EAAA,CAAA,CACH;;CAEJ,CAAA;AAEhB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure helpers for focus segments on the Timeline page (BOFF-9678): planned
|
|
3
|
+
* vs actual, and protected vs interrupted time.
|
|
4
|
+
*/
|
|
5
|
+
export interface TimelineFocusDetail {
|
|
6
|
+
status: string;
|
|
7
|
+
protectionLevel?: string | null;
|
|
8
|
+
plannedStartTime?: string | null;
|
|
9
|
+
plannedEndTime?: string | null;
|
|
10
|
+
protectedSeconds: number;
|
|
11
|
+
interruptedSeconds: number;
|
|
12
|
+
interruptionCount: number;
|
|
13
|
+
blockedAttemptCount: number;
|
|
14
|
+
}
|
|
15
|
+
/** Share (0..100) of a session's tracked time that stayed protected, or null when nothing was tracked. */
|
|
16
|
+
export declare function protectedPercent(focus: TimelineFocusDetail): number | null;
|
|
17
|
+
/**
|
|
18
|
+
* The short status chip for a focus segment: a planned block is "Planned"
|
|
19
|
+
* until its end, then "Missed" (it was never started); a session shows its
|
|
20
|
+
* own status.
|
|
21
|
+
*/
|
|
22
|
+
export declare function focusStatusLabel(isPlanned: boolean, focus: TimelineFocusDetail, endIso: string | null | undefined, now?: number): string;
|
|
23
|
+
/**
|
|
24
|
+
* How far the actual session drifted from its planned window, in whole
|
|
25
|
+
* minutes: positive = started late / ran over. Null when there is no plan.
|
|
26
|
+
*/
|
|
27
|
+
export declare function plannedDrift(actualStartIso: string, actualEndIso: string | null | undefined, focus: TimelineFocusDetail): {
|
|
28
|
+
startMinutes: number;
|
|
29
|
+
endMinutes: number | null;
|
|
30
|
+
} | null;
|
|
31
|
+
/** "5 min late", "on time", "10 min early". */
|
|
32
|
+
export declare function driftLabel(minutes: number, late?: string, early?: string): string;
|
|
33
|
+
//# sourceMappingURL=timelineFocus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timelineFocus.d.ts","sourceRoot":"","sources":["../../../../src/timecampus/pages/timeline/timelineFocus.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,gBAAgB,EAAE,MAAM,CAAC;IACzB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED,0GAA0G;AAC1G,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,mBAAmB,GAAG,MAAM,GAAG,IAAI,CAI1E;AAQD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,OAAO,EAClB,KAAK,EAAE,mBAAmB,EAC1B,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACjC,GAAG,SAAa,GACf,MAAM,CAKR;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,cAAc,EAAE,MAAM,EACtB,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACvC,KAAK,EAAE,mBAAmB,GACzB;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,CAY5D;AAED,+CAA+C;AAC/C,wBAAgB,UAAU,CACxB,OAAO,EAAE,MAAM,EACf,IAAI,SAAS,EACb,KAAK,SAAU,GACd,MAAM,CAGR"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/timecampus/pages/timeline/timelineFocus.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
let t = e.protectedSeconds + e.interruptedSeconds;
|
|
4
|
+
return t <= 0 ? null : Math.round(e.protectedSeconds / t * 100);
|
|
5
|
+
}
|
|
6
|
+
var t = {
|
|
7
|
+
ACTIVE: "In progress",
|
|
8
|
+
COMPLETED: "Completed",
|
|
9
|
+
ABANDONED: "Abandoned"
|
|
10
|
+
};
|
|
11
|
+
function n(e, n, r, i = Date.now()) {
|
|
12
|
+
return e ? r && Date.parse(r) <= i ? "Missed" : "Planned" : t[n.status] ?? n.status;
|
|
13
|
+
}
|
|
14
|
+
function r(e, t, n) {
|
|
15
|
+
return n.plannedStartTime ? {
|
|
16
|
+
startMinutes: Math.round((Date.parse(e) - Date.parse(n.plannedStartTime)) / 6e4),
|
|
17
|
+
endMinutes: t && n.plannedEndTime ? Math.round((Date.parse(t) - Date.parse(n.plannedEndTime)) / 6e4) : null
|
|
18
|
+
} : null;
|
|
19
|
+
}
|
|
20
|
+
function i(e, t = "late", n = "early") {
|
|
21
|
+
return e === 0 ? "on time" : e > 0 ? `${e} min ${t}` : `${-e} min ${n}`;
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { i as driftLabel, n as focusStatusLabel, r as plannedDrift, e as protectedPercent };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=timelineFocus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timelineFocus.js","names":[],"sources":["../../../../src/timecampus/pages/timeline/timelineFocus.ts"],"sourcesContent":["/**\n * Pure helpers for focus segments on the Timeline page (BOFF-9678): planned\n * vs actual, and protected vs interrupted time.\n */\n\nexport interface TimelineFocusDetail {\n status: string;\n protectionLevel?: string | null;\n plannedStartTime?: string | null;\n plannedEndTime?: string | null;\n protectedSeconds: number;\n interruptedSeconds: number;\n interruptionCount: number;\n blockedAttemptCount: number;\n}\n\n/** Share (0..100) of a session's tracked time that stayed protected, or null when nothing was tracked. */\nexport function protectedPercent(focus: TimelineFocusDetail): number | null {\n const total = focus.protectedSeconds + focus.interruptedSeconds;\n if (total <= 0) return null;\n return Math.round((focus.protectedSeconds / total) * 100);\n}\n\nconst SESSION_STATUS_LABELS: Record<string, string> = {\n ACTIVE: \"In progress\",\n COMPLETED: \"Completed\",\n ABANDONED: \"Abandoned\",\n};\n\n/**\n * The short status chip for a focus segment: a planned block is \"Planned\"\n * until its end, then \"Missed\" (it was never started); a session shows its\n * own status.\n */\nexport function focusStatusLabel(\n isPlanned: boolean,\n focus: TimelineFocusDetail,\n endIso: string | null | undefined,\n now = Date.now(),\n): string {\n if (isPlanned) {\n return endIso && Date.parse(endIso) <= now ? \"Missed\" : \"Planned\";\n }\n return SESSION_STATUS_LABELS[focus.status] ?? focus.status;\n}\n\n/**\n * How far the actual session drifted from its planned window, in whole\n * minutes: positive = started late / ran over. Null when there is no plan.\n */\nexport function plannedDrift(\n actualStartIso: string,\n actualEndIso: string | null | undefined,\n focus: TimelineFocusDetail,\n): { startMinutes: number; endMinutes: number | null } | null {\n if (!focus.plannedStartTime) return null;\n const startMinutes = Math.round(\n (Date.parse(actualStartIso) - Date.parse(focus.plannedStartTime)) / 60000,\n );\n const endMinutes =\n actualEndIso && focus.plannedEndTime\n ? Math.round(\n (Date.parse(actualEndIso) - Date.parse(focus.plannedEndTime)) / 60000,\n )\n : null;\n return { startMinutes, endMinutes };\n}\n\n/** \"5 min late\", \"on time\", \"10 min early\". */\nexport function driftLabel(\n minutes: number,\n late = \"late\",\n early = \"early\",\n): string {\n if (minutes === 0) return \"on time\";\n return minutes > 0 ? `${minutes} min ${late}` : `${-minutes} min ${early}`;\n}\n"],"mappings":";AAiBA,SAAgB,EAAiB,GAA2C;CAC1E,IAAM,IAAQ,EAAM,mBAAmB,EAAM;CAE7C,OADI,KAAS,IAAU,OAChB,KAAK,MAAO,EAAM,mBAAmB,IAAS,GAAG;AAC1D;AAEA,IAAM,IAAgD;CACpD,QAAQ;CACR,WAAW;CACX,WAAW;AACb;AAOA,SAAgB,EACd,GACA,GACA,GACA,IAAM,KAAK,IAAI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,MAAM,EAAE,MAAM,GACb,wBAAwB,
|
|
1
|
+
{"version":3,"file":"pageContext.d.ts","sourceRoot":"","sources":["../../src/utils/pageContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,UAAU,wBAAwB;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,WAAW;IAG1B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IAGpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,iBAAiB,IAAI,WAAW,CAiB/C;AAMD,wBAAgB,oCAAoC,CAClD,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb,wBAAwB,CAyF1B"}
|
|
@@ -14,11 +14,17 @@ function t(e, t) {
|
|
|
14
14
|
return t.match(e);
|
|
15
15
|
}
|
|
16
16
|
function n(e, n) {
|
|
17
|
-
let r = new URLSearchParams(n);
|
|
17
|
+
let r = new URLSearchParams(n), i = t(/^\/?timecampus\/projects\/(?!new\/?$)([^/]+)(?:\/(tasks))?\/?$/, e);
|
|
18
|
+
if (i) return {
|
|
19
|
+
entityType: "TIMECAMPUS_PROJECT",
|
|
20
|
+
entityId: i[1],
|
|
21
|
+
...i[2] ? { activeTab: i[2] } : {},
|
|
22
|
+
projectId: i[1],
|
|
23
|
+
metadata: { routePattern: "timecampus/projects/:projectId" }
|
|
24
|
+
};
|
|
18
25
|
for (let [n, r] of [
|
|
19
|
-
[/^\/?timecampus\/time\/projects\/([^/]+)$/, "TIMECAMPUS_PROJECT"],
|
|
20
26
|
[/^\/?timecampus\/time\/tasks\/([^/]+)$/, "TIMECAMPUS_TASK"],
|
|
21
|
-
[/^\/?timecampus\/meetings\/([^/]+)$/, "TIMECAMPUS_MEETING"],
|
|
27
|
+
[/^\/?timecampus\/meetings\/(?!(?:new|analytics)$)([^/]+)$/, "TIMECAMPUS_MEETING"],
|
|
22
28
|
[/^\/?timecampus\/pomodoro\/sessions\/([^/]+)$/, "TIMECAMPUS_POMODORO_SESSION"],
|
|
23
29
|
[/^\/?timecampus\/lifetime\/goals\/([^/]+)$/, "TIMECAMPUS_LIFE_GOAL"],
|
|
24
30
|
[/^\/?timecampus\/resource-planning\/plans\/([^/]+)$/, "TIMECAMPUS_RESOURCE_PLAN"]
|
|
@@ -42,15 +48,15 @@ function n(e, n) {
|
|
|
42
48
|
entityType: r,
|
|
43
49
|
metadata: { routePattern: n.source }
|
|
44
50
|
};
|
|
45
|
-
let
|
|
51
|
+
let a = r.get("tab") ?? (() => {
|
|
46
52
|
let t = e.split("/").filter(Boolean);
|
|
47
53
|
return t.length > 2 ? t[t.length - 1] : void 0;
|
|
48
54
|
})();
|
|
49
55
|
return {
|
|
50
|
-
activeTab:
|
|
56
|
+
activeTab: a ?? void 0,
|
|
51
57
|
projectId: r.get("projectId") ?? void 0,
|
|
52
58
|
metadata: {
|
|
53
|
-
...
|
|
59
|
+
...a ? { activeTab: a } : {},
|
|
54
60
|
...r.get("projectId") ? { projectId: r.get("projectId") } : {},
|
|
55
61
|
...r.get("date") ? { date: r.get("date") } : {}
|
|
56
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pageContext.js","names":[],"sources":["../../src/utils/pageContext.ts"],"sourcesContent":["/**\n * Page context gathering — captures the user's current browser context\n * to be sent alongside every assistant prompt for better AI awareness.\n *\n * Only emit keys the agent's ALLOWED_CONTEXT_KEYS allow-list actually\n * forwards (`~/products/wspace/sandbox/ai-assistant/src/context-loader.ts`):\n * currentUrl, currentPage, entityType, entityId, entityName, pageTitle,\n * pageType, activeTab, activeTool, selectedText, workspaceId, workspaceName,\n * projectId, projectName (+ legacy per-product back-compat keys). `platform`\n * and `version` are silently dropped server-side (the agent already knows\n * the product from `AI_ASSISTANT_PRODUCT` at boot), and `userAgent` is sent\n * over the wire but dropped agent-side — a needless fingerprinting leak for\n * a privacy-first product. None of the five are emitted here.\n */\n\ninterface ConversationContextShape {\n entityType?: string;\n entityId?: string;\n activeTab?: string;\n projectId?: string;\n metadata?: Record<string, unknown>;\n}\n\nexport interface PageContext {\n // `currentUrl` (NOT `activeUrl`) — must match the agent's allowed-context-key\n // contract, otherwise the agent filters it out.\n currentUrl: string;\n currentPage: string;\n // The entity the user is currently looking at, resolved from the route. Lets\n // the assistant act on \"this / current / here\" without asking for an id.\n entityType?: string;\n entityId?: string;\n // Surfaced separately from `metadata` so the allow-listed `activeTab` /\n // `projectId` keys actually reach the agent instead of being discarded.\n activeTab?: string;\n projectId?: string;\n}\n\nexport function gatherPageContext(): PageContext {\n const url = window.location.href;\n const pathSegments = window.location.pathname.split(\"/\").filter(Boolean);\n const currentPage = pathSegments.slice(0, 3).join(\"/\") || \"home\";\n const entity = resolveTimeCampusConversationContext(\n window.location.pathname,\n window.location.search,\n );\n\n return {\n currentUrl: url,\n currentPage,\n entityType: entity.entityType,\n entityId: entity.entityId,\n activeTab: entity.activeTab,\n projectId: entity.projectId,\n };\n}\n\nfunction matchPath(pattern: RegExp, pathname: string): RegExpMatchArray | null {\n return pathname.match(pattern);\n}\n\nexport function resolveTimeCampusConversationContext(\n pathname: string,\n search: string,\n): ConversationContextShape {\n const params = new URLSearchParams(search);\n\n
|
|
1
|
+
{"version":3,"file":"pageContext.js","names":[],"sources":["../../src/utils/pageContext.ts"],"sourcesContent":["/**\n * Page context gathering — captures the user's current browser context\n * to be sent alongside every assistant prompt for better AI awareness.\n *\n * Only emit keys the agent's ALLOWED_CONTEXT_KEYS allow-list actually\n * forwards (`~/products/wspace/sandbox/ai-assistant/src/context-loader.ts`):\n * currentUrl, currentPage, entityType, entityId, entityName, pageTitle,\n * pageType, activeTab, activeTool, selectedText, workspaceId, workspaceName,\n * projectId, projectName (+ legacy per-product back-compat keys). `platform`\n * and `version` are silently dropped server-side (the agent already knows\n * the product from `AI_ASSISTANT_PRODUCT` at boot), and `userAgent` is sent\n * over the wire but dropped agent-side — a needless fingerprinting leak for\n * a privacy-first product. None of the five are emitted here.\n */\n\ninterface ConversationContextShape {\n entityType?: string;\n entityId?: string;\n activeTab?: string;\n projectId?: string;\n metadata?: Record<string, unknown>;\n}\n\nexport interface PageContext {\n // `currentUrl` (NOT `activeUrl`) — must match the agent's allowed-context-key\n // contract, otherwise the agent filters it out.\n currentUrl: string;\n currentPage: string;\n // The entity the user is currently looking at, resolved from the route. Lets\n // the assistant act on \"this / current / here\" without asking for an id.\n entityType?: string;\n entityId?: string;\n // Surfaced separately from `metadata` so the allow-listed `activeTab` /\n // `projectId` keys actually reach the agent instead of being discarded.\n activeTab?: string;\n projectId?: string;\n}\n\nexport function gatherPageContext(): PageContext {\n const url = window.location.href;\n const pathSegments = window.location.pathname.split(\"/\").filter(Boolean);\n const currentPage = pathSegments.slice(0, 3).join(\"/\") || \"home\";\n const entity = resolveTimeCampusConversationContext(\n window.location.pathname,\n window.location.search,\n );\n\n return {\n currentUrl: url,\n currentPage,\n entityType: entity.entityType,\n entityId: entity.entityId,\n activeTab: entity.activeTab,\n projectId: entity.projectId,\n };\n}\n\nfunction matchPath(pattern: RegExp, pathname: string): RegExpMatchArray | null {\n return pathname.match(pattern);\n}\n\nexport function resolveTimeCampusConversationContext(\n pathname: string,\n search: string,\n): ConversationContextShape {\n const params = new URLSearchParams(search);\n\n // A project page lives at `/timecampus/projects/:projectId` (and its task\n // board at `.../tasks`) per TimeCampusRoutes.tsx; `projects/new` is the\n // create form, not a project.\n const projectMatch = matchPath(\n /^\\/?timecampus\\/projects\\/(?!new\\/?$)([^/]+)(?:\\/(tasks))?\\/?$/,\n pathname,\n );\n if (projectMatch) {\n return {\n entityType: \"TIMECAMPUS_PROJECT\",\n entityId: projectMatch[1],\n ...(projectMatch[2] ? { activeTab: projectMatch[2] } : {}),\n projectId: projectMatch[1],\n metadata: { routePattern: \"timecampus/projects/:projectId\" },\n };\n }\n\n const directMatches: Array<[RegExp, string]> = [\n [/^\\/?timecampus\\/time\\/tasks\\/([^/]+)$/, \"TIMECAMPUS_TASK\"],\n // `meetings/new` and `meetings/analytics` are pages, not meetings.\n [\n /^\\/?timecampus\\/meetings\\/(?!(?:new|analytics)$)([^/]+)$/,\n \"TIMECAMPUS_MEETING\",\n ],\n [\n /^\\/?timecampus\\/pomodoro\\/sessions\\/([^/]+)$/,\n \"TIMECAMPUS_POMODORO_SESSION\",\n ],\n [/^\\/?timecampus\\/lifetime\\/goals\\/([^/]+)$/, \"TIMECAMPUS_LIFE_GOAL\"],\n [\n /^\\/?timecampus\\/resource-planning\\/plans\\/([^/]+)$/,\n \"TIMECAMPUS_RESOURCE_PLAN\",\n ],\n ];\n\n for (const [pattern, entityType] of directMatches) {\n const match = matchPath(pattern, pathname);\n if (match) {\n return {\n entityType,\n entityId: match[1],\n metadata: { routePattern: pattern.source },\n };\n }\n }\n\n // Page-level matches: these TimeCampus modules are flat list/dashboard\n // pages with no per-entity detail route (confirmed against\n // TimeCampusRoutes.tsx), so there is no id to capture — but the assistant\n // still benefits from knowing which module the user is looking at, so it\n // can scope \"show me my expenses\" / \"approve this\" style prompts without\n // asking which module the user means.\n const pageLevelMatches: Array<[RegExp, string]> = [\n [/^\\/?timecampus\\/timeline\\/?$/, \"TIMECAMPUS_TIMELINE\"],\n [/^\\/?timecampus\\/time\\/entries\\/?$/, \"TIMECAMPUS_TIME_ENTRY\"],\n [/^\\/?timecampus\\/expense-tracking\\/?$/, \"TIMECAMPUS_EXPENSE\"],\n [/^\\/?timecampus\\/invoicing\\/?$/, \"TIMECAMPUS_INVOICING\"],\n [/^\\/?timecampus\\/time-approval\\/?$/, \"TIMECAMPUS_APPROVAL\"],\n [/^\\/?timecampus\\/client-portal\\/?$/, \"TIMECAMPUS_CLIENT_PORTAL\"],\n [/^\\/?timecampus\\/application-usage\\/?$/, \"TIMECAMPUS_APP_USAGE\"],\n ];\n\n for (const [pattern, entityType] of pageLevelMatches) {\n if (matchPath(pattern, pathname)) {\n return { entityType, metadata: { routePattern: pattern.source } };\n }\n }\n\n const activeTab =\n params.get(\"tab\") ??\n (() => {\n const segments = pathname.split(\"/\").filter(Boolean);\n return segments.length > 2 ? segments[segments.length - 1] : undefined;\n })();\n\n return {\n activeTab: activeTab ?? undefined,\n projectId: params.get(\"projectId\") ?? undefined,\n metadata: {\n ...(activeTab ? { activeTab } : {}),\n ...(params.get(\"projectId\")\n ? { projectId: params.get(\"projectId\") }\n : {}),\n ...(params.get(\"date\") ? { date: params.get(\"date\") } : {}),\n },\n };\n}\n"],"mappings":";AAsCA,SAAgB,IAAiC;CAC/C,IAAM,IAAM,OAAO,SAAS,MAEtB,IADe,OAAO,SAAS,SAAS,MAAM,GAAG,CAAC,CAAC,OAAO,OAC5C,CAAA,CAAa,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,KAAK,QACpD,IAAS,EACb,OAAO,SAAS,UAChB,OAAO,SAAS,MAClB;CAEA,OAAO;EACL,YAAY;EACZ;EACA,YAAY,EAAO;EACnB,UAAU,EAAO;EACjB,WAAW,EAAO;EAClB,WAAW,EAAO;CACpB;AACF;AAEA,SAAS,EAAU,GAAiB,GAA2C;CAC7E,OAAO,EAAS,MAAM,CAAO;AAC/B;AAEA,SAAgB,EACd,GACA,GAC0B;CAC1B,IAAM,IAAS,IAAI,gBAAgB,CAAM,GAKnC,IAAe,EACnB,kEACA,CACF;CACA,IAAI,GACF,OAAO;EACL,YAAY;EACZ,UAAU,EAAa;EACvB,GAAI,EAAa,KAAK,EAAE,WAAW,EAAa,GAAG,IAAI,CAAC;EACxD,WAAW,EAAa;EACxB,UAAU,EAAE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