@flamingo-stack/openframe-frontend-core 0.0.690 → 0.0.691-snapshot.20261001154617

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/dist/{chunk-22RSJ57Z.js → chunk-2YVTGPM7.js} +2 -2
  2. package/dist/{chunk-QNWQQ4RT.cjs → chunk-53O6PQ3F.cjs} +7 -7
  3. package/dist/{chunk-QNWQQ4RT.cjs.map → chunk-53O6PQ3F.cjs.map} +1 -1
  4. package/dist/{chunk-54X75QTC.cjs → chunk-5XPK2QGU.cjs} +14 -14
  5. package/dist/{chunk-54X75QTC.cjs.map → chunk-5XPK2QGU.cjs.map} +1 -1
  6. package/dist/{chunk-4HBYEZ3I.cjs → chunk-7BNWMOPM.cjs} +82 -82
  7. package/dist/{chunk-4HBYEZ3I.cjs.map → chunk-7BNWMOPM.cjs.map} +1 -1
  8. package/dist/{chunk-HLEXYTOE.js → chunk-7EPGJOKN.js} +4 -4
  9. package/dist/{chunk-XRSJER2B.js → chunk-A5NHAHV6.js} +4 -4
  10. package/dist/{chunk-P27OGSQL.cjs → chunk-ATREVNIN.cjs} +37 -37
  11. package/dist/{chunk-P27OGSQL.cjs.map → chunk-ATREVNIN.cjs.map} +1 -1
  12. package/dist/{chunk-S5M5SEW2.js → chunk-AVAZ6BD6.js} +5 -5
  13. package/dist/{chunk-DLRE5Y3G.js → chunk-C2SVJVEB.js} +2 -2
  14. package/dist/{chunk-KZXKT5AX.cjs → chunk-CG7OWW7X.cjs} +14 -14
  15. package/dist/{chunk-KZXKT5AX.cjs.map → chunk-CG7OWW7X.cjs.map} +1 -1
  16. package/dist/{chunk-AIXPQT3G.js → chunk-CKO6NKNE.js} +801 -222
  17. package/dist/chunk-CKO6NKNE.js.map +1 -0
  18. package/dist/{chunk-UFXV64WQ.cjs → chunk-CKUPANVU.cjs} +9 -9
  19. package/dist/{chunk-UFXV64WQ.cjs.map → chunk-CKUPANVU.cjs.map} +1 -1
  20. package/dist/{chunk-3ZAIHRQH.cjs → chunk-DKJDO7YM.cjs} +35 -35
  21. package/dist/{chunk-3ZAIHRQH.cjs.map → chunk-DKJDO7YM.cjs.map} +1 -1
  22. package/dist/{chunk-D7BFS7N6.cjs → chunk-DUURFYGS.cjs} +3 -3
  23. package/dist/{chunk-D7BFS7N6.cjs.map → chunk-DUURFYGS.cjs.map} +1 -1
  24. package/dist/{chunk-NMXL34Z2.cjs → chunk-DVSPRY2V.cjs} +3 -3
  25. package/dist/{chunk-NMXL34Z2.cjs.map → chunk-DVSPRY2V.cjs.map} +1 -1
  26. package/dist/{chunk-VLWUKFQE.cjs → chunk-EXWS2QSD.cjs} +1301 -722
  27. package/dist/chunk-EXWS2QSD.cjs.map +1 -0
  28. package/dist/{chunk-5CBQBTGN.cjs → chunk-F6LXGP6S.cjs} +7 -7
  29. package/dist/{chunk-5CBQBTGN.cjs.map → chunk-F6LXGP6S.cjs.map} +1 -1
  30. package/dist/{chunk-MDYTAKJ5.cjs → chunk-FTK3S57R.cjs} +22 -22
  31. package/dist/{chunk-MDYTAKJ5.cjs.map → chunk-FTK3S57R.cjs.map} +1 -1
  32. package/dist/{chunk-UAKWSR3U.js → chunk-GDZ7IC5B.js} +2 -2
  33. package/dist/{chunk-OD2WMUAO.cjs → chunk-GZRU2A4L.cjs} +197 -197
  34. package/dist/{chunk-OD2WMUAO.cjs.map → chunk-GZRU2A4L.cjs.map} +1 -1
  35. package/dist/{chunk-Q76YVNCQ.js → chunk-HM7ZGABI.js} +2 -2
  36. package/dist/{chunk-YCKGUQA2.cjs → chunk-I27PWVWE.cjs} +17 -12
  37. package/dist/chunk-I27PWVWE.cjs.map +1 -0
  38. package/dist/{chunk-TSENCZUL.js → chunk-IQTQIBZ3.js} +11 -11
  39. package/dist/{chunk-QUGV2GT3.cjs → chunk-KDCIYRZV.cjs} +34 -34
  40. package/dist/{chunk-QUGV2GT3.cjs.map → chunk-KDCIYRZV.cjs.map} +1 -1
  41. package/dist/{chunk-2MGTNYHW.cjs → chunk-KQZMM3QJ.cjs} +100 -100
  42. package/dist/{chunk-2MGTNYHW.cjs.map → chunk-KQZMM3QJ.cjs.map} +1 -1
  43. package/dist/{chunk-BJHM2OEY.cjs → chunk-LNKLB7GM.cjs} +17 -17
  44. package/dist/{chunk-BJHM2OEY.cjs.map → chunk-LNKLB7GM.cjs.map} +1 -1
  45. package/dist/{chunk-Z622ACFD.js → chunk-LYJJH4D6.js} +5 -5
  46. package/dist/{chunk-42RQ4NIL.js → chunk-LYQULSK4.js} +6 -6
  47. package/dist/{chunk-TBJWPNHU.js → chunk-MCNQKS6I.js} +4 -4
  48. package/dist/chunk-MCNQKS6I.js.map +1 -0
  49. package/dist/{chunk-JGVJRUGB.cjs → chunk-MIZU2OTO.cjs} +4 -4
  50. package/dist/{chunk-JGVJRUGB.cjs.map → chunk-MIZU2OTO.cjs.map} +1 -1
  51. package/dist/{chunk-BOM6MMWB.cjs → chunk-N3526CTH.cjs} +3 -3
  52. package/dist/{chunk-BOM6MMWB.cjs.map → chunk-N3526CTH.cjs.map} +1 -1
  53. package/dist/{chunk-2PQKZWWP.js → chunk-PKZGXRU2.js} +6 -6
  54. package/dist/{chunk-FCQR6VY4.cjs → chunk-Q25VYAEL.cjs} +26 -26
  55. package/dist/{chunk-FCQR6VY4.cjs.map → chunk-Q25VYAEL.cjs.map} +1 -1
  56. package/dist/{chunk-25X43LSD.js → chunk-RK47E3PP.js} +4 -4
  57. package/dist/{chunk-V5NOURSR.js → chunk-RLNNV46K.js} +5 -5
  58. package/dist/{chunk-ZBQZJAC7.cjs → chunk-RTKF5AYA.cjs} +7 -7
  59. package/dist/chunk-RTKF5AYA.cjs.map +1 -0
  60. package/dist/{chunk-RF2EYX3B.js → chunk-SC44YJCF.js} +2 -2
  61. package/dist/{chunk-2OD2PPNO.cjs → chunk-SDORFSFK.cjs} +37 -37
  62. package/dist/{chunk-2OD2PPNO.cjs.map → chunk-SDORFSFK.cjs.map} +1 -1
  63. package/dist/{chunk-5A3WSWZD.js → chunk-TEIHEFXP.js} +8 -8
  64. package/dist/{chunk-U4OJCJTH.js → chunk-TXFGG47A.js} +4 -4
  65. package/dist/{chunk-DMXI5D2Q.cjs → chunk-USKQURNF.cjs} +3 -3
  66. package/dist/{chunk-DMXI5D2Q.cjs.map → chunk-USKQURNF.cjs.map} +1 -1
  67. package/dist/{chunk-2KILTCND.js → chunk-UVUNBXS6.js} +6 -1
  68. package/dist/chunk-UVUNBXS6.js.map +1 -0
  69. package/dist/{chunk-X4WBGDNW.cjs → chunk-WTYQCT4A.cjs} +18 -18
  70. package/dist/{chunk-X4WBGDNW.cjs.map → chunk-WTYQCT4A.cjs.map} +1 -1
  71. package/dist/{chunk-OC3QH5WG.js → chunk-X5XFKI6N.js} +2 -2
  72. package/dist/{chunk-2V4KPBNZ.js → chunk-XAOAYDGR.js} +3 -3
  73. package/dist/{chunk-4BUPMSLY.js → chunk-Y7ZEVTLC.js} +3 -3
  74. package/dist/{chunk-DOUG4UEZ.js → chunk-Z7QCNCBN.js} +11 -11
  75. package/dist/{chunk-OQVHGPHA.js → chunk-ZAV2F4VX.js} +3 -3
  76. package/dist/components/case-studies/index.cjs +20 -20
  77. package/dist/components/case-studies/index.js +7 -7
  78. package/dist/components/chat/index.cjs +4 -4
  79. package/dist/components/chat/index.js +3 -3
  80. package/dist/components/contact/index.cjs +8 -8
  81. package/dist/components/contact/index.js +7 -7
  82. package/dist/components/docs/index.cjs +11 -11
  83. package/dist/components/docs/index.js +10 -10
  84. package/dist/components/embeds/index.cjs +8 -8
  85. package/dist/components/embeds/index.js +7 -7
  86. package/dist/components/faq/index.cjs +9 -9
  87. package/dist/components/faq/index.js +8 -8
  88. package/dist/components/features/index.cjs +39 -7
  89. package/dist/components/features/index.cjs.map +1 -1
  90. package/dist/components/features/index.d.ts +1 -0
  91. package/dist/components/features/index.d.ts.map +1 -1
  92. package/dist/components/features/index.js +38 -6
  93. package/dist/components/features/remote-session/index.d.ts +13 -0
  94. package/dist/components/features/remote-session/index.d.ts.map +1 -0
  95. package/dist/components/features/remote-session/remote-access-request-card.d.ts +19 -0
  96. package/dist/components/features/remote-session/remote-access-request-card.d.ts.map +1 -0
  97. package/dist/components/features/remote-session/remote-session-block.d.ts +41 -0
  98. package/dist/components/features/remote-session/remote-session-block.d.ts.map +1 -0
  99. package/dist/components/features/remote-session/remote-session-chat-panel.d.ts +23 -0
  100. package/dist/components/features/remote-session/remote-session-chat-panel.d.ts.map +1 -0
  101. package/dist/components/features/remote-session/remote-session-dialog.d.ts +15 -0
  102. package/dist/components/features/remote-session/remote-session-dialog.d.ts.map +1 -0
  103. package/dist/components/features/remote-session/remote-session-overlay.d.ts +12 -0
  104. package/dist/components/features/remote-session/remote-session-overlay.d.ts.map +1 -0
  105. package/dist/components/features/remote-session/remote-session-parts.d.ts +34 -0
  106. package/dist/components/features/remote-session/remote-session-parts.d.ts.map +1 -0
  107. package/dist/components/features/remote-session/types.d.ts +33 -0
  108. package/dist/components/features/remote-session/types.d.ts.map +1 -0
  109. package/dist/components/help-center-pages/index.cjs +101 -101
  110. package/dist/components/help-center-pages/index.js +21 -21
  111. package/dist/components/index.cjs +97 -65
  112. package/dist/components/index.cjs.map +1 -1
  113. package/dist/components/index.js +53 -21
  114. package/dist/components/index.js.map +1 -1
  115. package/dist/components/meeting-scheduler/index.cjs +58 -58
  116. package/dist/components/meeting-scheduler/index.js +8 -8
  117. package/dist/components/navigation/index.cjs +10 -10
  118. package/dist/components/navigation/index.js +9 -9
  119. package/dist/components/onboarding-guides/index.cjs +11 -11
  120. package/dist/components/onboarding-guides/index.js +10 -10
  121. package/dist/components/related-content/index.cjs +6 -6
  122. package/dist/components/related-content/index.js +5 -5
  123. package/dist/components/tickets/index.cjs +12 -12
  124. package/dist/components/tickets/index.js +11 -11
  125. package/dist/components/tickets/ticket-live-provider.d.ts.map +1 -1
  126. package/dist/components/ui/index.cjs +7 -7
  127. package/dist/components/ui/index.js +6 -6
  128. package/dist/hooks/index.cjs +4 -4
  129. package/dist/hooks/index.js +3 -3
  130. package/dist/index.cjs +44 -12
  131. package/dist/index.cjs.map +1 -1
  132. package/dist/index.js +42 -10
  133. package/dist/index.js.map +1 -1
  134. package/dist/utils/embed-authed-fetch.d.ts +18 -0
  135. package/dist/utils/embed-authed-fetch.d.ts.map +1 -1
  136. package/dist/utils/index.cjs +50 -6
  137. package/dist/utils/index.cjs.map +1 -1
  138. package/dist/utils/index.js +50 -6
  139. package/dist/utils/index.js.map +1 -1
  140. package/dist/utils/sse-subscription.d.ts +29 -11
  141. package/dist/utils/sse-subscription.d.ts.map +1 -1
  142. package/package.json +1 -1
  143. package/src/components/features/__tests__/remote-session.test.tsx +97 -0
  144. package/src/components/features/index.ts +1 -0
  145. package/src/components/features/remote-session/index.ts +36 -0
  146. package/src/components/features/remote-session/remote-access-request-card.tsx +102 -0
  147. package/src/components/features/remote-session/remote-session-block.tsx +182 -0
  148. package/src/components/features/remote-session/remote-session-chat-panel.tsx +178 -0
  149. package/src/components/features/remote-session/remote-session-dialog.tsx +77 -0
  150. package/src/components/features/remote-session/remote-session-overlay.tsx +33 -0
  151. package/src/components/features/remote-session/remote-session-parts.tsx +138 -0
  152. package/src/components/features/remote-session/types.ts +41 -0
  153. package/src/components/tickets/ticket-live-provider.tsx +14 -12
  154. package/src/stories/RemoteSessionAccessRequest.stories.tsx +71 -0
  155. package/src/stories/RemoteSessionBlock.stories.tsx +164 -0
  156. package/src/stories/RemoteSessionDialog.stories.tsx +49 -0
  157. package/src/stories/RemoteSessionIndicator.stories.tsx +44 -0
  158. package/src/utils/embed-authed-fetch.ts +21 -0
  159. package/src/utils/sse-subscription.ts +107 -20
  160. package/dist/chunk-2KILTCND.js.map +0 -1
  161. package/dist/chunk-AIXPQT3G.js.map +0 -1
  162. package/dist/chunk-TBJWPNHU.js.map +0 -1
  163. package/dist/chunk-VLWUKFQE.cjs.map +0 -1
  164. package/dist/chunk-YCKGUQA2.cjs.map +0 -1
  165. package/dist/chunk-ZBQZJAC7.cjs.map +0 -1
  166. /package/dist/{chunk-22RSJ57Z.js.map → chunk-2YVTGPM7.js.map} +0 -0
  167. /package/dist/{chunk-HLEXYTOE.js.map → chunk-7EPGJOKN.js.map} +0 -0
  168. /package/dist/{chunk-XRSJER2B.js.map → chunk-A5NHAHV6.js.map} +0 -0
  169. /package/dist/{chunk-S5M5SEW2.js.map → chunk-AVAZ6BD6.js.map} +0 -0
  170. /package/dist/{chunk-DLRE5Y3G.js.map → chunk-C2SVJVEB.js.map} +0 -0
  171. /package/dist/{chunk-UAKWSR3U.js.map → chunk-GDZ7IC5B.js.map} +0 -0
  172. /package/dist/{chunk-Q76YVNCQ.js.map → chunk-HM7ZGABI.js.map} +0 -0
  173. /package/dist/{chunk-TSENCZUL.js.map → chunk-IQTQIBZ3.js.map} +0 -0
  174. /package/dist/{chunk-Z622ACFD.js.map → chunk-LYJJH4D6.js.map} +0 -0
  175. /package/dist/{chunk-42RQ4NIL.js.map → chunk-LYQULSK4.js.map} +0 -0
  176. /package/dist/{chunk-2PQKZWWP.js.map → chunk-PKZGXRU2.js.map} +0 -0
  177. /package/dist/{chunk-25X43LSD.js.map → chunk-RK47E3PP.js.map} +0 -0
  178. /package/dist/{chunk-V5NOURSR.js.map → chunk-RLNNV46K.js.map} +0 -0
  179. /package/dist/{chunk-RF2EYX3B.js.map → chunk-SC44YJCF.js.map} +0 -0
  180. /package/dist/{chunk-5A3WSWZD.js.map → chunk-TEIHEFXP.js.map} +0 -0
  181. /package/dist/{chunk-U4OJCJTH.js.map → chunk-TXFGG47A.js.map} +0 -0
  182. /package/dist/{chunk-OC3QH5WG.js.map → chunk-X5XFKI6N.js.map} +0 -0
  183. /package/dist/{chunk-2V4KPBNZ.js.map → chunk-XAOAYDGR.js.map} +0 -0
  184. /package/dist/{chunk-4BUPMSLY.js.map → chunk-Y7ZEVTLC.js.map} +0 -0
  185. /package/dist/{chunk-DOUG4UEZ.js.map → chunk-Z7QCNCBN.js.map} +0 -0
  186. /package/dist/{chunk-OQVHGPHA.js.map → chunk-ZAV2F4VX.js.map} +0 -0
