@slack/radar-mcp 1.11.0 → 1.12.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 +2 -2
- package/dist/mcp/index.js +42 -5
- package/dist/mcp/prefs-tools.d.ts +15 -0
- package/dist/mcp/prefs-tools.js +204 -0
- package/dist/mcp/session-enable.d.ts +2 -1
- package/dist/mcp/session-enable.js +29 -2
- package/dist/mcp/snapshot.js +6 -1
- package/dist/mcp/tools.js +65 -2
- package/dist/shared/android.d.ts +33 -1
- package/dist/shared/android.js +203 -6
- package/dist/shared/constants.d.ts +8 -0
- package/dist/shared/constants.js +13 -1
- package/dist/shared/db.d.ts +14 -0
- package/dist/shared/db.js +16 -5
- package/dist/shared/prefs.d.ts +78 -0
- package/dist/shared/prefs.js +416 -0
- package/dist/shared/transport.d.ts +68 -0
- package/dist/web/log-session.d.ts +13 -0
- package/dist/web/log-session.js +16 -0
- package/dist/web/public/index.html +108 -3
- package/dist/web/public/next/app.js +58 -2
- package/dist/web/public/next/feed.js +261 -12
- package/dist/web/public/next/filter.js +200 -0
- package/dist/web/public/next/prefs.js +399 -0
- package/dist/web/public/next/registry.js +7 -6
- package/dist/web/public/next/store.js +201 -10
- package/dist/web/server.js +214 -5
- package/dist/web/spec.d.ts +7 -7
- package/dist/web/spec.js +12 -9
- package/package.json +1 -1
|
@@ -56,13 +56,16 @@
|
|
|
56
56
|
.reconnect { background:var(--surface); border:1px solid var(--warn); color:var(--warn); border-radius:8px; padding:4px 12px; font:inherit; font-size:12px; font-weight:600; cursor:pointer; }
|
|
57
57
|
.reconnect:hover { border-color:var(--warn-2); } .reconnect:disabled { opacity:.6; cursor:default; }
|
|
58
58
|
.profilewrap { font-size:12px; color:var(--blue-2); } .profilewrap b { color:var(--text); }
|
|
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
|
+
h1 .version { margin-left:auto; font-size:11px; font-weight:400; color:var(--muted-2); letter-spacing:0; }
|
|
59
61
|
.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; }
|
|
60
62
|
.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); }
|
|
61
|
-
.modebar { display:flex; gap:6px; margin:0 0 6px; flex-wrap:wrap; flex:0 0 auto; }
|
|
63
|
+
.modebar { display:flex; gap:6px; margin:0 0 6px; flex-wrap:wrap; flex:0 0 auto; align-items:center; }
|
|
62
64
|
.modebtn { background:var(--surface); border:1px solid var(--border-2); color:var(--muted-2); border-radius:8px; padding:6px 14px; font:inherit; font-size:12.5px; cursor:pointer; }
|
|
63
65
|
.modebtn:hover { border-color:var(--accent); color:var(--text); }
|
|
64
66
|
.modebtn.active { background:var(--accent-bg); border-color:var(--accent); color:var(--accent-text); font-weight:600; }
|
|
65
67
|
.modebtn.custom { margin-left:10px; border-style:dashed; color:var(--purple); } .modebtn.custom.active { background:var(--accent-bg); border-color:var(--purple); color:var(--purple); }
|
|
68
|
+
.modedivider { width:1px; height:20px; background:var(--border-2); margin:0 4px; }
|
|
66
69
|
.sub { margin:0 0 6px; flex:0 0 auto; } .sub .summary { display:block; color:var(--text-2); font-size:12px; font-weight:600; } .sub .tech { display:none; }
|
|
67
70
|
/* filters — slim when collapsed */
|
|
68
71
|
.filters { max-width:1100px; margin-bottom:6px; flex:0 0 auto; }
|
|
@@ -121,11 +124,59 @@
|
|
|
121
124
|
.stage.split .feedwrap-next { flex:2 1 380px; min-width:0; } .stage.split .inspector { flex:1 1 300px; }
|
|
122
125
|
.feedwrap-next { flex:1; min-width:0; display:flex; flex-direction:column; min-height:0; }
|
|
123
126
|
.feedbar { display:flex; gap:8px; align-items:center; margin-bottom:8px; flex-wrap:wrap; flex:0 0 auto; }
|
|
124
|
-
|
|
127
|
+
/* Filter box: pills + draft input wrap together in one field-shaped container (Android
|
|
128
|
+
Studio Logcat style). The wrap owns the border + padding + focus ring; the input inside
|
|
129
|
+
is chromeless so pills + draft read as one control. Pills flex-wrap onto more lines when
|
|
130
|
+
the query is long. */
|
|
131
|
+
.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 26px 4px 6px; cursor:text; }
|
|
132
|
+
.ffilterwrap:focus-within { border-color:var(--accent); }
|
|
133
|
+
.ffilterwrap .ffilter { flex:1; min-width:80px; background:transparent; border:none; padding:3px 4px; font:inherit; font-size:12.5px; color:var(--text); }
|
|
134
|
+
.ffilterwrap .ffilter:focus { outline:none; }
|
|
125
135
|
.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; }
|
|
126
136
|
.feedbar input:focus { outline:none; border-color:var(--accent); }
|
|
127
|
-
.ffilterclear { position:absolute; right:8px; top:
|
|
137
|
+
.ffilterclear { position:absolute; right:8px; 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; }
|
|
128
138
|
.ffilterclear:hover { color:#fff; background:var(--error-2); }
|
|
139
|
+
/* The draft input turns amber when its own text is an invalid regex mid-typing. Committed
|
|
140
|
+
terms use the per-pill amber (.fpill-bad) instead. */
|
|
141
|
+
.ffilterwrap:has(.ffilter.finvalid) { border-color:var(--warn); }
|
|
142
|
+
/* Fallback for browsers without :has(): the wrap keeps its normal border and the draft
|
|
143
|
+
amber shows on the input itself via a bottom border. */
|
|
144
|
+
.feedbar input.ffilter.finvalid { box-shadow:inset 0 -2px 0 var(--warn); }
|
|
145
|
+
/* Pills. Compact rounded chip inside the wrap; regex pills stay monospace so slashes read
|
|
146
|
+
as syntax. Every pill uses the same base padding + font-size as the input so the row
|
|
147
|
+
lines up visually. */
|
|
148
|
+
.fpill { display:inline-flex; align-items:center; gap:4px; background:var(--surface); border:1px solid var(--border-3); color:var(--text); border-radius:6px; padding:1px 4px 1px 7px; font-size:12.5px; line-height:1.4; max-width:340px; cursor:pointer; }
|
|
149
|
+
.fpill:hover { border-color:var(--accent); }
|
|
150
|
+
.fpill:focus-visible { outline:2px solid var(--accent); outline-offset:1px; }
|
|
151
|
+
.fpill-body { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
|
|
152
|
+
.fpill-sign { color:var(--muted-2); font-weight:700; margin-right:1px; }
|
|
153
|
+
.fpill-x { cursor:pointer; color:var(--muted-2); background:var(--surface-3); border-radius:50%; width:14px; height:14px; line-height:13px; text-align:center; font-size:9.5px; margin-left:2px; }
|
|
154
|
+
.fpill-x:hover { color:#fff; background:var(--error-2); }
|
|
155
|
+
.fpill-neg { background:var(--lvl-err-bg); border-color:var(--error-2); color:var(--error-2); }
|
|
156
|
+
.fpill-neg .fpill-sign { color:var(--error-2); }
|
|
157
|
+
.fpill-re, .fpill-quote { font-family:ui-monospace,Menlo,Consolas,monospace; }
|
|
158
|
+
.fpill-bad { background:var(--lvl-warn-bg); border-color:var(--warn); color:var(--warn-2); }
|
|
159
|
+
/* Kind-name pills on the Live view. Match the row's type chip color so "clog" reads the
|
|
160
|
+
same whether you see it in the pill or in the row's tchip. */
|
|
161
|
+
.fpill-kind-network { background:var(--chip-net-bg); border-color:var(--blue); color:var(--blue); }
|
|
162
|
+
.fpill-kind-rtm { background:var(--chip-rtm-bg); border-color:var(--purple); color:var(--purple); }
|
|
163
|
+
.fpill-kind-clog { background:var(--chip-clog-bg); border-color:var(--accent); color:var(--accent); }
|
|
164
|
+
.fpill-kind-trace { background:var(--chip-trace-bg); border-color:var(--warn); color:var(--warn); }
|
|
165
|
+
.fpill-kind-log { background:var(--chip-log-bg); border-color:var(--chip-log-fg); color:var(--chip-log-fg); }
|
|
166
|
+
/* A negated kind pill (e.g. -log) carries BOTH .fpill-neg and .fpill-kind-* at once; equal
|
|
167
|
+
specificity means whichever rule is defined later in the stylesheet wins, which happened
|
|
168
|
+
to be the kind color, burying the negation-red the "-" glyph is there to signal. The
|
|
169
|
+
compound selector below outranks the plain .fpill-kind-* rules so negated-red always wins
|
|
170
|
+
the background, regardless of source order. */
|
|
171
|
+
.fpill-neg.fpill-kind-network,
|
|
172
|
+
.fpill-neg.fpill-kind-rtm,
|
|
173
|
+
.fpill-neg.fpill-kind-clog,
|
|
174
|
+
.fpill-neg.fpill-kind-trace,
|
|
175
|
+
.fpill-neg.fpill-kind-log {
|
|
176
|
+
background: var(--lvl-err-bg);
|
|
177
|
+
border-color: var(--error-2);
|
|
178
|
+
color: var(--error-2);
|
|
179
|
+
}
|
|
129
180
|
.fbtn { background:var(--surface); border:1px solid var(--border-3); border-radius:8px; color:var(--text); padding:6px 10px; font:inherit; font-size:12px; cursor:pointer; white-space:nowrap; }
|
|
130
181
|
.fbtn:hover { border-color:var(--accent); } .fbtn:disabled { opacity:.4; cursor:default; } .fbtn.paused { color:var(--warn); border-color:var(--warn); }
|
|
131
182
|
.fcount { color:var(--muted); font-size:11.5px; white-space:nowrap; }
|
|
@@ -230,6 +281,60 @@
|
|
|
230
281
|
.dbout th { position:sticky; top:0; background:var(--surface); color:var(--muted-2); text-align:left; padding:7px 10px; border-bottom:1px solid var(--border); white-space:nowrap; }
|
|
231
282
|
.dbout td { padding:6px 10px; border-bottom:1px solid var(--rowline); max-width:380px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
|
|
232
283
|
.dbout tr:hover td { background:var(--hover); }
|
|
284
|
+
/* Prefs browser: mirrors db.ts CSS, same visual language */
|
|
285
|
+
.prefsview { display:flex; gap:16px; max-width:1180px; margin-top:8px; height:72vh; }
|
|
286
|
+
.prefsside { flex:0 0 260px; overflow:auto; border:1px solid var(--border); border-radius:10px; padding:12px; }
|
|
287
|
+
.prefssec { color:var(--muted); font-size:10.5px; text-transform:uppercase; letter-spacing:.06em; margin:6px 0 6px; } .prefssec:not(:first-child){ margin-top:14px; }
|
|
288
|
+
.prefsitem { padding:6px 9px; border-radius:7px; cursor:pointer; font-size:12.5px; display:flex; align-items:center; gap:6px; }
|
|
289
|
+
/* The filename is the ONLY element that shrinks/truncates -- min-width:0 is load-bearing in a
|
|
290
|
+
flex row (without it a child never shrinks below its content size, so overflow:hidden does
|
|
291
|
+
nothing and the row just clips everything past the sidebar edge, size span included). The
|
|
292
|
+
size/badge stay flex-shrink:0 so they are always visible regardless of filename length. */
|
|
293
|
+
.prefsitem .prefsitemname { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
|
|
294
|
+
.prefsitem:hover { background:var(--hover-soft); } .prefsitem.sel { background:var(--sel-soft); color:var(--accent); } .prefsitem .size { color:var(--muted); font-size:11px; flex-shrink:0; } .prefsitem .ffbadge { color:var(--accent); font-size:10px; font-weight:600; flex-shrink:0; }
|
|
295
|
+
.prefsitem.kbd { outline:2px solid var(--accent); outline-offset:-2px; }
|
|
296
|
+
/* Near-empty files (a handful of scalar entries at most) fade back so attention goes to the
|
|
297
|
+
files actually worth opening; still fully visible and clickable, just de-emphasized. */
|
|
298
|
+
.prefsitem.tiny { color:var(--muted); } .prefsitem.tiny .size { opacity:.7; }
|
|
299
|
+
.prefsmain { flex:1; min-width:0; display:flex; flex-direction:column; }
|
|
300
|
+
/* The search bar gets its own bordered/tinted container, set apart from the results below it
|
|
301
|
+
(.prefsout), so it reads as "search every file" rather than looking like a header row glued
|
|
302
|
+
to whichever file happens to be selected. */
|
|
303
|
+
.prefssearchbar { background:var(--surface-2); border:1px solid var(--border); border-radius:10px; padding:9px 11px; margin-bottom:10px; }
|
|
304
|
+
.prefssearchlabel { color:var(--muted); font-size:10px; text-transform:uppercase; letter-spacing:.06em; margin-bottom:6px; }
|
|
305
|
+
.prefssearch { display:flex; gap:8px; }
|
|
306
|
+
.prefssearch 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; } .prefssearch input:focus { outline:none; border-color:var(--accent); }
|
|
307
|
+
.prefssearch button { background:var(--accent-bg); border:1px solid var(--accent); color:var(--accent-text); border-radius:8px; padding:0 16px; font:inherit; font-size:12.5px; font-weight:600; cursor:pointer; display:flex; align-items:center; gap:6px; }
|
|
308
|
+
.prefssearch button:disabled { opacity:.7; cursor:default; }
|
|
309
|
+
.spinner { display:inline-block; width:11px; height:11px; border:2px solid currentColor; border-right-color:transparent; border-radius:50%; animation:prefsspin .7s linear infinite; }
|
|
310
|
+
@keyframes prefsspin { to { transform:rotate(360deg); } }
|
|
311
|
+
.prefsmeta { color:var(--muted); font-size:11.5px; margin-bottom:8px; }
|
|
312
|
+
.prefsprivacy { background:var(--lvl-warn-bg); border:1px solid var(--warn); color:var(--warn-2); border-radius:8px; padding:8px 11px; font-size:11.5px; line-height:1.5; margin-bottom:10px; }
|
|
313
|
+
.prefsprofile { color:var(--blue-2); font-size:11.5px; margin-bottom:8px; } .prefsprofile b { color:var(--text); }
|
|
314
|
+
.prefsprofcap { color:var(--muted); text-transform:uppercase; letter-spacing:.06em; font-size:10px; }
|
|
315
|
+
.prefsprofile 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; }
|
|
316
|
+
.prefsrefresh { background:var(--surface); border:1px solid var(--border-3); border-radius:6px; color:var(--muted-2); padding:2px 8px; font:inherit; font-size:11px; cursor:pointer; margin-left:8px; } .prefsrefresh:hover { border-color:var(--accent); color:var(--accent); }
|
|
317
|
+
.prefsout { flex:1; overflow:auto; border:1px solid var(--border); border-radius:10px; }
|
|
318
|
+
.prefsout table { border-collapse:collapse; width:100%; font-size:12px; }
|
|
319
|
+
.prefsout th { position:sticky; top:0; background:var(--surface); color:var(--muted-2); text-align:left; padding:7px 10px; border-bottom:1px solid var(--border); white-space:nowrap; }
|
|
320
|
+
.prefsout td { padding:6px 10px; border-bottom:1px solid var(--rowline); max-width:380px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; } .prefsout td.val { font-family:monospace; font-size:11.5px; cursor:pointer; }
|
|
321
|
+
.prefsout tr:hover td { background:var(--hover); }
|
|
322
|
+
.prefsout td.val:hover { color:var(--accent); }
|
|
323
|
+
.prefsout td.val.open { color:var(--accent); font-weight:600; }
|
|
324
|
+
/* Expanded value row: a full pretty-printed value below the clicked row, for values the
|
|
325
|
+
column truncates (JSON blobs like navigation_history/experiment_data routinely run past
|
|
326
|
+
380px with no other way to read or select the rest). */
|
|
327
|
+
.valexpand td { background:var(--surface-2); padding:10px; border-bottom:1px solid var(--rowline); white-space:normal; max-width:none; }
|
|
328
|
+
.valexpandbar { display:flex; gap:8px; margin-bottom:8px; }
|
|
329
|
+
.valexpandbar button { background:var(--surface); border:1px solid var(--border-3); border-radius:6px; color:var(--muted-2); padding:3px 10px; font:inherit; font-size:11px; cursor:pointer; } .valexpandbar button:hover { border-color:var(--accent); color:var(--accent); }
|
|
330
|
+
.valpretty { margin:0; white-space:pre-wrap; word-break:break-word; font-size:11.5px; line-height:1.45; color:var(--text-2); max-height:300px; overflow:auto; }
|
|
331
|
+
.truncwarn { background:var(--lvl-info-bg); border:1px solid var(--blue); color:var(--blue); border-radius:8px; padding:8px 11px; font-size:11.5px; margin-bottom:10px; }
|
|
332
|
+
/* Stronger treatment for the "no matches" case where files were skipped -- a search that
|
|
333
|
+
could not read anything is a different severity than one that read everything and found
|
|
334
|
+
nothing, so it must not share the same quiet blue "fyi" styling as a partial skip. */
|
|
335
|
+
.truncwarn.err { background:var(--lvl-warn-bg); border-color:var(--warn); color:var(--warn-2); }
|
|
336
|
+
.searchgroup { margin-bottom:16px; }
|
|
337
|
+
.searchfile { color:var(--muted-2); font-size:11px; font-weight:600; padding:6px 10px; background:var(--surface); border-radius:6px; margin-bottom:8px; }
|
|
233
338
|
.msg { color:var(--muted); font-size:12px; padding:10px; } .msg.err { color:var(--error); }
|
|
234
339
|
/* screen overlay */
|
|
235
340
|
#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; }
|
|
@@ -9,11 +9,13 @@ import { render } from "preact";
|
|
|
9
9
|
import { useState, useEffect, useCallback } from "preact/hooks";
|
|
10
10
|
import { useStoreValue } from "./hooks.js";
|
|
11
11
|
import { store, MODES, describeConstraints } from "./store.js";
|
|
12
|
+
import { SOURCES } from "./registry.js";
|
|
12
13
|
import { Feed } from "./feed.js";
|
|
13
14
|
import { Cards } from "./widgets.js";
|
|
14
15
|
import { Inspector } from "./inspector.js";
|
|
15
16
|
import { Filters } from "./filters.js";
|
|
16
17
|
import { DbBrowser } from "./db.js";
|
|
18
|
+
import { PrefsBrowser } from "./prefs.js";
|
|
17
19
|
import { ScreenOverlay } from "./screen.js";
|
|
18
20
|
function readTheme() {
|
|
19
21
|
try {
|
|
@@ -23,9 +25,35 @@ function readTheme() {
|
|
|
23
25
|
return "dark";
|
|
24
26
|
}
|
|
25
27
|
}
|
|
28
|
+
// Header device picker. With 2+ attached devices it is a dropdown of the ready ones (state
|
|
29
|
+
// "device"), current one selected; picking one pins it via store.selectDevice. With 0 or 1
|
|
30
|
+
// device it is a plain chip (the bound label, or "none"). Mirrors the DB browser's profile
|
|
31
|
+
// chip/select pattern (.dbprofile) rather than reinventing markup.
|
|
32
|
+
function DeviceChip() {
|
|
33
|
+
const devices = useStoreValue(store, "devices", () => store.devices);
|
|
34
|
+
const ready = devices.filter((d) => d.state === "device");
|
|
35
|
+
const selected = store.selectedDevice;
|
|
36
|
+
// Unpinned with exactly one ready device: bare adb targets that device anyway, so name it
|
|
37
|
+
// instead of claiming "none". "none" is reserved for genuinely nothing attached.
|
|
38
|
+
const label = selected?.label ?? (ready.length === 1 ? ready[0].label : "none");
|
|
39
|
+
// A device-select failure (e.g. an ambiguous /enable 409). Shown in warn styling next to the
|
|
40
|
+
// picker, which stays usable so the user can pick a valid device (a successful pick clears it).
|
|
41
|
+
const deviceError = store.deviceError;
|
|
42
|
+
if (store.devicesError) {
|
|
43
|
+
return html `<span class="profilewrap" title="adb devices failed; check adb">device: <b>adb error</b></span>`;
|
|
44
|
+
}
|
|
45
|
+
const picker = ready.length < 2
|
|
46
|
+
? html `<b>${label}</b>`
|
|
47
|
+
: html `<select onChange=${(e) => store.selectDevice(e.currentTarget.value)}>
|
|
48
|
+
${!selected ? html `<option value="" selected disabled>pick a device…</option>` : null}
|
|
49
|
+
${ready.map((d) => html `<option value=${d.serial} selected=${d.serial === selected?.serial}>${d.label} (${d.serial})</option>`)}
|
|
50
|
+
</select>`;
|
|
51
|
+
return html `<span class="profilewrap" title="the device Radar is bound to; pick another to switch">device: ${picker}${deviceError ? html `<span class="conn waiting" style="margin-left:6px">${deviceError}</span>` : null}</span>`;
|
|
52
|
+
}
|
|
26
53
|
function Header({ screenOpen, onScreenToggle }) {
|
|
27
54
|
const conn = useStoreValue(store, "conn", () => store.conn);
|
|
28
55
|
const profile = useStoreValue(store, "profile", () => store.profileLabel);
|
|
56
|
+
const version = useStoreValue(store, "version", () => store.serverVersion);
|
|
29
57
|
const [busy, setBusy] = useState(false);
|
|
30
58
|
const [theme, setTheme] = useState(readTheme);
|
|
31
59
|
const reconnect = useCallback(async () => {
|
|
@@ -50,9 +78,11 @@ function Header({ screenOpen, onScreenToggle }) {
|
|
|
50
78
|
SLACK RADAR DASHBOARD
|
|
51
79
|
<span class=${"conn " + conn.state}>${connected ? "● live" : "● " + (conn.msg || "reconnecting…")}</span>
|
|
52
80
|
<span class="profilewrap" title="the device profile Radar is connected to (first app to launch wins the socket)">profile: <b>${profile}</b></span>
|
|
81
|
+
<${DeviceChip} />
|
|
53
82
|
${!connected ? html `<button class="reconnect" disabled=${busy} onClick=${reconnect}>${busy ? "⟳ enabling…" : "⟳ Reconnect Radar"}</button>` : null}
|
|
54
83
|
<button class="themebtn" onClick=${toggleTheme} title="Toggle light / dark theme">${theme === "light" ? "🌙 Dark" : "☀ Light"}</button>
|
|
55
84
|
<button class=${"screenbtn" + (screenOpen ? " on" : "")} onClick=${onScreenToggle} title="Mirror the live device screen">▣ Screen</button>
|
|
85
|
+
${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}
|
|
56
86
|
</h1>
|
|
57
87
|
`;
|
|
58
88
|
}
|
|
@@ -61,9 +91,14 @@ function ModeBar() {
|
|
|
61
91
|
useEffect(() => store.on("spec", () => force((n) => n + 1)), []);
|
|
62
92
|
const activeKey = store.activeModeKey();
|
|
63
93
|
const pick = (specToPush) => store.setSpec(specToPush);
|
|
94
|
+
// Group modes by source kind for visual separation
|
|
95
|
+
const streamModes = MODES.filter((m) => SOURCES[m.spec.source]?.kind === "stream");
|
|
96
|
+
const stateModes = MODES.filter((m) => SOURCES[m.spec.source]?.kind === "state");
|
|
64
97
|
return html `
|
|
65
98
|
<div class="modebar">
|
|
66
|
-
${
|
|
99
|
+
${streamModes.map((m) => html `<button class=${"modebtn" + (activeKey === m.key ? " active" : "")} onClick=${() => pick(m.spec)}>${m.label}</button>`)}
|
|
100
|
+
${stateModes.length > 0 ? html `<span class="modedivider"></span>` : null}
|
|
101
|
+
${stateModes.map((m) => html `<button class=${"modebtn" + (activeKey === m.key ? " active" : "")} onClick=${() => pick(m.spec)}>${m.label}</button>`)}
|
|
67
102
|
${store.lastCustomSpec ? html `<button class=${"modebtn custom" + (activeKey === "__custom__" ? " active" : "")} title="pushed from a terminal Claude Code session; persists until refresh" onClick=${() => pick(store.lastCustomSpec)}>✎ ${store.lastCustomSpec.title || "Custom"}</button>` : null}
|
|
68
103
|
</div>
|
|
69
104
|
`;
|
|
@@ -142,6 +177,13 @@ function Blank() {
|
|
|
142
177
|
function App() {
|
|
143
178
|
const spec = useStoreValue(store, "spec", () => store.spec);
|
|
144
179
|
const [screenOpen, setScreenOpen] = useState(false);
|
|
180
|
+
// The DB and Prefs tabs cannot import the store (neither needs the SSE engine/timers a
|
|
181
|
+
// point-in-time browser has no use for), so neither can self-reset on a device change. The
|
|
182
|
+
// store emits "db-resync" on any bound-device change (first pin included, PR #94
|
|
183
|
+
// multi-device); folding that counter into each tab's key remounts it on a switch, which
|
|
184
|
+
// drops its picked-file/table/results state and re-fetches from the newly bound device. Name
|
|
185
|
+
// is a historical artifact (the DB tab needed this first); Prefs folds in the same counter.
|
|
186
|
+
const dbResync = useStoreValue(store, "db-resync", () => store.dbSerialVersion);
|
|
145
187
|
// The screen overlay is a fixed right-docked panel; widen the page padding while it is open so
|
|
146
188
|
// it never covers the feed/widgets.
|
|
147
189
|
useEffect(() => {
|
|
@@ -190,7 +232,21 @@ function App() {
|
|
|
190
232
|
<span class="summary">${spec.summary || "Device database browser"}</span>
|
|
191
233
|
<span class="tech">source=db (on-device SQLite snapshot, read-only)</span>
|
|
192
234
|
</div>
|
|
193
|
-
<${DbBrowser} spec=${spec} key
|
|
235
|
+
<${DbBrowser} spec=${spec} key=${"db-" + dbResync} />
|
|
236
|
+
`;
|
|
237
|
+
}
|
|
238
|
+
else if (spec.source === "prefs") {
|
|
239
|
+
// The Prefs browser is a self-contained, point-in-time container: it does NOT import the store
|
|
240
|
+
// (no SSE engine / timers on a tab that has no live feed). key folds in dbResync (PR #94
|
|
241
|
+
// multi-device: the same store event the DB tab remounts on) so a device switch also
|
|
242
|
+
// remounts Prefs -- without it Prefs kept the OLD device's files/entries on screen after
|
|
243
|
+
// switching, since its own useEffect only fetches once on initial mount.
|
|
244
|
+
view = html `
|
|
245
|
+
<div class="sub">
|
|
246
|
+
<span class="summary">${spec.summary || "Device preferences browser"}</span>
|
|
247
|
+
<span class="tech">source=prefs (on-device SharedPreferences snapshot, read-only)</span>
|
|
248
|
+
</div>
|
|
249
|
+
<${PrefsBrowser} spec=${spec} key=${"prefs-" + dbResync} />
|
|
194
250
|
`;
|
|
195
251
|
}
|
|
196
252
|
else {
|
|
@@ -6,11 +6,73 @@
|
|
|
6
6
|
import { html } from "./html.js";
|
|
7
7
|
import { useState, useEffect, useRef, useCallback, useMemo } from "preact/hooks";
|
|
8
8
|
import { store, shortUrl, shortPkg, MODES, fmtNum } from "./store.js";
|
|
9
|
+
import { STREAM_KINDS } from "./registry.js";
|
|
10
|
+
import { parseFilter, tokenize, isCompleteTerm } from "./filter.js";
|
|
9
11
|
const ROW_H = 24;
|
|
10
12
|
const OVERSCAN = 10;
|
|
11
13
|
// Feed UI prefs PERSIST across tab switches (the Feed unmounts/remounts per source). The text
|
|
12
14
|
// filter is global; sort is per-source (a Network "slowest" is meaningless on RTM).
|
|
13
15
|
const FEED_PREFS = { filter: "", sortBySource: {} };
|
|
16
|
+
// The set of kind names that render as colored kind-pills on the unified Live view (bare token
|
|
17
|
+
// equal to one of these). On a single-source tab the kind chip is invisible in the row (every
|
|
18
|
+
// row is the same kind), so a matching pill would just look like a bare-word pill; the coloring
|
|
19
|
+
// only kicks in when source === "all".
|
|
20
|
+
const KIND_TOKENS = new Set(STREAM_KINDS);
|
|
21
|
+
// Split the persisted filter string into committed pill tokens + a trailing draft. Uses the
|
|
22
|
+
// tokenizer that the parser uses, so pill-vs-string equivalence holds by construction: the
|
|
23
|
+
// pill list is exactly the tokens the parser would consume, minus the one still being typed.
|
|
24
|
+
// The draft is the LAST token when it is incomplete (mid /…/ or "…" span, or a bare "-"), or
|
|
25
|
+
// when the raw string has no trailing whitespace (still-being-typed complete token); otherwise
|
|
26
|
+
// the draft is "" and every token is a committed pill.
|
|
27
|
+
function splitPillsAndDraft(raw) {
|
|
28
|
+
const tokens = tokenize(raw);
|
|
29
|
+
if (!tokens.length)
|
|
30
|
+
return { pills: [], draft: "" };
|
|
31
|
+
const last = tokens[tokens.length - 1];
|
|
32
|
+
const endsWithSpace = raw.length > 0 && /\s$/.test(raw);
|
|
33
|
+
const lastIsDraft = !endsWithSpace || !isCompleteTerm(last);
|
|
34
|
+
if (lastIsDraft)
|
|
35
|
+
return { pills: tokens.slice(0, -1), draft: last };
|
|
36
|
+
return { pills: tokens, draft: "" };
|
|
37
|
+
}
|
|
38
|
+
// Join pill tokens + a draft back into the filter string. A trailing space after the pills
|
|
39
|
+
// keeps the draft as its own token (never glued to the previous pill), which is what the
|
|
40
|
+
// tokenizer would consume; when the draft is empty the string is just the pills separated by
|
|
41
|
+
// single spaces plus a trailing space (so appending more text starts a fresh token).
|
|
42
|
+
function joinPillsAndDraft(pills, draft) {
|
|
43
|
+
if (!pills.length && !draft)
|
|
44
|
+
return "";
|
|
45
|
+
if (!pills.length)
|
|
46
|
+
return draft;
|
|
47
|
+
const base = pills.join(" ");
|
|
48
|
+
return draft ? base + " " + draft : base + " ";
|
|
49
|
+
}
|
|
50
|
+
// The visual class for a pill token: bad (invalid regex), negated (leading "-"), regex ("/"),
|
|
51
|
+
// kind (bare token equal to a source kind, on the Live view only). A term can be both negated
|
|
52
|
+
// and regex/quoted; the negation class stacks on top of the shape class.
|
|
53
|
+
function pillClasses(raw, invalidSet, sourceIsAll) {
|
|
54
|
+
const classes = ["fpill"];
|
|
55
|
+
const body = raw.startsWith("-") ? raw.slice(1) : raw;
|
|
56
|
+
if (invalidSet.has(raw))
|
|
57
|
+
classes.push("fpill-bad");
|
|
58
|
+
if (raw.startsWith("-"))
|
|
59
|
+
classes.push("fpill-neg");
|
|
60
|
+
if (body.startsWith("/"))
|
|
61
|
+
classes.push("fpill-re");
|
|
62
|
+
else if (body.startsWith('"'))
|
|
63
|
+
classes.push("fpill-quote");
|
|
64
|
+
else if (sourceIsAll && KIND_TOKENS.has(body.toLowerCase()))
|
|
65
|
+
classes.push("fpill-kind", "fpill-kind-" + body.toLowerCase());
|
|
66
|
+
return classes.join(" ");
|
|
67
|
+
}
|
|
68
|
+
// The label shown on a pill. Negation renders as a leading "−" glyph outside the body so the
|
|
69
|
+
// body reads the same as it does in the filter string. Regex pills keep their slashes (that is
|
|
70
|
+
// how they were typed); quoted phrases keep their quotes.
|
|
71
|
+
function pillLabel(raw) {
|
|
72
|
+
if (raw.startsWith("-"))
|
|
73
|
+
return { neg: true, body: raw.slice(1) };
|
|
74
|
+
return { neg: false, body: raw };
|
|
75
|
+
}
|
|
14
76
|
// Platform-aware jump-pill labels. macOS has no Home/End, so show the chord that works there.
|
|
15
77
|
const IS_MAC = typeof navigator !== "undefined" && /Mac|iP(hone|ad|od)/.test(navigator.platform || navigator.userAgent || "");
|
|
16
78
|
const KEY_NEWEST = IS_MAC ? "⌘↑" : "Ctrl↑";
|
|
@@ -51,7 +113,9 @@ function neighborTabSpec(dir) {
|
|
|
51
113
|
const k = keys[next];
|
|
52
114
|
return k === "__custom__" ? store.lastCustomSpec || undefined : MODES.find((m) => m.key === k)?.spec;
|
|
53
115
|
}
|
|
54
|
-
// One searchable string per frame for the text filter
|
|
116
|
+
// One searchable string per frame for the text filter. The row KIND is deliberately NOT
|
|
117
|
+
// part of this string: a kind token would make "-log" silently exclude clogs (log ⊂ clog).
|
|
118
|
+
// Kind matching happens by EQUALITY via the predicate's second argument instead (see filterKind).
|
|
55
119
|
function searchText(ev) {
|
|
56
120
|
if ((ev._type || "") === "log")
|
|
57
121
|
return [ev.level, ev.package, ev.tag, ev.message].filter(Boolean).join(" ").toLowerCase();
|
|
@@ -59,6 +123,13 @@ function searchText(ev) {
|
|
|
59
123
|
return [ev.trace_name, ev.span_name].filter(Boolean).join(" ").toLowerCase();
|
|
60
124
|
return [ev.direction, ev.method, ev.event_type, ev.event_name, shortUrl(ev.url), ev.channel].filter(Boolean).join(" ").toLowerCase();
|
|
61
125
|
}
|
|
126
|
+
// The kind handed to the filter predicate. Only the unified view exposes it: that is where the
|
|
127
|
+
// type chip is visible, so "trace" / "-log" reading as kind filters matches what the user
|
|
128
|
+
// sees. On a single-source tab every row is the same kind, so kind matching would only turn
|
|
129
|
+
// the tab's own name into an invisible match-all ("network" matching every Network row).
|
|
130
|
+
function filterKind(ev, source) {
|
|
131
|
+
return source === "all" ? ev._type : undefined;
|
|
132
|
+
}
|
|
62
133
|
// One raw copy line per frame (Logcat-style), pulled from the ring on copy.
|
|
63
134
|
function rawLine(ev) {
|
|
64
135
|
const t = new Date(ev.timestamp || Date.now()).toLocaleTimeString();
|
|
@@ -135,6 +206,32 @@ export function Feed({ spec, onInspect, selectedId }) {
|
|
|
135
206
|
const [, bumpSnap] = useState(0);
|
|
136
207
|
const sortOpts = useMemo(() => sortOptionsFor(source), [source]);
|
|
137
208
|
const isLogish = source === "log" || source === "all";
|
|
209
|
+
// Compile the filter query ONCE per change (FEED_PREFS keeps the raw string across remounts;
|
|
210
|
+
// the parsed form rebuilds from it here). `parsed` drives the INSTANT feedback near the input
|
|
211
|
+
// (invalid-regex highlighting, the hint tooltip) -- those must never lag a keystroke, or a
|
|
212
|
+
// typo looks unrecognized for a beat. It must stay off the live `filter`, not a debounced copy.
|
|
213
|
+
const parsed = useMemo(() => parseFilter(filter, STREAM_KINDS), [filter]);
|
|
214
|
+
// debouncedFilter feeds ONLY the row-matching predicate below (matchParsed), which is what
|
|
215
|
+
// orderFrames/recompute actually run over the ring (up to 100k entries, on every keystroke
|
|
216
|
+
// without this). Debouncing the FEED WORK rather than the whole `parsed` value is deliberate:
|
|
217
|
+
// parsed itself stays synchronous so typing feedback (above) is never delayed by this.
|
|
218
|
+
const [debouncedFilter, setDebouncedFilter] = useState(filter);
|
|
219
|
+
useEffect(() => {
|
|
220
|
+
const t = setTimeout(() => setDebouncedFilter(filter), 180);
|
|
221
|
+
return () => clearTimeout(t);
|
|
222
|
+
}, [filter]);
|
|
223
|
+
const matchParsed = useMemo(() => parseFilter(debouncedFilter, STREAM_KINDS), [debouncedFilter]);
|
|
224
|
+
// The filter STRING stays the single source of truth (FEED_PREFS.filter); pills are a VIEW
|
|
225
|
+
// over it. tokenize splits the string as the parser would; the trailing token becomes the
|
|
226
|
+
// draft input (if it is incomplete, or if the string has no trailing space) so the user can
|
|
227
|
+
// keep typing where they left off. Every commit / pop / remove writes a new filter string,
|
|
228
|
+
// never touches the pill array directly, which keeps the pill list and the compiled predicate
|
|
229
|
+
// impossible to drift apart. On a page reload the persisted string re-tokenizes back into
|
|
230
|
+
// pills + draft with no state hand-off.
|
|
231
|
+
const { pills, draft } = useMemo(() => splitPillsAndDraft(filter), [filter]);
|
|
232
|
+
const setPillsAndDraft = useCallback((nextPills, nextDraft) => {
|
|
233
|
+
setFilter(joinPillsAndDraft(nextPills, nextDraft));
|
|
234
|
+
}, [setFilter]);
|
|
138
235
|
// On source change: keep the persisted filter, re-derive the per-source sort, reset transient
|
|
139
236
|
// view state (selection, pause, follow). Filter + sort persist; selection does not.
|
|
140
237
|
useEffect(() => {
|
|
@@ -149,9 +246,10 @@ export function Feed({ spec, onInspect, selectedId }) {
|
|
|
149
246
|
setNewCount(0);
|
|
150
247
|
}, [source]);
|
|
151
248
|
// Build the display order from a chronological list of matched frames (text filter + sort +
|
|
152
|
-
// inversion). The full-buffer pass; used on control changes.
|
|
249
|
+
// inversion). The full-buffer pass; used on control changes. Runs against matchParsed (the
|
|
250
|
+
// debounced predicate), not parsed, since this is the O(N) work the debounce exists to spare.
|
|
153
251
|
const orderFrames = useCallback((chrono) => {
|
|
154
|
-
const frames =
|
|
252
|
+
const frames = matchParsed.empty ? chrono : chrono.filter((ev) => matchParsed.test(searchText(ev), filterKind(ev, source)));
|
|
155
253
|
if (sort === "newest")
|
|
156
254
|
return frames.slice().reverse();
|
|
157
255
|
if (sort === "oldest")
|
|
@@ -165,7 +263,7 @@ export function Feed({ spec, onInspect, selectedId }) {
|
|
|
165
263
|
return opt.dir === "asc" ? 1 : -1;
|
|
166
264
|
return 0;
|
|
167
265
|
});
|
|
168
|
-
}, [
|
|
266
|
+
}, [matchParsed, sort, sortOpts, source]);
|
|
169
267
|
const recompute = useCallback(() => orderFrames(store.viewFrames()), [orderFrames]);
|
|
170
268
|
const forceSnap = useCallback(() => {
|
|
171
269
|
snapRef.current = recompute();
|
|
@@ -201,7 +299,7 @@ export function Feed({ spec, onInspect, selectedId }) {
|
|
|
201
299
|
ev._type = c.type;
|
|
202
300
|
if (!store.matches(ev))
|
|
203
301
|
continue;
|
|
204
|
-
if (
|
|
302
|
+
if (!matchParsed.empty && !matchParsed.test(searchText(ev), filterKind(ev, src)))
|
|
205
303
|
continue;
|
|
206
304
|
fresh.push(ev);
|
|
207
305
|
}
|
|
@@ -221,7 +319,7 @@ export function Feed({ spec, onInspect, selectedId }) {
|
|
|
221
319
|
el.scrollTop = 0; // glue to newest (top)
|
|
222
320
|
});
|
|
223
321
|
return off;
|
|
224
|
-
}, [recompute,
|
|
322
|
+
}, [recompute, matchParsed, sort, sortOpts]);
|
|
225
323
|
// Rebuild when the SERVER-SIDE filter (match/bodyContains) changes -- that changes what
|
|
226
324
|
// store.matches() admits, so the whole snapshot must refresh. Keyed so it only fires on a
|
|
227
325
|
// real filter change, not every spec poll.
|
|
@@ -571,20 +669,164 @@ export function Feed({ spec, onInspect, selectedId }) {
|
|
|
571
669
|
</div>
|
|
572
670
|
`);
|
|
573
671
|
}
|
|
672
|
+
// Per-pill amber replaces the whole-input amber border for COMMITTED terms; the draft input
|
|
673
|
+
// still turns amber when its own text is an invalid regex mid-typing (feedback while typing).
|
|
674
|
+
const invalidSet = new Set(parsed.invalid);
|
|
675
|
+
const draftInvalid = draft.length > 0 && invalidSet.has(draft);
|
|
676
|
+
// Per-pill hint tooltip: parseFilter.hints entries lead with the raw token followed by a
|
|
677
|
+
// space ("<raw> read as …"), so match on raw + " ". A bare prefix match would let /api/im
|
|
678
|
+
// pick up /api/imx's hint (they share a prefix) and show the wrong reading.
|
|
679
|
+
const hintFor = (raw) => parsed.hints.find((h) => h.startsWith(raw + " "));
|
|
680
|
+
// The draft input only surfaces a hint about ITS OWN text; hints for committed terms live on
|
|
681
|
+
// their pills. Without this gate the input tooltip showed stale copy about other terms.
|
|
682
|
+
const draftHint = draft ? parsed.hints.find((h) => h.startsWith(draft + " ")) : undefined;
|
|
683
|
+
const sourceIsAll = source === "all";
|
|
684
|
+
const focusDraftInput = () => {
|
|
685
|
+
const inp = filterRef.current;
|
|
686
|
+
if (inp && typeof inp.focus === "function")
|
|
687
|
+
inp.focus();
|
|
688
|
+
};
|
|
689
|
+
// Where the next committed draft is inserted. Normally the tail; set to the source index
|
|
690
|
+
// when a pill is popped for re-edit so the term returns to ITS spot instead of jumping to
|
|
691
|
+
// the end (AND is commutative so the predicate never cares, but the eye does). A ref, not
|
|
692
|
+
// state: it changes nothing visually until the next commit. Cleared when the draft is
|
|
693
|
+
// erased (erasing the popped text means "remove that term", so a new term goes to the tail).
|
|
694
|
+
const editSlotRef = useRef(null);
|
|
695
|
+
const commitDraft = (rawDraft) => {
|
|
696
|
+
// Only commit a complete non-empty term; a bare "-" or an open /… / "… span stays as draft.
|
|
697
|
+
if (!isCompleteTerm(rawDraft))
|
|
698
|
+
return false;
|
|
699
|
+
const slot = editSlotRef.current;
|
|
700
|
+
editSlotRef.current = null;
|
|
701
|
+
const nextPills = [...pills];
|
|
702
|
+
const at = slot == null ? nextPills.length : Math.max(0, Math.min(slot, nextPills.length));
|
|
703
|
+
nextPills.splice(at, 0, rawDraft);
|
|
704
|
+
setPillsAndDraft(nextPills, "");
|
|
705
|
+
return true;
|
|
706
|
+
};
|
|
707
|
+
// Pop the pill at idx into the draft for re-edit. A complete draft commits first (to its own
|
|
708
|
+
// slot rules); an incomplete draft blocks the pop so its text is never silently lost.
|
|
709
|
+
const popPillForEdit = (idx) => {
|
|
710
|
+
const raw = pills[idx];
|
|
711
|
+
if (draft && !isCompleteTerm(draft)) {
|
|
712
|
+
focusDraftInput();
|
|
713
|
+
return;
|
|
714
|
+
}
|
|
715
|
+
const nextPills = [...pills];
|
|
716
|
+
nextPills.splice(idx, 1);
|
|
717
|
+
editSlotRef.current = idx;
|
|
718
|
+
setPillsAndDraft(draft ? [...nextPills, draft] : nextPills, raw);
|
|
719
|
+
focusDraftInput();
|
|
720
|
+
};
|
|
721
|
+
const removePill = (idx) => {
|
|
722
|
+
// Removing a pill above the remembered re-edit slot shifts every later index down one;
|
|
723
|
+
// move the slot with it so a popped term still recommits to its visual spot.
|
|
724
|
+
const slot = editSlotRef.current;
|
|
725
|
+
if (slot != null && idx < slot)
|
|
726
|
+
editSlotRef.current = slot - 1;
|
|
727
|
+
const nextPills = [...pills];
|
|
728
|
+
nextPills.splice(idx, 1);
|
|
729
|
+
setPillsAndDraft(nextPills, draft);
|
|
730
|
+
};
|
|
574
731
|
return html `
|
|
575
732
|
<div class="feedwrap-next">
|
|
576
733
|
<div class="feedbar">
|
|
577
|
-
<span class="ffilterwrap"
|
|
578
|
-
|
|
734
|
+
<span class="ffilterwrap"
|
|
735
|
+
onClick=${(e) => {
|
|
736
|
+
// Click anywhere in the wrap that is NOT a pill focuses the draft input (matches
|
|
737
|
+
// browser input behavior: the whole wrap reads as one field).
|
|
738
|
+
const target = e.target;
|
|
739
|
+
if (target && typeof target.closest === "function" && target.closest(".fpill"))
|
|
740
|
+
return;
|
|
741
|
+
const inp = filterRef.current;
|
|
742
|
+
if (inp && typeof inp.focus === "function")
|
|
743
|
+
inp.focus();
|
|
744
|
+
}}>
|
|
745
|
+
${pills.map((raw, idx) => {
|
|
746
|
+
const { neg, body } = pillLabel(raw);
|
|
747
|
+
const cls = pillClasses(raw, invalidSet, sourceIsAll);
|
|
748
|
+
// The title always carries the raw term: long pills ellipsize at max-width, and
|
|
749
|
+
// hover is the only way to audit a truncated term without mutating the query.
|
|
750
|
+
const title = invalidSet.has(raw)
|
|
751
|
+
? raw + " · invalid regex, this whole term is ignored and filters nothing"
|
|
752
|
+
: hintFor(raw) || raw + " · click or Enter to edit · ✕ or Backspace to remove";
|
|
753
|
+
return html `
|
|
754
|
+
<span class=${cls} title=${title} key=${idx + ":" + raw}
|
|
755
|
+
role="button" tabindex="0" aria-label=${"filter term " + raw}
|
|
756
|
+
onKeyDown=${(e) => {
|
|
757
|
+
// Keyboard path mirrors the mouse path so interior pills stay reachable
|
|
758
|
+
// without a mouse: Tab focuses a pill, Enter pops it for edit, Backspace or
|
|
759
|
+
// Delete removes it.
|
|
760
|
+
if (e.key === "Enter") {
|
|
761
|
+
e.preventDefault();
|
|
762
|
+
popPillForEdit(idx);
|
|
763
|
+
}
|
|
764
|
+
else if (e.key === "Backspace" || e.key === "Delete") {
|
|
765
|
+
e.preventDefault();
|
|
766
|
+
removePill(idx);
|
|
767
|
+
focusDraftInput();
|
|
768
|
+
}
|
|
769
|
+
}}
|
|
770
|
+
onMouseDown=${(e) => {
|
|
771
|
+
// MouseDown so the click never blurs the input into a state where the pop
|
|
772
|
+
// races the setFilter (mousedown on a pill fires before the input's blur).
|
|
773
|
+
// The ✕ handler stops propagation, but a mousedown that lands directly on it
|
|
774
|
+
// still bubbles here first; skip in that case so the ✕ path owns removal.
|
|
775
|
+
const t = e.target;
|
|
776
|
+
const tCls = t && (t.className || t.attributes?.class || "");
|
|
777
|
+
if (typeof tCls === "string" && tCls.split(/\s+/).includes("fpill-x"))
|
|
778
|
+
return;
|
|
779
|
+
e.preventDefault();
|
|
780
|
+
popPillForEdit(idx);
|
|
781
|
+
}}>
|
|
782
|
+
${neg ? html `<span class="fpill-sign">−</span>` : null}<span class="fpill-body">${body}</span><span class="fpill-x"
|
|
783
|
+
title="remove this term"
|
|
784
|
+
onMouseDown=${(e) => {
|
|
785
|
+
e.preventDefault();
|
|
786
|
+
e.stopPropagation();
|
|
787
|
+
removePill(idx);
|
|
788
|
+
}}>✕</span>
|
|
789
|
+
</span>
|
|
790
|
+
`;
|
|
791
|
+
})}
|
|
792
|
+
<input class=${"ffilter" + (draftInvalid ? " finvalid" : "")} ref=${filterRef}
|
|
793
|
+
placeholder=${pills.length ? "" : "filter rows… -exclude /regex/ \"phrase\""} autocomplete="off" value=${draft}
|
|
794
|
+
title=${draftInvalid
|
|
795
|
+
? "invalid regex ignored: " + draft
|
|
796
|
+
: draftHint
|
|
797
|
+
? draftHint
|
|
798
|
+
: 'space-separated terms AND together · -term excludes · /pattern/ is regex with optional short flags (i/m/s/g, 1-2 letters, so /api/im reads as flags) · unterminated /…/ or flag typos like /error/x become literal regex · "quote" to match any /…/ literally · on Live, a kind name (log, clog, trace, rtm, network) matches by type or substring, and its -kind form excludes by type only (quote it, -"log", to exclude by text instead)'}
|
|
579
799
|
onFocus=${() => { if (sel.size)
|
|
580
800
|
clearSel(); }}
|
|
581
801
|
onKeyDown=${(e) => {
|
|
582
802
|
const el = e.currentTarget;
|
|
583
|
-
if (e.key === "
|
|
803
|
+
if (e.key === " ") {
|
|
804
|
+
// Space commits a COMPLETE draft term as a pill. commitDraft is the single
|
|
805
|
+
// completeness gate: when the draft is an open /…/ or "…" span it refuses,
|
|
806
|
+
// no preventDefault fires, and the space lands as literal text inside the
|
|
807
|
+
// span. One chokepoint, so a broken gate fails visibly instead of being
|
|
808
|
+
// masked by a redundant check here.
|
|
809
|
+
if (commitDraft(el.value))
|
|
810
|
+
e.preventDefault();
|
|
811
|
+
}
|
|
812
|
+
else if (e.key === "Enter") {
|
|
584
813
|
e.preventDefault();
|
|
814
|
+
commitDraft(el.value);
|
|
585
815
|
el.blur();
|
|
586
816
|
moveSel(1);
|
|
587
817
|
}
|
|
818
|
+
else if (e.key === "ArrowDown") {
|
|
819
|
+
e.preventDefault();
|
|
820
|
+
el.blur();
|
|
821
|
+
moveSel(1);
|
|
822
|
+
}
|
|
823
|
+
else if (e.key === "Backspace" && el.value === "" && pills.length) {
|
|
824
|
+
// Empty-input backspace pops the last pill back into the draft. Native browser
|
|
825
|
+
// behavior for chip inputs, and gives fast keyboard-only re-edits.
|
|
826
|
+
e.preventDefault();
|
|
827
|
+
const last = pills[pills.length - 1];
|
|
828
|
+
setPillsAndDraft(pills.slice(0, -1), last);
|
|
829
|
+
}
|
|
588
830
|
else if (e.key === "Escape") {
|
|
589
831
|
el.blur();
|
|
590
832
|
}
|
|
@@ -596,8 +838,15 @@ export function Feed({ spec, onInspect, selectedId }) {
|
|
|
596
838
|
store.setSpec(ns);
|
|
597
839
|
}
|
|
598
840
|
}}
|
|
599
|
-
onInput=${(e) =>
|
|
600
|
-
|
|
841
|
+
onInput=${(e) => {
|
|
842
|
+
const v = e.currentTarget.value;
|
|
843
|
+
// Erasing a popped pill's text to nothing means "remove that term": the term is
|
|
844
|
+
// gone from the string, so the remembered slot must not capture the NEXT term.
|
|
845
|
+
if (!v)
|
|
846
|
+
editSlotRef.current = null;
|
|
847
|
+
setPillsAndDraft(pills, v);
|
|
848
|
+
}} />
|
|
849
|
+
${filter ? html `<span class="ffilterclear" title="clear all" onClick=${() => setFilter("")}>✕</span>` : null}
|
|
601
850
|
</span>
|
|
602
851
|
${isLogish ? html `<label class="fsortlbl">app <select onChange=${(e) => changePkg(e.currentTarget.value)}><option value="__all__" selected=${curPkg === "__all__"}>all apps</option>${pkgOptions.map((p) => html `<option value=${p} selected=${p === curPkg}>${shortPkg(p)}</option>`)}</select></label>` : null}
|
|
603
852
|
<label class="fsortlbl">sort <select value=${sort} onChange=${(e) => setSort(e.currentTarget.value)}>${sortOpts.map((o) => html `<option value=${o.key}>${o.label}</option>`)}</select></label>
|
|
@@ -617,4 +866,4 @@ export function Feed({ spec, onInspect, selectedId }) {
|
|
|
617
866
|
</div>
|
|
618
867
|
`;
|
|
619
868
|
}
|
|
620
|
-
export { ROW_H, sortOptionsFor, searchText, rawLine, statusBand };
|
|
869
|
+
export { ROW_H, sortOptionsFor, searchText, filterKind, rawLine, statusBand };
|