@buoy-gg/js-top 7.0.3

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 (168) hide show
  1. package/LICENSE +58 -0
  2. package/README.md +56 -0
  3. package/lib/commonjs/index.js +97 -0
  4. package/lib/commonjs/index.js.map +1 -0
  5. package/lib/commonjs/js-top/components/BusySparkline.js +56 -0
  6. package/lib/commonjs/js-top/components/BusySparkline.js.map +1 -0
  7. package/lib/commonjs/js-top/components/JsTopHudOverlay.js +79 -0
  8. package/lib/commonjs/js-top/components/JsTopHudOverlay.js.map +1 -0
  9. package/lib/commonjs/js-top/components/JsTopModal.js +347 -0
  10. package/lib/commonjs/js-top/components/JsTopModal.js.map +1 -0
  11. package/lib/commonjs/js-top/components/TaskDetailView.js +329 -0
  12. package/lib/commonjs/js-top/components/TaskDetailView.js.map +1 -0
  13. package/lib/commonjs/js-top/components/TaskTable.js +360 -0
  14. package/lib/commonjs/js-top/components/TaskTable.js.map +1 -0
  15. package/lib/commonjs/js-top/engine/JsTopController.js +350 -0
  16. package/lib/commonjs/js-top/engine/JsTopController.js.map +1 -0
  17. package/lib/commonjs/js-top/engine/aggregator.js +148 -0
  18. package/lib/commonjs/js-top/engine/aggregator.js.map +1 -0
  19. package/lib/commonjs/js-top/engine/busyProbe.js +101 -0
  20. package/lib/commonjs/js-top/engine/busyProbe.js.map +1 -0
  21. package/lib/commonjs/js-top/engine/frameStack.js +133 -0
  22. package/lib/commonjs/js-top/engine/frameStack.js.map +1 -0
  23. package/lib/commonjs/js-top/engine/longtasks.js +141 -0
  24. package/lib/commonjs/js-top/engine/longtasks.js.map +1 -0
  25. package/lib/commonjs/js-top/engine/now.js +38 -0
  26. package/lib/commonjs/js-top/engine/now.js.map +1 -0
  27. package/lib/commonjs/js-top/engine/originRegistry.js +402 -0
  28. package/lib/commonjs/js-top/engine/originRegistry.js.map +1 -0
  29. package/lib/commonjs/js-top/engine/patches/bridge.js +60 -0
  30. package/lib/commonjs/js-top/engine/patches/bridge.js.map +1 -0
  31. package/lib/commonjs/js-top/engine/patches/microtasks.js +27 -0
  32. package/lib/commonjs/js-top/engine/patches/microtasks.js.map +1 -0
  33. package/lib/commonjs/js-top/engine/patches/promises.js +65 -0
  34. package/lib/commonjs/js-top/engine/patches/promises.js.map +1 -0
  35. package/lib/commonjs/js-top/engine/patches/timers.js +66 -0
  36. package/lib/commonjs/js-top/engine/patches/timers.js.map +1 -0
  37. package/lib/commonjs/js-top/engine/state.js +63 -0
  38. package/lib/commonjs/js-top/engine/state.js.map +1 -0
  39. package/lib/commonjs/js-top/engine/symbolicate.js +95 -0
  40. package/lib/commonjs/js-top/engine/symbolicate.js.map +1 -0
  41. package/lib/commonjs/js-top/sync/jsTopSyncAdapter.js +74 -0
  42. package/lib/commonjs/js-top/sync/jsTopSyncAdapter.js.map +1 -0
  43. package/lib/commonjs/js-top/types/index.js +46 -0
  44. package/lib/commonjs/js-top/types/index.js.map +1 -0
  45. package/lib/commonjs/js-top/utils/preferences.js +39 -0
  46. package/lib/commonjs/js-top/utils/preferences.js.map +1 -0
  47. package/lib/commonjs/package.json +1 -0
  48. package/lib/commonjs/preset.js +75 -0
  49. package/lib/commonjs/preset.js.map +1 -0
  50. package/lib/module/index.js +47 -0
  51. package/lib/module/index.js.map +1 -0
  52. package/lib/module/js-top/components/BusySparkline.js +52 -0
  53. package/lib/module/js-top/components/BusySparkline.js.map +1 -0
  54. package/lib/module/js-top/components/JsTopHudOverlay.js +75 -0
  55. package/lib/module/js-top/components/JsTopHudOverlay.js.map +1 -0
  56. package/lib/module/js-top/components/JsTopModal.js +343 -0
  57. package/lib/module/js-top/components/JsTopModal.js.map +1 -0
  58. package/lib/module/js-top/components/TaskDetailView.js +325 -0
  59. package/lib/module/js-top/components/TaskDetailView.js.map +1 -0
  60. package/lib/module/js-top/components/TaskTable.js +353 -0
  61. package/lib/module/js-top/components/TaskTable.js.map +1 -0
  62. package/lib/module/js-top/engine/JsTopController.js +347 -0
  63. package/lib/module/js-top/engine/JsTopController.js.map +1 -0
  64. package/lib/module/js-top/engine/aggregator.js +136 -0
  65. package/lib/module/js-top/engine/aggregator.js.map +1 -0
  66. package/lib/module/js-top/engine/busyProbe.js +94 -0
  67. package/lib/module/js-top/engine/busyProbe.js.map +1 -0
  68. package/lib/module/js-top/engine/frameStack.js +126 -0
  69. package/lib/module/js-top/engine/frameStack.js.map +1 -0
  70. package/lib/module/js-top/engine/longtasks.js +133 -0
  71. package/lib/module/js-top/engine/longtasks.js.map +1 -0
  72. package/lib/module/js-top/engine/now.js +33 -0
  73. package/lib/module/js-top/engine/now.js.map +1 -0
  74. package/lib/module/js-top/engine/originRegistry.js +388 -0
  75. package/lib/module/js-top/engine/originRegistry.js.map +1 -0
  76. package/lib/module/js-top/engine/patches/bridge.js +56 -0
  77. package/lib/module/js-top/engine/patches/bridge.js.map +1 -0
  78. package/lib/module/js-top/engine/patches/microtasks.js +23 -0
  79. package/lib/module/js-top/engine/patches/microtasks.js.map +1 -0
  80. package/lib/module/js-top/engine/patches/promises.js +62 -0
  81. package/lib/module/js-top/engine/patches/promises.js.map +1 -0
  82. package/lib/module/js-top/engine/patches/timers.js +62 -0
  83. package/lib/module/js-top/engine/patches/timers.js.map +1 -0
  84. package/lib/module/js-top/engine/state.js +54 -0
  85. package/lib/module/js-top/engine/state.js.map +1 -0
  86. package/lib/module/js-top/engine/symbolicate.js +91 -0
  87. package/lib/module/js-top/engine/symbolicate.js.map +1 -0
  88. package/lib/module/js-top/sync/jsTopSyncAdapter.js +70 -0
  89. package/lib/module/js-top/sync/jsTopSyncAdapter.js.map +1 -0
  90. package/lib/module/js-top/types/index.js +42 -0
  91. package/lib/module/js-top/types/index.js.map +1 -0
  92. package/lib/module/js-top/utils/preferences.js +34 -0
  93. package/lib/module/js-top/utils/preferences.js.map +1 -0
  94. package/lib/module/preset.js +71 -0
  95. package/lib/module/preset.js.map +1 -0
  96. package/lib/typescript/index.d.ts +21 -0
  97. package/lib/typescript/index.d.ts.map +1 -0
  98. package/lib/typescript/js-top/components/BusySparkline.d.ts +8 -0
  99. package/lib/typescript/js-top/components/BusySparkline.d.ts.map +1 -0
  100. package/lib/typescript/js-top/components/JsTopHudOverlay.d.ts +8 -0
  101. package/lib/typescript/js-top/components/JsTopHudOverlay.d.ts.map +1 -0
  102. package/lib/typescript/js-top/components/JsTopModal.d.ts +39 -0
  103. package/lib/typescript/js-top/components/JsTopModal.d.ts.map +1 -0
  104. package/lib/typescript/js-top/components/TaskDetailView.d.ts +15 -0
  105. package/lib/typescript/js-top/components/TaskDetailView.d.ts.map +1 -0
  106. package/lib/typescript/js-top/components/TaskTable.d.ts +38 -0
  107. package/lib/typescript/js-top/components/TaskTable.d.ts.map +1 -0
  108. package/lib/typescript/js-top/engine/JsTopController.d.ts +78 -0
  109. package/lib/typescript/js-top/engine/JsTopController.d.ts.map +1 -0
  110. package/lib/typescript/js-top/engine/__tests__/engine.test.d.ts +9 -0
  111. package/lib/typescript/js-top/engine/__tests__/engine.test.d.ts.map +1 -0
  112. package/lib/typescript/js-top/engine/aggregator.d.ts +33 -0
  113. package/lib/typescript/js-top/engine/aggregator.d.ts.map +1 -0
  114. package/lib/typescript/js-top/engine/busyProbe.d.ts +25 -0
  115. package/lib/typescript/js-top/engine/busyProbe.d.ts.map +1 -0
  116. package/lib/typescript/js-top/engine/frameStack.d.ts +44 -0
  117. package/lib/typescript/js-top/engine/frameStack.d.ts.map +1 -0
  118. package/lib/typescript/js-top/engine/longtasks.d.ts +37 -0
  119. package/lib/typescript/js-top/engine/longtasks.d.ts.map +1 -0
  120. package/lib/typescript/js-top/engine/now.d.ts +9 -0
  121. package/lib/typescript/js-top/engine/now.d.ts.map +1 -0
  122. package/lib/typescript/js-top/engine/originRegistry.d.ts +82 -0
  123. package/lib/typescript/js-top/engine/originRegistry.d.ts.map +1 -0
  124. package/lib/typescript/js-top/engine/patches/bridge.d.ts +17 -0
  125. package/lib/typescript/js-top/engine/patches/bridge.d.ts.map +1 -0
  126. package/lib/typescript/js-top/engine/patches/microtasks.d.ts +6 -0
  127. package/lib/typescript/js-top/engine/patches/microtasks.d.ts.map +1 -0
  128. package/lib/typescript/js-top/engine/patches/promises.d.ts +18 -0
  129. package/lib/typescript/js-top/engine/patches/promises.d.ts.map +1 -0
  130. package/lib/typescript/js-top/engine/patches/timers.d.ts +11 -0
  131. package/lib/typescript/js-top/engine/patches/timers.d.ts.map +1 -0
  132. package/lib/typescript/js-top/engine/state.d.ts +35 -0
  133. package/lib/typescript/js-top/engine/state.d.ts.map +1 -0
  134. package/lib/typescript/js-top/engine/symbolicate.d.ts +16 -0
  135. package/lib/typescript/js-top/engine/symbolicate.d.ts.map +1 -0
  136. package/lib/typescript/js-top/sync/jsTopSyncAdapter.d.ts +43 -0
  137. package/lib/typescript/js-top/sync/jsTopSyncAdapter.d.ts.map +1 -0
  138. package/lib/typescript/js-top/types/index.d.ts +130 -0
  139. package/lib/typescript/js-top/types/index.d.ts.map +1 -0
  140. package/lib/typescript/js-top/utils/preferences.d.ts +13 -0
  141. package/lib/typescript/js-top/utils/preferences.d.ts.map +1 -0
  142. package/lib/typescript/preset.d.ts +49 -0
  143. package/lib/typescript/preset.d.ts.map +1 -0
  144. package/package.json +67 -0
  145. package/src/index.tsx +69 -0
  146. package/src/js-top/components/BusySparkline.tsx +59 -0
  147. package/src/js-top/components/JsTopHudOverlay.tsx +78 -0
  148. package/src/js-top/components/JsTopModal.tsx +421 -0
  149. package/src/js-top/components/TaskDetailView.tsx +349 -0
  150. package/src/js-top/components/TaskTable.tsx +365 -0
  151. package/src/js-top/engine/JsTopController.ts +401 -0
  152. package/src/js-top/engine/__tests__/engine.test.ts +337 -0
  153. package/src/js-top/engine/aggregator.ts +148 -0
  154. package/src/js-top/engine/busyProbe.ts +100 -0
  155. package/src/js-top/engine/frameStack.ts +142 -0
  156. package/src/js-top/engine/longtasks.ts +137 -0
  157. package/src/js-top/engine/now.ts +33 -0
  158. package/src/js-top/engine/originRegistry.ts +495 -0
  159. package/src/js-top/engine/patches/bridge.ts +69 -0
  160. package/src/js-top/engine/patches/microtasks.ts +25 -0
  161. package/src/js-top/engine/patches/promises.ts +57 -0
  162. package/src/js-top/engine/patches/timers.ts +80 -0
  163. package/src/js-top/engine/state.ts +66 -0
  164. package/src/js-top/engine/symbolicate.ts +109 -0
  165. package/src/js-top/sync/jsTopSyncAdapter.ts +72 -0
  166. package/src/js-top/types/index.ts +144 -0
  167. package/src/js-top/utils/preferences.ts +35 -0
  168. package/src/preset.tsx +67 -0
