@slack/radar-mcp 1.24.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 +3 -3
- package/dist/mcp/flags-tools.js +3 -9
- package/dist/mcp/index.js +3 -33
- package/dist/mcp/tools.js +5 -5
- package/dist/shared/feature-flags.d.ts +11 -0
- package/dist/shared/feature-flags.js +18 -4
- 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 +1 -1
- package/dist/shared/switchboard.js +14 -2
- 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/spec.d.ts +1 -1
- package/dist/web/spec.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { spawn } from "child_process";
|
|
2
|
+
/** Refuses anything that is not a version, so a value like ".." can never aim the swap at ~/.slack-radar itself. */
|
|
3
|
+
export declare function runtimeCopyDirFor(version: string): string;
|
|
4
|
+
/**
|
|
5
|
+
* Copies the package.json and dist the app needs into destRoot. No node_modules: the dashboard
|
|
6
|
+
* and install-app-cli.js import node builtins only. Throws on failure so the install stops before
|
|
7
|
+
* it bakes a path to a file that is not there.
|
|
8
|
+
*/
|
|
9
|
+
export declare function copyRuntime(sourceRoot: string, destRoot: string): void;
|
|
2
10
|
/**
|
|
3
11
|
* Where a stable, version-free name for a node interpreter could live. Homebrew keeps one at
|
|
4
12
|
* `<prefix>/bin/node` (`/opt/homebrew` on Apple silicon, `/usr/local` on Intel) pointing into the
|
|
@@ -153,11 +161,12 @@ export declare function installAppMessage(result: {
|
|
|
153
161
|
}): string;
|
|
154
162
|
/**
|
|
155
163
|
* Entry point for `install-app --self-heal-check`, spawned in the background by RadarApp.swift
|
|
156
|
-
* on every dock launch. install-app bakes the .app's paths and version in ONCE,
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
164
|
+
* on every dock launch. install-app bakes the .app's paths and version in ONCE, and the app runs
|
|
165
|
+
* from its own copy of the package under ~/.slack-radar/app/<version>, so a Radar upgrade via
|
|
166
|
+
* `npx @slack/radar-mcp@latest` (the documented setup) leaves the installed app on the older
|
|
167
|
+
* version with no signal to the user. This rebuilds it in place, copying this process's own
|
|
168
|
+
* version (itself just resolved via the same `@latest` npx call) and pointing the app at that copy
|
|
169
|
+
* when it differs from what is installed, so the fix lands invisibly and takes effect on the NEXT
|
|
161
170
|
* launch. Never throws out of this function, except when the final state write itself fails: a
|
|
162
171
|
* launcher-triggered background process failing loudly would look like a crash, which is exactly
|
|
163
172
|
* what staying invisible rules out. That one throw exits non-zero, which the precheck counts as a failure.
|
|
@@ -178,8 +187,8 @@ export declare function checkLatestPublishedVersion(): Promise<string | null>;
|
|
|
178
187
|
export declare function _setSelfHealSpawnForTest(fn: typeof spawn): void;
|
|
179
188
|
export declare function _setSelfHealRebuildTimeoutForTest(ms: number): void;
|
|
180
189
|
/**
|
|
181
|
-
* Entry point for `install-app --self-heal-precheck`. RadarApp.swift now spawns THIS (
|
|
182
|
-
*
|
|
190
|
+
* Entry point for `install-app --self-heal-precheck`. RadarApp.swift now spawns THIS (install-app-cli.js
|
|
191
|
+
* in the app's own copy of the package, guaranteed self-heal-aware) instead of going straight to `npx
|
|
183
192
|
* -y @slack/radar-mcp@latest install-app --self-heal-check`. The direct-to-npx version had a real
|
|
184
193
|
* bug: nothing guaranteed `@latest` resolved to code that understood `--self-heal-check`, and the
|
|
185
194
|
* already-published old dispatch ignores unknown flags and runs the full INTERACTIVE install
|
package/dist/web/install-app.js
CHANGED
|
@@ -17,7 +17,10 @@
|
|
|
17
17
|
// everyone. The shell launcher stays as the fallback for a machine with no Swift toolchain.
|
|
18
18
|
//
|
|
19
19
|
// Either way the app holds NO dashboard logic -- it starts the server and renders localhost -- so it
|
|
20
|
-
// does not go stale when Radar upgrades (the SAME app keeps working against a newer dist).
|
|
20
|
+
// does not go stale when Radar upgrades (the SAME app keeps working against a newer dist). It runs
|
|
21
|
+
// from its own copy of the package under ~/.slack-radar/app/<version>, so the npx cache can change
|
|
22
|
+
// under it without changing what it serves. A self-heal rebuild copies the newer version and points
|
|
23
|
+
// the app at it. A checkout install needs install-app re-run to pick up dist edits.
|
|
21
24
|
import { execFileSync, spawn } from "child_process";
|
|
22
25
|
import fs from "fs";
|
|
23
26
|
import http from "http";
|
|
@@ -49,15 +52,39 @@ function bashQuote(value) {
|
|
|
49
52
|
function appDir() {
|
|
50
53
|
return path.join(os.homedir(), "Applications");
|
|
51
54
|
}
|
|
52
|
-
/** The
|
|
55
|
+
/** The package root this install runs from: two dirs above install-app.js (dist/web). */
|
|
56
|
+
function sourceRootPath() {
|
|
57
|
+
return path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
58
|
+
}
|
|
59
|
+
/** The dashboard entrypoint in the package being installed. Only used to check the install can
|
|
60
|
+
* proceed; the app bakes the copy's path instead (see runtimeCopyDir). */
|
|
53
61
|
function webBinPath() {
|
|
54
|
-
return path.join(
|
|
62
|
+
return path.join(sourceRootPath(), "dist", "web", "bin.js");
|
|
63
|
+
}
|
|
64
|
+
/** Where the app's own copies of the package live, one dir per version. */
|
|
65
|
+
function runtimeRoot() {
|
|
66
|
+
return path.join(os.homedir(), ".slack-radar", "app");
|
|
67
|
+
}
|
|
68
|
+
/** The copy this version's app runs from. Derived from RADAR_VERSION so a test can compute it. */
|
|
69
|
+
function runtimeCopyDir() {
|
|
70
|
+
return runtimeCopyDirFor(RADAR_VERSION);
|
|
71
|
+
}
|
|
72
|
+
/** Refuses anything that is not a version, so a value like ".." can never aim the swap at ~/.slack-radar itself. */
|
|
73
|
+
export function runtimeCopyDirFor(version) {
|
|
74
|
+
if (!/^[0-9][0-9A-Za-z.+-]*$/.test(version)) {
|
|
75
|
+
throw new Error(`refusing to copy the runtime for "${version}", which is not a version`);
|
|
76
|
+
}
|
|
77
|
+
return path.join(runtimeRoot(), version);
|
|
55
78
|
}
|
|
56
|
-
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
|
|
60
|
-
|
|
79
|
+
/**
|
|
80
|
+
* Copies the package.json and dist the app needs into destRoot. No node_modules: the dashboard
|
|
81
|
+
* and install-app-cli.js import node builtins only. Throws on failure so the install stops before
|
|
82
|
+
* it bakes a path to a file that is not there.
|
|
83
|
+
*/
|
|
84
|
+
export function copyRuntime(sourceRoot, destRoot) {
|
|
85
|
+
fs.mkdirSync(destRoot, { recursive: true });
|
|
86
|
+
fs.cpSync(path.join(sourceRoot, "package.json"), path.join(destRoot, "package.json"));
|
|
87
|
+
fs.cpSync(path.join(sourceRoot, "dist"), path.join(destRoot, "dist"), { recursive: true });
|
|
61
88
|
}
|
|
62
89
|
/**
|
|
63
90
|
* A keg-only formula (`brew install node@22`) is not linked into `<prefix>/bin`, so it has no entry
|
|
@@ -414,10 +441,12 @@ export function installPort(env = process.env, installed) {
|
|
|
414
441
|
* bakes execPath. With them, a synthetic Homebrew layout proves the wiring anywhere.
|
|
415
442
|
*/
|
|
416
443
|
export function installConfigValues(execPath, candidates) {
|
|
444
|
+
const copy = runtimeCopyDir();
|
|
417
445
|
return {
|
|
418
446
|
node: stableNodePath(execPath ?? process.execPath, candidates ?? stableNodeCandidates()),
|
|
419
|
-
webBin:
|
|
420
|
-
|
|
447
|
+
webBin: path.join(copy, "dist", "web", "bin.js"),
|
|
448
|
+
// install-app-cli.js, not mcp/index.js: it needs no node_modules, so the copy stays small.
|
|
449
|
+
mcpBin: path.join(copy, "dist", "web", "install-app-cli.js"),
|
|
421
450
|
port: installPort(),
|
|
422
451
|
};
|
|
423
452
|
}
|
|
@@ -578,6 +607,46 @@ function buildIcns(resourcesDir) {
|
|
|
578
607
|
// the finally below. Without this, one crashed install would wedge every self-heal check forever,
|
|
579
608
|
// since nothing else ever removes the lock file.
|
|
580
609
|
const STALE_LOCK_MS = 2 * 60 * 1000;
|
|
610
|
+
/**
|
|
611
|
+
* Puts the package copy at destDir: staged at `.new`, then renamed into place, with any existing
|
|
612
|
+
* same-version dir moved to `.old` first and removed after, the same shape as the bundle swap.
|
|
613
|
+
* When the install is already running from destDir (the app's own copy rebuilding the same
|
|
614
|
+
* version) the copy is skipped, since swapping a dir out from under the code reading it would
|
|
615
|
+
* delete the source.
|
|
616
|
+
*/
|
|
617
|
+
function installRuntimeCopy(sourceRoot, destDir) {
|
|
618
|
+
try {
|
|
619
|
+
if (fs.realpathSync(sourceRoot) === fs.realpathSync(destDir))
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
catch {
|
|
623
|
+
// destDir is not there yet, so the two cannot be the same dir.
|
|
624
|
+
}
|
|
625
|
+
const staging = `${destDir}.new`;
|
|
626
|
+
fs.mkdirSync(path.dirname(destDir), { recursive: true });
|
|
627
|
+
fs.rmSync(staging, { recursive: true, force: true });
|
|
628
|
+
copyRuntime(sourceRoot, staging);
|
|
629
|
+
swapIntoPlace(staging, destDir);
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* Renames a fully written staging dir over dest, keeping the old one at `.old` until the new one
|
|
633
|
+
* is in place. Clears a stale `.old` first (a crashed run's leftover) so the first rename cannot
|
|
634
|
+
* fail with ENOTEMPTY. Each rename is atomic, but the pair is not: a crash between them leaves dest
|
|
635
|
+
* at `.old` until a later run or a person moves it back. Node has no rename-exchange to close that.
|
|
636
|
+
*/
|
|
637
|
+
function swapIntoPlace(staging, dest) {
|
|
638
|
+
const backup = `${dest}.old`;
|
|
639
|
+
fs.rmSync(backup, { recursive: true, force: true });
|
|
640
|
+
if (fs.existsSync(dest))
|
|
641
|
+
fs.renameSync(dest, backup);
|
|
642
|
+
fs.renameSync(staging, dest);
|
|
643
|
+
try {
|
|
644
|
+
fs.rmSync(backup, { recursive: true, force: true });
|
|
645
|
+
}
|
|
646
|
+
catch {
|
|
647
|
+
// A leftover .old must not fail an otherwise-good install.
|
|
648
|
+
}
|
|
649
|
+
}
|
|
581
650
|
/**
|
|
582
651
|
* Create (or replace) the launcher app. Returns its path.
|
|
583
652
|
*
|
|
@@ -591,12 +660,12 @@ export function installMacApp() {
|
|
|
591
660
|
const dir = appDir();
|
|
592
661
|
const app = path.join(dir, `${APP_NAME}.app`);
|
|
593
662
|
const staging = `${app}.new`;
|
|
594
|
-
const backup = `${app}.old`;
|
|
595
663
|
// Resolved once, since both build paths below need the same answer.
|
|
596
664
|
const values = installConfigValues();
|
|
597
665
|
const webBin = values.webBin;
|
|
598
|
-
|
|
599
|
-
|
|
666
|
+
const sourceBin = webBinPath();
|
|
667
|
+
if (!fs.existsSync(sourceBin)) {
|
|
668
|
+
throw new Error(`cannot find the dashboard entrypoint at ${sourceBin}`);
|
|
600
669
|
}
|
|
601
670
|
// "wx" is atomic create-if-absent, so there is no check-then-create race on the lock itself.
|
|
602
671
|
// A second caller finding it already there fails immediately rather than racing the same
|
|
@@ -629,6 +698,7 @@ export function installMacApp() {
|
|
|
629
698
|
}
|
|
630
699
|
}
|
|
631
700
|
try {
|
|
701
|
+
installRuntimeCopy(sourceRootPath(), runtimeCopyDir());
|
|
632
702
|
const macos = path.join(staging, "Contents", "MacOS");
|
|
633
703
|
const resources = path.join(staging, "Contents", "Resources");
|
|
634
704
|
fs.rmSync(staging, { recursive: true, force: true });
|
|
@@ -647,25 +717,7 @@ export function installMacApp() {
|
|
|
647
717
|
}
|
|
648
718
|
fs.writeFileSync(path.join(staging, "Contents", "Info.plist"), infoPlist(native ? "SlackRadar" : "radar-launcher", values.port));
|
|
649
719
|
const icon = buildIcns(resources);
|
|
650
|
-
|
|
651
|
-
// step. The pair is not one atomic transaction though: a crash between the two renames leaves
|
|
652
|
-
// no `app` at all (it is sitting at `backup`) until the process resumes and completes the
|
|
653
|
-
// second rename or a person restores it by hand -- Node's fs has no rename-exchange primitive
|
|
654
|
-
// to close that particular gap, so this is close to the best achievable on POSIX, not a full
|
|
655
|
-
// guarantee. Clear any stale `.old` first (a previous run's crash leftover) so the first
|
|
656
|
-
// rename cannot fail with ENOTEMPTY.
|
|
657
|
-
fs.rmSync(backup, { recursive: true, force: true });
|
|
658
|
-
if (fs.existsSync(app)) {
|
|
659
|
-
fs.renameSync(app, backup);
|
|
660
|
-
}
|
|
661
|
-
fs.renameSync(staging, app);
|
|
662
|
-
// Best-effort cleanup on success; a leftover .old must not fail an otherwise-good install.
|
|
663
|
-
try {
|
|
664
|
-
fs.rmSync(backup, { recursive: true, force: true });
|
|
665
|
-
}
|
|
666
|
-
catch {
|
|
667
|
-
// harmless
|
|
668
|
-
}
|
|
720
|
+
swapIntoPlace(staging, app);
|
|
669
721
|
// Nudge Launch Services to notice the new bundle so it appears in Spotlight immediately
|
|
670
722
|
// instead of whenever the system next rescans. Best effort; the app works regardless.
|
|
671
723
|
try {
|
|
@@ -774,11 +826,12 @@ function logNoInstalledVersion(checkedAt, reason) {
|
|
|
774
826
|
}
|
|
775
827
|
/**
|
|
776
828
|
* Entry point for `install-app --self-heal-check`, spawned in the background by RadarApp.swift
|
|
777
|
-
* on every dock launch. install-app bakes the .app's paths and version in ONCE,
|
|
778
|
-
*
|
|
779
|
-
*
|
|
780
|
-
*
|
|
781
|
-
*
|
|
829
|
+
* on every dock launch. install-app bakes the .app's paths and version in ONCE, and the app runs
|
|
830
|
+
* from its own copy of the package under ~/.slack-radar/app/<version>, so a Radar upgrade via
|
|
831
|
+
* `npx @slack/radar-mcp@latest` (the documented setup) leaves the installed app on the older
|
|
832
|
+
* version with no signal to the user. This rebuilds it in place, copying this process's own
|
|
833
|
+
* version (itself just resolved via the same `@latest` npx call) and pointing the app at that copy
|
|
834
|
+
* when it differs from what is installed, so the fix lands invisibly and takes effect on the NEXT
|
|
782
835
|
* launch. Never throws out of this function, except when the final state write itself fails: a
|
|
783
836
|
* launcher-triggered background process failing loudly would look like a crash, which is exactly
|
|
784
837
|
* what staying invisible rules out. That one throw exits non-zero, which the precheck counts as a failure.
|
|
@@ -898,8 +951,8 @@ export function _setSelfHealRebuildTimeoutForTest(ms) {
|
|
|
898
951
|
selfHealRebuildTimeoutMs = ms;
|
|
899
952
|
}
|
|
900
953
|
/**
|
|
901
|
-
* Entry point for `install-app --self-heal-precheck`. RadarApp.swift now spawns THIS (
|
|
902
|
-
*
|
|
954
|
+
* Entry point for `install-app --self-heal-precheck`. RadarApp.swift now spawns THIS (install-app-cli.js
|
|
955
|
+
* in the app's own copy of the package, guaranteed self-heal-aware) instead of going straight to `npx
|
|
903
956
|
* -y @slack/radar-mcp@latest install-app --self-heal-check`. The direct-to-npx version had a real
|
|
904
957
|
* bug: nothing guaranteed `@latest` resolved to code that understood `--self-heal-check`, and the
|
|
905
958
|
* already-published old dispatch ignores unknown flags and runs the full INTERACTIVE install
|
|
@@ -770,11 +770,11 @@ enum QuitStopOutcome {
|
|
|
770
770
|
/// window is what is left after this app's own window is excluded by id.
|
|
771
771
|
case leftForWindow
|
|
772
772
|
/// This app spawned it, and the server said somebody is using it without saying who, so it was left
|
|
773
|
-
/// running. On the quit side that answer
|
|
774
|
-
///
|
|
775
|
-
/// the wire contract says a new kind is to be expected. Stopping a server whose
|
|
776
|
-
/// somebody was on it would be the implicit path costing somebody a page, which is
|
|
777
|
-
/// arm reserves for an explicit request. The cost is one orphaned server, which the launch path reclaims.
|
|
773
|
+
/// running. On the quit side that answer should not come from a server this app spawned, since it
|
|
774
|
+
/// runs RADAR_WEB_BIN, which is this app's own version. If it ever does, it is a kind this binary
|
|
775
|
+
/// has not heard of, and the wire contract says a new kind is to be expected. Stopping a server whose
|
|
776
|
+
/// newer answer said somebody was on it would be the implicit path costing somebody a page, which is
|
|
777
|
+
/// the trade the launch arm reserves for an explicit request. The cost is one orphaned server, which the launch path reclaims.
|
|
778
778
|
case leftUnattributed
|
|
779
779
|
}
|
|
780
780
|
|
|
@@ -853,8 +853,8 @@ final class SpawnedDashboard {
|
|
|
853
853
|
// used to kill the server that tab was reading.
|
|
854
854
|
//
|
|
855
855
|
// someoneUnnamed keeps the server too, and the route in matters. A server THIS app spawned runs
|
|
856
|
-
// RADAR_WEB_BIN, which is this app's version
|
|
857
|
-
// app, see triggerSelfHealCheck), so it understands the exclusion and never produces the OLD-server
|
|
856
|
+
// RADAR_WEB_BIN, which is this app's own version (a self-heal rebuild installs the newer version and
|
|
857
|
+
// points the app at it, see triggerSelfHealCheck), so it understands the exclusion and never produces the OLD-server
|
|
858
858
|
// route into someoneUnnamed. The route it can produce is a kind this binary has not heard of, which
|
|
859
859
|
// is exactly what the wire contract says to expect when the server is ahead, and that answer says
|
|
860
860
|
// somebody is there. A quit is nobody asking, so it may not cost that somebody a page; the launch
|
|
@@ -1396,14 +1396,15 @@ func ensureDashboardRunning(respectInUse: Bool = true, ticket: LaunchTicket? = n
|
|
|
1396
1396
|
}
|
|
1397
1397
|
|
|
1398
1398
|
/// Fire-and-forget check that a newer Radar is available, so a dock app that install-app baked
|
|
1399
|
-
/// paths and a version into ONCE self-heals on the NEXT launch instead of staying
|
|
1400
|
-
///
|
|
1399
|
+
/// paths and a version into ONCE self-heals on the NEXT launch instead of staying on its own copy
|
|
1400
|
+
/// of the older version after an `npx @slack/radar-mcp@latest` upgrade. Never blocks: this must
|
|
1401
1401
|
/// add no delay before the window appears, so there is no waitUntilExit and no exit-status check.
|
|
1402
1402
|
///
|
|
1403
|
-
/// Spawns the ALREADY-INSTALLED
|
|
1403
|
+
/// Spawns the ALREADY-INSTALLED install-app-cli.js (RADAR_MCP_BIN, in the app's own copy of the
|
|
1404
|
+
/// package), not `npx @latest` directly: nothing guarantees
|
|
1404
1405
|
/// `@latest` resolves to code that understands `--self-heal-check`, and the already-published old
|
|
1405
1406
|
/// dispatch ignores that unknown flag and runs the full INTERACTIVE install unconditionally. The
|
|
1406
|
-
/// installed
|
|
1407
|
+
/// installed copy is guaranteed to be from THIS build, so it knows to check the registry
|
|
1407
1408
|
/// itself before ever touching npx -- see install-app.ts's runSelfHealPrecheck().
|
|
1408
1409
|
func triggerSelfHealCheck() {
|
|
1409
1410
|
// Existence-checked, like the dashboard start. It used to be spawned under the baked path whatever
|
|
@@ -395,14 +395,15 @@
|
|
|
395
395
|
:root.light .voice-guide { opacity:.6; }
|
|
396
396
|
.voice-legend { display:flex; gap:8px 14px; font-size:11px; color:var(--muted-2); margin-top:8px; flex-wrap:wrap; }
|
|
397
397
|
.voice-legend span::before { content:""; display:inline-block; width:10px; height:10px; border-radius:2px; margin-right:6px; vertical-align:-1px; background:var(--muted); }
|
|
398
|
-
.voice-legend .m::before { background:var(--blue); } .voice-legend .y::before { background:var(--accent); } .voice-legend .r::before { background:var(--warn); } .voice-legend .s::before { background:var(--purple); } .voice-legend .f::before { background:var(--muted-2); }
|
|
398
|
+
.voice-legend .m::before { background:var(--blue); } .voice-legend .y::before { background:var(--accent); } .voice-legend .r::before { background:var(--warn); } .voice-legend .s::before { background:var(--purple); } .voice-legend .f::before { background:var(--muted-2); } .voice-legend .en::before { background:var(--muted); } .voice-legend .cd::before { background:var(--blue-2); }
|
|
399
399
|
/* Plain swatch, matching the clipped peak rect in voice.ts's levelBars. */
|
|
400
|
+
.voice-legend .hd::before { background:var(--muted-2); opacity:.45; }
|
|
400
401
|
.voice-legend .clip::before { background:var(--error); }
|
|
401
402
|
/* Legend swatches teach the tracks' own shapes, not just their colours: a thin vertical bar
|
|
402
403
|
for the line-tick markers (half height for the focus tick, half width for the stop tick,
|
|
403
404
|
matching their own glyphs), a two-band gradient standing in for the stall's dashed cap, and a
|
|
404
405
|
head-plus-stem shape for the error dot and the mixed glyph's own square-capped shape line. */
|
|
405
|
-
.voice-legend .r::before, .voice-legend .s::before, .voice-legend .st::before, .voice-legend .e::before, .voice-legend .f::before { width:3px; height:11px; border-radius:1.5px; }
|
|
406
|
+
.voice-legend .r::before, .voice-legend .s::before, .voice-legend .st::before, .voice-legend .e::before, .voice-legend .en::before, .voice-legend .f::before, .voice-legend .cd::before { width:3px; height:11px; border-radius:1.5px; }
|
|
406
407
|
.voice-legend .f::before { height:6px; }
|
|
407
408
|
.voice-legend .s::before { width:2px; }
|
|
408
409
|
.voice-legend .st::before { width:3px; height:11px; border:0; border-radius:0; background:repeating-linear-gradient(to bottom, var(--warn-2) 0 4px, transparent 4px 7px); }
|
|
@@ -691,6 +692,7 @@
|
|
|
691
692
|
carry the disagreement signal and the raw accent/muted tokens sat under 4.5:1 in light. */
|
|
692
693
|
.flagval.on { color:var(--accent-text); } .flagval.off { color:var(--text-2); } .flagval.dim { color:var(--muted-2); font-weight:400; }
|
|
693
694
|
.flagval.variant { font-variant-numeric:normal; font-family:ui-monospace,Menlo,Consolas,monospace; font-size:11.5px; }
|
|
695
|
+
.flagrestart { margin-left:6px; font-size:10.5px; white-space:nowrap; color:var(--text-2); }
|
|
694
696
|
.flagsview .dbout tr.overridden td { background:var(--hover); }
|
|
695
697
|
/* live observer patch: briefly highlight a row whose value just changed */
|
|
696
698
|
.flagsview .dbout tr.flash td { animation:flagflash 1.2s ease-out; }
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// GENERATED by scripts/mirror-shared.mjs from src/shared/feature-flags.ts. Do not edit; edit the source.
|
|
2
|
+
// Shared feature-flag response handling for the callers that read the device's
|
|
3
|
+
// /api/feature_flags route: the MCP tools (flags-tools.ts), the web server (web/server.ts) and the
|
|
4
|
+
// dashboard's Flags tab, which gets a mirrored copy of this file (scripts/mirror-shared.mjs). So it
|
|
5
|
+
// must stay import-free. The "Not Found" rewrite and the restart sentence live here once instead
|
|
6
|
+
// of drifting between copies.
|
|
7
|
+
/**
|
|
8
|
+
* Rewrite the device's raw "Not Found" into an actionable message. The route 404s as valid
|
|
9
|
+
* JSON ({"error":"Not Found"}) on builds that predate the feature-flag Radar plugin, which is
|
|
10
|
+
* correct but useless to a caller with no way to know this route is plugin-gated.
|
|
11
|
+
* A 401 is not read here; both callers decide it from the HTTP status before this runs.
|
|
12
|
+
*/
|
|
13
|
+
export function friendlyFeatureFlagError(error) {
|
|
14
|
+
if (typeof error !== "string")
|
|
15
|
+
return "Unknown device error.";
|
|
16
|
+
if (error === "Not Found") {
|
|
17
|
+
return "This debug build does not serve feature flags yet (update to a build with the feature-flag Radar plugin).";
|
|
18
|
+
}
|
|
19
|
+
return error;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The one sentence for a flag whose latest value differs from what the app runs. A flag the app
|
|
23
|
+
* read once keeps that value until restart, so `enabled` (latest or override) can differ from
|
|
24
|
+
* `session_enabled`. Only two real booleans that differ earn a note: an absent or non-boolean
|
|
25
|
+
* session_enabled is "not known", and saying nothing there is the honest answer.
|
|
26
|
+
*/
|
|
27
|
+
export function flagRestartNote(row) {
|
|
28
|
+
const { enabled, session_enabled: session } = row;
|
|
29
|
+
if (typeof enabled !== "boolean" || typeof session !== "boolean" || enabled === session)
|
|
30
|
+
return undefined;
|
|
31
|
+
const source = row.is_overridden === true ? "override" : "fetched";
|
|
32
|
+
return `app uses ${session} until restart, ${source} ${enabled}`;
|
|
33
|
+
}
|
|
@@ -10,7 +10,7 @@ import { gappedFieldHint } from "./filters.js";
|
|
|
10
10
|
import { STREAM_KINDS, LOG_LEVEL_ORDER, levelRank, EXCLUDE_MAX_TERMS, EXCLUDE_MAX_TERM_LENGTH, SWITCHBOARD_KINDS } from "./registry.js";
|
|
11
11
|
import { parseFilter, tokenize, isCompleteTerm, isQuote } from "./filter.js";
|
|
12
12
|
import { inSessionCut, sameSessionCut } from "./voice-model.js";
|
|
13
|
-
import { savedTurnLabel, switchboardClockLabel } from "./switchboard-note.js";
|
|
13
|
+
import { cardLabel, connectionEndedNormally, reconnectTryLabel, savedTurnLabel, switchboardClockLabel } from "./switchboard-note.js";
|
|
14
14
|
const ROW_H = 24;
|
|
15
15
|
const OVERSCAN = 10;
|
|
16
16
|
// How long the empty line's counts may stay behind the cache after an eviction before the next
|
|
@@ -166,6 +166,9 @@ export function switchboardArrow(direction) {
|
|
|
166
166
|
// A state change whose destination reads as a failure. Cosmetic only (the kind badge turns red):
|
|
167
167
|
// switchboard rows carry no logcat level, so this is where a failed transition stands out.
|
|
168
168
|
export function switchboardFailed(ev) {
|
|
169
|
+
// A normal server ending is a Failed state too, but not a fault, so it keeps the plain badge.
|
|
170
|
+
if (connectionEndedNormally(ev))
|
|
171
|
+
return false;
|
|
169
172
|
return ev.kind === "state" && /fail|error/i.test(String(ev.to ?? ""));
|
|
170
173
|
}
|
|
171
174
|
// dBFS reads better than a raw 0..1 peak: 0.05 and 0.5 both look "quiet" on a linear scale, but
|
|
@@ -187,7 +190,7 @@ export function switchboardSummary(ev) {
|
|
|
187
190
|
const num = (v) => (typeof v === "number" ? v : undefined);
|
|
188
191
|
const text = (v) => (v == null ? "" : String(v));
|
|
189
192
|
switch (ev.kind) {
|
|
190
|
-
case "session": return text(ev.event)
|
|
193
|
+
case "session": return `${text(ev.event)}${ev.mic_encoding ? ` ${text(ev.mic_encoding)}` : ""}`;
|
|
191
194
|
// The state kind and the transition are set apart so a word both carry ("speaking speaking →
|
|
192
195
|
// quiet") does not read as a stutter.
|
|
193
196
|
case "state": return `${text(ev.state_kind)} · ${text(ev.from)} → ${text(ev.to)}${ev.cause ? ` (${text(ev.cause)})` : ""}`.trim();
|
|
@@ -239,6 +242,14 @@ export function switchboardSummary(ev) {
|
|
|
239
242
|
}
|
|
240
243
|
// An unknown outcome shows as its device token, quoted unless plain (see savedTurnLabel).
|
|
241
244
|
case "saved_turn": return savedTurnLabel(ev.outcome, ev.has_thread);
|
|
245
|
+
// Unknown kinds and events show as sent (see cardLabel); the id follows so one card's moves line up.
|
|
246
|
+
case "card": return [cardLabel(ev.card_kind, ev.event, ev.by), typeof ev.card_id === "string" ? ev.card_id : ""].filter(Boolean).join(" ");
|
|
247
|
+
// The export line's words: "drop try 2 ready", "drop gave_up after 2 tries".
|
|
248
|
+
case "reconnect_try": {
|
|
249
|
+
const trigger = typeof ev.trigger === "string" ? ev.trigger : "?";
|
|
250
|
+
const outcome = typeof ev.outcome === "string" ? ev.outcome : "?";
|
|
251
|
+
return reconnectTryLabel(trigger, outcome, num(ev.try));
|
|
252
|
+
}
|
|
242
253
|
default: return "";
|
|
243
254
|
}
|
|
244
255
|
}
|
|
@@ -18,8 +18,11 @@
|
|
|
18
18
|
// timestamp when the device recorded this row, so one row is distinguishable from an older
|
|
19
19
|
// one. Named to match every other source's wire shape.
|
|
20
20
|
// type "toggle" | "experiment"
|
|
21
|
-
// enabled toggles only: the
|
|
22
|
-
//
|
|
21
|
+
// enabled toggles only: the latest boolean (override if set, else the server value),
|
|
22
|
+
// which the app may not run until restart.
|
|
23
|
+
// session_enabled toggles only: the flag's own value the app runs this session. Absent on older
|
|
24
|
+
// builds and experiments; absent or non-boolean means not known, so nothing is
|
|
25
|
+
// shown.
|
|
23
26
|
// group_name experiments only: the EFFECTIVE group/variant string (e.g. "treatment_a";
|
|
24
27
|
// "" / "control" is the baseline arm).
|
|
25
28
|
// is_overridden true when a local debug override is active
|
|
@@ -34,6 +37,7 @@
|
|
|
34
37
|
import { html } from "./html.js";
|
|
35
38
|
import { useState, useEffect, useCallback, useRef } from "preact/hooks";
|
|
36
39
|
import { normalizeStreamType } from "./registry.js";
|
|
40
|
+
import { flagRestartNote } from "./feature-flags.js";
|
|
37
41
|
// A row is unique per (scope, org_id, type, key), not by key alone: the device lists each key once
|
|
38
42
|
// per scope AND once per signed-in org, and a toggle and an experiment could share a name. Leaving
|
|
39
43
|
// org out collapsed two workspaces onto one row, so whichever wrote last won. `scope` is a
|
|
@@ -90,6 +94,14 @@ function flagValue(f) {
|
|
|
90
94
|
// what it means here. Says only what dim means: plenty of undimmed values are single-row groups,
|
|
91
95
|
// so undimmed does not imply a disagreement.
|
|
92
96
|
const DIM_TITLE = "every row of this flag in this scope shows this same value";
|
|
97
|
+
// Shown next to the pill when the app still runs an older value than the latest one. The visible
|
|
98
|
+
// text says what the app runs; the title is the shared sentence.
|
|
99
|
+
function restartMark(x) {
|
|
100
|
+
const note = flagRestartNote(x);
|
|
101
|
+
if (note === undefined)
|
|
102
|
+
return null;
|
|
103
|
+
return html `<span class="flagrestart" title=${note}>runs ${x.session_enabled ? "ON" : "OFF"} until restart</span>`;
|
|
104
|
+
}
|
|
93
105
|
// Render a flag value. Booleans (toggles) show ON/OFF; a variant group-name string shows as a
|
|
94
106
|
// text pill ("" / "control" read as the off/baseline arm). `dim` mutes a value that every row of
|
|
95
107
|
// the flag agrees on, so a disagreement is the only full-weight value in a multi-row group.
|
|
@@ -430,7 +442,7 @@ function Table({ rows, flashed, dimmed, }) {
|
|
|
430
442
|
<td class="scope">${x.scope || "—"}</td>
|
|
431
443
|
<td class="org" title=${orgTitle(x)}>${x.org_id || "—"}</td>
|
|
432
444
|
<td class="ftype"><span class=${"ftbadge " + t.cls}>${t.label}</span></td>
|
|
433
|
-
<td class="val">${valuePill(flagValue(x), dimmed.has(dimGroup(x)))}</td>
|
|
445
|
+
<td class="val">${valuePill(flagValue(x), dimmed.has(dimGroup(x)))}${restartMark(x)}</td>
|
|
434
446
|
<td class="origin"><span class=${"orbadge " + o.cls}>${o.label}</span></td>
|
|
435
447
|
</tr>`;
|
|
436
448
|
})}
|
|
@@ -23,8 +23,8 @@ export const MATCH_FIELDS = {
|
|
|
23
23
|
log: ["tag", "message", "pid", "package", "subsystem", "process"],
|
|
24
24
|
// The voice transport's records: `kind` picks the record shape, the rest are that shape's key
|
|
25
25
|
// fields (frame: direction/frame_type, state: state_kind, phase: phase, session/player: event,
|
|
26
|
-
// turn: clock, saved_turn: outcome).
|
|
27
|
-
switchboard: ["kind", "session_id", "direction", "frame_type", "state_kind", "phase", "event", "clock", "outcome"],
|
|
26
|
+
// turn: clock, saved_turn: outcome, reconnect_try: trigger, card: card_kind and card_id).
|
|
27
|
+
switchboard: ["kind", "session_id", "direction", "frame_type", "state_kind", "phase", "event", "clock", "outcome", "trigger", "card_kind", "card_id"],
|
|
28
28
|
};
|
|
29
29
|
// `all` = the union of every streaming source's fields (deduped, order-stable). Derived, not
|
|
30
30
|
// hand-maintained, so adding a source's fields above surfaces them in the unified Live tab too.
|
|
@@ -127,7 +127,7 @@ export const SOURCE_ORDER = ["all", "network", "rtm", "clog", "trace", "log", "s
|
|
|
127
127
|
// are their own containers, not feed filters). Derived from SOURCES so adding a streaming source
|
|
128
128
|
// surfaces it in Filters with no edit there. Ordered by SOURCE_ORDER (the modebar order) for a stable, familiar list.
|
|
129
129
|
export const FILTER_SOURCES = SOURCE_ORDER.filter((s) => SOURCES[s]?.kind === "stream");
|
|
130
|
-
// The
|
|
130
|
+
// The ten switchboard record kinds, in the order the toolbar's kind chips show them. Each chip
|
|
131
131
|
// writes the exclude term `kind:<name>`; a spec listing that term shows the chip off. These are
|
|
132
132
|
// the kinds switchboardFields (store.ts) knows fields for; a test holds the two lists together.
|
|
133
|
-
export const SWITCHBOARD_KINDS = ["session", "state", "frame", "phase", "player", "levels", "turn", "saved_turn"];
|
|
133
|
+
export const SWITCHBOARD_KINDS = ["session", "state", "frame", "phase", "player", "levels", "turn", "saved_turn", "card", "reconnect_try"];
|