@slack/radar-mcp 1.17.1 → 1.18.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/README.md +31 -10
- package/dist/mcp/flags-tools.d.ts +14 -9
- package/dist/mcp/flags-tools.js +70 -20
- package/dist/mcp/index.js +32 -4
- package/dist/mcp/platform-detect.d.ts +2 -0
- package/dist/mcp/platform-detect.js +2 -0
- package/dist/mcp/tools.js +4 -3
- package/dist/shared/android-dashboard-screen.d.ts +15 -0
- package/dist/shared/android-dashboard-screen.js +48 -0
- package/dist/shared/android.d.ts +1 -0
- package/dist/shared/android.js +12 -1
- package/dist/shared/dashboard-screen.d.ts +35 -0
- package/dist/shared/dashboard-screen.js +12 -0
- package/dist/shared/ios-dashboard-screen.d.ts +32 -0
- package/dist/shared/ios-dashboard-screen.js +266 -0
- package/dist/shared/ios.d.ts +72 -0
- package/dist/shared/ios.js +313 -0
- package/dist/shared/platform.d.ts +3 -0
- package/dist/shared/platform.js +16 -0
- package/dist/shared/screen-artifacts.d.ts +27 -0
- package/dist/shared/screen-artifacts.js +73 -0
- package/dist/shared/screen.d.ts +20 -11
- package/dist/shared/screen.js +47 -70
- package/dist/shared/transport.d.ts +38 -0
- package/dist/shared/webapp.d.ts +1 -0
- package/dist/shared/webapp.js +2 -0
- package/dist/web/bin.js +13 -9
- package/dist/web/public/index.html +63 -12
- package/dist/web/public/next/app.js +24 -1
- package/dist/web/public/next/db.js +292 -39
- package/dist/web/public/next/flags.js +306 -48
- package/dist/web/public/next/screen.js +219 -73
- package/dist/web/public/next/store.js +63 -1
- package/dist/web/server.d.ts +19 -9
- package/dist/web/server.js +330 -84
- package/package.json +3 -2
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { html } from "./html.js";
|
|
7
7
|
import { useState, useEffect, useRef, useCallback } from "preact/hooks";
|
|
8
8
|
import { showToast, showSaveToast, onDownloadFinished, revealInFinder, isCaptureDownloadMatch, } from "./toast.js";
|
|
9
|
+
import { useLatestRef } from "./hooks.js";
|
|
9
10
|
// The MJPEG live stream runs at 20fps (measured sweet spot: 20 beats 12 on both frame
|
|
10
11
|
// rate and jitter; 30/60 add no frames and worsen jitter). The cache-buster ?t pins a
|
|
11
12
|
// fresh connection each time the <img> is (re)wired so a stale frame is never reused.
|
|
@@ -13,25 +14,37 @@ const STREAM_FPS = 20;
|
|
|
13
14
|
function streamSrc() {
|
|
14
15
|
return "/screen/stream?fps=" + STREAM_FPS + "&t=" + Date.now();
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
+
function snapshotSrc() {
|
|
18
|
+
return "/screen/shot?inline=1&t=" + Date.now();
|
|
19
|
+
}
|
|
20
|
+
// The only control that clears a stuck device-side screenrecord ON DEMAND, hence a visible label.
|
|
21
|
+
// The Android title names the recording kill because "reset the mirror" does not imply it; other
|
|
22
|
+
// platforms' redetect only re-probes, so their title must not claim it.
|
|
23
|
+
const REDETECT_TITLE_ANDROID = "Re-detect the display and reset the mirror. Also stops Radar's screen recording on the device.";
|
|
24
|
+
const REDETECT_TITLE = "Re-detect the display and reset the mirror.";
|
|
25
|
+
export function ScreenOverlay({ open, onClose, capsSource, }) {
|
|
17
26
|
const [caps, setCaps] = useState(null);
|
|
18
27
|
const [consent, setConsent] = useState(false);
|
|
19
28
|
const [recording, setRecording] = useState(false);
|
|
20
|
-
|
|
29
|
+
// Two lines with two owners, so neither's writers can destroy the other's message. `status` is
|
|
30
|
+
// the transient line (mirror state, refusals and start failures, redetect results); `save` is
|
|
31
|
+
// the capture lifecycle, the in-progress or recording note and then the outcome in its place,
|
|
32
|
+
// carrying the reveal link and staying up until the next capture. One shared line needed an
|
|
33
|
+
// ownership protocol over one string; the split is what makes "a stream drop cannot erase a
|
|
34
|
+
// save confirmation" structural instead of checked, and keeping the whole capture lifecycle on
|
|
35
|
+
// its own line is what lets the mirror's "live." survive a screenshot.
|
|
36
|
+
const [status, setStatus] = useState("");
|
|
37
|
+
const [save, setSave] = useState(null);
|
|
21
38
|
// Set once the native side (packaged dock app only) confirms a download actually finished and
|
|
22
39
|
// reports its real on-disk path -- the requested filename can differ from the final one on a
|
|
23
40
|
// collision, so this can only be known after the fact, not guessed at request time.
|
|
24
41
|
const [revealPath, setRevealPath] = useState(null);
|
|
25
|
-
// The capture
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
// and revealing a PNG. Gating acceptance is what closes it; clearing afterwards cannot,
|
|
32
|
-
// because the overwrite has already happened by the time the path arrives.
|
|
33
|
-
// It holds the FILE, not just a flag: two captures a download-latency apart would otherwise
|
|
34
|
-
// leave the hint naming the second save while a click revealed the first one's file.
|
|
42
|
+
// The capture the save line is waiting on, set from the moment a save is requested. The native
|
|
43
|
+
// side reports a finished download hundreds of ms after the request (it can only name the real
|
|
44
|
+
// on-disk path once the write completes), so the gate is what keeps a late path from attaching
|
|
45
|
+
// to a line that has since moved on to a newer capture. It holds the FILE, not just a flag:
|
|
46
|
+
// two captures a download-latency apart would otherwise leave the line naming the second save
|
|
47
|
+
// while a click revealed the first one's file.
|
|
35
48
|
const awaitedFile = useRef(null);
|
|
36
49
|
useEffect(() => onDownloadFinished((path) => {
|
|
37
50
|
const want = awaitedFile.current;
|
|
@@ -47,8 +60,7 @@ export function ScreenOverlay({ open, onClose }) {
|
|
|
47
60
|
// unmounts), so an unmount-cleanup never fires to stop a recording on close. Track the
|
|
48
61
|
// live recording flag in a ref so the open-keyed effect below reads the CURRENT value
|
|
49
62
|
// (not a stale closure) when it tears down.
|
|
50
|
-
const recordingRef =
|
|
51
|
-
recordingRef.current = recording;
|
|
63
|
+
const recordingRef = useLatestRef(recording);
|
|
52
64
|
// Trigger a download by navigating a hidden iframe at the endpoint, never the visible page.
|
|
53
65
|
// The server already sends Content-Disposition: attachment on these routes, and a browser (or
|
|
54
66
|
// WKWebView) treats that the same in a subframe as in the main frame: it hands the response to
|
|
@@ -71,34 +83,45 @@ export function ScreenOverlay({ open, onClose }) {
|
|
|
71
83
|
const triggerDownload = (url) => {
|
|
72
84
|
getDownloadFrame().src = url;
|
|
73
85
|
};
|
|
74
|
-
//
|
|
75
|
-
//
|
|
76
|
-
//
|
|
77
|
-
// success looks identical to a silent failure, and closing the panel to trigger
|
|
78
|
-
// auto-save path
|
|
79
|
-
// is what
|
|
80
|
-
// Report a completed save the same way for a screenshot and a recording: the inline hint AND
|
|
81
|
-
// the floating toast, and the reveal gate opened for THIS save's file, so a native
|
|
82
|
-
// download-finished path is accepted only when it is the one this message names.
|
|
86
|
+
// Report a completed save the same way for a screenshot and a recording: the inline save line
|
|
87
|
+
// AND the floating toast, with the reveal gate opened for THIS save's file, so a native
|
|
88
|
+
// download-finished path is accepted only when it is the one this message names. Both surfaces
|
|
89
|
+
// because a silent success looks identical to a silent failure, and closing the panel to trigger
|
|
90
|
+
// this (the auto-save path below) unmounts the inline line before anyone can read it, so the
|
|
91
|
+
// toast is what survives that.
|
|
83
92
|
// A save whose file the server did not name still gets announced, it just cannot offer reveal:
|
|
84
93
|
// with no name there is nothing to match a late download path against, and matching nothing is
|
|
85
94
|
// how the wrong file got revealed in the first place.
|
|
95
|
+
// The outcome replaces the in-progress note IN PLACE: announceStart below put that note on this
|
|
96
|
+
// same line, so nothing here touches the status line, and a mirror message ("live.") survives a
|
|
97
|
+
// capture untouched.
|
|
86
98
|
const announceSave = useCallback((msg, file) => {
|
|
87
99
|
awaitedFile.current = file;
|
|
88
|
-
|
|
100
|
+
setSave(msg);
|
|
89
101
|
if (file)
|
|
90
102
|
showSaveToast(msg, file);
|
|
91
103
|
else
|
|
92
104
|
showToast(msg);
|
|
93
105
|
}, []);
|
|
94
106
|
// Say what actually happened, with the reveal gate shut: there is no file to reveal, so a
|
|
95
|
-
// late path from an earlier save must not attach itself to this line.
|
|
107
|
+
// late path from an earlier save must not attach itself to this line. A failure replaces the
|
|
108
|
+
// in-progress note the same way a success does, because it IS this capture's outcome.
|
|
96
109
|
const announceFailure = useCallback((msg) => {
|
|
97
110
|
awaitedFile.current = null;
|
|
98
111
|
setRevealPath(null);
|
|
99
|
-
|
|
112
|
+
setSave(msg);
|
|
100
113
|
showToast(msg);
|
|
101
114
|
}, []);
|
|
115
|
+
// A capture's in-progress note opens the same line its outcome will close, so the note and the
|
|
116
|
+
// answer cannot stack and no capture writer ever crosses onto the status line (the mirror keeps
|
|
117
|
+
// whatever it was saying). Shuts the reveal gate for the PREVIOUS save first: the old line is
|
|
118
|
+
// being replaced, so a click during the request must not reveal the file it used to name, and a
|
|
119
|
+
// late download path from it has nothing to attach to.
|
|
120
|
+
const announceStart = useCallback((msg) => {
|
|
121
|
+
awaitedFile.current = null;
|
|
122
|
+
setRevealPath(null);
|
|
123
|
+
setSave(msg);
|
|
124
|
+
}, []);
|
|
102
125
|
// Ask the server to save, and only claim success once it says it did. Both capture routes are
|
|
103
126
|
// two-phase for the same reason: the download itself is a Content-Disposition response the
|
|
104
127
|
// page cannot observe, so the JSON reply is the only place an error can be seen.
|
|
@@ -134,8 +157,9 @@ export function ScreenOverlay({ open, onClose }) {
|
|
|
134
157
|
}, [announceFailure, announceSave]);
|
|
135
158
|
const stopAndSave = useCallback(async () => {
|
|
136
159
|
setRecording(false);
|
|
160
|
+
announceStart("stopping recording…");
|
|
137
161
|
await requestSave("/screen/record/stop", "recording", "nothing to save (recording was too short or never started)");
|
|
138
|
-
}, [requestSave]);
|
|
162
|
+
}, [announceStart, requestSave]);
|
|
139
163
|
// Stop + save a running recording when the panel closes. Without this, closing the panel
|
|
140
164
|
// (or toggling ▣ Screen) mid-recording unmounts the <img> and drops the live viewer, but
|
|
141
165
|
// the server keeps screenrecord + ffmpeg + a growing mp4 alive (removeViewer only cleans
|
|
@@ -152,37 +176,113 @@ export function ScreenOverlay({ open, onClose }) {
|
|
|
152
176
|
setConsent(!!c.consent);
|
|
153
177
|
}
|
|
154
178
|
catch {
|
|
155
|
-
|
|
179
|
+
// Keeping prev is the part that changes behavior: on the open path the subscribe effect
|
|
180
|
+
// below has already seeded it off the store, so nulling here would throw away a real answer
|
|
181
|
+
// and strand an open panel on the install prose. The store read is only the cold fallback
|
|
182
|
+
// for a catch that beats that effect.
|
|
183
|
+
setCaps((prev) => prev ?? capsSource.screenCaps);
|
|
156
184
|
}
|
|
157
|
-
}, []);
|
|
185
|
+
}, [capsSource]);
|
|
158
186
|
useEffect(() => {
|
|
159
187
|
if (open)
|
|
160
188
|
loadCaps();
|
|
161
189
|
}, [open, loadCaps]);
|
|
162
|
-
//
|
|
163
|
-
//
|
|
164
|
-
//
|
|
165
|
-
//
|
|
166
|
-
//
|
|
167
|
-
//
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
190
|
+
// Live caps while open: the store mirrors handleHealth's screen object off its /health polls,
|
|
191
|
+
// so a capability change reaches an OPEN overlay without reopening it. What can move is narrow.
|
|
192
|
+
// On Android /health reads the cached probe, so something has to refresh that cache first: this
|
|
193
|
+
// tab pressing the screenshot button, or any tab's /screen/caps?refresh=1. On iOS the caps are
|
|
194
|
+
// rebuilt from a booted simulator whenever something drops the controller cache, and /enable
|
|
195
|
+
// drops it, so an enable press followed by any /health poll is itself a re-probe. loadCaps above
|
|
196
|
+
// stays the on-open authority because its refresh=1 forces a re-detect; this only reacts to
|
|
197
|
+
// later changes.
|
|
198
|
+
useEffect(() => {
|
|
199
|
+
if (!open)
|
|
200
|
+
return;
|
|
201
|
+
// Read the store's existing copy once BEFORE subscribing, the order hooks.ts documents for
|
|
202
|
+
// useStoreValue: updateScreenCaps dedupes, so a copy banked while this overlay was closed
|
|
203
|
+
// never emits again. Seeds only when there is nothing yet, so loadCaps keeps precedence.
|
|
204
|
+
setCaps((prev) => prev ?? capsSource.screenCaps);
|
|
205
|
+
return capsSource.on("screen-caps", (c) => {
|
|
206
|
+
setCaps((prev) => {
|
|
207
|
+
// consent is carried over explicitly because /health's copy never has it (only
|
|
208
|
+
// /screen/caps does), and carrying it by name keeps that structural rather than dependent
|
|
209
|
+
// on the payload staying complete. Nothing reads caps.consent after load (the panel's
|
|
210
|
+
// consent answer is its own state), so the retention is shape stability for the equality
|
|
211
|
+
// below, not a data dependency; the stream itself is held steady by the derived flags.
|
|
212
|
+
const next = { ...c, consent: prev?.consent };
|
|
213
|
+
return prev && JSON.stringify(prev) === JSON.stringify(next) ? prev : next;
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
}, [open, capsSource]);
|
|
217
|
+
// The wiring effect keys on these two flags, not on the caps object: caps now move while the
|
|
218
|
+
// panel is open, and an unrelated field flipping (scrcpy appearing, a new installHint) would
|
|
219
|
+
// otherwise re-point the <img>, drop a healthy MJPEG stream and restart the 3.5s first-frame
|
|
220
|
+
// hint. capsKnown separates "no answer yet" from "answered, no mirror" for the downgrade below.
|
|
221
|
+
const liveCast = !!(caps && caps.liveCast);
|
|
222
|
+
const snapshotCast = !!(caps && caps.snapshotCast);
|
|
223
|
+
const capsKnown = !!caps;
|
|
224
|
+
// The single answer the record button and its own handler both read, so the capability half
|
|
225
|
+
// cannot disagree between them; consent stays the handler's own gate, and its refusal names it.
|
|
226
|
+
// False while the caps are unknown: an enabled button whose handler answers "needs ffmpeg" is the
|
|
227
|
+
// contradiction users hit, seconds after granting the consent that same message asks for.
|
|
228
|
+
const canRecord = !!(caps && (caps.recording ?? caps.liveCast));
|
|
175
229
|
// wire the live <img> once consent + ffmpeg are present
|
|
176
230
|
useEffect(() => {
|
|
177
231
|
if (!open || !consent)
|
|
178
232
|
return;
|
|
179
|
-
if (
|
|
233
|
+
if (liveCast && imgRef.current) {
|
|
180
234
|
imgRef.current.src = streamSrc();
|
|
181
|
-
|
|
182
|
-
const id = setTimeout(() =>
|
|
235
|
+
setStatus("capturing first frame (~3s on a foldable)…");
|
|
236
|
+
const id = setTimeout(() => setStatus("live. ▣ Screen again to close."), 3500);
|
|
183
237
|
return () => clearTimeout(id);
|
|
184
238
|
}
|
|
185
|
-
|
|
239
|
+
if (snapshotCast && imgRef.current) {
|
|
240
|
+
let failures = 0;
|
|
241
|
+
let inflight = false;
|
|
242
|
+
let currentUrl = null;
|
|
243
|
+
const img = imgRef.current;
|
|
244
|
+
const refresh = async () => {
|
|
245
|
+
if (inflight || !img)
|
|
246
|
+
return;
|
|
247
|
+
inflight = true;
|
|
248
|
+
try {
|
|
249
|
+
const r = await fetch(snapshotSrc());
|
|
250
|
+
if (!r.ok)
|
|
251
|
+
throw new Error();
|
|
252
|
+
const blob = await r.blob();
|
|
253
|
+
const url = URL.createObjectURL(blob);
|
|
254
|
+
if (currentUrl)
|
|
255
|
+
URL.revokeObjectURL(currentUrl);
|
|
256
|
+
currentUrl = url;
|
|
257
|
+
img.src = url;
|
|
258
|
+
failures = 0;
|
|
259
|
+
img.classList.remove("stale");
|
|
260
|
+
}
|
|
261
|
+
catch {
|
|
262
|
+
failures++;
|
|
263
|
+
if (failures >= 3)
|
|
264
|
+
img.classList.add("stale");
|
|
265
|
+
}
|
|
266
|
+
finally {
|
|
267
|
+
inflight = false;
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
refresh();
|
|
271
|
+
const id = setInterval(refresh, 1000);
|
|
272
|
+
setStatus("simulator mirror (refreshes every second). ▣ Screen again to close.");
|
|
273
|
+
return () => {
|
|
274
|
+
clearInterval(id);
|
|
275
|
+
if (currentUrl)
|
|
276
|
+
URL.revokeObjectURL(currentUrl);
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
// Losing every mirror while open swaps the body to the install block, so a leftover "live."
|
|
280
|
+
// or simulator-mirror line would sit above text saying ffmpeg is not installed. Clearing the
|
|
281
|
+
// status line unconditionally is safe now that saves live on their own line: everything on
|
|
282
|
+
// this line is transient, and the body swap itself explains the state.
|
|
283
|
+
if (capsKnown && !liveCast && !snapshotCast)
|
|
284
|
+
setStatus("");
|
|
285
|
+
}, [open, consent, capsKnown, liveCast, snapshotCast]);
|
|
186
286
|
const accept = useCallback(async () => {
|
|
187
287
|
try {
|
|
188
288
|
// X-Radar-Dashboard marks this as coming from our own client. Without it the server refuses
|
|
@@ -191,33 +291,56 @@ export function ScreenOverlay({ open, onClose }) {
|
|
|
191
291
|
setConsent(true);
|
|
192
292
|
}
|
|
193
293
|
catch {
|
|
194
|
-
|
|
294
|
+
setStatus("consent failed");
|
|
195
295
|
}
|
|
196
|
-
}, [
|
|
296
|
+
}, []);
|
|
197
297
|
const shot = useCallback(async () => {
|
|
198
298
|
if (!consent) {
|
|
199
|
-
|
|
299
|
+
setStatus("accept the notice first");
|
|
200
300
|
return;
|
|
201
301
|
}
|
|
202
302
|
if (saving)
|
|
203
303
|
return;
|
|
204
304
|
setSaving(true);
|
|
205
|
-
|
|
305
|
+
announceStart("taking a screenshot…");
|
|
206
306
|
try {
|
|
207
307
|
await requestSave("/screen/shot/save", "screenshot", "nothing to save");
|
|
208
308
|
}
|
|
209
309
|
finally {
|
|
210
310
|
setSaving(false);
|
|
211
311
|
}
|
|
212
|
-
}, [consent, saving,
|
|
312
|
+
}, [consent, saving, announceStart, requestSave]);
|
|
213
313
|
const rec = useCallback(async () => {
|
|
214
|
-
|
|
215
|
-
|
|
314
|
+
// The gate is about STARTING one. A recording already running has to stay stoppable even after
|
|
315
|
+
// the caps that allowed it went away, which they now can while the panel is open.
|
|
316
|
+
if (!recording && !(consent && canRecord)) {
|
|
317
|
+
// Naming ffmpeg is only honest once the server has answered. With consent already given and no
|
|
318
|
+
// caps yet, the refusal says what the body says: the answer is still being fetched.
|
|
319
|
+
setStatus(consent && !capsKnown
|
|
320
|
+
? "still detecting screen capture support…"
|
|
321
|
+
: "recording needs ffmpeg + consent");
|
|
216
322
|
return;
|
|
217
323
|
}
|
|
218
324
|
if (!recording) {
|
|
219
|
-
|
|
220
|
-
|
|
325
|
+
try {
|
|
326
|
+
const response = await fetch("/screen/record/start", { method: "POST", headers: { "X-Radar-Dashboard": "1" } });
|
|
327
|
+
const result = await response.json().catch(() => ({}));
|
|
328
|
+
if (!response.ok || !result.ok) {
|
|
329
|
+
// Start refusals and failures stay on the status line: no capture began, so the save
|
|
330
|
+
// line still holds the LAST capture's outcome, which is still true and still reveals.
|
|
331
|
+
setStatus(result.error || "recording failed to start");
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
setRecording(true);
|
|
335
|
+
// The recording IS the capture in progress, so its note lives on the save line like the
|
|
336
|
+
// other lifecycle notes; "stopping recording…" and then the outcome replace it in place.
|
|
337
|
+
// Leaving it on the status line stranded a false "recording…" for the session once the
|
|
338
|
+
// announcers stopped clearing that line.
|
|
339
|
+
announceStart("recording…");
|
|
340
|
+
}
|
|
341
|
+
catch {
|
|
342
|
+
setStatus("recording failed to start");
|
|
343
|
+
}
|
|
221
344
|
}
|
|
222
345
|
else {
|
|
223
346
|
await stopAndSave();
|
|
@@ -226,25 +349,30 @@ export function ScreenOverlay({ open, onClose }) {
|
|
|
226
349
|
if (imgRef.current)
|
|
227
350
|
imgRef.current.src = streamSrc();
|
|
228
351
|
}
|
|
229
|
-
}, [consent,
|
|
352
|
+
}, [consent, canRecord, capsKnown, recording, announceStart, stopAndSave]);
|
|
230
353
|
const redetect = useCallback(async () => {
|
|
231
|
-
|
|
354
|
+
setStatus("re-detecting active panel…");
|
|
232
355
|
// Authored: redetect tears down the live cast and deletes finished recordings, so the server
|
|
233
356
|
// refuses it without proof this is our own client.
|
|
234
357
|
const r = await (await fetch("/screen/redetect", { headers: { "X-Radar-Dashboard": "1" } }))
|
|
235
358
|
.json()
|
|
236
359
|
.catch(() => ({}));
|
|
237
|
-
if (
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
360
|
+
if (r.error) {
|
|
361
|
+
setStatus(r.error);
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
if (consent && caps && caps.liveCast && imgRef.current)
|
|
365
|
+
imgRef.current.src = streamSrc();
|
|
366
|
+
setStatus("display: " + (r.display || "default"));
|
|
367
|
+
}
|
|
368
|
+
}, [consent, caps]);
|
|
241
369
|
if (!open)
|
|
242
370
|
return null;
|
|
243
371
|
let body;
|
|
244
372
|
if (!consent) {
|
|
245
373
|
body = html `
|
|
246
374
|
<div class="scconsent">
|
|
247
|
-
This mirrors the <b>live device screen</b>. It shows whatever is on the
|
|
375
|
+
This mirrors the <b>live device screen</b>. It shows whatever is on the device right now,
|
|
248
376
|
including open DMs, message content, and notifications. Review what is on screen before
|
|
249
377
|
sharing it. Frames are not requested until you accept, and the mirror stays on until you
|
|
250
378
|
restart the dashboard. If you <b>record</b>, the clip is saved to a file on this computer
|
|
@@ -253,8 +381,14 @@ export function ScreenOverlay({ open, onClose }) {
|
|
|
253
381
|
</div>
|
|
254
382
|
`;
|
|
255
383
|
}
|
|
256
|
-
else if (caps && caps.liveCast) {
|
|
257
|
-
body = html `<img id="screenimg" ref=${imgRef} alt="device screen" onError=${() =>
|
|
384
|
+
else if (caps && (caps.liveCast || caps.snapshotCast)) {
|
|
385
|
+
body = html `<img id="screenimg" ref=${imgRef} alt="device screen" onError=${() => setStatus("stream dropped (device disconnected?). reset to retry.")} />`;
|
|
386
|
+
}
|
|
387
|
+
else if (!capsKnown) {
|
|
388
|
+
// No answer from the server yet: the iOS simctl probe takes seconds, and a failed on-open fetch
|
|
389
|
+
// with an empty store answers nothing at all. The install block below states a negative the
|
|
390
|
+
// server never gave, so it waits until there is an answer to state.
|
|
391
|
+
body = html `<div class="scdetect">Detecting screen capture support…</div>`;
|
|
258
392
|
}
|
|
259
393
|
else {
|
|
260
394
|
const cmd = caps && caps.installHint;
|
|
@@ -265,25 +399,37 @@ export function ScreenOverlay({ open, onClose }) {
|
|
|
265
399
|
? html `<span> Install it with this command, then reopen this panel:<br /><br /><code>${cmd}</code> <button class="sccopy" onClick=${(e) => { navigator.clipboard?.writeText(cmd); e.currentTarget.textContent = "copied"; }}>copy</button></span>`
|
|
266
400
|
: html `<span> Install it with your system package manager (for example <code>brew install ffmpeg</code> on macOS, <code>winget install ffmpeg</code> on Windows, or <code>sudo apt install ffmpeg</code> on Debian/Ubuntu), then reopen this panel.</span>`}
|
|
267
401
|
</div>
|
|
268
|
-
|
|
402
|
+
${caps && caps.screenshot
|
|
403
|
+
? html `<div class="scinstall">📷 Screenshot works without ffmpeg — use the button above.</div>`
|
|
404
|
+
: null}
|
|
269
405
|
${caps && caps.scrcpy ? html `<div class="scinstall">scrcpy is installed; for a native mirror window run <code>scrcpy</code> in a terminal.</div>` : null}
|
|
270
406
|
`;
|
|
271
407
|
}
|
|
408
|
+
// A running recording keeps its stop button no matter what the caps say now. Caps move while the
|
|
409
|
+
// panel is open, so gating on the current ones alone would render "■ stop" disabled the moment a
|
|
410
|
+
// simulator shut down, leaving the close path as the only way to end a recording in progress.
|
|
411
|
+
// The screenshot button below stays gated on `saving` alone because neither it nor its handler
|
|
412
|
+
// reads the caps: the POST is what finds out whether a capture works, and it reports its own
|
|
413
|
+
// failure, so there is no claim here to keep in step with.
|
|
414
|
+
const recDisabled = saving || (!recording && !canRecord);
|
|
272
415
|
return html `
|
|
273
416
|
<div id="screenpanel" class="on">
|
|
274
417
|
<div class="schead">
|
|
275
418
|
<span class="sctitle">Device screen</span>
|
|
276
419
|
<button class="scbtn" onClick=${shot} disabled=${saving} title="Full-resolution screenshot">📷</button>
|
|
277
|
-
<button class=${"scbtn" + (recording ? " rec" : "")}
|
|
278
|
-
<button class="scbtn" onClick=${redetect} title
|
|
420
|
+
<button class=${"scbtn" + (recording ? " rec" : "")} disabled=${recDisabled} onClick=${rec} title="Record to mp4">${recording ? "■ stop" : "● rec"}</button>
|
|
421
|
+
<button class="scbtn" onClick=${redetect} title=${caps?.platform === "android" ? REDETECT_TITLE_ANDROID : REDETECT_TITLE}>⟳ reset</button>
|
|
279
422
|
<button class="scbtn" onClick=${onClose} title="Close">✕</button>
|
|
280
423
|
</div>
|
|
281
|
-
<div
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
424
|
+
<div id="schint">${status}</div>
|
|
425
|
+
${save
|
|
426
|
+
? html `<div
|
|
427
|
+
id="scsave"
|
|
428
|
+
style=${revealPath ? { cursor: "pointer", textDecoration: "underline" } : undefined}
|
|
429
|
+
title=${revealPath ? "Click to show in Finder" : undefined}
|
|
430
|
+
onClick=${revealPath ? () => revealInFinder(revealPath) : undefined}
|
|
431
|
+
>${save}</div>`
|
|
432
|
+
: null}
|
|
287
433
|
<div id="screenbody">${body}</div>
|
|
288
434
|
</div>
|
|
289
435
|
`;
|
|
@@ -33,7 +33,7 @@ export const MODES = [
|
|
|
33
33
|
{ key: "log", label: "Logs", spec: { title: "Device Logs", summary: "Live Slack app logcat, color-coded by level. Scroll the full session buffer, select a range, copy raw lines.", source: "log", viz: ["feed", "inspector"], match: { package: "com.Slack.internal.debug" } } },
|
|
34
34
|
{ key: "db", label: "Database", spec: { title: "Device DB", summary: "Browse the on-device SQLite databases (read-only snapshot).", source: "db" } },
|
|
35
35
|
{ key: "prefs", label: "Preferences", spec: { title: "Device Preferences", summary: "Browse the on-device SharedPreferences (including feature-flag overrides), read-only.", source: "prefs" } },
|
|
36
|
-
{ key: "flags", label: "Feature Flags", spec: { title: "Feature Flags", summary: "Every feature flag the Slack app knows about, with its current effective value and whether it is locally overridden. Live-updates as flags change on the device. Filter by name.", source: "flags" } },
|
|
36
|
+
{ key: "flags", label: "Feature Flags", spec: { title: "Feature Flags", summary: "Every feature flag and experiment the Slack app knows about, with its current effective value (ON/OFF for toggles, group name for experiments), its scope, and whether it is locally overridden. Live-updates as flags and experiments change on the device. Filter by name.", source: "flags" } },
|
|
37
37
|
];
|
|
38
38
|
// Dashboard mode key -> the ping `sources` name that must be present for the tab to work. Only
|
|
39
39
|
// sources the device ships as plugins are gateable; the rest (network/db/prefs/...) always show,
|
|
@@ -96,6 +96,9 @@ class Store {
|
|
|
96
96
|
// Last self-heal check's outcome, fetched once at boot (see fetchSelfHeal). null until that
|
|
97
97
|
// fetch resolves. Drives the header's passive "self-healed to a newer version" indicator.
|
|
98
98
|
selfHeal = null;
|
|
99
|
+
// Whether any MCP client has ever connected on this machine, fetched once at boot (see
|
|
100
|
+
// fetchSetupHint). null until that fetch resolves so the header never flashes the hint early.
|
|
101
|
+
setupHint = null;
|
|
99
102
|
// Set true once the kill button has shut the server down. The header swaps to a "dashboard
|
|
100
103
|
// stopped" state, and the poll loops are torn down so a now-dead server does not spam the
|
|
101
104
|
// console with failed fetches. Emitted as "stopped".
|
|
@@ -185,6 +188,13 @@ class Store {
|
|
|
185
188
|
// Capture-source names the device declares on ping (seam builds). null = old build with no
|
|
186
189
|
// discovery, in which case every tab shows (today's behavior). Emitted as "sources" on change.
|
|
187
190
|
deviceSources = null;
|
|
191
|
+
// Screen capabilities as the server last stamped them on /health (handleHealth's `screen`
|
|
192
|
+
// field). The passive live view for an already-open screen overlay: the overlay's on-open
|
|
193
|
+
// /screen/caps?refresh=1 stays the authoritative re-detect, this copy is what lets caps
|
|
194
|
+
// changes reach it afterwards without reopening. Emitted as "screen-caps" only on a real
|
|
195
|
+
// change (JSON fingerprint, same style as the spec key).
|
|
196
|
+
screenCaps = null;
|
|
197
|
+
_screenCapsKey = null;
|
|
188
198
|
cache = [];
|
|
189
199
|
cacheKeys = new Set();
|
|
190
200
|
seen = {};
|
|
@@ -322,6 +332,7 @@ class Store {
|
|
|
322
332
|
this.spec = { blank: true, viz: [] };
|
|
323
333
|
this.conn = { state: "waiting", msg: "connecting…" };
|
|
324
334
|
this.selfHeal = null;
|
|
335
|
+
this.setupHint = null;
|
|
325
336
|
this.stopped = false;
|
|
326
337
|
this.profileLabel = "detecting…";
|
|
327
338
|
this.serverVersion = "";
|
|
@@ -337,6 +348,8 @@ class Store {
|
|
|
337
348
|
this._lastProofTs = 0;
|
|
338
349
|
this.connClock = () => Date.now();
|
|
339
350
|
this.deviceSources = null;
|
|
351
|
+
this.screenCaps = null;
|
|
352
|
+
this._screenCapsKey = null;
|
|
340
353
|
this.cache = [];
|
|
341
354
|
this.cacheKeys = new Set();
|
|
342
355
|
this.seen = {};
|
|
@@ -430,6 +443,11 @@ class Store {
|
|
|
430
443
|
this.clearRecords();
|
|
431
444
|
// The old device's declared sources do not describe the new one; null until its next poll.
|
|
432
445
|
this.updateSources(null);
|
|
446
|
+
// Same for the screen capabilities: they come from the old device's platform, so a new phone
|
|
447
|
+
// would inherit them for one poll. The fingerprint goes too, or an identical caps object from
|
|
448
|
+
// the new device would be deduped as unchanged and never re-emitted.
|
|
449
|
+
this.screenCaps = null;
|
|
450
|
+
this._screenCapsKey = null;
|
|
433
451
|
// Best-effort latency win: age the fresh-frame stamp so the next pollHealth really fetches.
|
|
434
452
|
// Backfill frames can re-freshen it within ms; pollProfile's 5s read is the backstop.
|
|
435
453
|
this._lastEventTs = 0;
|
|
@@ -472,6 +490,7 @@ class Store {
|
|
|
472
490
|
// until the next 700ms tick happened to read the corrected value.
|
|
473
491
|
await this.bootDefault();
|
|
474
492
|
this.fetchSelfHeal();
|
|
493
|
+
this.fetchSetupHint();
|
|
475
494
|
this.pollSpec();
|
|
476
495
|
this._intervals.push(setInterval(() => this.pollSpec(), POLL_SPEC_MS));
|
|
477
496
|
this.pollHealth();
|
|
@@ -613,6 +632,25 @@ class Store {
|
|
|
613
632
|
/* leave selfHeal null; the header just renders nothing */
|
|
614
633
|
}
|
|
615
634
|
}
|
|
635
|
+
// Fetch-once like fetchSelfHeal: the marker only changes when an MCP server boots, and the
|
|
636
|
+
// header's setup hint does not need to notice that mid-session.
|
|
637
|
+
async fetchSetupHint() {
|
|
638
|
+
try {
|
|
639
|
+
const res = await fetch("/setup-hint");
|
|
640
|
+
// An older dashboard refuses unknown paths with a parseable JSON error body, so a shape
|
|
641
|
+
// check is what keeps that 403 from reading as "no MCP has ever connected".
|
|
642
|
+
if (!res.ok)
|
|
643
|
+
return;
|
|
644
|
+
const state = await res.json();
|
|
645
|
+
if (typeof state?.mcpSeen !== "boolean")
|
|
646
|
+
return;
|
|
647
|
+
this.setupHint = state;
|
|
648
|
+
this.emit("setup-hint", state);
|
|
649
|
+
}
|
|
650
|
+
catch {
|
|
651
|
+
/* leave setupHint null; the header just renders nothing */
|
|
652
|
+
}
|
|
653
|
+
}
|
|
616
654
|
markLocalPush(spec) {
|
|
617
655
|
this._localPushKey = JSON.stringify(spec);
|
|
618
656
|
}
|
|
@@ -1021,6 +1059,23 @@ class Store {
|
|
|
1021
1059
|
this.deviceSources = names;
|
|
1022
1060
|
this.emit("sources", names);
|
|
1023
1061
|
}
|
|
1062
|
+
// Track the server's screen capabilities off /health replies. Unlike updateSources this is NOT
|
|
1063
|
+
// gated on device:true, because the gate answers a different question: device:true is the app
|
|
1064
|
+
// ping, while the caps come from the platform controller. On Android they are host facts
|
|
1065
|
+
// (ffmpeg/scrcpy present, platform) that a device blip cannot change; on iOS they are rebuilt
|
|
1066
|
+
// from a booted simulator whenever something drops the controller cache, and once that happens a
|
|
1067
|
+
// shut-down simulator SHOULD degrade an open overlay rather than wait on a flag that does not
|
|
1068
|
+
// feed it. A reply without the field (an older server) is ignored so the last good copy stands.
|
|
1069
|
+
updateScreenCaps(raw) {
|
|
1070
|
+
if (!raw || typeof raw !== "object")
|
|
1071
|
+
return;
|
|
1072
|
+
const key = JSON.stringify(raw);
|
|
1073
|
+
if (key === this._screenCapsKey)
|
|
1074
|
+
return;
|
|
1075
|
+
this._screenCapsKey = key;
|
|
1076
|
+
this.screenCaps = raw;
|
|
1077
|
+
this.emit("screen-caps", this.screenCaps);
|
|
1078
|
+
}
|
|
1024
1079
|
async pollHealth() {
|
|
1025
1080
|
if (this.connClock() - this._lastEventTs < 6000) {
|
|
1026
1081
|
this._healthMisses = 0;
|
|
@@ -1034,6 +1089,9 @@ class Store {
|
|
|
1034
1089
|
}
|
|
1035
1090
|
try {
|
|
1036
1091
|
const h = await (await fetch("/health")).json();
|
|
1092
|
+
// Screen caps ride every /health reply and come from the platform controller, not from the
|
|
1093
|
+
// app ping the gate below reads, so they update outside that gate.
|
|
1094
|
+
this.updateScreenCaps(h.screen);
|
|
1037
1095
|
// Detect a device SWITCH under the live dashboard off /health's pinned serial. This edge
|
|
1038
1096
|
// only covers the QUIET case: the fresh-frame early return above skips this fetch while the
|
|
1039
1097
|
// stream is busy, so a switch made from another tab (whose stream stays busy here) is caught
|
|
@@ -1095,6 +1153,10 @@ class Store {
|
|
|
1095
1153
|
if (healthR && healthR.device) {
|
|
1096
1154
|
this.updateSources(Array.isArray(healthR.sources) ? healthR.sources : null);
|
|
1097
1155
|
}
|
|
1156
|
+
// Same starvation backstop for the screen caps: this reply is the /health an open
|
|
1157
|
+
// overlay actually sees while the stream is chatty.
|
|
1158
|
+
if (healthR)
|
|
1159
|
+
this.updateScreenCaps(healthR.screen);
|
|
1098
1160
|
this.profiles = (profilesR && profilesR.profiles) || [];
|
|
1099
1161
|
if (uid == null) {
|
|
1100
1162
|
this.profileLabel = this._lastBoundLabel ? "last seen " + this._lastBoundLabel + " — reconnecting…" : "waiting for device…";
|
package/dist/web/server.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import http from "http";
|
|
2
|
+
import { type DashboardScreenController } from "../shared/dashboard-screen.js";
|
|
2
3
|
import type { ProcessState } from "../shared/transport.js";
|
|
3
4
|
import { type LogFrame } from "./log-session.js";
|
|
4
|
-
import { stopRecording, getLive } from "../shared/screen.js";
|
|
5
5
|
declare const WEB_PORT: number;
|
|
6
6
|
/**
|
|
7
7
|
* Decide whether to drop a log frame under backpressure. LIVE frames are dropped
|
|
@@ -31,6 +31,14 @@ export declare function seedInitialSpec(): void;
|
|
|
31
31
|
* Same post-bind discipline as seedInitialSpec: the port owner is the sole legitimate writer.
|
|
32
32
|
*/
|
|
33
33
|
export declare function cleanupOnBind(): void;
|
|
34
|
+
/**
|
|
35
|
+
* Arm the screen cleanup-on-exit handlers for THIS process. Same post-bind discipline, and the
|
|
36
|
+
* same reason, as cleanupOnBind and seedInitialSpec: the handler deletes ~/.slack-radar/screen
|
|
37
|
+
* captures, which are per USER rather than per port, so a second launcher that LOSES the bind
|
|
38
|
+
* would delete the running dashboard's clips on its way out. Registered from createServer()
|
|
39
|
+
* before, which is exactly the window that made adopting a dashboard cost the winner its saves.
|
|
40
|
+
*/
|
|
41
|
+
export declare function registerScreenCleanupOnBind(): void;
|
|
34
42
|
export declare const TAB_LIVENESS_MS = 75000;
|
|
35
43
|
export declare const AUTO_CLOSE_GRACE_MS: number;
|
|
36
44
|
/**
|
|
@@ -89,8 +97,7 @@ export declare function getPresenceState(): {
|
|
|
89
97
|
/** Reset presence between tests (module state is a process singleton). */
|
|
90
98
|
export declare function resetPresenceForTest(): void;
|
|
91
99
|
interface ShutdownDeps {
|
|
92
|
-
|
|
93
|
-
stopRecording?: typeof stopRecording;
|
|
100
|
+
screen?: Pick<DashboardScreenController, "isRecording" | "stopRecording">;
|
|
94
101
|
exit?: (code: number) => void;
|
|
95
102
|
log?: (msg: string) => void;
|
|
96
103
|
}
|
|
@@ -130,12 +137,15 @@ export declare function shutdownDashboard(server: {
|
|
|
130
137
|
*
|
|
131
138
|
* NOT routed through handleEnable, which is written around an HTTP response. Two of the steps it
|
|
132
139
|
* additionally performs really are no-ops in a fresh process (resetState and resetDbState only clear
|
|
133
|
-
* in-process fields that are already at their defaults)
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
140
|
+
* in-process fields that are already at their defaults). The screen teardown is NOT a no-op and runs
|
|
141
|
+
* here instead (see armDevice): boot owns the orphan reap, which is what lets /enable reserve its
|
|
142
|
+
* own teardown for a genuine device switch rather than spend one on its first press. /enable still
|
|
143
|
+
* reaps as a fallback when boot could not pin a serial to reap for, so a launch that cannot arm
|
|
144
|
+
* does not leave the orphan alive for the whole process. One gap is deliberately left rather than
|
|
145
|
+
* claimed away: the switched-device branch (cleanupPulledDatabases + logSession.restart) is gated
|
|
146
|
+
* on a serial inherited from the environment, so a boot carrying a stale ANDROID_SERIAL can
|
|
147
|
+
* legitimately be a switch, and only Reconnect performs that part. If a third step is ever needed
|
|
148
|
+
* here, extract the shared core instead of copying it.
|
|
139
149
|
*/
|
|
140
150
|
export declare function armOnBoot(): void;
|
|
141
151
|
/**
|