@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.
Files changed (36) hide show
  1. package/README.md +31 -10
  2. package/dist/mcp/flags-tools.d.ts +14 -9
  3. package/dist/mcp/flags-tools.js +70 -20
  4. package/dist/mcp/index.js +32 -4
  5. package/dist/mcp/platform-detect.d.ts +2 -0
  6. package/dist/mcp/platform-detect.js +2 -0
  7. package/dist/mcp/tools.js +4 -3
  8. package/dist/shared/android-dashboard-screen.d.ts +15 -0
  9. package/dist/shared/android-dashboard-screen.js +48 -0
  10. package/dist/shared/android.d.ts +1 -0
  11. package/dist/shared/android.js +12 -1
  12. package/dist/shared/dashboard-screen.d.ts +35 -0
  13. package/dist/shared/dashboard-screen.js +12 -0
  14. package/dist/shared/ios-dashboard-screen.d.ts +32 -0
  15. package/dist/shared/ios-dashboard-screen.js +266 -0
  16. package/dist/shared/ios.d.ts +72 -0
  17. package/dist/shared/ios.js +313 -0
  18. package/dist/shared/platform.d.ts +3 -0
  19. package/dist/shared/platform.js +16 -0
  20. package/dist/shared/screen-artifacts.d.ts +27 -0
  21. package/dist/shared/screen-artifacts.js +73 -0
  22. package/dist/shared/screen.d.ts +20 -11
  23. package/dist/shared/screen.js +47 -70
  24. package/dist/shared/transport.d.ts +38 -0
  25. package/dist/shared/webapp.d.ts +1 -0
  26. package/dist/shared/webapp.js +2 -0
  27. package/dist/web/bin.js +13 -9
  28. package/dist/web/public/index.html +63 -12
  29. package/dist/web/public/next/app.js +24 -1
  30. package/dist/web/public/next/db.js +292 -39
  31. package/dist/web/public/next/flags.js +306 -48
  32. package/dist/web/public/next/screen.js +219 -73
  33. package/dist/web/public/next/store.js +63 -1
  34. package/dist/web/server.d.ts +19 -9
  35. package/dist/web/server.js +330 -84
  36. package/package.json +3 -2
@@ -0,0 +1,27 @@
1
+ /**
2
+ * The one definition of where screen captures live. Exported so screen.ts shares this exact
3
+ * directory rather than rebuilding the same path: two independent joins can be tightened on one
4
+ * side and not the other, and cleanup that scans a different directory than capture writes to
5
+ * deletes nothing.
6
+ */
7
+ export declare const SCREEN_DIRECTORY: string;
8
+ /** Allocate an owner-only path for a recording containing sensitive screen content. */
9
+ export declare function createRecordingPath(): string;
10
+ /** Restrict a completed recording to its owner. */
11
+ export declare function secureRecording(recording: string): void;
12
+ /** Remove a failed or cancelled recording without surfacing cleanup errors. */
13
+ export declare function removeRecording(recording: string): void;
14
+ /**
15
+ * Remove every Radar-owned capture at a session boundary: a dashboard boot, a device change, a first
16
+ * enable that boot could not reap for, a deliberate re-detect, or process exit. Recordings and
17
+ * screenshots both hold sensitive live screen content and must not linger across sessions on disk.
18
+ * NOT run on a plain re-arm of the same device, which leaves the user's own clips alone. The name
19
+ * check keeps an unrelated file that landed in the dir out of reach.
20
+ *
21
+ * The one implementation on purpose: screen.ts re-exports this rather than keeping the copy it used
22
+ * to have, so the dir and the name pattern cannot be tightened on one session-boundary cleanup and
23
+ * not the other.
24
+ */
25
+ export declare function cleanupRecordings(): void;
26
+ /** Resolve a safe recording download without allowing traversal or unrelated files. */
27
+ export declare function recordingPath(file: string): string | null;
@@ -0,0 +1,73 @@
1
+ import fs from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ /**
5
+ * The one definition of where screen captures live. Exported so screen.ts shares this exact
6
+ * directory rather than rebuilding the same path: two independent joins can be tightened on one
7
+ * side and not the other, and cleanup that scans a different directory than capture writes to
8
+ * deletes nothing.
9
+ */
10
+ export const SCREEN_DIRECTORY = path.join(os.homedir(), ".slack-radar", "screen");
11
+ const RECORDING_NAME = /^radar_screen_[\w-]+\.(mp4|png)$/;
12
+ /** Allocate an owner-only path for a recording containing sensitive screen content. */
13
+ export function createRecordingPath() {
14
+ fs.mkdirSync(SCREEN_DIRECTORY, { recursive: true, mode: 0o700 });
15
+ // mkdir's mode only applies when creating the directory. Repair permissions left by an
16
+ // older Radar version as well, so every implementation gets the same privacy posture.
17
+ try {
18
+ fs.chmodSync(SCREEN_DIRECTORY, 0o700);
19
+ }
20
+ catch {
21
+ // Best-effort; secureRecording() still restricts the finished file itself.
22
+ }
23
+ const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
24
+ return path.join(SCREEN_DIRECTORY, `radar_screen_${timestamp}.mp4`);
25
+ }
26
+ /** Restrict a completed recording to its owner. */
27
+ export function secureRecording(recording) {
28
+ try {
29
+ fs.chmodSync(recording, 0o600);
30
+ }
31
+ catch {
32
+ // Best-effort; the owner-only directory remains the primary control.
33
+ }
34
+ }
35
+ /** Remove a failed or cancelled recording without surfacing cleanup errors. */
36
+ export function removeRecording(recording) {
37
+ try {
38
+ fs.unlinkSync(recording);
39
+ }
40
+ catch {
41
+ // The file may not have been created yet.
42
+ }
43
+ }
44
+ /**
45
+ * Remove every Radar-owned capture at a session boundary: a dashboard boot, a device change, a first
46
+ * enable that boot could not reap for, a deliberate re-detect, or process exit. Recordings and
47
+ * screenshots both hold sensitive live screen content and must not linger across sessions on disk.
48
+ * NOT run on a plain re-arm of the same device, which leaves the user's own clips alone. The name
49
+ * check keeps an unrelated file that landed in the dir out of reach.
50
+ *
51
+ * The one implementation on purpose: screen.ts re-exports this rather than keeping the copy it used
52
+ * to have, so the dir and the name pattern cannot be tightened on one session-boundary cleanup and
53
+ * not the other.
54
+ */
55
+ export function cleanupRecordings() {
56
+ try {
57
+ for (const file of fs.readdirSync(SCREEN_DIRECTORY)) {
58
+ if (RECORDING_NAME.test(file))
59
+ removeRecording(path.join(SCREEN_DIRECTORY, file));
60
+ }
61
+ }
62
+ catch {
63
+ // The directory may not exist yet.
64
+ }
65
+ }
66
+ /** Resolve a safe recording download without allowing traversal or unrelated files. */
67
+ export function recordingPath(file) {
68
+ const base = path.basename(file);
69
+ if (!RECORDING_NAME.test(base))
70
+ return null;
71
+ const recording = path.join(SCREEN_DIRECTORY, base);
72
+ return fs.existsSync(recording) ? recording : null;
73
+ }
@@ -37,14 +37,8 @@
37
37
  * explicitly on cleanup.
