@slack/radar-mcp 1.18.1 → 1.20.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 +40 -4
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/tools.js +7 -2
- package/dist/mcp/web-child-env.js +10 -7
- package/dist/shared/android.d.ts +10 -21
- package/dist/shared/android.js +30 -9
- package/dist/shared/constants.d.ts +4 -3
- package/dist/shared/constants.js +4 -3
- package/dist/shared/ios.d.ts +5 -10
- package/dist/shared/ios.js +23 -5
- package/dist/shared/transport.d.ts +31 -19
- package/dist/shared/wire.d.ts +24 -0
- package/dist/shared/wire.js +6 -0
- package/dist/web/install-app.d.ts +64 -1
- package/dist/web/install-app.js +174 -24
- package/dist/web/macapp/RadarApp.swift +1311 -75
- package/dist/web/public/index.html +72 -5
- package/dist/web/public/next/app.js +173 -24
- package/dist/web/public/next/db.js +177 -18
- package/dist/web/public/next/feed.js +129 -20
- package/dist/web/public/next/filter.js +24 -11
- package/dist/web/public/next/filters.js +8 -0
- package/dist/web/public/next/registry.js +12 -1
- package/dist/web/public/next/store.js +666 -45
- package/dist/web/server.d.ts +115 -8
- package/dist/web/server.js +734 -58
- package/dist/web/spec.d.ts +3 -0
- package/dist/web/spec.js +28 -0
- package/package.json +1 -1
|
@@ -35,6 +35,8 @@
|
|
|
35
35
|
--accent:#0e9f6e; --accent-bg:#d6f3e6; --accent-text:#0a7d56;
|
|
36
36
|
--blue:#1d6fd0; --blue-2:#2f6bbf; --purple:#7a3fd0;
|
|
37
37
|
--warn:#b06c00; --warn-2:#8a5a00; --error:#d83a30; --error-2:#e0473d;
|
|
38
|
+
/* Amber for small semibold TEXT on the light page (the head, tail and reason spans, the Reconnect label): #b06c00 measures 3.89:1 against --bg and 4.21:1 on --surface, under WCAG AA's 4.5:1 for text that size; #8a5a00 measures 5.47:1 and 5.93:1. Same value as --warn-2 on purpose. Borders keep --warn. */
|
|
39
|
+
--warn-text:#8a5a00;
|
|
38
40
|
--hover:#eaf1f8; --sel:#d4e6f7; --hover-soft:#eaf1f8; --sel-soft:#dbe9f7;
|
|
39
41
|
--shadow:rgba(20,40,70,.18); --overlay:rgba(20,30,45,.28);
|
|
40
42
|
--chip-net-bg:#dbeafe; --chip-rtm-bg:#ecddfb; --chip-clog-bg:#d6f3e6; --chip-trace-bg:#faedcf; --chip-log-bg:#e7ebf0; --chip-log-fg:#4a5666;
|
|
@@ -52,9 +54,16 @@
|
|
|
52
54
|
#app { height:100%; display:flex; flex-direction:column; min-height:0; }
|
|
53
55
|
h1 { font-size:13px; font-weight:600; color:var(--muted-2); margin:0 0 6px; letter-spacing:.04em; display:flex; align-items:center; gap:8px; flex-wrap:wrap; flex:0 0 auto; }
|
|
54
56
|
.conn { font-size:13px; font-weight:600; }
|
|
55
|
-
.conn.connected { color:var(--accent); } .conn.waiting { color:var(--warn); }
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
.conn.connected { color:var(--accent); } .conn.waiting { color:var(--warn-text, var(--warn)); }
|
|
58
|
+
/* The status row: the recovery tail plus the reason / pick-error spans, on a line of its own (rendered last in the h1 so it takes the line below the controls and never pushes them down; they may still wrap for width reasons of their own) that stays while the Reconnect button shows, and exactly one text line tall: the reason never wraps, it ellipsizes with the full wording on hover, so its members can mount and unmount without changing the header's height. The reason spans drop to regular weight so the seam between the automation's status and the server's reason is visible. */
|
|
59
|
+
/* min-width:0 on the row itself is load-bearing: as an h1 flex item its automatic minimum is its content-based minimum (min-content, which for these nowrap children is the full wording's width), and without it the row grows past the header and the reason is clipped at the window edge instead of ellipsizing. */
|
|
60
|
+
.statusrow { flex-basis:100%; min-width:0; display:flex; flex-wrap:nowrap; align-items:center; gap:8px; min-height:1.5em; }
|
|
61
|
+
.statusrow .conn { white-space:nowrap; }
|
|
62
|
+
.statusrow .conn[title] { cursor:help; }
|
|
63
|
+
.statusrow .reason { font-weight:400; flex:1 1 auto; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; cursor:help; }
|
|
64
|
+
/* min-width holds the button's own width across its "Reconnect Radar" / "enabling…" relabel (the wider label measures ~150px; the headroom covers a wider fallback glyph). What keeps the button and the chip after it from shifting at an ATTEMPT boundary is the header's markup order: the changing recovery tail renders after them, on its own status row, and the conn span before them holds its text between the outage's two ends (a device-list change aside). */
|
|
65
|
+
.reconnect { background:var(--surface); border:1px solid var(--warn); color:var(--warn-text, var(--warn)); border-radius:8px; padding:4px 12px; min-width:160px; text-align:center; font:inherit; font-size:12px; font-weight:600; cursor:pointer; }
|
|
66
|
+
.reconnect:hover { border-color:var(--warn-2); } .reconnect:disabled { opacity:.75; cursor:default; }
|
|
58
67
|
.profilewrap { font-size:12px; color:var(--blue-2); } .profilewrap b { color:var(--text); }
|
|
59
68
|
.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
69
|
h1 .version { margin-left:auto; font-size:11px; font-weight:400; color:var(--muted-2); letter-spacing:0; }
|
|
@@ -135,14 +144,34 @@
|
|
|
135
144
|
Studio Logcat style). The wrap owns the border + padding + focus ring; the input inside
|
|
136
145
|
is chromeless so pills + draft read as one control. Pills flex-wrap onto more lines when
|
|
137
146
|
the query is long. */
|
|
138
|
-
.ffilterwrap { position:relative; flex:1; display:flex; flex-wrap:wrap; align-items:center; gap:5px; min-width:140px; background:var(--surface-2); border:1px solid var(--border-2); border-radius:8px; padding:4px
|
|
147
|
+
.ffilterwrap { position:relative; flex:1; display:flex; flex-wrap:wrap; align-items:center; gap:5px; min-width:140px; background:var(--surface-2); border:1px solid var(--border-2); border-radius:8px; padding:4px 48px 4px 6px; cursor:text; }
|
|
139
148
|
.ffilterwrap:focus-within { border-color:var(--accent); }
|
|
140
149
|
.ffilterwrap .ffilter { flex:1; min-width:80px; background:transparent; border:none; padding:3px 4px; font:inherit; font-size:12.5px; color:var(--text); }
|
|
141
150
|
.ffilterwrap .ffilter:focus { outline:none; }
|
|
151
|
+
/* The placeholder is the standing syntax reminder, so it needs real contrast: the browser
|
|
152
|
+
default grey lands near 2:1 on the light theme. --muted-2 clears 6:1 on both themes. */
|
|
153
|
+
.ffilterwrap .ffilter::placeholder { color:var(--muted-2); opacity:1; }
|
|
154
|
+
/* With pills present the hint is 27 monospace characters; below that width it hard-clips
|
|
155
|
+
mid-word, so the input drops to its own row instead. Without :has() the input keeps its
|
|
156
|
+
80px minimum and the hint clips; cosmetic, and every browser the dashboard runs in has it. */
|
|
157
|
+
.ffilterwrap:has(.fpill) .ffilter { min-width:28ch; }
|
|
142
158
|
.feedbar input { 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; }
|
|
143
159
|
.feedbar input:focus { outline:none; border-color:var(--accent); }
|
|
144
|
-
.ffilterclear { position:absolute; right:
|
|
160
|
+
.ffilterclear { position:absolute; right:32px; top:9px; cursor:pointer; color:var(--muted-2); background:var(--surface); border-radius:50%; width:16px; height:16px; line-height:14px; text-align:center; font-size:10px; }
|
|
145
161
|
.ffilterclear:hover { color:#fff; background:var(--error-2); }
|
|
162
|
+
/* The ? is the standing way in to the syntax; the placeholder only hints at it and vanishes
|
|
163
|
+
the moment somebody types. The legend opens under the box so it reads next to the input. */
|
|
164
|
+
.fhelp { position:absolute; right:8px; top:8px; cursor:pointer; color:var(--muted-2); border:1px solid var(--border-3); border-radius:50%; width:16px; height:16px; line-height:14px; text-align:center; font-size:10px; font-weight:600; user-select:none; }
|
|
165
|
+
.fhelp:hover, .fhelp.open { color:var(--text); border-color:var(--accent); }
|
|
166
|
+
/* Focus is the pill's ring, so it reads as focus and not as "open". */
|
|
167
|
+
.fhelp:focus-visible { outline:2px solid var(--accent); outline-offset:1px; }
|
|
168
|
+
/* Anchored to the box's left edge: the box is the wide element on the bar, so the legend has
|
|
169
|
+
room to its right and never runs off the viewport on a narrow window. */
|
|
170
|
+
.fhelppop { position:absolute; left:0; top:calc(100% + 4px); z-index:5; display:grid; grid-template-columns:auto 1fr; gap:4px 12px; max-width:min(460px, 90vw); background:var(--surface); border:1px solid var(--border-3); border-radius:8px; padding:8px 10px; font-size:12px; color:var(--text); box-shadow:0 4px 16px var(--shadow); cursor:default; }
|
|
171
|
+
/* --accent-text, not --accent: the accent lands near 3.4:1 on the light surface, and the same
|
|
172
|
+
call is made for the other small accent text in this file. */
|
|
173
|
+
.fhelppop code { color:var(--accent-text); font-size:11.5px; white-space:nowrap; }
|
|
174
|
+
.fhelppop .fhelpnote { grid-column:1 / -1; color:var(--muted-2); padding-top:2px; }
|
|
146
175
|
/* The draft input turns amber when its own text is an invalid regex mid-typing. Committed
|
|
147
176
|
terms use the per-pill amber (.fpill-bad) instead. */
|
|
148
177
|
.ffilterwrap:has(.ffilter.finvalid) { border-color:var(--warn); }
|
|
@@ -162,6 +191,14 @@
|
|
|
162
191
|
.fpill-neg { background:var(--lvl-err-bg); border-color:var(--error-2); color:var(--error-2); }
|
|
163
192
|
.fpill-neg .fpill-sign { color:var(--error-2); }
|
|
164
193
|
.fpill-re, .fpill-quote { font-family:ui-monospace,Menlo,Consolas,monospace; }
|
|
194
|
+
/* A phrase pill is tinted and carries curly marks outside the ellipsizing body, so it reads as
|
|
195
|
+
a phrase even when a long pasted line truncates. */
|
|
196
|
+
.fpill-quote { background:var(--surface-3); }
|
|
197
|
+
.fpill-q { color:var(--muted-2); }
|
|
198
|
+
/* A negated phrase pill (-"log", the documented way to exclude by text on Live) carries both
|
|
199
|
+
classes at equal specificity; the compound keeps the negation red on the background, same
|
|
200
|
+
reasoning as the negated kind pills below. */
|
|
201
|
+
.fpill-neg.fpill-quote { background:var(--lvl-err-bg); }
|
|
165
202
|
.fpill-bad { background:var(--lvl-warn-bg); border-color:var(--warn); color:var(--warn-2); }
|
|
166
203
|
/* Kind-name pills on the Live view. Match the row's type chip color so "clog" reads the
|
|
167
204
|
same whether you see it in the pill or in the row's tchip. */
|
|
@@ -293,6 +330,36 @@
|
|
|
293
330
|
.dbout tr:hover td { background:var(--hover); }
|
|
294
331
|
.dbout tr { cursor:pointer; }
|
|
295
332
|
.dbout tr.rowsel td { background:var(--sel-soft); }
|
|
333
|
+
/* Sortable column headers in the results grid. .dbsortable only lands on headers the DB grid
|
|
334
|
+
renders, so the flags table (which reuses .dbout but builds its own header row) picks up none of
|
|
335
|
+
this. Every header owns a direction slot at all times, a dim ↕ when unsorted, which is what
|
|
336
|
+
holds the column boundaries still across a click: measured, 0.00px of movement on every column.
|
|
337
|
+
The slot's fixed width is insurance on top of that, for a fallback font whose glyph advances
|
|
338
|
+
differ; this stack is monospace, so they do not.
|
|
339
|
+
Three colour decisions, each measured against the surface the element actually sits on:
|
|
340
|
+
- the sorted column is --accent-text, not --accent. On light, #0e9f6e is 3.39:1 against the
|
|
341
|
+
header's --surface, under WCAG AA's 4.5:1 for text this size; #0a7d56 is 5.15:1. Dark is
|
|
342
|
+
9.62:1 either way. Same reasoning as --warn-text above.
|
|
343
|
+
- the slot's three states are a colour progression, not an alpha one. At opacity .3 the
|
|
344
|
+
resting ↕ measured 1.61:1, under the 3:1 floor for a state indicator, and it is the only
|
|
345
|
+
at-rest sign that a header is clickable. As --muted it is 4.55:1 light and 3.52:1 dark.
|
|
346
|
+
- hover is a BACKGROUND change so the SORTED column gets feedback too. The colour rules have
|
|
347
|
+
to exclude .sorted, because hover is the more specific selector and would otherwise
|
|
348
|
+
overwrite the sorted colour and de-highlight the very column being pointed at, which left
|
|
349
|
+
the clearing click with no hover response at all. Brightening instead is not available:
|
|
350
|
+
--accent on light is dimmer than --accent-text. The cost is that hovering the sorted column
|
|
351
|
+
is the tightest state in the feature, 4.52:1 on light, 0.02 over the floor. */
|
|
352
|
+
.dbout th.dbsortable:hover { background:var(--hover-soft); }
|
|
353
|
+
.dbout th.dbsortable:not(.sorted):hover { color:var(--text); }
|
|
354
|
+
.dbout th.sorted { color:var(--accent-text); }
|
|
355
|
+
.dbout th .dbsortdir { display:inline-block; width:9px; margin-left:5px; font-size:10px; vertical-align:1px; text-align:center; color:var(--muted); }
|
|
356
|
+
.dbout th.dbsortable:not(.sorted):hover .dbsortdir { color:var(--text); }
|
|
357
|
+
.dbout th.sorted .dbsortdir { color:var(--accent-text); }
|
|
358
|
+
/* Brighter than the --muted meta text it sits inside: this is the only place the grid says what a
|
|
359
|
+
sort covered, and --muted against the page's --bg measures 3.84:1 on dark. --muted-2 is 7.11:1
|
|
360
|
+
there and 6.89:1 on light. Its separating space is in the TEXT rather than a margin here, so the
|
|
361
|
+
line also reads correctly when it is copied or read aloud. */
|
|
362
|
+
.dbsortnote { color:var(--muted-2); }
|
|
296
363
|
/* DB dock -- docked right of the grid, shared by the row detail and the query history via
|
|
297
364
|
tabs; the split shrinks the grid to make room. Mirrors the feed's .stage.split layout. */
|
|
298
365
|
.dbsplit { flex:1; min-height:0; display:flex; gap:14px; align-items:stretch; }
|
|
@@ -8,7 +8,7 @@ import { html } from "./html.js";
|
|
|
8
8
|
import { render } from "preact";
|
|
9
9
|
import { useState, useEffect, useCallback, useRef } from "preact/hooks";
|
|
10
10
|
import { useStoreValue } from "./hooks.js";
|
|
11
|
-
import { store, MODES, modeServed, describeConstraints } from "./store.js";
|
|
11
|
+
import { store, MODES, modeServed, describeConstraints, AUTO_REARM_MAX_FAILS, specForTab } from "./store.js";
|
|
12
12
|
import { SOURCES } from "./registry.js";
|
|
13
13
|
import { Feed } from "./feed.js";
|
|
14
14
|
import { Cards } from "./widgets.js";
|
|
@@ -48,11 +48,9 @@ function DeviceChip() {
|
|
|
48
48
|
// Unpinned with exactly one ready device: bare adb targets that device anyway, so name it
|
|
49
49
|
// instead of claiming "none". "none" is reserved for genuinely nothing attached.
|
|
50
50
|
const label = selected?.label ?? (ready.length === 1 ? ready[0].label : "none");
|
|
51
|
-
//
|
|
52
|
-
//
|
|
53
|
-
//
|
|
54
|
-
// header row explain the same outage twice, and the reconnect reason is the later answer.
|
|
55
|
-
const deviceError = store.visibleEnableError ? null : store.deviceError;
|
|
51
|
+
// The chip carries only the picker. Its pick error renders in the Header AFTER the controls
|
|
52
|
+
// (see pickError there): inside the chip, the error's mount/unmount changed the chip's width and
|
|
53
|
+
// moved the Reconnect button beside it at exactly the attempt boundaries a user reaches for it.
|
|
56
54
|
if (store.devicesError) {
|
|
57
55
|
return html `<span class="profilewrap" title="adb devices failed; check adb">device: <b>adb error</b></span>`;
|
|
58
56
|
}
|
|
@@ -62,19 +60,53 @@ function DeviceChip() {
|
|
|
62
60
|
${!selected ? html `<option value="" selected disabled>pick a device…</option>` : null}
|
|
63
61
|
${ready.map((d) => html `<option value=${d.serial} selected=${d.serial === selected?.serial}>${d.label} (${d.serial})</option>`)}
|
|
64
62
|
</select>`;
|
|
65
|
-
return html `<span class="profilewrap" title="the device Radar is bound to; pick another to switch">device: ${picker}
|
|
63
|
+
return html `<span class="profilewrap" title="the device Radar is bound to; pick another to switch">device: ${picker}</span>`;
|
|
66
64
|
}
|
|
67
65
|
export function Header({ screenOpen, onScreenToggle }) {
|
|
68
66
|
const conn = useStoreValue(store, "conn", () => store.conn);
|
|
69
67
|
// Why the last Reconnect press failed, shown next to the button that produced it. The store's
|
|
70
|
-
// getter owns
|
|
71
|
-
// earlier one
|
|
68
|
+
// getter owns all three conditions (disconnected, the reason belongs to THIS outage rather
|
|
69
|
+
// than an earlier one, and no fresh flight is in progress — a new attempt supersedes the old
|
|
70
|
+
// answer), so there is no gating to get wrong here.
|
|
72
71
|
const enableError = useStoreValue(store, "enable-error", () => store.visibleEnableError);
|
|
72
|
+
const enableInstructs = useStoreValue(store, "enable-error", () => store.visibleEnableInstructs);
|
|
73
73
|
const profile = useStoreValue(store, "profile", () => store.profileLabel);
|
|
74
74
|
const version = useStoreValue(store, "version", () => store.serverVersion);
|
|
75
75
|
const selfHeal = useStoreValue(store, "self-heal", () => store.selfHeal);
|
|
76
76
|
const setupHint = useStoreValue(store, "setup-hint", () => store.setupHint);
|
|
77
77
|
const stopped = useStoreValue(store, "stopped", () => store.stopped);
|
|
78
|
+
// The recovery state, all store-owned: `enabling` is the single-flight latch reconnect()
|
|
79
|
+
// itself holds (manual press and auto-re-arm alike), so the button disables and relabels
|
|
80
|
+
// off the same fact that refuses a concurrent /enable. `sessionEnded` drives the conn span
|
|
81
|
+
// (the fixed diagnosis) and, with `exhausted`/`terminal`, the recovery tail rendered after
|
|
82
|
+
// the button: the diagnosed message must come from the latch, not conn.msg, because
|
|
83
|
+
// pollHealth's generic "device offline, retrying…" overwrites conn.msg within one 2s tick —
|
|
84
|
+
// and is factually wrong for this outage mode.
|
|
85
|
+
const enabling = useStoreValue(store, "enabling", () => store.enabling);
|
|
86
|
+
const autoRearming = useStoreValue(store, "auto-rearm", () => store.autoRearming);
|
|
87
|
+
const sessionEnded = useStoreValue(store, "session-ended", () => store.sessionEnded);
|
|
88
|
+
const exhausted = useStoreValue(store, "auto-rearm", () => store.autoRearmExhausted);
|
|
89
|
+
const terminal = useStoreValue(store, "auto-rearm", () => store.autoRearmTerminal);
|
|
90
|
+
const flapped = useStoreValue(store, "auto-rearm", () => store.autoRearmFlapped);
|
|
91
|
+
const suppressed = useStoreValue(store, "auto-rearm", () => store.autoRearmSuppressed);
|
|
92
|
+
const needsPick = useStoreValue(store, "devices", () => store.needsDevicePick);
|
|
93
|
+
// Whether this dashboard process may arm the device on its own (an agent spawned it, or
|
|
94
|
+
// SLACK_RADAR_NO_ARM is set). Such a tab NEVER arms unattended, so it must not promise a
|
|
95
|
+
// retry or offer to stop one — it says what is true for it: press the button. Tri-state:
|
|
96
|
+
// null means no /health reply has answered yet, and the store refuses to arm until one does,
|
|
97
|
+
// so an unanswered tab hides the automation controls like a blocked one (mayAutoRearm false)
|
|
98
|
+
// but renders its own "checking…" tail rather than an instruction the reply may withdraw.
|
|
99
|
+
const selfArmBlocked = useStoreValue(store, "self-arm-blocked", () => store.selfArmBlocked);
|
|
100
|
+
const mayAutoRearm = selfArmBlocked === false;
|
|
101
|
+
// A device-select failure (e.g. an ambiguous /enable 409). Only a later pick that works clears
|
|
102
|
+
// it; a bound-device change does not (a failed pick the server did pin moves the baseline
|
|
103
|
+
// after the error is written, so the error is about the device just pinned — see
|
|
104
|
+
// checkSerialEdge). Suppressed while a reconnect reason is on screen (two differently worded
|
|
105
|
+
// spans explaining one outage) and during an /enable flight (a new attempt supersedes the old
|
|
106
|
+
// answer, and visibleEnableError is null for the same reason).
|
|
107
|
+
const pickError = useStoreValue(store, "device-error", () => store.deviceError);
|
|
108
|
+
const pickInstructs = useStoreValue(store, "device-error", () => store.deviceErrorInstructs);
|
|
109
|
+
const visiblePickError = enableError || enabling ? null : pickError;
|
|
78
110
|
const [hintDismissed, setHintDismissed] = useState(readSetupHintDismissed);
|
|
79
111
|
const dismissHint = useCallback(() => {
|
|
80
112
|
try {
|
|
@@ -85,7 +117,6 @@ export function Header({ screenOpen, onScreenToggle }) {
|
|
|
85
117
|
}
|
|
86
118
|
setHintDismissed(true);
|
|
87
119
|
}, []);
|
|
88
|
-
const [busy, setBusy] = useState(false);
|
|
89
120
|
const [killing, setKilling] = useState(false);
|
|
90
121
|
// Arm/confirm for the destructive kill button: the FIRST click only arms a "sure?" state
|
|
91
122
|
// (auto-disarms after a few seconds so a stray click never leaves a live trap); the SECOND
|
|
@@ -97,10 +128,11 @@ export function Header({ screenOpen, onScreenToggle }) {
|
|
|
97
128
|
useEffect(() => () => { if (killArmTimer.current)
|
|
98
129
|
clearTimeout(killArmTimer.current); }, []);
|
|
99
130
|
const [theme, setTheme] = useState(readTheme);
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
131
|
+
// Press state lives in the store's `enabling` latch (reconnect() refuses overlap itself),
|
|
132
|
+
// not in component state: the same flight must disable the button whether a press or the
|
|
133
|
+
// auto-re-arm started it.
|
|
134
|
+
const reconnect = useCallback(() => {
|
|
135
|
+
void store.reconnect();
|
|
104
136
|
}, []);
|
|
105
137
|
const kill = useCallback(async () => {
|
|
106
138
|
if (!killArmed) {
|
|
@@ -140,36 +172,152 @@ export function Header({ screenOpen, onScreenToggle }) {
|
|
|
140
172
|
return html `<h1>SLACK RADAR DASHBOARD <span class="conn waiting">● dashboard stopped</span></h1>`;
|
|
141
173
|
}
|
|
142
174
|
const connected = conn.state === "connected";
|
|
175
|
+
// The no-radar-session wording is split in two so the controls between them hold still: the
|
|
176
|
+
// conn span keeps the fixed diagnosis ("● no radar session on the device") for the whole
|
|
177
|
+
// outage, and the part that changes with what the automation is doing renders in its own
|
|
178
|
+
// span AFTER the Reconnect button and the automation chip. A relabel of that tail at an
|
|
179
|
+
// attempt boundary therefore cannot move the button or the chip under a cursor reaching for
|
|
180
|
+
// them. The head does change at the outage's two ENDS (the diagnosis replacing the generic
|
|
181
|
+
// waiting message; the armed reply's interim message replacing the diagnosis), and the
|
|
182
|
+
// profile label can change during one; accepted, since neither is an attempt boundary.
|
|
183
|
+
//
|
|
184
|
+
// The tail is a short sentence of its own (capitalised, and closed with a period when a
|
|
185
|
+
// reason follows it): at 1280px and below with a typical profile label it already wraps to
|
|
186
|
+
// its own line, where a lowercase fragment read as an unrelated second status. The tail and
|
|
187
|
+
// the reason spans share one status row, rendered LAST in the header so it takes the line
|
|
188
|
+
// below whatever the controls occupy and can never push them down (they may still wrap for
|
|
189
|
+
// width reasons of their own), one text line tall (the reason is ellipsized, full text on
|
|
190
|
+
// hover) and present whenever the Reconnect button is — so a reason mounting or unmounting at an
|
|
191
|
+
// attempt boundary, or at a manual press in an undiagnosed outage, changes what the row says,
|
|
192
|
+
// not how tall the header is (a height change reflows everything below it).
|
|
193
|
+
//
|
|
194
|
+
// The tail's precedence, each rung earning its rank: an unresolved device PICK outranks
|
|
195
|
+
// everything (the policy refuses to act until the human picks, so promising a retry would be
|
|
196
|
+
// false); a flight IN PROGRESS outranks the give-up wording (a manual press after give-up
|
|
197
|
+
// must not render "press Reconnect" beside its own disabled, already-pressed button; the
|
|
198
|
+
// manual flight renders no tail at all, since the button already reads "enabling…"); a
|
|
199
|
+
// BLOCKED process says the press is the human's; the human's own persisted STOP outranks an
|
|
200
|
+
// unanswered consent question (the store refuses on suppression whatever the answer); an
|
|
201
|
+
// UNANSWERED question says so rather than issuing an instruction the reply may withdraw.
|
|
202
|
+
// An imperative yields only to a reason span that itself instructs (see reasonInstructs): a
|
|
203
|
+
// reason that merely explains the failure leaves the tail's ", press Reconnect" in place, so
|
|
204
|
+
// the row always carries exactly one instruction.
|
|
205
|
+
const inOutage = !connected && sessionEnded;
|
|
206
|
+
const connLabel = connected
|
|
207
|
+
? "● live"
|
|
208
|
+
: sessionEnded
|
|
209
|
+
? needsPick
|
|
210
|
+
? "● multiple devices attached, pick one"
|
|
211
|
+
: "● no radar session on the device"
|
|
212
|
+
: "● " + (conn.msg || "reconnecting…");
|
|
213
|
+
// Whether the reason about to render beside the tail tells the user to do something. Read off
|
|
214
|
+
// the reply's own flag (set where each wording is written) rather than judged from the prose:
|
|
215
|
+
// some reasons carry adb's stderr verbatim, which no verb list classifies, and a reworded
|
|
216
|
+
// message would silently drift a regex. The pick error stands in for the reason when no
|
|
217
|
+
// reconnect reason is on screen.
|
|
218
|
+
const reasonInstructs = enableError ? enableInstructs : visiblePickError ? pickInstructs : false;
|
|
219
|
+
const press = reasonInstructs ? "" : ", press Reconnect";
|
|
220
|
+
// "gave up after N tries" names real attempts only: a refusal the server will repeat for every
|
|
221
|
+
// unattended retry ends the outage's automation at the attempt that receives it (usually the
|
|
222
|
+
// first), and that reads "gave up" with no count, since the number of attempts is not what
|
|
223
|
+
// ended it; the reason span beside it says why.
|
|
224
|
+
// A count reached through drops (the session kept dying right after coming back) names what
|
|
225
|
+
// happened instead of "tries" the tab did not all make.
|
|
226
|
+
const gaveUp = terminal
|
|
227
|
+
? "Auto re-enable gave up"
|
|
228
|
+
: flapped
|
|
229
|
+
? "Auto re-enable gave up, the session keeps dying soon after coming back"
|
|
230
|
+
: "Auto re-enable gave up after " + AUTO_REARM_MAX_FAILS + " tries";
|
|
231
|
+
const tailText = !inOutage || needsPick
|
|
232
|
+
? null
|
|
233
|
+
: enabling || autoRearming
|
|
234
|
+
? autoRearming
|
|
235
|
+
? "Re-enabling automatically…"
|
|
236
|
+
: null
|
|
237
|
+
: selfArmBlocked === true
|
|
238
|
+
? reasonInstructs ? "Auto re-enable is unavailable on this tab" : "Press Reconnect"
|
|
239
|
+
: suppressed
|
|
240
|
+
? "Auto re-enable is off" + press
|
|
241
|
+
: selfArmBlocked === null
|
|
242
|
+
? "Checking whether this tab may re-enable…"
|
|
243
|
+
: exhausted
|
|
244
|
+
? gaveUp + press
|
|
245
|
+
: "Will retry automatically";
|
|
246
|
+
const followedByReason = !!(enableError || visiblePickError);
|
|
247
|
+
const recoveryTail = tailText && followedByReason && !/[.…]$/.test(tailText) ? tailText + "." : tailText;
|
|
248
|
+
// Why this tab does not recover on its own. Only where that is KNOWN: the server folds both
|
|
249
|
+
// reasons into one boolean, so a blocked tab names the pair; an unanswered tab says what it is
|
|
250
|
+
// waiting for, since the reason is not yet known and for a human launch would be false.
|
|
251
|
+
const tailTitle = !inOutage || enabling || autoRearming
|
|
252
|
+
? undefined
|
|
253
|
+
: selfArmBlocked === true
|
|
254
|
+
? "This dashboard process does not arm the device on its own (it was started by an agent, or SLACK_RADAR_NO_ARM is set). Reconnect works as usual."
|
|
255
|
+
: suppressed
|
|
256
|
+
? mayAutoRearm
|
|
257
|
+
? undefined
|
|
258
|
+
: "Turned off for dashboards at this address. The resume control appears once a /health reply says this tab may re-enable on its own (this dashboard version may not report it)."
|
|
259
|
+
: selfArmBlocked === null
|
|
260
|
+
? "No /health reply has said yet whether this tab may re-enable on its own (this dashboard version may not report it). Reconnect works as usual."
|
|
261
|
+
: exhausted
|
|
262
|
+
? AUTO_REARM_MAX_FAILS + " failed attempts, or a session that died within a minute of each re-enable. Press Reconnect; automatic re-enable starts again once the session stays up for a minute."
|
|
263
|
+
: "Once right away (or on the minute, if the session just came back and died again), then about once a minute, up to " + AUTO_REARM_MAX_FAILS + " tries. A session that dies again within a minute of coming back counts as a failed try.";
|
|
264
|
+
// One status row: the tail, then the reason and pick-error spans. Present whenever the Reconnect
|
|
265
|
+
// button is (any disconnected state, diagnosed or not), plus whenever a pick error shows, so its
|
|
266
|
+
// members can come and go — including across a manual press — without changing the header's
|
|
267
|
+
// height.
|
|
268
|
+
const statusRow = !connected || !!visiblePickError;
|
|
143
269
|
return html `
|
|
144
270
|
<h1>
|
|
145
271
|
SLACK RADAR DASHBOARD
|
|
146
|
-
<span class=${"conn " + conn.state}>${
|
|
272
|
+
<span class=${"conn " + conn.state}>${connLabel}</span>
|
|
147
273
|
<span class="profilewrap" title="the device profile Radar is connected to (first app to launch wins the socket)">profile: <b>${profile}</b></span>
|
|
148
274
|
<${DeviceChip} />
|
|
149
|
-
${!connected ? html `<button class="reconnect" disabled=${
|
|
150
|
-
${
|
|
275
|
+
${!connected ? html `<button class="reconnect" disabled=${enabling} onClick=${reconnect}>${enabling ? "⟳ enabling…" : "⟳ Reconnect Radar"}</button>` : null}
|
|
276
|
+
${suppressed
|
|
277
|
+
// The choice PERSISTS across reloads, so its way back must not depend on being
|
|
278
|
+
// mid-outage: a user who opted out yesterday sees the state and can undo it any time.
|
|
279
|
+
// Hidden where the process cannot self-arm anyway (agent-spawned, NO_ARM set, or not
|
|
280
|
+
// yet answered).
|
|
281
|
+
? mayAutoRearm
|
|
282
|
+
? html `<button class="themebtn" onClick=${() => store.setAutoRearmSuppressed(false)} title="Automatic re-enable is off for dashboards at this address, and remembered until you turn it back on. Click to allow it again.">↻ resume auto re-enable</button>`
|
|
283
|
+
: null
|
|
284
|
+
// Offered while the automation is armed for this outage — including after its budget is
|
|
285
|
+
// spent (it refills on the next recovery, so there is still something to switch off) and
|
|
286
|
+
// including MID-FLIGHT: pressing cannot cancel an /enable already sent, but it stops
|
|
287
|
+
// every future attempt, and for a user whose re-arms always SUCCEED the flight is the
|
|
288
|
+
// only window this control ever renders in (a successful attempt retires the outage
|
|
289
|
+
// before an idle frame exists). Action-voiced like the theme button in the same row
|
|
290
|
+
// (the label names what a click does), which is why the give-up tail says "gave up"
|
|
291
|
+
// and never "stopped": "stopped" beside "stop" read as a contradiction.
|
|
292
|
+
: inOutage && !needsPick && mayAutoRearm
|
|
293
|
+
? html `<button class="themebtn" onClick=${() => store.setAutoRearmSuppressed(true)} title="Stop dashboards at this address from re-enabling Radar automatically, in this outage and later ones. It cannot cancel an attempt already in flight. Remembered until you turn it back on, and other tabs open on this address pick it up. It does not turn Radar off, and an MCP session can still arm the device.">✋ stop auto re-enable</button>`
|
|
294
|
+
: null}
|
|
151
295
|
<button class="themebtn" onClick=${toggleTheme} title="Toggle light / dark theme">${theme === "light" ? "🌙 Dark" : "☀ Light"}</button>
|
|
152
296
|
<button class=${"screenbtn" + (screenOpen ? " on" : "")} onClick=${onScreenToggle} title="Mirror the live device screen">▣ Screen</button>
|
|
153
297
|
<button class=${"themebtn killbtn" + (killArmed ? " armed" : "")} disabled=${killing} onClick=${kill} title=${killArmed ? "Click again to confirm" : "Stop the dashboard server"}>${killing ? "⏻ stopping…" : killArmed ? "⏻ Confirm stop?" : "⏻ Stop dashboard"}</button>
|
|
154
298
|
${version ? html `<span class="version" title="Version of the dashboard process. It can differ from your Claude Code MCP session if a dashboard from an earlier launch still holds the port; restart the dashboard to match.">v${version}</span>` : null}
|
|
155
299
|
${selfHeal?.outcome === "updated" ? html `<span class="version" title="Radar self-healed to a newer version on this launch">↑ updated to v${selfHeal.toVersion}</span>` : null}
|
|
156
300
|
${selfHeal?.outcome === "error" ? html `<span class="conn waiting" title=${"The dock launcher's self-heal check failed: " + (selfHeal.error || "unknown error") + ". Log: ~/Library/Logs/slack-radar-dashboard.log"}>⚠ self-heal check failed</span>` : null}
|
|
157
|
-
${setupHint && !setupHint.mcpSeen && !hintDismissed ? html `<span class="setuphint" title="Radar has not seen an agent client start its MCP server on this machine. The dashboard works without one.">No agent client has connected yet. <a href="https://slack-github.com/slack/slack-radar-mcp#installation" target="_blank" rel="noreferrer">Set up agent tools</a>.<button class="hintdismiss" onClick=${dismissHint} aria-label="Hide the agent tools hint permanently
|
|
301
|
+
${setupHint && !setupHint.mcpSeen && !hintDismissed ? html `<span class="setuphint" title="Radar has not seen an agent client start its MCP server on this machine. The dashboard works without one.">No agent client has connected yet. <a href="https://slack-github.com/slack/slack-radar-mcp#installation" target="_blank" rel="noreferrer">Set up agent tools</a>.<button class="hintdismiss" onClick=${dismissHint} aria-label="Hide the agent tools hint permanently for dashboards at this address" title="Hide this hint permanently for dashboards at this address">✕</button></span>` : null}
|
|
302
|
+
${statusRow ? html `<span class="statusrow">${recoveryTail ? html `<span class=${"conn " + conn.state} title=${tailTitle}>${recoveryTail}</span>` : null}${enableError ? html `<span class="conn waiting reason" title=${enableError}>${enableError}</span>` : null}${visiblePickError ? html `<span class="conn waiting reason" title=${visiblePickError}>${visiblePickError}</span>` : null}</span>` : null}
|
|
158
303
|
</h1>
|
|
159
304
|
`;
|
|
160
305
|
}
|
|
161
|
-
function ModeBar() {
|
|
306
|
+
export function ModeBar() {
|
|
162
307
|
const [, force] = useState(0);
|
|
163
308
|
useEffect(() => store.on("spec", () => force((n) => n + 1)), []);
|
|
164
309
|
const deviceSources = useStoreValue(store, "sources", () => store.deviceSources);
|
|
165
310
|
const activeKey = store.activeModeKey();
|
|
166
|
-
const pick = (specToPush) => store.setSpec(specToPush);
|
|
311
|
+
const pick = (specToPush) => store.setSpec(specForTab(specToPush, store.spec, store.lastLogLevel));
|
|
167
312
|
const serves = (m) => modeServed(m.key, deviceSources);
|
|
168
313
|
// A device switch can hide the active tab (leaner build). Reset to the first tab so the
|
|
169
|
-
// user is never stranded on an invisible mode rendering a dead feed.
|
|
314
|
+
// user is never stranded on an invisible mode rendering a dead feed. Through specForTab like
|
|
315
|
+
// every other preset push, so the level floor rides along: Live carries log rows, so a bare
|
|
316
|
+
// MODES[0].spec would not just skip the floor for this one push, applySpec would also forget
|
|
317
|
+
// it (lastLogLevel back to ""), and the next Logs click would start at VERBOSE.
|
|
170
318
|
useEffect(() => {
|
|
171
319
|
if (activeKey && activeKey !== "__custom__" && !modeServed(activeKey, deviceSources)) {
|
|
172
|
-
store.setSpec(MODES[0].spec);
|
|
320
|
+
store.setSpec(specForTab(MODES[0].spec, store.spec, store.lastLogLevel));
|
|
173
321
|
}
|
|
174
322
|
}, [deviceSources, activeKey]);
|
|
175
323
|
// Group modes by source kind for visual separation
|
|
@@ -180,7 +328,7 @@ function ModeBar() {
|
|
|
180
328
|
${streamModes.map((m) => html `<button class=${"modebtn" + (activeKey === m.key ? " active" : "")} onClick=${() => pick(m.spec)}>${m.label}</button>`)}
|
|
181
329
|
${stateModes.length > 0 ? html `<span class="modedivider"></span>` : null}
|
|
182
330
|
${stateModes.map((m) => html `<button class=${"modebtn" + (activeKey === m.key ? " active" : "")} onClick=${() => pick(m.spec)}>${m.label}</button>`)}
|
|
183
|
-
${store.lastCustomSpec ? html `<button class=${"modebtn custom" + (activeKey === "__custom__" ? " active" : "")} title="pushed from a terminal Claude Code session; persists until refresh" onClick=${() =>
|
|
331
|
+
${store.lastCustomSpec ? html `<button class=${"modebtn custom" + (activeKey === "__custom__" ? " active" : "")} title="pushed from a terminal Claude Code session; persists until refresh" onClick=${() => store.setSpec(store.lastCustomSpec)}>✎ ${store.lastCustomSpec.title || "Custom"}</button>` : null}
|
|
184
332
|
</div>
|
|
185
333
|
`;
|
|
186
334
|
}
|
|
@@ -293,7 +441,8 @@ function App() {
|
|
|
293
441
|
if (next === cur)
|
|
294
442
|
return;
|
|
295
443
|
const nextKey = keys[next];
|
|
296
|
-
const
|
|
444
|
+
const preset = MODES.find((m) => m.key === nextKey)?.spec;
|
|
445
|
+
const nextSpec = nextKey === "__custom__" ? store.lastCustomSpec : preset && specForTab(preset, store.spec, store.lastLogLevel);
|
|
297
446
|
if (nextSpec)
|
|
298
447
|
store.setSpec(nextSpec);
|
|
299
448
|
e.preventDefault();
|