@slack/radar-mcp 1.23.0 → 1.25.0
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 +14 -7
- package/dist/mcp/dashboard-identity.d.ts +10 -0
- package/dist/mcp/dashboard-identity.js +20 -0
- package/dist/mcp/debug-package-reset.d.ts +5 -0
- package/dist/mcp/debug-package-reset.js +28 -0
- package/dist/mcp/flags-tools.d.ts +2 -0
- package/dist/mcp/flags-tools.js +10 -2
- package/dist/mcp/index.js +74 -54
- package/dist/mcp/radar-http.js +3 -1
- package/dist/mcp/session-enable.d.ts +1 -0
- package/dist/mcp/session-enable.js +52 -8
- package/dist/mcp/switchboard-tools.d.ts +5 -2
- package/dist/mcp/switchboard-tools.js +18 -12
- package/dist/mcp/tools.js +69 -169
- package/dist/mcp/web-child-env.js +2 -1
- package/dist/shared/android.d.ts +74 -10
- package/dist/shared/android.js +344 -103
- package/dist/shared/constants.d.ts +17 -5
- package/dist/shared/constants.js +59 -5
- package/dist/shared/db.d.ts +1 -1
- package/dist/shared/db.js +21 -14
- package/dist/shared/debug-log.js +2 -4
- package/dist/shared/enable-diagnosis.d.ts +27 -1
- package/dist/shared/enable-diagnosis.js +73 -0
- package/dist/shared/feature-flags.d.ts +11 -0
- package/dist/shared/feature-flags.js +18 -4
- package/dist/shared/log-session.d.ts +2 -1
- package/dist/shared/prefs.js +4 -5
- package/dist/shared/radar-request-raw.js +3 -1
- package/dist/shared/switchboard-note.d.ts +19 -0
- package/dist/shared/switchboard-note.js +76 -0
- package/dist/shared/switchboard-report.js +40 -4
- package/dist/shared/switchboard.d.ts +2 -1
- package/dist/shared/switchboard.js +17 -3
- package/dist/shared/transport.d.ts +24 -0
- package/dist/shared/wire.d.ts +2 -0
- package/dist/web/install-app-cli.d.ts +2 -0
- package/dist/web/install-app-cli.js +60 -0
- package/dist/web/install-app.d.ts +16 -7
- package/dist/web/install-app.js +92 -39
- package/dist/web/macapp/RadarApp.swift +12 -11
- package/dist/web/public/index.html +4 -2
- package/dist/web/public/next/feature-flags.js +33 -0
- package/dist/web/public/next/feed.js +13 -2
- package/dist/web/public/next/flags.js +15 -3
- package/dist/web/public/next/registry.js +4 -4
- package/dist/web/public/next/store.js +89 -3
- package/dist/web/public/next/switchboard-note.js +76 -0
- package/dist/web/public/next/voice-model.js +196 -14
- package/dist/web/public/next/voice.js +68 -10
- package/dist/web/server.d.ts +17 -0
- package/dist/web/server.js +180 -35
- package/dist/web/spec.d.ts +1 -1
- package/dist/web/spec.js +1 -1
- package/package.json +1 -1
package/dist/web/server.js
CHANGED
|
@@ -12,11 +12,11 @@ import { resolveAdbPath } from "../shared/android.js";
|
|
|
12
12
|
import { createTransport } from "../shared/platform.js";
|
|
13
13
|
import { planReconnect } from "../shared/stream.js";
|
|
14
14
|
import { createDashboardScreenController, } from "../shared/dashboard-screen.js";
|
|
15
|
-
import { ENABLE_PING_WAITS_MS, RADAR_HOST, RADAR_PORT, RADAR_VERSION, WEB_PORT_DEFAULT } from "../shared/constants.js";
|
|
15
|
+
import { ENABLE_PING_WAITS_MS, RADAR_HOST, RADAR_PORT, RADAR_VERSION, WEB_PORT_DEFAULT, resetSlackDebugPackage } from "../shared/constants.js";
|
|
16
16
|
import { radarRequestRaw } from "../shared/radar-request-raw.js";
|
|
17
17
|
import { TokenFileError, clearRadarTokenCache, radarTokenHeaderFor, tokenFileMessage, unauthorizedMessageFor } from "../shared/radar-token.js";
|
|
18
18
|
import { friendlyFeatureFlagError } from "../shared/feature-flags.js";
|
|
19
|
-
import { deviceServerSilentError, readProcessState, } from "../shared/enable-diagnosis.js";
|
|
19
|
+
import { deviceServerSilentError, foreignRadarOwnerMessage, BareEnableError, readProcessState, } from "../shared/enable-diagnosis.js";
|
|
20
20
|
import { cleanupPulledDatabases, initializeDatabasePath, listDatabases, pullDatabase, pulledSize, queryDatabase, resetDbState, availableUsers, } from "../shared/db.js";
|
|
21
21
|
import { listPrefsFiles, readPrefsFile, parsePrefsXml, searchPrefs, } from "../shared/prefs.js";
|
|
22
22
|
import { BLANK_SPEC, coerceSpec, validateSpec } from "./spec.js";
|
|
@@ -157,27 +157,60 @@ const PING_PROBE_MS = 4000;
|
|
|
157
157
|
// forward port -- the split-brain flows both ways. Platforms without a shared
|
|
158
158
|
// host-level forward may omit reassertForward, so this falls back to ensureForward.
|
|
159
159
|
function forwardForRead() {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
//
|
|
166
|
-
//
|
|
167
|
-
//
|
|
168
|
-
//
|
|
169
|
-
//
|
|
170
|
-
const
|
|
160
|
+
const built = transport.reassertForward?.() ?? transport.ensureForward();
|
|
161
|
+
if (built)
|
|
162
|
+
clearDeviceAbsent();
|
|
163
|
+
return built;
|
|
164
|
+
}
|
|
165
|
+
// With no device attached every poll costs adb spawns and a doomed ping, from every open tab.
|
|
166
|
+
// After a probe that could neither build a forward nor reach the device port, /health and the
|
|
167
|
+
// /stream retry stay quiet for this long. Only the absent answer is cached, never a live one.
|
|
168
|
+
// Any sign the desk has a device again (a forward that builds, or a device listing) ends the
|
|
169
|
+
// window at once.
|
|
170
|
+
export const DEVICE_ABSENT_BACKOFF_MS = 10_000;
|
|
171
|
+
let deviceAbsentBackoffMs = DEVICE_ABSENT_BACKOFF_MS;
|
|
172
|
+
// Set by a mark, zeroed by a clear. The window runs out by itself and only throttles probes.
|
|
173
|
+
let deviceAbsentUntil = 0;
|
|
174
|
+
/** Milliseconds left in the device-absent window, 0 when it is not open. */
|
|
175
|
+
export function deviceAbsentMsLeft(now = Date.now()) {
|
|
176
|
+
return Math.max(0, deviceAbsentUntil - now);
|
|
177
|
+
}
|
|
178
|
+
export function markDeviceAbsent(now = Date.now()) {
|
|
179
|
+
deviceAbsentUntil = now + deviceAbsentBackoffMs;
|
|
180
|
+
}
|
|
181
|
+
function clearDeviceAbsent() {
|
|
182
|
+
deviceAbsentUntil = 0;
|
|
183
|
+
}
|
|
184
|
+
export function resetDeviceAbsentForTest() {
|
|
185
|
+
clearDeviceAbsent();
|
|
186
|
+
}
|
|
187
|
+
// Test seam: the real window would make every stream test wait ten seconds of wall clock.
|
|
188
|
+
export function _setDeviceAbsentBackoffForTest(ms) {
|
|
189
|
+
deviceAbsentBackoffMs = ms ?? DEVICE_ABSENT_BACKOFF_MS;
|
|
190
|
+
}
|
|
191
|
+
let logSession = transport.logSession ?? null;
|
|
171
192
|
// Kill the persistent capture child on process exit so it does not orphan when the
|
|
172
193
|
// dashboard is spawned and later terminated by the open_radar_dashboard MCP tool.
|
|
173
194
|
logSession?.registerCleanup();
|
|
174
|
-
//
|
|
175
|
-
//
|
|
176
|
-
|
|
177
|
-
//
|
|
178
|
-
//
|
|
179
|
-
|
|
180
|
-
//
|
|
195
|
+
// Set once a log stream has asked for the capture. The sweep only restarts a capture some
|
|
196
|
+
// stream wanted, so a dashboard nobody opened a log tab on never spawns a reader.
|
|
197
|
+
let captureArmed = false;
|
|
198
|
+
// Open log streams. A page keeps its stream open while hidden and still gets live frames, so
|
|
199
|
+
// stopping the capture under it would lose lines to the gap the next start skips.
|
|
200
|
+
let openLogStreams = 0;
|
|
201
|
+
// The capture is NOT stopped when the last log stream disconnects (e.g. switching to the
|
|
202
|
+
// Network tab): it keeps filling the session ring so returning to a log tab still shows the
|
|
203
|
+
// full history, the way Android Studio retains logcat for the whole session. The sweep stops
|
|
204
|
+
// it when no tab has polled for TAB_LIVENESS_MS and no log stream is open, keeping the ring.
|
|
205
|
+
// With no device, `adb logcat` waits for it, as it always did. Memory stays bounded by the
|
|
206
|
+
// ring cap and by the per-connection backpressure guard in handleStream (a stalled client
|
|
207
|
+
// drops frames rather than buffering without limit).
|
|
208
|
+
// Test seam: the real session spawns adb logcat, which a test host may not have.
|
|
209
|
+
export function _setLogSessionForTest(session) {
|
|
210
|
+
logSession = session ?? transport.logSession ?? null;
|
|
211
|
+
captureArmed = false;
|
|
212
|
+
openLogStreams = 0;
|
|
213
|
+
}
|
|
181
214
|
function writeSpec(spec) {
|
|
182
215
|
try {
|
|
183
216
|
fs.mkdirSync(SPEC_DIR, { recursive: true });
|
|
@@ -296,7 +329,8 @@ export function registerScreenCleanupOnBind() {
|
|
|
296
329
|
// throttling batches chained timers to roughly once per minute after a tab is hidden past 5
|
|
297
330
|
// minutes, occasionally stretching to ~90s. 75s covers the common throttled gap; a rare longer
|
|
298
331
|
// gap still just flaps the tab out and back in (the 5-minute grace below absorbs that flap
|
|
299
|
-
// harmlessly), it does not misfire an auto-close.
|
|
332
|
+
// harmlessly), it does not misfire an auto-close. An open log stream holds the capture through
|
|
333
|
+
// the flap, so the flap only touches the auto-close bookkeeping. Exported so tests pin the real constant
|
|
300
334
|
// instead of a duplicated copy.
|
|
301
335
|
export const TAB_LIVENESS_MS = 75_000;
|
|
302
336
|
/**
|
|
@@ -582,6 +616,37 @@ export function getPresenceState() {
|
|
|
582
616
|
emptySince: presence.emptySince,
|
|
583
617
|
};
|
|
584
618
|
}
|
|
619
|
+
/**
|
|
620
|
+
* Keep the host log capture only while a tab is polling or a log stream is open.
|
|
621
|
+
* Stopping keeps the ring, so a tab that comes back still replays the history. Starting is
|
|
622
|
+
* limited to a capture some log stream armed earlier. Exported for tests with a fake clock.
|
|
623
|
+
*/
|
|
624
|
+
export function reconcileCapture(now = Date.now()) {
|
|
625
|
+
if (!logSession)
|
|
626
|
+
return "keep";
|
|
627
|
+
const liveTab = [...presence.tabs.values()].some((ts) => now - ts <= TAB_LIVENESS_MS);
|
|
628
|
+
const keep = liveTab || openLogStreams > 0;
|
|
629
|
+
const running = logSession.isRunning();
|
|
630
|
+
if (!keep) {
|
|
631
|
+
// Also when not running: stop() clears the restart timer that subscribe or a child exit
|
|
632
|
+
// arms, so a reader is not spawned for a capture nobody wants.
|
|
633
|
+
logSession.stop();
|
|
634
|
+
return running ? "stop" : "keep";
|
|
635
|
+
}
|
|
636
|
+
if (!running && captureArmed) {
|
|
637
|
+
logSession.start();
|
|
638
|
+
return "start";
|
|
639
|
+
}
|
|
640
|
+
return "keep";
|
|
641
|
+
}
|
|
642
|
+
/** One sweep step: auto-close wins, otherwise the capture is reconciled. */
|
|
643
|
+
export function sweepTick(now, onClose) {
|
|
644
|
+
if (sweepPresence(now)) {
|
|
645
|
+
onClose();
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
reconcileCapture(now);
|
|
649
|
+
}
|
|
585
650
|
/** Reset presence between tests (module state is a process singleton). */
|
|
586
651
|
export function resetPresenceForTest() {
|
|
587
652
|
presence.tabs.clear();
|
|
@@ -854,8 +919,14 @@ async function armDevice() {
|
|
|
854
919
|
// default, which can be SHORTER than one another process explicitly asked for. An MCP session that
|
|
855
920
|
// armed for 30 minutes would have its idle window silently cut to the default by someone merely
|
|
856
921
|
// opening a dashboard to look, with no error surfaced to either side.
|
|
857
|
-
|
|
922
|
+
const bootPing = await pingDevice(true);
|
|
923
|
+
if (bootPing.state === "armed") {
|
|
924
|
+
// A 401 or 500 also counts as armed above, but only a 200 body is Radar's own status.
|
|
925
|
+
const body = bootPing.status === 200 ? parsedPingBody(bootPing.body) : null;
|
|
926
|
+
if (body)
|
|
927
|
+
transport.adoptRadarOwner?.(body);
|
|
858
928
|
return;
|
|
929
|
+
}
|
|
859
930
|
// Anything else the ping says is inconclusive HERE, including a reset: the probe travels the
|
|
860
931
|
// adb forward, and the host adb server accepts every connection before discovering whether the
|
|
861
932
|
// device side exists, so an absent socket and a misbehaving live session read identically. The
|
|
@@ -893,8 +964,7 @@ export function startAutoCloseSweep(server) {
|
|
|
893
964
|
if (process.env.SLACK_RADAR_NO_AUTO_CLOSE === "1")
|
|
894
965
|
return null;
|
|
895
966
|
const timer = setInterval(() => {
|
|
896
|
-
|
|
897
|
-
void shutdownDashboard(server);
|
|
967
|
+
sweepTick(Date.now(), () => void shutdownDashboard(server));
|
|
898
968
|
}, AUTO_CLOSE_SWEEP_MS);
|
|
899
969
|
timer.unref();
|
|
900
970
|
return timer;
|
|
@@ -1410,12 +1480,18 @@ async function handleHealth(res) {
|
|
|
1410
1480
|
let unauthorized = false;
|
|
1411
1481
|
let forwarded = false;
|
|
1412
1482
|
if (transport.supportsRadarHttpTools) {
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1483
|
+
// Window open: skip the ping too. A tokenless ping at a port another process forwarded
|
|
1484
|
+
// would read 401 and flap the headline.
|
|
1485
|
+
if (deviceAbsentMsLeft() === 0) {
|
|
1486
|
+
forwarded = forwardForRead();
|
|
1487
|
+
const startedAt = Date.now();
|
|
1488
|
+
ping = await pingDevice(forwarded);
|
|
1489
|
+
ok = ping.state === "armed" && ping.status === 200 && pingMatchesTransport(ping);
|
|
1490
|
+
unauthorized = ping.state === "armed" && ping.status === 401 && pingMatchesTransport(ping);
|
|
1491
|
+
if (!forwarded && ping.state === "unarmed")
|
|
1492
|
+
markDeviceAbsent();
|
|
1493
|
+
noteHealthPing(ok, unauthorized, startedAt);
|
|
1494
|
+
}
|
|
1419
1495
|
}
|
|
1420
1496
|
else if (transport.supportsHostLogs) {
|
|
1421
1497
|
// A log-only transport has no app-side HTTP listener to probe. Resolve its selected host
|
|
@@ -1437,6 +1513,8 @@ async function handleHealth(res) {
|
|
|
1437
1513
|
if (ok) {
|
|
1438
1514
|
try {
|
|
1439
1515
|
const p = JSON.parse(ping.body);
|
|
1516
|
+
// A dashboard up before the MCP armed learns the owner here instead of only at boot.
|
|
1517
|
+
transport.adoptRadarOwner?.(p);
|
|
1440
1518
|
if (p.android_user_id != null)
|
|
1441
1519
|
uid = String(p.android_user_id);
|
|
1442
1520
|
if (typeof p.profile === "string")
|
|
@@ -1897,6 +1975,9 @@ tab) {
|
|
|
1897
1975
|
// the pulled-DB scratch is A's. Same two drops the switched path below performs; only the
|
|
1898
1976
|
// screen teardown is withheld, and lastArmedSerial stays put so the press earns it.
|
|
1899
1977
|
cleanupPulledDatabases();
|
|
1978
|
+
// Device B may run a different Slack debug build; the next arm re-detects it.
|
|
1979
|
+
resetSlackDebugPackage();
|
|
1980
|
+
transport.releaseDebugBuild?.();
|
|
1900
1981
|
logSession?.restart();
|
|
1901
1982
|
return { status: 200, body: {
|
|
1902
1983
|
enabled: false,
|
|
@@ -1942,6 +2023,9 @@ tab) {
|
|
|
1942
2023
|
// on its next /stream reconnect; nothing here needs to force-restart it eagerly.
|
|
1943
2024
|
if (switched) {
|
|
1944
2025
|
cleanupPulledDatabases();
|
|
2026
|
+
// Device B may run a different Slack debug build; the next arm re-detects it.
|
|
2027
|
+
resetSlackDebugPackage();
|
|
2028
|
+
transport.releaseDebugBuild?.();
|
|
1945
2029
|
logSession?.restart();
|
|
1946
2030
|
// The old device's streamed switchboard records belong to the wrong hardware.
|
|
1947
2031
|
clearSwitchboardHostStore();
|
|
@@ -1999,6 +2083,8 @@ tab) {
|
|
|
1999
2083
|
// enabled:false after the ping probe times out. Async for the same reason as the boot chain:
|
|
2000
2084
|
// the broadcast waits for ordered delivery under a 15 second ceiling, and a Reconnect press
|
|
2001
2085
|
// must not hold the event loop for it.
|
|
2086
|
+
// A fresh enable decides the build again, so drop the one a past arm held.
|
|
2087
|
+
transport.releaseDebugBuild?.();
|
|
2002
2088
|
if (transport.activateAsync) {
|
|
2003
2089
|
await transport.activateAsync(transport.getTimeoutMinutes());
|
|
2004
2090
|
}
|
|
@@ -2014,12 +2100,13 @@ tab) {
|
|
|
2014
2100
|
}
|
|
2015
2101
|
const activateError = transport.getLastActivateError?.() ?? null;
|
|
2016
2102
|
if (activateError) {
|
|
2103
|
+
const bare = transport.getLastActivateBareError?.() != null;
|
|
2017
2104
|
return { status: 200, body: {
|
|
2018
2105
|
enabled: false,
|
|
2019
|
-
error: transport.supportsRadarHttpTools
|
|
2106
|
+
error: bare ? activateError : transport.supportsRadarHttpTools
|
|
2020
2107
|
? `Broadcast failed: ${activateError}. Is the device connected?`
|
|
2021
2108
|
: `Log capture activation failed: ${activateError}`,
|
|
2022
|
-
instructs:
|
|
2109
|
+
instructs: bare,
|
|
2023
2110
|
device_serial: pinnedSerial(),
|
|
2024
2111
|
} };
|
|
2025
2112
|
}
|
|
@@ -2045,6 +2132,21 @@ tab) {
|
|
|
2045
2132
|
return refusedReply();
|
|
2046
2133
|
}
|
|
2047
2134
|
const enabled = ping.state === "armed" && ping.status === 200;
|
|
2135
|
+
// Another build holding the socket answers a healthy ping, so the arm did not land on ours.
|
|
2136
|
+
const pingBody = enabled && transport.foreignRadarOwner ? parsedPingBody(ping.body) : null;
|
|
2137
|
+
// The dashboard is a viewer: it follows the build that owns the socket. An override or an owner
|
|
2138
|
+
// that is not a shipped id is not adopted, so the check below still refuses it.
|
|
2139
|
+
if (pingBody)
|
|
2140
|
+
transport.adoptRadarOwner?.(pingBody);
|
|
2141
|
+
const foreignOwner = pingBody ? transport.foreignRadarOwner?.(pingBody) ?? null : null;
|
|
2142
|
+
if (foreignOwner !== null) {
|
|
2143
|
+
return { status: 200, body: {
|
|
2144
|
+
enabled: false,
|
|
2145
|
+
error: foreignRadarOwnerMessage(transport.logPackage ?? "the armed build", foreignOwner),
|
|
2146
|
+
instructs: true,
|
|
2147
|
+
device_serial: pinnedSerial(),
|
|
2148
|
+
} };
|
|
2149
|
+
}
|
|
2048
2150
|
// A verified arm refutes any cached "no_session" the same way a stream connect does (the
|
|
2049
2151
|
// memo is evidence about a session this route just restored): without this, another stream
|
|
2050
2152
|
// client's mid-retry memo read could announce the pre-arm diagnosis for up to its TTL and
|
|
@@ -3259,6 +3361,7 @@ function handleStream(req, res) {
|
|
|
3259
3361
|
const armLogs = () => {
|
|
3260
3362
|
if (!wantsLogs || closed)
|
|
3261
3363
|
return;
|
|
3364
|
+
captureArmed = true;
|
|
3262
3365
|
const ok = logSession?.start() ?? false;
|
|
3263
3366
|
if (!ok) {
|
|
3264
3367
|
const failure = logSession?.takeLastFailure();
|
|
@@ -3279,6 +3382,29 @@ function handleStream(req, res) {
|
|
|
3279
3382
|
return;
|
|
3280
3383
|
settled = true;
|
|
3281
3384
|
retries++;
|
|
3385
|
+
// While the window is open there is nothing to diagnose or rebuild: wait it out.
|
|
3386
|
+
const absentMs = deviceAbsentMsLeft();
|
|
3387
|
+
if (absentMs > 0) {
|
|
3388
|
+
// The skipped probe is the only thing that retracts a latched no_session, and it would
|
|
3389
|
+
// keep saying "no radar session" while the device is simply gone.
|
|
3390
|
+
if (lastReason === "no_session")
|
|
3391
|
+
announce("waiting", "device not answering, retrying…", "undiagnosed");
|
|
3392
|
+
// An early clear (/enable, activate, the device chip's listing) must wake the stream
|
|
3393
|
+
// before the old deadline, so re-read the window every couple of seconds instead of
|
|
3394
|
+
// sleeping it.
|
|
3395
|
+
const tick = () => {
|
|
3396
|
+
if (closed)
|
|
3397
|
+
return;
|
|
3398
|
+
const left = deviceAbsentMsLeft();
|
|
3399
|
+
if (left === 0) {
|
|
3400
|
+
connect();
|
|
3401
|
+
return;
|
|
3402
|
+
}
|
|
3403
|
+
setTimeout(tick, Math.min(left, 2000));
|
|
3404
|
+
};
|
|
3405
|
+
setTimeout(tick, Math.min(absentMs, 2000));
|
|
3406
|
+
return;
|
|
3407
|
+
}
|
|
3282
3408
|
// A failure that keeps repeating deserves a WHY. The second attempt (the first repeat —
|
|
3283
3409
|
// one failure is routine) and a coarse cadence after that, so a fresh classification can
|
|
3284
3410
|
// still ARRIVE mid-outage without running an adb probe on every 2s retry. announce never
|
|
@@ -3436,12 +3562,14 @@ function handleStream(req, res) {
|
|
|
3436
3562
|
retry();
|
|
3437
3563
|
});
|
|
3438
3564
|
});
|
|
3439
|
-
upstream.on("error", () => {
|
|
3565
|
+
upstream.on("error", (err) => {
|
|
3440
3566
|
if (attempt !== attemptSeq)
|
|
3441
3567
|
return;
|
|
3442
3568
|
clearTimeout(myDeadline);
|
|
3443
3569
|
if (headersDeadline === myDeadline)
|
|
3444
3570
|
headersDeadline = null;
|
|
3571
|
+
if (!forwarded && err.code === "ECONNREFUSED")
|
|
3572
|
+
markDeviceAbsent();
|
|
3445
3573
|
announce("waiting", "device unreachable, retrying…");
|
|
3446
3574
|
retry();
|
|
3447
3575
|
});
|
|
@@ -3501,7 +3629,10 @@ function handleStream(req, res) {
|
|
|
3501
3629
|
// never tears down the capture or loses lines in a reconnect gap.
|
|
3502
3630
|
let unsubscribeLogs = null;
|
|
3503
3631
|
let unsubscribeLogStatus = null;
|
|
3632
|
+
let countedLogStream = false;
|
|
3504
3633
|
if (wantsLogs) {
|
|
3634
|
+
openLogStreams++;
|
|
3635
|
+
countedLogStream = true;
|
|
3505
3636
|
// Subscribe before starting so a synchronous spawn failure is announced with its
|
|
3506
3637
|
// real cause. armLogs' fallback wording would otherwise win the status deduper and
|
|
3507
3638
|
// hide the more useful failure emitted by LogSession.
|
|
@@ -3555,6 +3686,8 @@ function handleStream(req, res) {
|
|
|
3555
3686
|
clearInterval(heartbeat);
|
|
3556
3687
|
if (headersDeadline)
|
|
3557
3688
|
clearTimeout(headersDeadline);
|
|
3689
|
+
if (countedLogStream)
|
|
3690
|
+
openLogStreams--;
|
|
3558
3691
|
if (unsubscribeLogs)
|
|
3559
3692
|
unsubscribeLogs(); // detach listener; capture stays up
|
|
3560
3693
|
if (unsubscribeLogStatus)
|
|
@@ -3585,6 +3718,15 @@ function listDevices(res) {
|
|
|
3585
3718
|
// listDevices() at all (undefined) is treated as "no devices", not an adb error.
|
|
3586
3719
|
const listed = transport.listDevices?.();
|
|
3587
3720
|
const adbError = listed === null;
|
|
3721
|
+
// A failed forward plus a refused port is also what an adb server restart looks like, and the
|
|
3722
|
+
// page lists devices every 5s, so a listed device is the earliest free sign the desk is not
|
|
3723
|
+
// empty. A null listing or only unauthorized/offline entries leave the window alone. With the
|
|
3724
|
+
// pin on serial X and only Y attached, each /health poll and each waiting stream re-marks after
|
|
3725
|
+
// a clear, so the forward pair repeats about once per chip poll; bounded, no state kept for it.
|
|
3726
|
+
// This reads the listing only, builds no forward and runs nothing else, so a GET on this open
|
|
3727
|
+
// route can at most end the probe window early.
|
|
3728
|
+
if (listed?.some((d) => d.state === "device"))
|
|
3729
|
+
clearDeviceAbsent();
|
|
3588
3730
|
sendJson(res, 200, {
|
|
3589
3731
|
devices: listed ?? [],
|
|
3590
3732
|
selected: transport.getSelectedDevice?.() ?? null,
|
|
@@ -3604,11 +3746,13 @@ function activateRadar(res, userId) {
|
|
|
3604
3746
|
});
|
|
3605
3747
|
return;
|
|
3606
3748
|
}
|
|
3749
|
+
clearDeviceAbsent();
|
|
3607
3750
|
try {
|
|
3608
3751
|
if (userId && transport.activateForUser) {
|
|
3609
3752
|
transport.activateForUser(userId, 5);
|
|
3610
3753
|
}
|
|
3611
3754
|
else {
|
|
3755
|
+
transport.releaseDebugBuild?.();
|
|
3612
3756
|
transport.activate(5);
|
|
3613
3757
|
}
|
|
3614
3758
|
}
|
|
@@ -3617,7 +3761,8 @@ function activateRadar(res, userId) {
|
|
|
3617
3761
|
ok: false,
|
|
3618
3762
|
error: e instanceof TokenFileError
|
|
3619
3763
|
? tokenFileMessage(e, "dashboard")
|
|
3620
|
-
:
|
|
3764
|
+
: e instanceof BareEnableError ? e.message
|
|
3765
|
+
: `Broadcast failed: ${e.message}. Is the device connected?`,
|
|
3621
3766
|
});
|
|
3622
3767
|
return;
|
|
3623
3768
|
}
|
|
@@ -3628,7 +3773,7 @@ function activateRadar(res, userId) {
|
|
|
3628
3773
|
}
|
|
3629
3774
|
const activateError = transport.getLastActivateError?.();
|
|
3630
3775
|
if (activateError) {
|
|
3631
|
-
sendJson(res, 502, { ok: false, error: `Broadcast failed: ${activateError}. Is the device connected?` });
|
|
3776
|
+
sendJson(res, 502, { ok: false, error: transport.getLastActivateBareError?.() ? activateError : `Broadcast failed: ${activateError}. Is the device connected?` });
|
|
3632
3777
|
return;
|
|
3633
3778
|
}
|
|
3634
3779
|
sendJson(res, 200, {
|
package/dist/web/spec.d.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* Sources the dashboard can read. The first five plus "switchboard" are live streams; "all" is
|
|
15
15
|
* their unified timeline. "db", "prefs", and "flags" are read-only point-in-time browsers (not
|
|
16
16
|
* streams) and are each handled as a distinct view. "switchboard" is the Slackbot voice transport's
|
|
17
|
-
* own event stream (session / state / frame / phase / player / levels / turn / saved_turn records),
|
|
17
|
+
* own event stream (session / state / frame / phase / player / levels / turn / saved_turn / card records),
|
|
18
18
|
* device-produced like rtm.
|
|
19
19
|
*/
|
|
20
20
|
export declare const SOURCES: readonly ["rtm", "network", "clog", "trace", "log", "switchboard", "all", "db", "prefs", "flags"];
|
package/dist/web/spec.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* Sources the dashboard can read. The first five plus "switchboard" are live streams; "all" is
|
|
15
15
|
* their unified timeline. "db", "prefs", and "flags" are read-only point-in-time browsers (not
|
|
16
16
|
* streams) and are each handled as a distinct view. "switchboard" is the Slackbot voice transport's
|
|
17
|
-
* own event stream (session / state / frame / phase / player / levels / turn / saved_turn records),
|
|
17
|
+
* own event stream (session / state / frame / phase / player / levels / turn / saved_turn / card records),
|
|
18
18
|
* device-produced like rtm.
|
|
19
19
|
*/
|
|
20
20
|
export const SOURCES = ["rtm", "network", "clog", "trace", "log", "switchboard", "all", "db", "prefs", "flags"];
|