38
38
  */
39
39
  import { type ChildProcess } from "child_process";
40
- /**
41
- * Remove all captures from the screen tmp dir. Recordings and screenshots both hold
42
- * sensitive live screen content and must not linger across sessions on disk. Called on
43
- * resetScreenState() (device re-enable) and on process exit — the same posture the
44
- * DB-browser uses for its pulled copies. Scoped to the names this module writes so it
45
- * never deletes an unrelated file that landed in the dir.
46
- */
47
- export declare function cleanupRecordings(): void;
40
+ import { cleanupRecordings } from "./screen-artifacts.js";
41
+ export { cleanupRecordings };
48
42
  /** Resolve an ffmpeg binary, or null if none is installed. Cached. */
49
43
  export declare function resolveFfmpeg(): string | null;
50
44
  /** Whether scrcpy is installed (the no-ffmpeg fallback hint). Cached. */
@@ -78,9 +72,12 @@ export declare function ffmpegInstallHint(): string;
78
72
  export declare function screenCapabilities(): {
79
73
  screenshot: boolean;
80
74
  liveCast: boolean;
75
+ snapshotCast: boolean;
76
+ recording: boolean;
81
77
  ffmpeg: boolean;
82
78
  scrcpy: boolean;
83
79
  installHint: string | null;
80
+ platform: string;
84
81
  };
85
82
  /** Grant consent to mirror the live screen. Per server process. */
86
83
  export declare function grantScreenConsent(): void;