@@ -0,0 +1,178 @@
1
+ 'use client';
2
+
3
+ import { useEffect, useRef } from 'react';
4
+ import { cn } from '../../../utils/cn';
5
+ import { MessageOffIcon, Send03Icon } from '../../icons-v2-generated';
6
+ import { Button } from '../../ui/button/button';
7
+ import { SquareAvatar } from '../../ui/square-avatar';
8
+ import { RemoteSessionEndButton } from './remote-session-block';
9
+ import {
10
+ REMOTE_SESSION_DRAG_HANDLE_CLASS,
11
+ RemoteSessionDragger,
12
+ RemoteSessionRecordingTag,
13
+ } from './remote-session-parts';
14
+ import type { RemoteSessionChatMessage, RemoteSessionDragHandlers, RemoteSessionParty } from './types';
15
+
16
+ export interface RemoteSessionChatPanelProps {
17
+ party: RemoteSessionParty;
18
+ /** Elapsed session time, e.g. from `useRemoteSessionTimer`. */
19
+ elapsed: string;
20
+ messages: RemoteSessionChatMessage[];
21
+ showRecordingTag?: boolean;
22
+ /** The composer's text; owned by the host so it survives hiding the block. */
23
+ draft: string;
24
+ onDraftChange: (draft: string) => void;
25
+ /** Called with the trimmed text; the composer clears itself through `onDraftChange`. */
26
+ onSend: (text: string) => void;
27
+ /** False while the chat is still connecting: the composer is disabled. */
28
+ ready?: boolean;
29
+ error?: string | null;
30
+ onCloseChat: () => void;
31
+ onEndSession: () => void;
32
+ /** Makes the header and the dragger move the window. */
33
+ dragHandlers?: RemoteSessionDragHandlers;
34
+ }
35
+
36
+ function formatTime(at: Date): string {
37
+ return at.toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' });
38
+ }
39
+
40
+ /** The chat with the technician inside the session block. */
41
+ export function RemoteSessionChatPanel({
42
+ party,
43
+ elapsed,
44
+ messages,
45
+ showRecordingTag = false,
46
+ draft,
47
+ onDraftChange,
48
+ onSend,
49
+ ready = true,
50
+ error,
51
+ onCloseChat,
52
+ onEndSession,
53
+ dragHandlers,
54
+ }: RemoteSessionChatPanelProps) {
55
+ const listRef = useRef<HTMLDivElement>(null);
56
+
57
+ // The list is the trigger: the newest row must come into view on every change.
58
+ useEffect(() => {
59
+ const list = listRef.current;
60
+ if (list) list.scrollTop = list.scrollHeight;
61
+ }, [messages]);
62
+
63
+ const handleSend = () => {
64
+ const text = draft.trim();
65
+ if (!text) return;
66
+ onSend(text);
67
+ onDraftChange('');
68
+ };
69
+
70
+ return (
71
+ <div className="flex min-h-0 flex-1 flex-col">
72
+ <div className="relative flex flex-col gap-[var(--spacing-system-m)] p-[var(--spacing-system-m)]">
73
+ <RemoteSessionDragger dragHandlers={dragHandlers} />
74
+ <div
75
+ className={cn(
76
+ 'flex w-full flex-col pr-[var(--spacing-system-mf)]',
77
+ dragHandlers && REMOTE_SESSION_DRAG_HANDLE_CLASS,
78
+ )}
79
+ {...dragHandlers}
80
+ >
81
+ <p className="w-full truncate text-ods-text-primary text-h4">
82
+ Your IT support team is connected <span className="text-ods-text-secondary">({elapsed})</span>
83
+ </p>
84
+ <p className="w-full truncate text-ods-text-secondary text-h4">You can end this session at any time</p>
85
+ </div>
86
+ {showRecordingTag && <RemoteSessionRecordingTag />}
87
+ <div className="flex w-full items-stretch gap-[var(--spacing-system-m)]">
88
+ <Button
89
+ variant="outline"
90
+ fullWidth
91
+ leftIcon={<MessageOffIcon size={24} color="currentColor" />}
92
+ onClick={onCloseChat}
93
+ >
94
+ Close Chat
95
+ </Button>
96
+ <RemoteSessionEndButton onEndSession={onEndSession} />
97
+ </div>
98
+ </div>
99
+ <div
100
+ ref={listRef}
101
+ className="flex min-h-0 flex-1 flex-col overflow-y-auto bg-ods-card p-[var(--spacing-system-m)]"
102
+ >
103
+ {/* mt-auto (not justify-end) keeps the top of an overflowing list scrollable. */}
104
+ <div className="mt-auto flex flex-col gap-[var(--spacing-system-s)]">
105
+ {messages.map(message =>
106
+ message.author === 'system' ? (
107
+ <p key={message.id} className="w-full text-center text-ods-text-secondary text-h6">
108
+ {message.text}
109
+ </p>
110
+ ) : (
111
+ <RemoteSessionChatMessageRow key={message.id} message={message} party={party} />
112
+ ),
113
+ )}
114
+ </div>
115
+ </div>
116
+ {error && <p className="bg-ods-card px-[var(--spacing-system-m)] text-ods-error text-h6">{error}</p>}
117
+ <form
118
+ className="flex items-center gap-[var(--spacing-system-xs)] bg-ods-card px-[var(--spacing-system-m)] pb-[var(--spacing-system-m)]"
119
+ onSubmit={event => {
120
+ event.preventDefault();
121
+ handleSend();
122
+ }}
123
+ >
124
+ <input
125
+ value={draft}
126
+ onChange={event => onDraftChange(event.target.value)}
127
+ disabled={!ready}
128
+ placeholder={ready ? 'Enter your Message...' : 'Loading chat...'}
129
+ aria-label="Message"
130
+ className="h-12 min-w-0 flex-1 rounded-md border border-ods-border bg-ods-bg px-[var(--spacing-system-s)] text-ods-text-primary outline-none text-h6 placeholder:text-ods-text-secondary"
131
+ />
132
+ <button
133
+ type="submit"
134
+ aria-label="Send message"
135
+ disabled={!ready}
136
+ className="flex size-12 shrink-0 items-center justify-center"
137
+ >
138
+ <Send03Icon size={24} color="currentColor" className="text-ods-text-primary" />
139
+ </button>
140
+ </form>
141
+ </div>
142
+ );
143
+ }
144
+
145
+ function RemoteSessionChatMessageRow({
146
+ message,
147
+ party,
148
+ }: {
149
+ message: RemoteSessionChatMessage;
150
+ party: RemoteSessionParty;
151
+ }) {
152
+ const isTechnician = message.author === 'technician';
153
+ const technician = message.name ?? party.technicianName ?? 'Technician';
154
+ return (
155
+ <div className="flex w-full flex-col">
156
+ <div className="flex w-full items-center gap-[var(--spacing-system-xs)]">
157
+ {isTechnician && (
158
+ <SquareAvatar
159
+ variant="round"
160
+ sizePx={16}
161
+ src={party.technicianAvatarUrl ?? undefined}
162
+ fallback={technician}
163
+ />
164
+ )}
165
+ <span
166
+ className={cn(
167
+ 'min-w-0 flex-1 truncate text-code',
168
+ isTechnician ? 'text-ods-accent' : 'text-ods-text-secondary',
169
+ )}
170
+ >
171
+ {isTechnician ? technician : 'User'}
172
+ </span>
173
+ <span className="shrink-0 text-ods-text-secondary text-h6">{formatTime(message.at)}</span>
174
+ </div>
175
+ <p className="w-full break-words text-ods-text-primary text-h6">{message.text}</p>
176
+ </div>
177
+ );
178
+ }
@@ -0,0 +1,77 @@
1
+ 'use client';
2
+
3
+ import type { ReactNode } from 'react';
4
+ import { Button } from '../../ui/button/button';
5
+ import type { RemoteSessionDialogVariant } from './types';
6
+
7
+ export interface RemoteSessionDialogProps {
8
+ variant: RemoteSessionDialogVariant;
9
+ /** Named in the "ended" and "connection lost" notices. */
10
+ organizationName: string;
11
+ /** End confirm: the end call is in flight. */
12
+ ending?: boolean;
13
+ /** End confirm: the user confirmed. */
14
+ onEndSession?: () => void;
15
+ /** Cancel (end confirm) or Close (the notices). */
16
+ onClose: () => void;
17
+ }
18
+
19
+ const NOTICE_COPY: Record<Exclude<RemoteSessionDialogVariant, 'end-confirm'>, { title: string; suffix: string }> = {
20
+ 'session-ended': { title: 'Remote session ended', suffix: 'has disconnected from your device.' },
21
+ 'connection-lost': { title: 'Connection lost', suffix: 'lost the connection to your device.' },
22
+ };
23
+
24
+ /** The session's terminal dialogs: the end confirm and the "it is over" notices. */
25
+ export function RemoteSessionDialog({
26
+ variant,
27
+ organizationName,
28
+ ending = false,
29
+ onEndSession,
30
+ onClose,
31
+ }: RemoteSessionDialogProps) {
32
+ if (variant === 'end-confirm') {
33
+ return (
34
+ <DialogCard>
35
+ <div className="flex w-full flex-col gap-[var(--spacing-system-xs)]">
36
+ <h1 className="w-full text-ods-text-primary text-h2">End remote session?</h1>
37
+ <p className="w-full text-ods-text-primary text-h4">
38
+ The technician will lose access to your device immediately.
39
+ </p>
40
+ </div>
41
+ <div className="flex w-full items-stretch gap-[var(--spacing-system-l)]">
42
+ <Button variant="outline" fullWidth disabled={ending} onClick={onClose}>
43
+ Cancel
44
+ </Button>
45
+ <Button variant="destructive" fullWidth loading={ending} onClick={onEndSession}>
46
+ End Session
47
+ </Button>
48
+ </div>
49
+ </DialogCard>
50
+ );
51
+ }
52
+
53
+ const copy = NOTICE_COPY[variant];
54
+ return (
55
+ <DialogCard>
56
+ <div className="flex w-full flex-col gap-[var(--spacing-system-xs)]">
57
+ <h1 className="w-full text-ods-text-primary text-h2">{copy.title}</h1>
58
+ <p className="w-full text-ods-text-primary text-h4">
59
+ <span className="text-ods-accent">{organizationName}</span> {copy.suffix}
60
+ </p>
61
+ </div>
62
+ <div className="flex w-full justify-end">
63
+ <Button variant="outline" className="w-1/2" onClick={onClose}>
64
+ Close
65
+ </Button>
66
+ </div>
67
+ </DialogCard>
68
+ );
69
+ }
70
+
71
+ function DialogCard({ children }: { children: ReactNode }) {
72
+ return (
73
+ <div className="flex w-full flex-col gap-[var(--spacing-system-l)] rounded-md border border-ods-border bg-ods-card p-[var(--spacing-system-xl)]">
74
+ {children}
75
+ </div>
76
+ );
77
+ }
@@ -0,0 +1,33 @@
1
+ 'use client';
2
+
3
+ import { cn } from '../../../utils/cn';
4
+ import { MonitorOffIcon } from '../../icons-v2-generated';
5
+
6
+ /*
7
+ * The always-visible "your screen is being controlled" indicator: a border
8
+ * around the screen and an End Session pill hanging from its top edge.
9
+ * The colour is the ODS warning token, not the accent: the accent follows
10
+ * tenant branding, and this indicator must stay a recognisable fixed yellow.
11
+ */
12
+
13
+ /** The warning-yellow frame drawn around a whole screen; it never takes pointer events. */
14
+ export function RemoteSessionBorder({ className }: { className?: string }) {
15
+ return <div className={cn('pointer-events-none size-full border-4 border-ods-warning', className)} />;
16
+ }
17
+
18
+ /**
19
+ * The End Session pill. It sits flush against the top edge of the screen, so
20
+ * only its bottom corners are rounded and it reads as one piece with the border.
21
+ */
22
+ export function RemoteSessionPill({ onEndSession }: { onEndSession: () => void }) {
23
+ return (
24
+ <button
25
+ type="button"
26
+ className="flex items-center gap-[var(--spacing-system-xsf)] rounded-b-md bg-ods-warning px-[var(--spacing-system-m)] py-[var(--spacing-system-xs)] text-ods-text-on-accent"
27
+ onClick={onEndSession}
28
+ >
29
+ <MonitorOffIcon size={24} color="currentColor" />
30
+ <span className="whitespace-nowrap text-h3">End Session</span>
31
+ </button>
32
+ );
33
+ }
@@ -0,0 +1,138 @@
1
+ 'use client';
2
+
3
+ import { type CSSProperties, type ReactNode, useEffect, useState } from 'react';
4
+ import { cn } from '../../../utils/cn';
5
+ import { DraggerIcon, RecordingIcon } from '../../icons-v2-generated';
6
+ import { OpenFrameLogo } from '../../icons/openframe-logo';
7
+ import { SquareAvatar } from '../../ui/square-avatar';
8
+ import type { RemoteSessionDragHandlers } from './types';
9
+
10
+ /**
11
+ * The remote session surfaces are fixed-size desktop windows (440 / 600 px
12
+ * wide), so the responsive ODS scale would step their typography and spacing
13
+ * down to the mobile values below the 800 px breakpoint. The scope pins the
14
+ * scale to its desktop values; everything inside keeps the regular utilities.
15
+ */
16
+ const DESKTOP_SCALE = {
17
+ '--spacing-system-xs': '0.5rem',
18
+ '--spacing-system-s': '0.75rem',
19
+ '--spacing-system-m': '1rem',
20
+ '--spacing-system-l': '1.5rem',
21
+ '--spacing-system-xl': '2.5rem',
22
+ '--font-size-h1-title': '3.5rem',
23
+ '--font-size-h2-sub-title': '2rem',
24
+ '--font-size-h3-body': '1.125rem',
25
+ '--font-size-h4-body': '1.125rem',
26
+ '--font-size-h5-caption': '0.875rem',
27
+ '--font-size-h6-caption': '0.875rem',
28
+ '--font-line-space-h1-main-title': '4rem',
29
+ '--font-line-space-h2-sub-title': '2.5rem',
30
+ '--font-line-space-h3-body': '1.5rem',
31
+ '--font-line-space-h4-body': '1.5rem',
32
+ '--font-line-space-h5-caption': '1.25rem',
33
+ '--font-line-space-h6-caption': '1.25rem',
34
+ } as CSSProperties;
35
+
36
+ export interface RemoteSessionScopeProps {
37
+ children: ReactNode;
38
+ className?: string;
39
+ }
40
+
41
+ /**
42
+ * Root of every remote session surface: the desktop type and spacing scale,
43
+ * and the OpenFrame brand whatever the host app's tenant branding is - the
44
+ * "you are being helped" surfaces are OpenFrame-branded by design.
45
+ */
46
+ export function RemoteSessionScope({ children, className }: RemoteSessionScopeProps) {
47
+ return (
48
+ <div data-app-type="openframe" style={DESKTOP_SCALE} className={className}>
49
+ {children}
50
+ </div>
51
+ );
52
+ }
53
+
54
+ export interface RemoteSessionOrgLogoProps {
55
+ name: string;
56
+ logoUrl?: string | null;
57
+ /** Width and height in px. */
58
+ sizePx: number;
59
+ className?: string;
60
+ }
61
+
62
+ /** Organization logo tile; the OpenFrame mark when there is no logo. */
63
+ export function RemoteSessionOrgLogo({ name, logoUrl, sizePx, className }: RemoteSessionOrgLogoProps) {
64
+ if (logoUrl) {
65
+ return (
66
+ <SquareAvatar
67
+ variant="square"
68
+ fit="contain"
69
+ sizePx={sizePx}
70
+ src={logoUrl}
71
+ alt={name}
72
+ fallback={name}
73
+ className={cn('shrink-0 rounded-md border border-ods-border bg-ods-card', className)}
74
+ />
75
+ );
76
+ }
77
+ return (
78
+ <div
79
+ role="img"
80
+ aria-label={name}
81
+ style={{ width: sizePx, height: sizePx }}
82
+ className={cn(
83
+ 'flex shrink-0 items-center justify-center rounded-md border border-ods-border bg-ods-card',
84
+ className,
85
+ )}
86
+ >
87
+ <OpenFrameLogo className="size-1/2" />
88
+ </div>
89
+ );
90
+ }
91
+
92
+ /** The green SESSION RECORDING tag. */
93
+ export function RemoteSessionRecordingTag() {
94
+ return (
95
+ <div className="flex h-8 items-center gap-[var(--spacing-system-xs)] self-start rounded-md bg-ods-success-secondary p-[var(--spacing-system-xsf)]">
96
+ <RecordingIcon size={16} color="currentColor" className="text-ods-success" />
97
+ <span className="text-ods-success text-h5">Session Recording</span>
98
+ </div>
99
+ );
100
+ }
101
+
102
+ /** Grab cursor on the surfaces the window is moved by. */
103
+ export const REMOTE_SESSION_DRAG_HANDLE_CLASS = 'cursor-grab active:cursor-grabbing';
104
+
105
+ /** The dragger glyph in the top-right corner of a block header: the visible handle for moving it. */
106
+ export function RemoteSessionDragger({ dragHandlers }: { dragHandlers?: RemoteSessionDragHandlers }) {
107
+ return (
108
+ <span
109
+ aria-hidden
110
+ className={cn(
111
+ 'absolute right-[var(--spacing-system-xsf)] top-[var(--spacing-system-xsf)] text-ods-text-secondary',
112
+ dragHandlers && REMOTE_SESSION_DRAG_HANDLE_CLASS,
113
+ )}
114
+ {...dragHandlers}
115
+ >
116
+ <DraggerIcon size={24} color="currentColor" />
117
+ </span>
118
+ );
119
+ }
120
+
121
+ /** `m:ss` for an elapsed duration; `h:mm:ss` from the first hour on. */
122
+ export function formatRemoteSessionElapsed(elapsedMs: number): string {
123
+ const total = Math.max(0, Math.floor(elapsedMs / 1000));
124
+ const hours = Math.floor(total / 3600);
125
+ const minutes = Math.floor((total % 3600) / 60);
126
+ const seconds = String(total % 60).padStart(2, '0');
127
+ return hours > 0 ? `${hours}:${String(minutes).padStart(2, '0')}:${seconds}` : `${minutes}:${seconds}`;
128
+ }
129
+
130
+ /** The session's elapsed time since `startedAt` (ISO), ticking once a second. */
131
+ export function useRemoteSessionTimer(startedAt: string): string {
132
+ const [nowMs, setNowMs] = useState(() => Date.now());
133
+ useEffect(() => {
134
+ const timer = setInterval(() => setNowMs(Date.now()), 1_000);
135
+ return () => clearInterval(timer);
136
+ }, []);
137
+ return formatRemoteSessionElapsed(nowMs - Date.parse(startedAt));
138
+ }
@@ -0,0 +1,41 @@
1
+ import type { HTMLAttributes } from 'react';
2
+
3
+ /**
4
+ * Who is on the other end of a remote session, as the end user's surfaces show
5
+ * it: the organization always, the technician when the backend names one.
6
+ */
7
+ export interface RemoteSessionParty {
8
+ organizationName: string;
9
+ organizationLogoUrl?: string | null;
10
+ /** Shown under the organization name; offered as a link only when it is https. */
11
+ organizationSiteUrl?: string | null;
12
+ /** Present for the technician variant of the session block; the organization variant otherwise. */
13
+ technicianName?: string | null;
14
+ technicianAvatarUrl?: string | null;
15
+ }
16
+
17
+ /** The end user's answer to a remote access request. */
18
+ export type RemoteAccessDecision = 'APPROVED' | 'DENIED';
19
+
20
+ export type RemoteSessionChatAuthor = 'technician' | 'user' | 'system';
21
+
22
+ export interface RemoteSessionChatMessage {
23
+ id: string;
24
+ author: RemoteSessionChatAuthor;
25
+ /** The technician's display name on their rows; the party's technician otherwise. */
26
+ name?: string | null;
27
+ text: string;
28
+ at: Date;
29
+ }
30
+
31
+ /** The terminal dialogs of a session: the end confirm and the two "it is over" notices. */
32
+ export type RemoteSessionDialogVariant = 'end-confirm' | 'session-ended' | 'connection-lost';
33
+
34
+ /**
35
+ * Pointer handlers a host attaches to the surfaces the user moves the window
36
+ * by (the desktop chat starts a native window drag from them).
37
+ */
38
+ export type RemoteSessionDragHandlers = Pick<
39
+ HTMLAttributes<HTMLElement>,
40
+ 'onPointerDown' | 'onPointerMove' | 'onPointerUp'
41
+ >;
@@ -3,10 +3,10 @@
3
3
  /**
4
4
  * TicketLiveProvider — the ONE client home for support-ticket realtime.
5
5
  *
6
- * DOMAIN logic only — connection lifecycle (subscribed-confirm, server
7
- * retry grace, failed-reconnect pacing, hidden-tab suspend/resume) is
8
- * owned entirely by the common SSE client (`createSseSubscription`);
9
- * this provider consumes its consolidated `onConnectedChange` signal.
6
+ * DOMAIN logic only — connection lifecycle is owned entirely by the
7
+ * common SSE client (`createSseSubscription`; its module header lists
8
+ * the policies); this provider consumes its consolidated
9
+ * `onConnectedChange` signal.
10
10
  *
11
11
  * Owns:
12
12
  * - the unread summary — delivered EXCLUSIVELY by the stream
@@ -20,8 +20,9 @@
20
20
  * - the ticket-contract `no-stream` (204) retry policy.
21
21
  *
22
22
  * There is NO polling anywhere and NO summary endpoint. Hosts whose
23
- * stream endpoint 404s (terminal) or is absent get no unread indication
24
- * — the indication IS a realtime feature.
23
+ * stream endpoint 404s or is absent get no unread indication — the
24
+ * indication IS a realtime feature (a 404ing endpoint is re-probed on
25
+ * presence, rate-limited by the client).
25
26
  *
26
27
  * Invalidation semantics on events — deliberately `invalidateQueries`,
27
28
  * NOT `setQueryData` patches: the ticket hooks run `gcTime: 0`, so
@@ -286,11 +287,10 @@ export function TicketLiveProvider({ children, enabled = true }: TicketLiveProvi
286
287
  };
287
288
 
288
289
  const handleStatus = (status: SseTransportStatus) => {
289
- // The client owns connection lifecycle (confirm timeout, server
290
- // retry grace, failed-reconnect pacing, hidden-suspend). The only
291
- // transport status with DOMAIN meaning is the ticket contract's
292
- // `no-stream` (204 = zero owned tickets): remember it so a domain
293
- // signal (own create_ticket, window focus) can retry.
290
+ // The client owns connection lifecycle. The only transport status
291
+ // with DOMAIN meaning is the ticket contract's `no-stream` (204 =
292
+ // zero owned tickets): remember it so a domain signal (own
293
+ // create_ticket, window focus) can retry.
294
294
  if (status === 'open') noStreamRef.current = false;
295
295
  if (status === 'no-stream') noStreamRef.current = true;
296
296
  };
@@ -324,7 +324,9 @@ export function TicketLiveProvider({ children, enabled = true }: TicketLiveProvi
324
324
  });
325
325
 
326
326
  const retryIfIdle = () => {
327
- // After a 204 (no-stream), a focus signal is the retry trigger.
327
+ // After a 204 (no-stream), a focus signal is the retry trigger. Only
328
+ // 204 — the client's contract leaves that retry to the caller; it
329
+ // retries terminal / 401 states on its own.
328
330
  if (noStreamRef.current) {
329
331
  noStreamRef.current = false;
330
332
  subscriptionRef.current?.reconnectNow();
@@ -0,0 +1,71 @@
1
+ import type { Meta, StoryObj } from '@storybook/nextjs-vite';
2
+ import type React from 'react';
3
+ import { fn } from 'storybook/test';
4
+
5
+ import {
6
+ RemoteAccessRequestCard,
7
+ RemoteSessionScope,
8
+ type RemoteSessionParty,
9
+ } from '../components/features/remote-session';
10
+
11
+ /**
12
+ * The end user's consent dialog for a remote access request, shown by the
13
+ * desktop chat in a 600 px always-on-top window. The host owns the request,
14
+ * the delivery ack and the decision call; the card only renders and reports
15
+ * the click.
16
+ */
17
+
18
+ const party: RemoteSessionParty = {
19
+ organizationName: 'TechFlow Solutions',
20
+ organizationSiteUrl: 'https://www.techflow.com',
21
+ technicianName: 'Mike Rodriguez',
22
+ };
23
+
24
+ function WindowDecorator(Story: React.ComponentType) {
25
+ return (
26
+ <RemoteSessionScope className="w-[600px]">
27
+ <Story />
28
+ </RemoteSessionScope>
29
+ );
30
+ }
31
+
32
+ const meta = {
33
+ title: 'Remote Session/Client/Access Request',
34
+ component: RemoteAccessRequestCard,
35
+ tags: ['autodocs'],
36
+ decorators: [WindowDecorator],
37
+ args: { party, onDecide: fn(), onOpenSite: fn() },
38
+ } satisfies Meta<typeof RemoteAccessRequestCard>;
39
+
40
+ export default meta;
41
+ type Story = StoryObj<typeof meta>;
42
+
43
+ /** A recorded session: the recording notice above the consent line. */
44
+ export const Recorded: Story = {
45
+ args: { showRecordingNotice: true },
46
+ };
47
+
48
+ /** Not recorded: no notice. */
49
+ export const NotRecorded: Story = {
50
+ args: { showRecordingNotice: false },
51
+ };
52
+
53
+ /** No site and no logo: the OpenFrame mark, no website button. */
54
+ export const WithoutSite: Story = {
55
+ args: { party: { organizationName: 'TechFlow Solutions' } },
56
+ };
57
+
58
+ /** A non-https site is shown but never offered as a link. */
59
+ export const PlainHttpSite: Story = {
60
+ args: { party: { ...party, organizationSiteUrl: 'http://techflow.local' } },
61
+ };
62
+
63
+ /** Allow Access sent: both buttons lock, the chosen one spins. */
64
+ export const Allowing: Story = {
65
+ args: { showRecordingNotice: true, deciding: 'APPROVED' },
66
+ };
67
+
68
+ /** The decision could not be sent: the error replaces the closing line. */
69
+ export const DecisionFailed: Story = {
70
+ args: { showRecordingNotice: true, error: 'Could not reach the server. Try again.' },
71
+ };