@@ -0,0 +1,421 @@
1
+ /**
2
+ * JS TOP modal — the Task Manager window.
3
+ *
4
+ * Layout: header (busy% pill + pause/clear controls) → busy sparkline →
5
+ * coverage banner (when bridge tier is unavailable) → ranked task table →
6
+ * blocking-task list.
7
+ *
8
+ * Data source is the local JsTopController by default. The desktop
9
+ * dashboard mounts this same component via react-native-web and injects the
10
+ * synced device snapshot + remote actions through `remoteSnapshot` /
11
+ * `remoteActions` — the modal never samples the Electron renderer.
12
+ */
13
+
14
+ import { useCallback, useEffect, useMemo, useState } from "react";
15
+ import {
16
+ StyleSheet,
17
+ Text,
18
+ TouchableOpacity,
19
+ View,
20
+ } from "react-native";
21
+ import {
22
+ Activity,
23
+ JsModal,
24
+ macOSColors,
25
+ ModalHeader,
26
+ Pause,
27
+ Play,
28
+ Trash2,
29
+ type ModalState,
30
+ } from "@buoy-gg/shared-ui";
31
+ import type { JsTopSnapshot } from "../types";
32
+ import type { JsTopRow } from "../types";
33
+ import { JsTopController } from "../engine/JsTopController";
34
+ import { BusySparkline } from "./BusySparkline";
35
+ import { TaskTable } from "./TaskTable";
36
+ import { TaskDetailView } from "./TaskDetailView";
37
+
38
+ export interface JsTopRemoteActions {
39
+ pause: () => void;
40
+ resume: () => void;
41
+ clear: () => void;
42
+ }
43
+
44
+ export interface JsTopModalProps {
45
+ visible: boolean;
46
+ onClose: () => void;
47
+ /** App-stack back (from the floating menu's AppHost). */
48
+ onBack?: () => void;
49
+ onMinimize?: (modalState: ModalState) => void;
50
+ initialModalState?: ModalState;
51
+ minimizeTargetPosition?: { x: number; y: number };
52
+ enableSharedModalDimensions?: boolean;
53
+ /** Desktop dashboard: render from a synced device snapshot. */
54
+ remoteSnapshot?: JsTopSnapshot | null;
55
+ remoteActions?: JsTopRemoteActions;
56
+ /** Desktop Workbench: render inline, parent supplies window chrome. */
57
+ embedded?: boolean;
58
+ }
59
+
60
+ function busyColor(pct: number): string {
61
+ if (pct >= 80) return macOSColors.semantic.error;
62
+ if (pct >= 40) return macOSColors.semantic.warning;
63
+ return macOSColors.semantic.success;
64
+ }
65
+
66
+ /** ≥100ms is a dropped-tap-level freeze — escalate to red. */
67
+ function freezeColor(worstMs: number): string {
68
+ return worstMs >= 100
69
+ ? macOSColors.semantic.error
70
+ : macOSColors.semantic.warning;
71
+ }
72
+
73
+ /**
74
+ * The one-line answer to "what should I look at?" — rendered above the
75
+ * table so triage never requires reading it. Priority: a named culprit >
76
+ * freezes > saturated-by-UI-work > healthy.
77
+ */
78
+ function diagnose(s: JsTopSnapshot): {
79
+ color: string;
80
+ icon: string;
81
+ text: string;
82
+ } {
83
+ const culprit = s.rows.find(
84
+ (r) => r.api !== "unattributed" && r.api !== "other",
85
+ );
86
+ if (culprit && culprit.pctOfBusy >= 25 && s.busyPct >= 15) {
87
+ return {
88
+ color:
89
+ culprit.pctOfBusy >= 50
90
+ ? macOSColors.semantic.error
91
+ : macOSColors.semantic.warning,
92
+ icon: "▲",
93
+ text: `${culprit.label} is eating ${Math.round(culprit.pctOfBusy)}% of thread time — start there.`,
94
+ };
95
+ }
96
+ if (s.freezeSummary.count > 0) {
97
+ return {
98
+ color: freezeColor(s.freezeSummary.worstMs),
99
+ icon: "▲",
100
+ text: `${s.freezeSummary.count} freeze${s.freezeSummary.count === 1 ? "" : "s"} in the last 60s (worst ${s.freezeSummary.worstMs}ms) — check rows marked ⚠.`,
101
+ };
102
+ }
103
+ if (s.busyPct >= 80) {
104
+ return {
105
+ color: macOSColors.semantic.warning,
106
+ icon: "▲",
107
+ text: "Thread saturated by UI/React work — open Highlight Updates to find re-renders.",
108
+ };
109
+ }
110
+ return {
111
+ color: macOSColors.semantic.success,
112
+ icon: "●",
113
+ text: `Thread healthy at ${Math.round(s.busyPct)}% load — nothing worth chasing.`,
114
+ };
115
+ }
116
+
117
+ export function JsTopModal({
118
+ visible,
119
+ onClose,
120
+ onBack,
121
+ onMinimize,
122
+ initialModalState,
123
+ minimizeTargetPosition,
124
+ remoteSnapshot,
125
+ remoteActions,
126
+ embedded = false,
127
+ }: JsTopModalProps) {
128
+ const isRemote = remoteSnapshot !== undefined;
129
+ const [localSnapshot, setLocalSnapshot] = useState<JsTopSnapshot | null>(
130
+ null,
131
+ );
132
+
133
+ // Local mode: subscribing is what starts the engine (and unsubscribing on
134
+ // close is what stops it — zero overhead when the window isn't open).
135
+ useEffect(() => {
136
+ if (isRemote || !visible) return;
137
+ return JsTopController.subscribe(setLocalSnapshot);
138
+ }, [isRemote, visible]);
139
+
140
+ const snapshot = isRemote ? remoteSnapshot : localSnapshot;
141
+
142
+ const actions = useMemo<JsTopRemoteActions>(
143
+ () =>
144
+ remoteActions ?? {
145
+ pause: () => JsTopController.pause(),
146
+ resume: () => JsTopController.resume(),
147
+ clear: () => JsTopController.clear(),
148
+ },
149
+ [remoteActions],
150
+ );
151
+
152
+ const paused = snapshot?.paused ?? false;
153
+ const hasData = (snapshot?.rows.length ?? 0) > 0;
154
+
155
+ // Tap-through detail. Local mode re-pulls the detail on every snapshot
156
+ // tick (this component re-renders), so the detail view stays live.
157
+ // Remote mode (desktop) has no local engine — rows aren't tappable there.
158
+ const [detailKey, setDetailKey] = useState<string | null>(null);
159
+ const onSelectRow = useCallback(
160
+ (row: JsTopRow) => setDetailKey(row.key),
161
+ [],
162
+ );
163
+ const detail =
164
+ !isRemote && detailKey ? JsTopController.getOriginDetail(detailKey) : null;
165
+ const inDetail = detailKey !== null;
166
+
167
+ // Shared ModalHeader compound — same structure as Network/Events/Console:
168
+ // Content (brand icon + title + live busy pill) and 32px icon Actions.
169
+ // In the detail view the chevron pops back to the table.
170
+ const headerContent = (
171
+ <ModalHeader>
172
+ {inDetail ? (
173
+ <ModalHeader.Navigation onBack={() => setDetailKey(null)} />
174
+ ) : onBack ? (
175
+ <ModalHeader.Navigation onBack={onBack} />
176
+ ) : null}
177
+ <ModalHeader.Content title="" noMargin>
178
+ <View style={styles.titleRow}>
179
+ <Activity size={14} color="#34D399" />
180
+ <Text style={styles.title}>JS Top</Text>
181
+ {snapshot && (
182
+ <View
183
+ style={[
184
+ styles.busyPill,
185
+ { borderColor: busyColor(snapshot.busyPct) },
186
+ ]}
187
+ >
188
+ <Text
189
+ style={[
190
+ styles.busyText,
191
+ { color: busyColor(snapshot.busyPct) },
192
+ ]}
193
+ >
194
+ {snapshot.busyPct.toFixed(0)}% BUSY
195
+ </Text>
196
+ </View>
197
+ )}
198
+ {snapshot && snapshot.freezeSummary.count > 0 && (
199
+ <View
200
+ style={[
201
+ styles.busyPill,
202
+ { borderColor: freezeColor(snapshot.freezeSummary.worstMs) },
203
+ ]}
204
+ >
205
+ <Text
206
+ style={[
207
+ styles.busyText,
208
+ { color: freezeColor(snapshot.freezeSummary.worstMs) },
209
+ ]}
210
+ >
211
+ ⚠ {snapshot.freezeSummary.count} ·{" "}
212
+ {snapshot.freezeSummary.worstMs}ms
213
+ </Text>
214
+ </View>
215
+ )}
216
+ </View>
217
+ </ModalHeader.Content>
218
+ <ModalHeader.Actions>
219
+ <TouchableOpacity
220
+ onPress={paused ? actions.resume : actions.pause}
221
+ style={[styles.actionBtn, paused && styles.actionBtnActive]}
222
+ accessibilityLabel={paused ? "Resume sampling" : "Pause sampling"}
223
+ >
224
+ {paused ? (
225
+ <Play size={14} color={macOSColors.semantic.info} />
226
+ ) : (
227
+ <Pause size={14} color={macOSColors.text.secondary} />
228
+ )}
229
+ </TouchableOpacity>
230
+ <TouchableOpacity
231
+ onPress={actions.clear}
232
+ disabled={!hasData}
233
+ style={[styles.actionBtn, !hasData && styles.actionBtnDisabled]}
234
+ accessibilityLabel="Clear stats"
235
+ >
236
+ <Trash2
237
+ size={14}
238
+ color={hasData ? macOSColors.text.muted : macOSColors.text.muted}
239
+ />
240
+ </TouchableOpacity>
241
+ </ModalHeader.Actions>
242
+ </ModalHeader>
243
+ );
244
+
245
+ const body = (
246
+ <View style={styles.body}>
247
+ {inDetail ? (
248
+ detail ? (
249
+ <TaskDetailView detail={detail} />
250
+ ) : (
251
+ <Text style={styles.waiting}>
252
+ This origin is no longer tracked (cleared or evicted).
253
+ </Text>
254
+ )
255
+ ) : snapshot ? (
256
+ <>
257
+ {(() => {
258
+ const d = diagnose(snapshot);
259
+ return (
260
+ <View style={[styles.diagnosis, { borderLeftColor: d.color }]}>
261
+ <Text style={[styles.diagnosisIcon, { color: d.color }]}>
262
+ {d.icon}
263
+ </Text>
264
+ <Text style={styles.diagnosisText}>{d.text}</Text>
265
+ </View>
266
+ );
267
+ })()}
268
+ <View style={styles.sparklineRow}>
269
+ <Text style={styles.sparklineCaption}>
270
+ JS THREAD LOAD · LAST 30s
271
+ </Text>
272
+ <BusySparkline history={snapshot.busyHistory} />
273
+ </View>
274
+ {!snapshot.tiers.bridge && (
275
+ <Text style={styles.tierBanner}>
276
+ “System” rows are UI/React/native work pure JS can’t name —
277
+ timers, rAF and Promise chains are fully attributed.
278
+ </Text>
279
+ )}
280
+ <TaskTable
281
+ rows={snapshot.rows}
282
+ onSelectRow={isRemote ? undefined : onSelectRow}
283
+ />
284
+ </>
285
+ ) : (
286
+ <Text style={styles.waiting}>
287
+ {isRemote ? "Waiting for device…" : "Starting engine…"}
288
+ </Text>
289
+ )}
290
+ </View>
291
+ );
292
+
293
+ if (embedded) {
294
+ return (
295
+ <View style={styles.embeddedRoot}>
296
+ <View style={styles.embeddedHeader}>{headerContent}</View>
297
+ {body}
298
+ </View>
299
+ );
300
+ }
301
+
302
+ return (
303
+ <JsModal
304
+ visible={visible}
305
+ onClose={onClose}
306
+ onMinimize={onMinimize}
307
+ minimizeTargetPosition={minimizeTargetPosition}
308
+ initialModalState={initialModalState}
309
+ header={{ showToggleButton: true, customContent: headerContent }}
310
+ persistenceKey="buoy-js-top-modal"
311
+ enablePersistence={true}
312
+ initialMode="bottomSheet"
313
+ disableScrollWrapper
314
+ >
315
+ {body}
316
+ </JsModal>
317
+ );
318
+ }
319
+
320
+ const styles = StyleSheet.create({
321
+ titleRow: {
322
+ flexDirection: "row",
323
+ alignItems: "center",
324
+ gap: 8,
325
+ },
326
+ title: {
327
+ color: macOSColors.text.primary,
328
+ fontSize: 14,
329
+ fontWeight: "500",
330
+ },
331
+ busyPill: {
332
+ borderWidth: 1,
333
+ borderRadius: 4,
334
+ paddingHorizontal: 6,
335
+ paddingVertical: 2,
336
+ },
337
+ busyText: {
338
+ fontSize: 10,
339
+ fontWeight: "700",
340
+ fontVariant: ["tabular-nums"],
341
+ },
342
+ actionBtn: {
343
+ width: 32,
344
+ height: 32,
345
+ borderRadius: 8,
346
+ backgroundColor: macOSColors.background.hover,
347
+ borderWidth: 1,
348
+ borderColor: macOSColors.border.default,
349
+ alignItems: "center",
350
+ justifyContent: "center",
351
+ },
352
+ actionBtnActive: {
353
+ backgroundColor: macOSColors.semantic.infoBackground,
354
+ borderColor: macOSColors.semantic.info + "40",
355
+ },
356
+ actionBtnDisabled: {
357
+ opacity: 0.55,
358
+ },
359
+ body: {
360
+ flex: 1,
361
+ minHeight: 0,
362
+ backgroundColor: macOSColors.background.base,
363
+ },
364
+ diagnosis: {
365
+ flexDirection: "row",
366
+ alignItems: "center",
367
+ gap: 8,
368
+ marginHorizontal: 10,
369
+ marginTop: 8,
370
+ paddingHorizontal: 10,
371
+ paddingVertical: 8,
372
+ backgroundColor: macOSColors.background.card,
373
+ borderRadius: 6,
374
+ borderLeftWidth: 3,
375
+ },
376
+ diagnosisIcon: {
377
+ fontSize: 11,
378
+ fontWeight: "700",
379
+ },
380
+ diagnosisText: {
381
+ flex: 1,
382
+ color: macOSColors.text.primary,
383
+ fontSize: 12,
384
+ lineHeight: 16,
385
+ },
386
+ sparklineRow: {
387
+ paddingHorizontal: 10,
388
+ paddingVertical: 8,
389
+ gap: 4,
390
+ },
391
+ sparklineCaption: {
392
+ color: macOSColors.text.muted,
393
+ fontSize: 8,
394
+ fontWeight: "700",
395
+ letterSpacing: 0.5,
396
+ },
397
+ tierBanner: {
398
+ color: macOSColors.text.muted,
399
+ fontSize: 10,
400
+ paddingHorizontal: 10,
401
+ paddingBottom: 6,
402
+ },
403
+ waiting: {
404
+ color: macOSColors.text.muted,
405
+ fontSize: 12,
406
+ textAlign: "center",
407
+ paddingVertical: 32,
408
+ },
409
+ embeddedRoot: {
410
+ position: "absolute",
411
+ top: 0,
412
+ left: 0,
413
+ right: 0,
414
+ bottom: 0,
415
+ backgroundColor: macOSColors.background.base,
416
+ },
417
+ embeddedHeader: {
418
+ borderBottomWidth: 1,
419
+ borderBottomColor: macOSColors.border.default,
420
+ },
421
+ });