@@ -238,13 +235,25 @@ export declare function screenshotSaveErrorMessage(result: Extract<ScreenshotSav
238
235
  * frame of whatever is on the phone, so the dir is owner-only and the file owner-read/write.
239
236
  */
240
237
  export declare function saveScreenshot(): Promise<ScreenshotSaveResult>;
241
- /** Reset detection + tear down any live cast. Called on device re-enable and shutdown. */
238
+ /**
239
+ * Forget the cached display so the next use re-detects it, and NOTHING else. This is the safe
240
+ * subset of resetScreenState for a re-enable of the SAME device, where a live cast is very likely
241
+ * something the user is watching right now and the recordings on disk are theirs.
242
+ */
243
+ export declare function resetScreenDetection(): void;
244
+ /**
245
+ * Reset detection AND tear everything down: this process's live cast, the recorded mp4s, and any
246
+ * orphaned device-side screenrecord radar left behind. Only for a real session boundary (dashboard
247
+ * boot, different hardware, a first enable that boot could not reap for, a deliberate re-detect, or
248
+ * process exit): the recordings and the live cast are work a user may be in the middle of, so
249
+ * calling this when nothing actually changed destroys it.
250
+ */
242
251
  export declare function resetScreenState(): void;
243
252
  /**
244
253
  * Kill any live cast (and orphaned device-side screenrecord) on process exit. Mirrors
245
254
  * logcat-capture.registerCleanup(); without it, Ctrl-C on an open mirror orphans the
246
255
  * screenrecord + ffmpeg children and leaves the device transport congested for the
247
- * next session. Called from createServer().
256
+ * next session. Called once the port bind is won (see registerScreenCleanupOnBind), so a launcher
257
+ * that loses the bind never arms a handler that would delete the winner's captures.
248
258
  */
249
259
  export declare function registerScreenCleanup(): void;
250
- export {};
@@ -36,44 +36,24 @@
36
36
  * close; orphaned screenrecord procs congest the single adb transport. Kill
37
37
  * explicitly on cleanup.
38
38
  */
39
- import { spawn, execFile, execFileSync } from "child_process";
40
39
  import fs from "fs";
41
- import os from "os";
42
40
  import path from "path";
41
+ import { spawn, execFile, execFileSync } from "child_process";
43
42
  import { promisify } from "util";
44
43
  import { resolveAdbPath } from "./android.js";
45
- const SC_TMP = path.join(os.homedir(), ".slack-radar", "screen");
44
+ import { SCREEN_DIRECTORY, cleanupRecordings, createRecordingPath, secureRecording, } from "./screen-artifacts.js";
46
45
  /**
47
- * The only file names this module writes into the screen tmp dir, and therefore the only
48
- * ones it will clean up or serve for download. Screenshots (png) joined recordings (mp4)
49
- * here when screenshots became two-phase: a screenshot has to exist on disk for the
50
- * outcome to be reportable before the browser is told to download it.
46
+ * The only file names this module writes into the screen tmp dir, and therefore the only ones it
47
+ * will serve for download. Screenshots (png) joined recordings (mp4) here when screenshots became
48
+ * two-phase: a screenshot has to exist on disk for the outcome to be reportable before the browser
49
+ * is told to download it.
51
50
  */
52
51
  const CAPTURE_NAME = /^radar_screen_[\w-]+\.(mp4|png)$/;
53
- /**
54
- * Remove all captures from the screen tmp dir. Recordings and screenshots both hold
55
- * sensitive live screen content and must not linger across sessions on disk. Called on
56
- * resetScreenState() (device re-enable) and on process exit — the same posture the
57
- * DB-browser uses for its pulled copies. Scoped to the names this module writes so it
58
- * never deletes an unrelated file that landed in the dir.
59
- */
60
- export function cleanupRecordings() {
61
- try {
62
- for (const f of fs.readdirSync(SC_TMP)) {
63
- if (CAPTURE_NAME.test(f)) {
64
- try {
65
- fs.unlinkSync(path.join(SC_TMP, f));
66
- }
67
- catch {
68
- // best-effort per file
69
- }
70
- }
71
- }
72
- }
73
- catch {
74
- // dir may not exist yet; nothing to clean
75
- }
76
- }
52
+ // Re-exported for the callers that reach the session-boundary cleanup through this module. This file
53
+ // carried a second copy of it, with its own dir and name pattern, until boot started reaching the
54
+ // screen-artifacts copy directly: two cleanups whose constants could be tightened apart with nothing
55
+ // failing.
56
+ export { cleanupRecordings };
77
57
  const SC_SIZE = "720x1612";
78
58
  const SC_BITRATE = "8000000";
79
59
  const SC_BOUNDARY = "radarframe";
@@ -191,12 +171,14 @@ export function ffmpegInstallHint() {
191
171
  export function screenCapabilities() {
192
172
  const ffmpeg = resolveFfmpeg() !== null;
193
173
  return {
194
- // screencap path is pure adb, always available when a device is attached.
195
174
  screenshot: true,
196
175
  liveCast: ffmpeg,
176
+ snapshotCast: false,
177
+ recording: ffmpeg,
197
178
  ffmpeg,
198
179
  scrcpy: hasScrcpy(),
199
- installHint: ffmpeg ? null : ffmpegInstallHint(),
180
+ installHint: !ffmpeg ? ffmpegInstallHint() : null,
181
+ platform: "android",
200
182
  };
201
183
  }
202
184
  // ---- consent (server-enforced, per process) ---------------------------------
@@ -689,24 +671,7 @@ export function startRecording() {
689
671
  return null;
690
672
  if (scLive.recording)
691
673
  return scLive.recording.path;
692
- // Recordings capture live screen content (open DMs, message text, notifications),
693
- // so the dir is owner-only (0700) and each mp4 owner-read/write only (0600) — the
694
- // same posture the DB-browser uses for its equally-sensitive pulled copies. Without
695
- // this the dir is world-traversable (~0755) and ffmpeg writes the file under the
696
- // default umask (~0644, world-readable), exposing captures to other local users.
697
- fs.mkdirSync(SC_TMP, { recursive: true, mode: 0o700 });
698
- // mkdirSync's `mode` only applies when CREATING the dir; a dir left over from an
699
- // earlier session (or created before this posture existed) keeps its old perms
700
- // (~0755, world-traversable). chmod unconditionally so the owner-only guarantee
701
- // holds regardless of when the dir first appeared.
702
- try {
703
- fs.chmodSync(SC_TMP, 0o700);
704
- }
705
- catch {
706
- // best-effort; file is still written 0600 below
707
- }
708
- const safe = new Date().toISOString().replace(/[:.]/g, "-");
709
- const out = path.join(SC_TMP, `radar_screen_${safe}.mp4`);
674
+ const out = createRecordingPath();
710
675
  // Time the recording by real frame arrival, not a fixed input rate (the arg shape + the
711
676
  // reasons it must be exactly this are in recordingArgs). The old args stamped every frame
712
677
  // at a fixed 1/fps, so a clip recorded over N real seconds played back as frames/fps
@@ -738,12 +703,7 @@ export function stopRecording(L = scLive) {
738
703
  // The finished mp4 holds captured screen content; restrict to owner before
739
704
  // it is downloadable. The 0700 dir already blocks other-user traversal; this
740
705
  // is defense-in-depth on the file itself (ffmpeg created it under the umask).
741
- try {
742
- fs.chmodSync(r.path, 0o600);
743
- }
744
- catch {
745
- // best-effort; dir perms are the primary control
746
- }
706
+ secureRecording(r.path);
747
707
  resolve(r.path);
748
708
  }
749
709
  };
@@ -767,7 +727,7 @@ export function capturePath(file) {
767
727
  const base = path.basename(file);
768
728
  if (!CAPTURE_NAME.test(base))
769
729
  return null;
770
- const p = path.join(SC_TMP, base);
730
+ const p = path.join(SCREEN_DIRECTORY, base);
771
731
  return fs.existsSync(p) ? p : null;
772
732
  }
773
733
  /** The user-facing wording for each way a screenshot save can fail. */
@@ -794,16 +754,16 @@ export async function saveScreenshot() {
794
754
  if (!png)
795
755
  return { ok: false, reason: "capture-failed" };
796
756
  const safe = new Date().toISOString().replace(/[:.]/g, "-");
797
- const out = path.join(SC_TMP, `radar_screen_${safe}.png`);
757
+ const out = path.join(SCREEN_DIRECTORY, `radar_screen_${safe}.png`);
798
758
  // Every host-side step is inside one try, so a failure to CREATE the dir is reported the same
799
759
  // way as a failure to write the file. Left outside, an unwritable home threw straight out of
800
760
  // here, and the route calling it has no catch, so the request hung until the client timed out.
801
761
  try {
802
- fs.mkdirSync(SC_TMP, { recursive: true, mode: 0o700 });
762
+ fs.mkdirSync(SCREEN_DIRECTORY, { recursive: true, mode: 0o700 });
803
763
  // mkdirSync's mode only applies on creation, so a dir from an earlier session keeps its
804
764
  // old (world-traversable) perms. Same unconditional chmod startRecording does.
805
765
  try {
806
- fs.chmodSync(SC_TMP, 0o700);
766
+ fs.chmodSync(SCREEN_DIRECTORY, 0o700);
807
767
  }
808
768
  catch {
809
769
  // best-effort; the file mode below is still applied
@@ -816,11 +776,25 @@ export async function saveScreenshot() {
816
776
  return { ok: true, path: out };
817
777
  }
818
778
  // ---- lifecycle ---------------------------------------------------------------
819
- /** Reset detection + tear down any live cast. Called on device re-enable and shutdown. */
820
- export function resetScreenState() {
779
+ /**
780
+ * Forget the cached display so the next use re-detects it, and NOTHING else. This is the safe
781
+ * subset of resetScreenState for a re-enable of the SAME device, where a live cast is very likely
782
+ * something the user is watching right now and the recordings on disk are theirs.
783
+ */
784
+ export function resetScreenDetection() {
821
785
  scDetected = false;
822
786
  scDisplay = null;
823
787
  scNote = "";
788
+ }
789
+ /**
790
+ * Reset detection AND tear everything down: this process's live cast, the recorded mp4s, and any
791
+ * orphaned device-side screenrecord radar left behind. Only for a real session boundary (dashboard
792
+ * boot, different hardware, a first enable that boot could not reap for, a deliberate re-detect, or
793
+ * process exit): the recordings and the live cast are work a user may be in the middle of, so
794
+ * calling this when nothing actually changed destroys it.
795
+ */
796
+ export function resetScreenState() {
797
+ resetScreenDetection();
824
798
  if (scLive) {
825
799
  cleanupLive(scLive);
826
800
  scLive = null;
@@ -829,12 +803,13 @@ export function resetScreenState() {
829
803
  // session boundary on disk.
830
804
  cleanupRecordings();
831
805
  // Best-effort: clean up orphaned device-side screenrecord procs that the host pipe
832
- // close did not kill (they congest the single adb transport). NOTE: `-f screenrecord`
833
- // is device-WIDE — it kills every screenrecord on the device, not just radar's. That
834
- // is intentional for a debug tool (radar should not leave the transport congested),
835
- // but a user running an unrelated manual screenrecord would have it killed too.
806
+ // close did not kill (they congest the single adb transport). The match is by cmdline and
807
+ // device-wide, so it also kills another dashboard's live cast and a hand-run
808
+ // `screenrecord --output-format=h264`; only the plain `screenrecord file.mp4` form falls
809
+ // outside the pattern. Single token deliberately: adb shell rejoins and re-parses the argv,
810
+ // so a pattern containing a space would need device-side quoting.
836
811
  try {
837
- execFile(adb(), ["shell", "pkill", "-9", "-f", "screenrecord"], { timeout: 5000 }, () => { });
812
+ execFile(adb(), ["shell", "pkill", "-9", "-f", "output-format=h264"], { timeout: 5000 }, () => { });
838
813
  }
839
814
  catch {
840
815
  // best-effort
@@ -845,7 +820,8 @@ let cleanupRegistered = false;
845
820
  * Kill any live cast (and orphaned device-side screenrecord) on process exit. Mirrors
846
821
  * logcat-capture.registerCleanup(); without it, Ctrl-C on an open mirror orphans the
847
822
  * screenrecord + ffmpeg children and leaves the device transport congested for the
848
- * next session. Called from createServer().
823
+ * next session. Called once the port bind is won (see registerScreenCleanupOnBind), so a launcher
824
+ * that loses the bind never arms a handler that would delete the winner's captures.
849
825
  */
850
826
  export function registerScreenCleanup() {
851
827
  if (cleanupRegistered)
@@ -885,7 +861,8 @@ function signalCleanup() {
885
861
  scLive = null;
886
862
  }
887
863
  try {
888
- execFileSync(adb(), ["shell", "pkill", "-9", "-f", "screenrecord"], {
864
+ // Same device-wide cmdline match as resetScreenState; see the note there for what it reaches.
865
+ execFileSync(adb(), ["shell", "pkill", "-9", "-f", "output-format=h264"], {
889
866
  timeout: 3000,
890
867
  stdio: "ignore",
891
868
  });
@@ -35,6 +35,8 @@ export interface DeviceInfo {
35
35
  serial: string;
36
36
  label: string;
37
37
  state: string;
38
+ /** Platform discriminator for mixed or platform-specific device UIs. */
39
+ platform?: string;
38
40
  }
39
41
  export interface DeviceTransport {
40
42
  /**
@@ -54,6 +56,15 @@ export interface DeviceTransport {
54
56
  * transport has to opt in deliberately instead of inheriting access it cannot serve.
55
57
  */
56
58
  readonly supportsLocalFileAccess?: boolean;
59
+ /**
60
+ * Whether this transport can serve Radar's request/response HTTP tools (network calls, RTM,
61
+ * clogs, traces, feature flags, and ping).
62
+ *
63
+ * This is separate from supportsLocalFileAccess: the webapp transport serves the HTTP API but
64
+ * cannot read adb-backed databases or preferences. Absent means unsupported, so a new transport
65
+ * must opt in before callRadar can touch the host-global Radar port.
66
+ */
67
+ readonly supportsRadarHttpTools?: boolean;
57
68
  /**
58
69
  * Whether this transport has a device dashboard for open_radar_dashboard to open.
59
70
  *
@@ -258,4 +269,31 @@ export interface DeviceTransport {
258
269
  serial: string;
259
270
  label: string;
260
271
  } | null;
272
+ /**
273
+ * Async variant of selectDevice for non-blocking boot/enable flows. Optional; platforms
274
+ * without an async device-listing path may omit it (the dashboard guards on presence).
275
+ */
276
+ selectDeviceAsync?(serial: string | null): Promise<{
277
+ ok: true;
278
+ serial: string | null;
279
+ switched?: boolean;
280
+ devices: DeviceInfo[];
281
+ } | {
282
+ ok: false;
283
+ error: string;
284
+ devices: DeviceInfo[];
285
+ }>;
286
+ /**
287
+ * Async variant of reassertForward for non-blocking boot/enable flows. Optional.
288
+ */
289
+ reassertForwardAsync?(): Promise<boolean>;
290
+ /**
291
+ * Async variant of activate for non-blocking boot/enable flows. Optional.
292
+ */
293
+ activateAsync?(timeoutMinutes: number): Promise<void>;
294
+ /**
295
+ * Async probe for whether the radar local socket is bound on the device. Optional;
296
+ * only platforms that can test socket presence without blocking should implement this.
297
+ */
298
+ radarSocketPresentAsync?(): Promise<"present" | "absent" | "unknown">;
261
299
  }
@@ -20,6 +20,7 @@ import type { DeviceTransport } from "./transport.js";
20
20
  */
21
21
  export declare class WebappTransport implements DeviceTransport {
22
22
  readonly platform = "webapp";
23
+ readonly supportsRadarHttpTools = true;
23
24
  private forwarded;
24
25
  private currentTimeoutMinutes;
25
26
  /**
@@ -19,6 +19,8 @@
19
19
  */
20
20
  export class WebappTransport {
21
21
  platform = "webapp";
22
+ // The local webapp dev server is itself the Radar HTTP endpoint; no adb/file access is implied.
23
+ supportsRadarHttpTools = true;
22
24
  forwarded = false;
23
25
  currentTimeoutMinutes = 5;
24
26
  /**
package/dist/web/bin.js CHANGED
@@ -3,7 +3,7 @@ import { execSync } from "child_process";
3
3
  import { realpathSync } from "fs";
4
4
  import http from "http";
5
5
  import { fileURLToPath } from "url";
6
- import { armOnBoot, cleanupOnBind, createServer, seedInitialSpec, shutdownDashboard, startAutoCloseSweep, WEB_PORT, } from "./server.js";
6
+ import { armOnBoot, cleanupOnBind, createServer, registerScreenCleanupOnBind, seedInitialSpec, shutdownDashboard, startAutoCloseSweep, WEB_PORT, } from "./server.js";
7
7
  import { RADAR_VERSION } from "../shared/constants.js";
8
8
  /**
9
9
  * One loopback GET against the dashboard's own port, used by the adopt path. Resolves with the
@@ -144,6 +144,7 @@ export function startWebServer() {
144
144
  // so adopting it leaves its view and open DB-browser tab intact.
145
145
  seedInitialSpec();
146
146
  cleanupOnBind();
147
+ registerScreenCleanupOnBind();
147
148
  // Arm the auto-close sweep only now that THIS process owns the port. Doing it post-bind (not
148
149
  // in createServer) keeps importing the module — or a second launcher that loses the bind —
149
150
  // from arming a timer that could process.exit. The interval is unref'd inside.
@@ -165,14 +166,17 @@ export function startWebServer() {
165
166
  });
166
167
  // The /shutdown route and the auto-close sweep both funnel through shutdownDashboard, so the
167
168
  // server.close + timeout-fallback exit -- and the finalize-a-live-recording safety step --
168
- // cannot drift between THOSE two paths. Ctrl-C / SIGTERM do NOT reach this handler: screen.ts's
169
- // registerScreenCleanup() (called earlier, inside createServer()) registers its own SIGINT/
170
- // SIGTERM listeners that call process.exit() synchronously, and Node runs signal listeners in
171
- // registration order -- so screen.ts's handler always wins the race and this one below never
172
- // runs. That handler's own signalCleanup() does its own (fire-and-forget, non-recording-safe)
173
- // teardown. Pre-existing gap, not introduced here; fixing it means touching screen.ts, which is
174
- // out of scope for this change. Registering below anyway costs nothing and is the load-bearing
175
- // path IF screen.ts's signal handling ever stops calling process.exit() synchronously.
169
+ // cannot drift between THOSE two paths. Ctrl-C / SIGTERM mostly do not get that far, because
170
+ // Node runs signal listeners in registration order and two other modules register first:
171
+ // log-session's cleanup (from server.js module load, Android only) and, on the platforms without
172
+ // it, this handler ahead of the platform screen controller's own (which now registers post-bind, from
173
+ // registerScreenCleanupOnBind). Both of those call process.exit() synchronously, so on Android
174
+ // the logcat handler ends the process before this runs at all, and on iOS this one starts and is
175
+ // then cut short by the iOS controller's exit. Either way a live recording is torn down fire-and-forget
176
+ // rather than finalized. Pre-existing gap, not introduced here; closing it means restructuring
177
+ // signal handling across three modules, which is out of scope for a change about reap placement.
178
+ // Registering below still costs nothing and is the load-bearing path IF those handlers ever stop
179
+ // exiting synchronously.
176
180
  const shutdown = () => void shutdownDashboard(server);
177
181
  process.on("SIGINT", shutdown);
178
182
  process.on("SIGTERM", shutdown);
@@ -58,6 +58,12 @@
58
58
  .profilewrap { font-size:12px; color:var(--blue-2); } .profilewrap b { color:var(--text); }
59
59
  .profilewrap select { background:var(--surface); border:1px solid var(--border-2); border-radius:6px; color:var(--text); padding:3px 6px; font:inherit; font-size:11px; margin-left:4px; cursor:pointer; }
60
60
  h1 .version { margin-left:auto; font-size:11px; font-weight:400; color:var(--muted-2); letter-spacing:0; }
61
+ /* Blue, not amber: this is an onboarding suggestion, and amber is what a real fault uses. */
62
+ h1 .setuphint { font-size:11px; font-weight:400; color:var(--blue-2); letter-spacing:0; }
63
+ h1 .setuphint a { color:inherit; }
64
+ /* Sized like .chip .x rather than a bare glyph: dismissal has no undo, so it needs a real target. */
65
+ h1 .setuphint .hintdismiss { background:var(--surface); border:1px solid var(--border-2); border-radius:50%; color:inherit; cursor:pointer; font:inherit; line-height:1; width:16px; height:16px; padding:0; margin-left:6px; }
66
+ h1 .setuphint .hintdismiss:hover { border-color:var(--accent); color:var(--text); }
61
67
  .themebtn, .screenbtn { background:var(--surface); border:1px solid var(--border-2); color:var(--muted-2); border-radius:8px; padding:5px 12px; font:inherit; font-size:12.5px; cursor:pointer; }
62
68
  .themebtn:hover, .screenbtn:hover { border-color:var(--accent); color:var(--text); } .screenbtn.on { background:var(--accent-bg); border-color:var(--accent); color:var(--accent-text); }
63
69
  .killbtn.armed { border-color:var(--error); color:var(--error); } .killbtn.armed:hover { border-color:var(--error-2); color:var(--error-2); }
@@ -267,6 +273,9 @@
267
273
  .dbitem { padding:6px 9px; border-radius:7px; cursor:pointer; font-size:12.5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
268
274
  .dbitem:hover { background:var(--hover-soft); } .dbitem.sel { background:var(--sel-soft); color:var(--accent); } .dbitem .rows { float:right; color:var(--muted); font-size:11px; }
269
275
  .dbitem.kbd { outline:2px solid var(--accent); outline-offset:-2px; } /* keyboard-focused row */
276
+ .dbhistbtn { background:var(--surface); border:1px solid var(--border-2); border-radius:8px; color:var(--muted); padding:0 12px; font:inherit; font-size:12.5px; cursor:pointer; display:flex; align-items:center; gap:6px; }
277
+ .dbhistbtn:hover { color:var(--text); border-color:var(--border-3); } .dbhistbtn.on { color:var(--accent); border-color:var(--accent); }
278
+ .dbhistn { color:var(--muted-2); font-size:11px; font-variant-numeric:tabular-nums; }
270
279
  .dbmain { flex:1; min-width:0; display:flex; flex-direction:column; }
271
280
  .dbqbar { display:flex; gap:8px; margin-bottom:8px; }
272
281
  .dbqbar input { flex:1; background:var(--surface); border:1px solid var(--border-2); border-radius:8px; color:var(--text); padding:8px 11px; font:inherit; font-size:12.5px; } .dbqbar input:focus { outline:none; border-color:var(--accent); }
@@ -284,16 +293,27 @@
284
293
  .dbout tr:hover td { background:var(--hover); }
285
294
  .dbout tr { cursor:pointer; }
286
295
  .dbout tr.rowsel td { background:var(--sel-soft); }
287
- /* DB row detail panel -- docked right of the grid; the split shrinks the grid to make room.
288
- Mirrors the feed's .stage.split + .inspector layout. */
296
+ /* DB dock -- docked right of the grid, shared by the row detail and the query history via
297
+ tabs; the split shrinks the grid to make room. Mirrors the feed's .stage.split layout. */
289
298
  .dbsplit { flex:1; min-height:0; display:flex; gap:14px; align-items:stretch; }
290
299
  .dbsplit .dbout { flex:1; min-width:0; }
291
300
  .dbsplit.open .dbout { flex:2 1 0; }
292
- .rowinspector { flex:1 1 360px; min-width:300px; max-width:520px; overflow:auto; background:var(--surface-2); border:1px solid var(--border); border-radius:10px; padding:12px 14px; }
293
- .rowinspector .inspector-hd { display:flex; justify-content:space-between; align-items:center; gap:8px; margin-bottom:8px; }
301
+ .dbdock { flex:1 1 360px; min-width:300px; max-width:520px; display:flex; flex-direction:column; min-height:0; background:var(--surface-2); border:1px solid var(--border); border-radius:10px; overflow:hidden; }
302
+ .dbdocktabs { display:flex; align-items:center; gap:6px; padding:8px 10px; border-bottom:1px solid var(--border); flex:0 0 auto; }
303
+ .dbtab { cursor:pointer; color:var(--muted); font-size:10.5px; text-transform:uppercase; letter-spacing:.06em; padding:3px 9px; border-radius:6px; border:1px solid transparent; }
304
+ .dbtab:hover { color:var(--text); } .dbtab.on { color:var(--accent-text); background:var(--accent-bg); border-color:var(--accent); }
305
+ .dbdocktabs .x { margin-left:auto; cursor:pointer; color:var(--muted-2); border:1px solid var(--border-3); border-radius:6px; padding:1px 8px; flex:0 0 auto; }
306
+ .dbdocktabs .x:hover { color:var(--error); border-color:var(--error); }
307
+ .rowinspector { flex:1; min-width:0; overflow:auto; padding:12px 14px; }
308
+ .rowinspector .inspector-hd { display:flex; align-items:center; gap:8px; margin-bottom:8px; }
294
309
  .rowinspector .inspector-hd .ttl { color:var(--text); font-size:13px; font-weight:600; word-break:break-word; }
295
- .rowinspector .inspector-hd .x { cursor:pointer; color:var(--muted-2); border:1px solid var(--border-3); border-radius:6px; padding:1px 8px; flex:0 0 auto; }
296
- .rowinspector .inspector-hd .x:hover { color:var(--error); border-color:var(--error); }
310
+ /* query history (the dock's other tab) */
311
+ .dbhistbar { display:flex; justify-content:flex-end; padding:7px 12px 3px; flex:0 0 auto; }
312
+ .dbhistclear { cursor:pointer; color:var(--muted-2); font-size:10.5px; text-transform:uppercase; letter-spacing:.05em; } .dbhistclear:hover { color:var(--error); }
313
+ .dbhistlist { flex:1; min-height:0; overflow:auto; padding:0 6px 8px; }
314
+ .dbhist { padding:7px 10px; border-radius:7px; cursor:pointer; font-family:ui-monospace,Menlo,Consolas,monospace; font-size:11.5px; color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
315
+ .dbhist:hover { background:var(--hover-soft); color:var(--text); } .dbhist.kbd { outline:2px solid var(--accent); outline-offset:-2px; }
316
+ .dbhistempty { padding:14px; color:var(--muted); font-size:12px; line-height:1.5; }
297
317
  .rowfield { border:1px solid var(--border); border-radius:8px; margin-bottom:8px; overflow:hidden; }
298
318
  .rowfield-hd { display:flex; align-items:center; gap:8px; padding:6px 10px; background:var(--surface-2); border-bottom:1px solid var(--border); }
299
319
  .rowfield-k { font-size:11px; text-transform:uppercase; letter-spacing:.06em; color:var(--muted-2); font-weight:600; word-break:break-all; }
@@ -368,16 +388,38 @@
368
388
  /* feature flags (source:"flags") -- reuses .dbout for the table */
369
389
  .flagsview { display:flex; flex-direction:column; gap:10px; max-width:1180px; margin-top:8px; height:72vh; }
370
390
  .flagsbar { display:flex; gap:10px; align-items:center; }
391
+ /* scope toggle: authenticated | unauthenticated | all, styled as a small segmented control */
392
+ .scopetabs { display:inline-flex; gap:2px; background:var(--surface-2); border:1px solid var(--border-2); border-radius:8px; padding:2px; flex-shrink:0; }
393
+ .scopetab { background:transparent; border:none; color:var(--muted); border-radius:6px; padding:4px 10px; font:inherit; font-size:11.5px; cursor:pointer; white-space:nowrap; }
394
+ .scopetab:hover { color:var(--text); }
395
+ .scopetab.sel { background:var(--accent-bg); color:var(--accent); font-weight:600; }
371
396
  /* the filter input fills the row like the feed's, and shares the feedbar input styling */
372
397
  .flagsbar .ffilterwrap { flex:1; min-width:140px; }
373
398
  .flagsbar input { flex:1; background:var(--surface-2); border:1px solid var(--border-2); border-radius:8px; color:var(--text); padding:7px 10px; font:inherit; font-size:12.5px; } .flagsbar input:focus { outline:none; border-color:var(--accent); }
374
- .flagsmeta { color:var(--muted); font-size:11.5px; white-space:nowrap; }
399
+ /* the meta line carries load-bearing facts (row counts, org names, the build note), so it uses
400
+ the AA-passing secondary token rather than --muted (3.8-4.2:1). */
401
+ .flagsmeta { color:var(--muted-2); font-size:11.5px; white-space:nowrap; }
375
402
  .flagsrefresh { margin-left:auto; background:var(--surface); border:1px solid var(--border-2); color:var(--muted-2); border-radius:8px; padding:5px 12px; font:inherit; font-size:11.5px; cursor:pointer; } .flagsrefresh:hover { border-color:var(--accent); color:var(--text); }
376
- .flagsview .dbout th.val, .flagsview .dbout td.val { width:90px; }
403
+ /* --muted-2 like the org column beside it: same secondary-text role, and --muted under-contrasts
404
+ in light theme (3.8-4.2:1, see the note above). */
405
+ .flagsview .dbout th.scope, .flagsview .dbout td.scope { width:120px; color:var(--muted-2); font-size:11.5px; }
406
+ /* org ids are identifiers and can be long (an enterprise id, or a team id with a prefix), so
407
+ they get monospace and ellipsis; the cell carries the full value as a title. */
408
+ .flagsview .dbout th.org, .flagsview .dbout td.org { width:132px; color:var(--muted-2); font-family:ui-monospace,Menlo,Consolas,monospace; font-size:11.5px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
409
+ .flagsview .dbout th.ftype, .flagsview .dbout td.ftype { width:96px; }
410
+ /* value column holds ON/OFF or an experiment group name (e.g. "treatment_a"), so it is wider
411
+ than the old boolean-only 90px */
412
+ .flagsview .dbout th.val, .flagsview .dbout td.val { width:140px; }
377
413
  .flagsview .dbout th.origin, .flagsview .dbout td.origin { width:160px; }
378
414
  .flagsview .dbout td.key { font-family:ui-monospace,Menlo,Consolas,monospace; color:var(--text); }
379
415
  .flagval { font-variant-numeric:tabular-nums; font-weight:600; }
380
- .flagval.on { color:var(--accent); } .flagval.off { color:var(--muted); } .flagval.dim { opacity:.55; font-weight:400; }
416
+ /* dim = every row of the flag agrees on this value. A solid token, not opacity: alpha-blended
417
+ accent green lands near 2:1 contrast, and with two orgs most of the column agrees, so the
418
+ dimmed state has to stay readable (--muted-2 measures >=6:1 on both themes, at rest; the 1.2s
419
+ flash fade briefly dips lower). Full-weight
420
+ pills use the text-grade tokens (accent-text 4.75-10.5:1, text-2 9.3-13.4:1) because they
421
+ carry the disagreement signal and the raw accent/muted tokens sat under 4.5:1 in light. */
422
+ .flagval.on { color:var(--accent-text); } .flagval.off { color:var(--text-2); } .flagval.dim { color:var(--muted-2); font-weight:400; }
381
423
  .flagval.variant { font-variant-numeric:normal; font-family:ui-monospace,Menlo,Consolas,monospace; font-size:11.5px; }
382
424
  .flagsview .dbout tr.overridden td { background:var(--hover); }
383
425
  /* live observer patch: briefly highlight a row whose value just changed */
@@ -386,13 +428,22 @@
386
428
  .orbadge { display:inline-block; padding:1px 7px; border-radius:4px; font-size:10.5px; font-weight:600; white-space:nowrap; border:1px solid var(--border-2); }
387
429
  .orbadge.or-server { color:var(--accent); border-color:var(--accent); }
388
430
  .orbadge.or-override { color:#ffb454; border-color:#ffb454; }
431
+ /* flag kind badge: experiment (multi-variant) vs toggle (boolean) */
432
+ .ftbadge { display:inline-block; padding:1px 7px; border-radius:4px; font-size:10.5px; font-weight:600; white-space:nowrap; border:1px solid var(--border-2); }
433
+ .ftbadge.ft-experiment { color:#b48ead; border-color:#b48ead; }
434
+ .ftbadge.ft-toggle { color:var(--muted); border-color:var(--border-2); }
389
435
  /* screen overlay */
390
436
  #screenpanel { position:fixed; top:0; right:0; bottom:0; width:340px; background:var(--surface-2); border-left:1px solid var(--border); z-index:40; display:flex; flex-direction:column; padding:12px; box-shadow:-4px 0 16px var(--shadow); overflow:auto; }
391
437
  #screenpanel .schead { display:flex; align-items:center; gap:8px; margin-bottom:10px; }
392
438
  #screenpanel .sctitle { font-size:12.5px; color:var(--text); font-weight:600; flex:1; }
393
- #screenpanel .scbtn { background:var(--surface); border:1px solid var(--border-2); color:var(--muted-2); border-radius:6px; padding:3px 9px; font:inherit; font-size:11.5px; cursor:pointer; } #screenpanel .scbtn:hover { border-color:var(--accent); color:var(--text); } #screenpanel .scbtn.rec { color:var(--error); border-color:var(--error); }
394
- #screenimg { width:100%; border:1px solid var(--border); border-radius:8px; background:#000; min-height:120px; }
439
+ #screenpanel .scbtn { background:var(--surface); border:1px solid var(--border-2); color:var(--muted-2); border-radius:6px; padding:3px 9px; font:inherit; font-size:11.5px; cursor:pointer; } #screenpanel .scbtn:hover:not(:disabled) { border-color:var(--accent); color:var(--text); } #screenpanel .scbtn:disabled { opacity:0.4; cursor:not-allowed; } #screenpanel .scbtn.rec { color:var(--error); border-color:var(--error); }
440
+ #screenimg { width:100%; border:1px solid var(--border); border-radius:8px; background:#000; min-height:120px; transition:opacity 0.3s; } #screenimg.stale { opacity:0.5; }
395
441
  #schint { font-size:11.5px; color:var(--muted); margin-bottom:8px; line-height:1.5; }
442
+ /* The save line sits under the status line and outlives it, so it has to read as the standing
443
+ answer rather than another transient note. Full text colour is what carries that at a glance:
444
+ persistence alone only reads over time, and the reveal underline is dock-app only, so in a
445
+ plain browser two muted lines would look like two transient notes. */
446
+ #scsave { font-size:11.5px; color:var(--text); margin:-4px 0 8px; line-height:1.5; }
396
447
  /* Floating save confirmation. Lives outside the docked side panel on purpose: the panel is
397
448
  only 340px wide and clipped to the right edge, and closing it (which auto-saves a running
398
449
  recording) unmounts it entirely, so anything panel-local can be invisible exactly when it
@@ -407,7 +458,7 @@
407
458
  #radartoast.on.clickable { pointer-events:auto; cursor:pointer; }
408
459
  .scconsent { background:var(--surface); border:1px solid var(--border-3); border-radius:8px; padding:12px; font-size:12px; color:var(--text-2); line-height:1.55; } .scconsent b { color:var(--warn-2); }
409
460
  .scconsent .scaccept { background:var(--accent-bg); border:1px solid var(--accent); color:var(--accent-text); border-radius:6px; padding:6px 14px; font:inherit; font-size:12px; cursor:pointer; margin-top:10px; display:block; } .scconsent .scaccept:hover { filter:brightness(1.1); }
410
- .scinstall { background:var(--surface-2); border:1px solid var(--border); border-radius:6px; padding:8px 10px; margin-top:8px; font-size:11.5px; color:var(--text-2); } .scinstall code { color:var(--copybtn-fg); }
461
+ .scinstall, .scdetect { background:var(--surface-2); border:1px solid var(--border); border-radius:6px; padding:8px 10px; margin-top:8px; font-size:11.5px; color:var(--text-2); } .scinstall code { color:var(--copybtn-fg); }
411
462
  .scinstall .sccopy { background:var(--copybtn-bg); border:1px solid var(--copybtn-border); color:var(--copybtn-fg); border-radius:5px; padding:2px 8px; font:inherit; font-size:11px; cursor:pointer; margin-left:6px; }
412
463
  </style>
413
464
  <!-- No-build Preact: the import map resolves the bare `preact` + `preact/hooks` + `htm`