sodabase 0.1.5 → 0.1.8
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/dist/api/client.js +35 -2
- package/dist/api/fakeClient.js +8 -1
- package/dist/app.js +15 -4
- package/dist/ui.js +92 -21
- package/package.json +1 -1
package/dist/api/client.js
CHANGED
|
@@ -12,6 +12,21 @@ export const MCP_URL = "https://sodabase.io/mcp";
|
|
|
12
12
|
export const SKILL_REF = "sodabase/agent-skills";
|
|
13
13
|
/** An error thrown when `connect()`'s poll is aborted (the user left the connect screen). */
|
|
14
14
|
const abortedError = () => new ApiError("connect aborted", 499, "aborted");
|
|
15
|
+
/** Pull the `email` claim out of a GoTrue JWT without verifying it (display only — the server already
|
|
16
|
+
* authenticated the token). Best-effort: any malformed part just yields undefined. */
|
|
17
|
+
function emailFromJwt(jwt) {
|
|
18
|
+
try {
|
|
19
|
+
const payload = jwt.split(".")[1];
|
|
20
|
+
if (!payload)
|
|
21
|
+
return undefined;
|
|
22
|
+
const json = Buffer.from(payload.replace(/-/g, "+").replace(/_/g, "/"), "base64").toString("utf8");
|
|
23
|
+
const claims = JSON.parse(json);
|
|
24
|
+
return typeof claims.email === "string" && claims.email ? claims.email : undefined;
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
15
30
|
/** Resolve after `ms`, or reject immediately if `signal` aborts (so leaving the screen doesn't wait).
|
|
16
31
|
* The abort listener is removed when the timer wins — otherwise connect()'s per-poll calls would pile
|
|
17
32
|
* up listeners on the same signal and trip Node's MaxListenersExceededWarning (which corrupts the TUI). */
|
|
@@ -53,11 +68,18 @@ export class SodabaseClient {
|
|
|
53
68
|
this.bearer = token;
|
|
54
69
|
}
|
|
55
70
|
// ── Leg 1: GoTrue sign-in (loopback PKCE → aud="authenticated" session) ──────
|
|
56
|
-
async signIn(provider) {
|
|
71
|
+
async signIn(provider, onUrl) {
|
|
57
72
|
// Matches the web app's @supabase/ssr PKCE flow, driven from a loopback redirect.
|
|
58
73
|
// Config + the one-time redirect-allowlist requirement live in gotrueAuth.ts.
|
|
59
74
|
const cfg = resolveGoTrueConfig();
|
|
60
|
-
const session = await loopbackSignIn(provider ? { ...cfg, provider } : cfg
|
|
75
|
+
const session = await loopbackSignIn(provider ? { ...cfg, provider } : cfg, {
|
|
76
|
+
// Still open the browser (the default behaviour), but also hand the URL back to the caller so
|
|
77
|
+
// the wizard can show it — a user whose browser didn't open can copy it.
|
|
78
|
+
onUrl: (url) => {
|
|
79
|
+
openUrl(url);
|
|
80
|
+
onUrl?.(url);
|
|
81
|
+
},
|
|
82
|
+
});
|
|
61
83
|
this.bearer = session.accessToken;
|
|
62
84
|
return session;
|
|
63
85
|
}
|
|
@@ -176,6 +198,17 @@ export class SodabaseClient {
|
|
|
176
198
|
...(p.already_watched ? { watching: true } : {}),
|
|
177
199
|
}));
|
|
178
200
|
}
|
|
201
|
+
// ── Identity: who's signed in + which workspace (for the home report header) ──
|
|
202
|
+
async whoami() {
|
|
203
|
+
const me = await this.get("/me");
|
|
204
|
+
const email = this.bearer ? emailFromJwt(this.bearer) : undefined;
|
|
205
|
+
return {
|
|
206
|
+
...(email ? { email } : {}),
|
|
207
|
+
// `||` (not `??`) so an empty-string name/role from the API falls back instead of rendering blank.
|
|
208
|
+
workspaceName: me.workspace_name || me.workspace_id || "your workspace",
|
|
209
|
+
role: me.role || "member",
|
|
210
|
+
};
|
|
211
|
+
}
|
|
179
212
|
// ── Status: the workspace's watched projects + live open-issue counts ────────
|
|
180
213
|
async dashboardProjects() {
|
|
181
214
|
const rows = await this.get("/projects");
|
package/dist/api/fakeClient.js
CHANGED
|
@@ -44,7 +44,10 @@ export class FakeClient {
|
|
|
44
44
|
hasConfigToml: true,
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
-
async signIn(
|
|
47
|
+
async signIn(provider, onUrl) {
|
|
48
|
+
// Mirror the real authorize URL shape so the demo shows the same copy-paste line (never opened).
|
|
49
|
+
onUrl?.(`https://supabase-demo.supabase.co/auth/v1/authorize?provider=${provider ?? "google"}` +
|
|
50
|
+
`&redirect_to=http%3A%2F%2F127.0.0.1%3A8976%2Fcallback`);
|
|
48
51
|
await this.tick(800);
|
|
49
52
|
return { accessToken: "demo.gotrue.jwt", expiresAt: Date.now() + 3600_000 };
|
|
50
53
|
}
|
|
@@ -59,6 +62,10 @@ export class FakeClient {
|
|
|
59
62
|
setBearer() {
|
|
60
63
|
/* no-op in demo */
|
|
61
64
|
}
|
|
65
|
+
async whoami() {
|
|
66
|
+
await this.tick(120);
|
|
67
|
+
return { email: "you@example.com", workspaceName: "Demo", role: "owner" };
|
|
68
|
+
}
|
|
62
69
|
async connect(signal) {
|
|
63
70
|
// No real browser in demo — just simulate the authorize + callback round-trip.
|
|
64
71
|
await this.tick(900);
|
package/dist/app.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useApp, useInput, useStdout } from "ink";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, useApp, useInput, useStdout } from "ink";
|
|
3
3
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
|
-
import { AgentView, Chrome, Connect, Home, ManageProjects, ManageTables, McpInstall, ScopeAdjust, SignIn, WizardProvider, } from "./ui.js";
|
|
4
|
+
import { AgentView, Chrome, Connect, Home, ManageProjects, ManageTables, McpInstall, ScopeAdjust, SignIn, TooSmall, WizardProvider, MIN_COLS, MIN_ROWS, } from "./ui.js";
|
|
5
5
|
// The alternate-screen takeover and dark theming (OSC 11/10) are set up in cli.tsx before the first render;
|
|
6
6
|
// here we only track the terminal size so the frame can fill its full height.
|
|
7
7
|
/** Track the terminal size for the full-height frame; null when stdout isn't a sized TTY (piped output). */
|
|
@@ -115,5 +115,16 @@ export function App({ services, fast, interactive, signedIn, demo, fullscreen })
|
|
|
115
115
|
// Full-height frame only when cli.tsx put us in fullscreen (interactive TTY); otherwise inline (size null).
|
|
116
116
|
const termSize = useTerminalSize();
|
|
117
117
|
const size = fullscreen ? termSize : null;
|
|
118
|
-
|
|
118
|
+
// Too-small guard (fullscreen only): below the minimum the frame clips/wraps, so show a resize prompt rather
|
|
119
|
+
// than a broken layout. Reactive — useTerminalSize re-renders on resize, so enlarging restores the wizard.
|
|
120
|
+
// Piped/CI (size null) is never gated: there's no window to resize and the output is plain and scrollable.
|
|
121
|
+
const tooSmall = !!size && (size.columns < MIN_COLS || size.rows < MIN_ROWS);
|
|
122
|
+
// The wizard stays MOUNTED while the prompt shows — hidden with display:none, not swapped out — so resizing
|
|
123
|
+
// below the minimum and back preserves every screen's state and never re-runs its effects (e.g. AgentView
|
|
124
|
+
// would otherwise re-enqueue the onboarding job on each remount). Only the visible branch is rendered to the
|
|
125
|
+
// terminal; the hidden one lays out as nothing but keeps its React state and timers alive. Because it stays
|
|
126
|
+
// mounted, its input handlers also stay registered — so `tooSmall` is passed down and useGatedInput freezes
|
|
127
|
+
// every screen's useInput while hidden (otherwise a blind keypress could toggle a table or commit scope). The
|
|
128
|
+
// global escape handler above stays live, so the user can still quit from the resize prompt.
|
|
129
|
+
return (_jsxs(WizardProvider, { value: { services, fast, interactive, signedIn, demo, tooSmall }, children: [tooSmall && size && _jsx(TooSmall, { size: size }), _jsx(Box, { display: tooSmall ? "none" : "flex", flexDirection: "column", children: _jsx(Chrome, { size: size, children: Current ? _jsx(Current, { ctx: ctx, onDone: onDone }) : null }) })] }));
|
|
119
130
|
}
|
package/dist/ui.js
CHANGED
|
@@ -25,6 +25,14 @@ function useWizard() {
|
|
|
25
25
|
throw new Error("WizardProvider missing");
|
|
26
26
|
return w;
|
|
27
27
|
}
|
|
28
|
+
/** useInput for the screens, additionally frozen while the terminal is too small. The wizard is kept mounted
|
|
29
|
+
* (display:none) when too small so its state survives a resize — but its handlers must not act on keystrokes
|
|
30
|
+
* the user can't see (e.g. a blind watch/unwatch or scope commit). The global escape handler lives on raw
|
|
31
|
+
* useInput in app.tsx, so quitting still works while the resize prompt is up. */
|
|
32
|
+
function useGatedInput(handler, options) {
|
|
33
|
+
const { tooSmall } = useWizard();
|
|
34
|
+
useInput(handler, { ...options, isActive: (options?.isActive ?? true) && !tooSmall });
|
|
35
|
+
}
|
|
28
36
|
// ── Fullscreen chrome ─────────────────────────────────────────────────────────
|
|
29
37
|
// A persistent top bar (brand + version) and a bottom key-hint bar, with the active screen centered
|
|
30
38
|
// between them — the whole wizard takes over the terminal (alternate screen; see app.tsx). Screens publish
|
|
@@ -111,6 +119,16 @@ export function Chrome({ size, children, }) {
|
|
|
111
119
|
// frame top-aligns (its start stays visible) instead of centering and pushing the top off-screen.
|
|
112
120
|
return (_jsx(ChromeCtx.Provider, { value: api, children: _jsxs(Box, { flexDirection: "column", width: columns, height: size.rows, backgroundColor: BG, children: [_jsx(TopBar, { columns: columns }), _jsxs(Box, { flexGrow: 1, flexDirection: "column", alignItems: "center", paddingX: 2, backgroundColor: BG, children: [_jsx(Box, { flexGrow: 1, flexShrink: 0 }), _jsxs(Box, { flexDirection: "column", alignItems: "center", flexShrink: 0, children: [_jsx(BrandMark, {}), children] }), _jsx(Box, { flexGrow: 1, flexShrink: 0 })] }), _jsx(BottomBar, { columns: columns, children: footer })] }) }));
|
|
113
121
|
}
|
|
122
|
+
// The smallest terminal the fullscreen frame lays out cleanly: below this the two-column setup screen, the
|
|
123
|
+
// top/bottom bars and the centered body start to clip or wrap, so we show a resize prompt instead of a broken
|
|
124
|
+
// frame (mirrors PostHog's wizard). Checked only in the fullscreen/interactive path; piped output isn't gated.
|
|
125
|
+
export const MIN_COLS = 80;
|
|
126
|
+
export const MIN_ROWS = 28;
|
|
127
|
+
/** Shown in place of the wizard when the terminal is smaller than MIN_COLS×MIN_ROWS. Re-renders reactively as
|
|
128
|
+
* the user resizes (App watches the terminal size), so enlarging the window brings the wizard straight back. */
|
|
129
|
+
export function TooSmall({ size }) {
|
|
130
|
+
return (_jsxs(Box, { flexDirection: "column", width: size.columns, height: size.rows, backgroundColor: BG, padding: 1, children: [_jsx(Text, { color: "yellow", bold: true, children: "The Sodabase wizard needs more room. Please make this terminal bigger." }), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { color: MUTED, children: ["Currently ", size.columns, "\u00D7", size.rows, ", needs at least ", MIN_COLS, "\u00D7", MIN_ROWS, "."] }) })] }));
|
|
131
|
+
}
|
|
114
132
|
// ── presentational bits ─────────────────────────────────────────────────────────
|
|
115
133
|
function Eyebrow({ children }) {
|
|
116
134
|
return (_jsx(Text, { color: ACCENT, bold: true, children: children }));
|
|
@@ -158,6 +176,8 @@ export function SignIn({ onDone }) {
|
|
|
158
176
|
const [code, setCode] = useState("");
|
|
159
177
|
const [err, setErr] = useState(null);
|
|
160
178
|
const [project, setProject] = useState(null);
|
|
179
|
+
// The provider authorize URL being opened — shown so a user whose browser didn't open can copy it.
|
|
180
|
+
const [signInUrl, setSignInUrl] = useState(undefined);
|
|
161
181
|
const mounted = useRef(true);
|
|
162
182
|
useEffect(() => () => void (mounted.current = false), []);
|
|
163
183
|
// Finish sign-in the same way for every path: set the bearer, persist (never in --demo), advance.
|
|
@@ -189,9 +209,13 @@ export function SignIn({ onDone }) {
|
|
|
189
209
|
async function go(provider) {
|
|
190
210
|
setChosen(provider);
|
|
191
211
|
setErr(null);
|
|
212
|
+
setSignInUrl(undefined); // clear any stale URL from a previous attempt
|
|
192
213
|
setStage("signing");
|
|
193
214
|
try {
|
|
194
|
-
complete(await services.signIn(provider)
|
|
215
|
+
complete(await services.signIn(provider, (url) => {
|
|
216
|
+
if (mounted.current)
|
|
217
|
+
setSignInUrl(url);
|
|
218
|
+
}));
|
|
195
219
|
}
|
|
196
220
|
catch (e) {
|
|
197
221
|
fail(e);
|
|
@@ -242,7 +266,7 @@ export function SignIn({ onDone }) {
|
|
|
242
266
|
void go(); // non-interactive: env/default provider, no picker
|
|
243
267
|
return () => void (on = false);
|
|
244
268
|
}, []);
|
|
245
|
-
|
|
269
|
+
useGatedInput((input, key) => {
|
|
246
270
|
// Escape steps back through the text-entry stages (so it never destroys a half-typed sign-in);
|
|
247
271
|
// from the picker or a transient stage it quits. SignIn owns escape entirely — App's global
|
|
248
272
|
// handler defers to the sign-in screen.
|
|
@@ -333,7 +357,7 @@ export function SignIn({ onDone }) {
|
|
|
333
357
|
return (_jsxs(Box, { flexDirection: "column", paddingX: 2, marginTop: 1, alignItems: "center", children: [_jsx(Eyebrow, { children: signedIn ? "Signed in" : "Project detected" }), signedIn ? (_jsx(Box, { marginTop: 1, children: _jsxs(Text, { children: [_jsx(Text, { color: "green", children: "\u2714" }), " Already signed in ", _jsx(Text, { dimColor: true, children: "(using your saved session)" })] }) })) : (_jsxs(_Fragment, { children: [_jsx(Box, { marginTop: 1, flexDirection: "column", width: 64, children: _jsx(Text, { children: "We'll set up data-quality monitoring for your Supabase project \u2014 watching freshness, volume and quality drift, without touching a line of your code." }) }), _jsx(Box, { marginTop: 1, flexDirection: "column", children: !project ? (_jsxs(Text, { children: [_jsx(Text, { color: "green", children: spin }), " Detecting Supabase project\u2026"] })) : (_jsx(ProjectFacts, { project: project })) }), stage === "pick" ? (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { dimColor: true, children: "How do you want to sign in?" }), _jsx(Box, { marginTop: 1, flexDirection: "column", children: PROVIDERS.map((p, i) => {
|
|
334
358
|
const here = i === cursor;
|
|
335
359
|
return (_jsxs(Text, { color: here ? "green" : undefined, children: [here ? "❯ " : " ", p.label] }, p.id));
|
|
336
|
-
}) })] })) : stage === "email" ? (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { dimColor: true, children: "Enter your email \u2014 we'll send you a sign-in code." }), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { children: ["Email: ", _jsx(Text, { color: "green", children: email }), _jsx(Text, { inverse: true, children: " " })] }) })] })) : stage === "sending" ? (_jsx(Box, { marginTop: 1, children: _jsxs(Text, { children: [_jsx(Text, { color: "green", children: spin }), " Sending a sign-in code to ", email, "\u2026"] }) })) : stage === "code" ? (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsxs(Text, { dimColor: true, children: ["We emailed a sign-in code to ", email, ". Enter it below."] }), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { children: ["Code: ", _jsx(Text, { color: "green", children: code }), _jsx(Text, { inverse: true, children: " " })] }) })] })) : stage === "verifying" ? (_jsx(Box, { marginTop: 1, children: _jsxs(Text, { children: [_jsx(Text, { color: "green", children: spin }), " Verifying your code\u2026"] }) })) : stage === "error" && err ? (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { color: "red", children: err.text }), err.hint && _jsx(Text, { dimColor: true, children: err.hint })] })) : (
|
|
360
|
+
}) })] })) : stage === "email" ? (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { dimColor: true, children: "Enter your email \u2014 we'll send you a sign-in code." }), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { children: ["Email: ", _jsx(Text, { color: "green", children: email }), _jsx(Text, { inverse: true, children: " " })] }) })] })) : stage === "sending" ? (_jsx(Box, { marginTop: 1, children: _jsxs(Text, { children: [_jsx(Text, { color: "green", children: spin }), " Sending a sign-in code to ", email, "\u2026"] }) })) : stage === "code" ? (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsxs(Text, { dimColor: true, children: ["We emailed a sign-in code to ", email, ". Enter it below."] }), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { children: ["Code: ", _jsx(Text, { color: "green", children: code }), _jsx(Text, { inverse: true, children: " " })] }) })] })) : stage === "verifying" ? (_jsx(Box, { marginTop: 1, children: _jsxs(Text, { children: [_jsx(Text, { color: "green", children: spin }), " Verifying your code\u2026"] }) })) : stage === "error" && err ? (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { color: "red", children: err.text }), err.hint && _jsx(Text, { dimColor: true, children: err.hint })] })) : (_jsxs(Box, { marginTop: 1, flexDirection: "column", alignItems: "center", children: [_jsxs(Text, { children: [_jsx(Text, { color: "green", children: spin }), " Opening your browser to sign in with ", providerLabel, "\u2026"] }), signInUrl && (_jsxs(Box, { marginTop: 1, flexDirection: "column", width: 64, children: [_jsx(Text, { dimColor: true, children: "If your browser didn't open, visit this URL:" }), _jsx(Text, { color: ACCENT, children: signInUrl })] }))] }))] }))] }));
|
|
337
361
|
}
|
|
338
362
|
// ── Phase: connect (multi-step: authorize → list → pick project) ─────────────────
|
|
339
363
|
/** Short status tags shown next to a project in the picker: "watching" (already set up in this workspace) and
|
|
@@ -418,7 +442,7 @@ export function Connect({ onDone }) {
|
|
|
418
442
|
// later pick of a NEW project resets the flag left over from a previous "manage" round.
|
|
419
443
|
onDone({ connectionId: connId, projectRef: ref, alreadyWatching: !!project?.watching });
|
|
420
444
|
}
|
|
421
|
-
|
|
445
|
+
useGatedInput((_i, key) => {
|
|
422
446
|
if (!projects || chosen)
|
|
423
447
|
return;
|
|
424
448
|
if (key.upArrow)
|
|
@@ -451,11 +475,21 @@ const STEP_LABELS = {
|
|
|
451
475
|
};
|
|
452
476
|
const stepLabel = (name) => STEP_LABELS[name] ?? name;
|
|
453
477
|
export function AgentView({ ctx, onDone }) {
|
|
454
|
-
|
|
455
|
-
const { services, fast } = useWizard();
|
|
478
|
+
const { services, fast, interactive } = useWizard();
|
|
456
479
|
const [steps, setSteps] = useState([]);
|
|
457
480
|
const [logs, setLogs] = useState(["Planning the trust setup."]);
|
|
458
481
|
const [error, setError] = useState(null);
|
|
482
|
+
// The job is finished and we're holding the completed screen until the user presses a key (interactive
|
|
483
|
+
// only) — so the "all 5 done" result doesn't flash past before they can read it.
|
|
484
|
+
const [finished, setFinished] = useState(false);
|
|
485
|
+
// Each completed step logs exactly one tail line. Without this, every poll re-appended the latest
|
|
486
|
+
// completed step's line while the job sat on it, printing the same row several times over.
|
|
487
|
+
const loggedRef = useRef(new Set());
|
|
488
|
+
useFooter(_jsx(Text, { dimColor: true, children: finished ? "done · enter to continue" : "setting up… · esc to cancel" }), [finished]);
|
|
489
|
+
useGatedInput((_i, key) => {
|
|
490
|
+
if (key.return)
|
|
491
|
+
onDone({});
|
|
492
|
+
}, { isActive: interactive && finished });
|
|
459
493
|
useEffect(() => {
|
|
460
494
|
let on = true;
|
|
461
495
|
(async () => {
|
|
@@ -466,10 +500,20 @@ export function AgentView({ ctx, onDone }) {
|
|
|
466
500
|
if (!on)
|
|
467
501
|
return;
|
|
468
502
|
setSteps(st.steps);
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
503
|
+
// Append a tail line for any step that just reached a terminal state, once each, in order.
|
|
504
|
+
for (const s of st.steps) {
|
|
505
|
+
if ((s.status === "done" || s.status === "skipped") && s.detail && !loggedRef.current.has(s.name)) {
|
|
506
|
+
loggedRef.current.add(s.name);
|
|
507
|
+
setLogs((l) => [...l, `${stepLabel(s.name)} — ${s.detail}`].slice(-4));
|
|
508
|
+
}
|
|
509
|
+
}
|
|
472
510
|
if (st.status === "done") {
|
|
511
|
+
// Interactive: hold the completed screen until a keypress. Non-interactive (CI/pipe): no
|
|
512
|
+
// keyboard to wait on, so advance after a readable beat as before.
|
|
513
|
+
if (interactive) {
|
|
514
|
+
setFinished(true);
|
|
515
|
+
return;
|
|
516
|
+
}
|
|
473
517
|
await sleep(fast ? 80 : 500);
|
|
474
518
|
if (on)
|
|
475
519
|
onDone({});
|
|
@@ -495,7 +539,7 @@ export function AgentView({ ctx, onDone }) {
|
|
|
495
539
|
const mk = s.status === "done" ? "✔" : s.status === "running" ? "▶" : s.status === "skipped" ? "—" : "□";
|
|
496
540
|
const color = s.status === "done" || s.status === "running" ? "green" : undefined;
|
|
497
541
|
return (_jsxs(Text, { color: color, dimColor: s.status === "pending" || s.status === "queued" || s.status === "skipped", children: [" ", mk, " ", stepLabel(s.name)] }, s.name));
|
|
498
|
-
}), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { children: [_jsx(Text, { color: "green", children: "Progress" }), " ", _jsx(Text, { bold: true, children: `${done}/${total}` })] }) })] })] }), _jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { dimColor: true, children: "Tail logs" }), logs.map((l, i) => (_jsxs(Text, { dimColor: true, children: [" ", l] }, i)))] })] }))] }));
|
|
542
|
+
}), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { children: [_jsx(Text, { color: "green", children: "Progress" }), " ", _jsx(Text, { bold: true, children: `${done}/${total}` })] }) }), finished && (_jsx(Box, { marginTop: 1, children: _jsx(Text, { color: "green", children: "\u2714 Monitoring is live \u2014 press enter to continue" }) }))] })] }), _jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { dimColor: true, children: "Tail logs" }), logs.map((l, i) => (_jsxs(Text, { dimColor: true, children: [" ", l] }, i)))] })] }))] }));
|
|
499
543
|
}
|
|
500
544
|
// ── Phase: Scope (onboard-then-adjust; monitor ids) ──────────────────────────────
|
|
501
545
|
export function ScopeAdjust({ onDone }) {
|
|
@@ -557,7 +601,7 @@ export function ScopeAdjust({ onDone }) {
|
|
|
557
601
|
setError(e instanceof Error ? e.message : String(e));
|
|
558
602
|
}
|
|
559
603
|
}
|
|
560
|
-
|
|
604
|
+
useGatedInput((_i, key) => {
|
|
561
605
|
if (!proposals || committed)
|
|
562
606
|
return;
|
|
563
607
|
if (key.upArrow)
|
|
@@ -596,12 +640,15 @@ export function McpInstall({ onDone }) {
|
|
|
596
640
|
// The agents the MCP install actually wrote, so the skill-error hold can advance with the right context.
|
|
597
641
|
const [installedAgents, setInstalledAgents] = useState([]);
|
|
598
642
|
const [busy, setBusy] = useState(false);
|
|
643
|
+
// Install succeeded and we're holding the result screen until the user presses enter (so the ✔ summary
|
|
644
|
+
// and "restart your agent" note don't flash past before returning to the hub).
|
|
645
|
+
const [ready, setReady] = useState(false);
|
|
599
646
|
const [error, setError] = useState(null);
|
|
600
647
|
// MCP install is reached only from the hub menu (interactive). Back-navigation can unmount this
|
|
601
648
|
// mid-install, so guard every post-await state update.
|
|
602
649
|
const mounted = useRef(true);
|
|
603
650
|
useEffect(() => () => void (mounted.current = false), []);
|
|
604
|
-
useFooter(busy ? (_jsx(Text, { dimColor: true, children: "installing\u2026" })) : (_jsx(Text, { dimColor: true, children: "\u2191\u2193 move \u00B7 space toggle \u00B7 enter install \u00B7 n skip \u00B7 esc to go back" })), [busy]);
|
|
651
|
+
useFooter(busy ? (_jsx(Text, { dimColor: true, children: "installing\u2026" })) : ready || skillError ? (_jsx(Text, { dimColor: true, children: "enter to continue" })) : (_jsx(Text, { dimColor: true, children: "\u2191\u2193 move \u00B7 space toggle \u00B7 enter install \u00B7 n skip \u00B7 esc to go back" })), [busy, ready, skillError]);
|
|
605
652
|
async function run(choices) {
|
|
606
653
|
if (choices.length === 0) {
|
|
607
654
|
onDone({ installed: [] });
|
|
@@ -631,10 +678,14 @@ export function McpInstall({ onDone }) {
|
|
|
631
678
|
await sleep(fast ? 300 : 900);
|
|
632
679
|
if (!mounted.current)
|
|
633
680
|
return;
|
|
634
|
-
// Hold on a skill failure so the manual fallback is readable/actionable (enter advances)
|
|
635
|
-
//
|
|
681
|
+
// Hold on a skill failure so the manual fallback is readable/actionable (enter advances). Otherwise,
|
|
682
|
+
// interactive: hold the success screen until the user presses enter; non-interactive: just finish.
|
|
636
683
|
if (skillFailed)
|
|
637
684
|
setBusy(false);
|
|
685
|
+
else if (interactive) {
|
|
686
|
+
setBusy(false);
|
|
687
|
+
setReady(true);
|
|
688
|
+
}
|
|
638
689
|
else
|
|
639
690
|
onDone({ installed: choices });
|
|
640
691
|
}
|
|
@@ -646,9 +697,15 @@ export function McpInstall({ onDone }) {
|
|
|
646
697
|
setError(e instanceof Error ? e.message : String(e));
|
|
647
698
|
}
|
|
648
699
|
}
|
|
649
|
-
|
|
700
|
+
useGatedInput((input, key) => {
|
|
650
701
|
if (busy)
|
|
651
702
|
return;
|
|
703
|
+
if (ready) {
|
|
704
|
+
// Holding on the success screen: enter returns to the hub.
|
|
705
|
+
if (key.return)
|
|
706
|
+
onDone({ installed: installedAgents });
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
652
709
|
if (skillError) {
|
|
653
710
|
// Holding after a non-fatal skill failure: the MCP already landed, so advance on enter.
|
|
654
711
|
if (key.return)
|
|
@@ -670,8 +727,8 @@ export function McpInstall({ onDone }) {
|
|
|
670
727
|
void run([]);
|
|
671
728
|
else if (key.return)
|
|
672
729
|
void run(AGENTS.filter((_, i) => sel[i]));
|
|
673
|
-
}, { isActive: interactive && !busy && (!result || skillError !== null) });
|
|
674
|
-
return (_jsxs(Box, { flexDirection: "column", paddingX: 2, marginTop: 1, alignItems: "center", children: [_jsx(Eyebrow, { children: "Set up your coding agent (optional)" }), error ? (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsxs(Text, { color: "yellow", children: ["Couldn't auto-install the MCP: ", error] }), _jsx(Text, { dimColor: true, children: "Add it yourself (Claude Code):" }), _jsxs(Text, { color: "cyan", children: [" ", "claude mcp add --transport http sodabase https://sodabase.io/mcp"] }), interactive && (_jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "enter to continue" }) }))] })) : result ? (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsxs(Text, { dimColor: true, children: ["Ran: ", result.command] }), result.wrote.map((w) => (_jsxs(Text, { children: [" ", _jsx(Text, { color: "green", children: "\u2714" }), " ", w.agent, " ", _jsxs(Text, { dimColor: true, children: ["\u2192 ", w.path] })] }, w.agent))), skillResult && (_jsxs(Text, { children: [" ", _jsx(Text, { color: "green", children: "\u2714" }), " trust-advisor skill ", _jsx(Text, { dimColor: true, children: "\u2192 sodabase/agent-skills" })] })), skillError && (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { color: "yellow", children: ["Couldn't install the trust-advisor skill: ", skillError] }), _jsx(Text, { dimColor: true, children: "Add it yourself:" }), _jsxs(Text, { color: "cyan", children: [" ", "npx skills add sodabase/agent-skills"] })] })), _jsx(Text, { color: "green", children: "Ready next time you restart your agent." }), skillError && interactive && (_jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "enter to continue" }) }))] })) : (_jsxs(_Fragment, { children: [_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { dimColor: true, children: "Install the Sodabase MCP + trust-advisor skill so your agent can ask \"is this data safe to trust?\"" }), _jsx(Text, { dimColor: true, children: "Explicit \u2014 we show the exact change and only write on your confirm." })] }), _jsx(Box, { marginTop: 1, flexDirection: "column", children: AGENTS.map((a, i) => {
|
|
730
|
+
}, { isActive: interactive && !busy && (!result || skillError !== null || ready) });
|
|
731
|
+
return (_jsxs(Box, { flexDirection: "column", paddingX: 2, marginTop: 1, alignItems: "center", children: [_jsx(Eyebrow, { children: "Set up your coding agent (optional)" }), error ? (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsxs(Text, { color: "yellow", children: ["Couldn't auto-install the MCP: ", error] }), _jsx(Text, { dimColor: true, children: "Add it yourself (Claude Code):" }), _jsxs(Text, { color: "cyan", children: [" ", "claude mcp add --transport http sodabase https://sodabase.io/mcp"] }), interactive && (_jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "enter to continue" }) }))] })) : result ? (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsxs(Text, { dimColor: true, children: ["Ran: ", result.command] }), result.wrote.map((w) => (_jsxs(Text, { children: [" ", _jsx(Text, { color: "green", children: "\u2714" }), " ", w.agent, " ", _jsxs(Text, { dimColor: true, children: ["\u2192 ", w.path] })] }, w.agent))), skillResult && (_jsxs(Text, { children: [" ", _jsx(Text, { color: "green", children: "\u2714" }), " trust-advisor skill ", _jsx(Text, { dimColor: true, children: "\u2192 sodabase/agent-skills" })] })), skillError && (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { color: "yellow", children: ["Couldn't install the trust-advisor skill: ", skillError] }), _jsx(Text, { dimColor: true, children: "Add it yourself:" }), _jsxs(Text, { color: "cyan", children: [" ", "npx skills add sodabase/agent-skills"] })] })), _jsx(Text, { color: "green", children: "Ready next time you restart your agent." }), (ready || skillError) && interactive && (_jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "enter to continue" }) }))] })) : (_jsxs(_Fragment, { children: [_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { dimColor: true, children: "Install the Sodabase MCP + trust-advisor skill so your agent can ask \"is this data safe to trust?\"" }), _jsx(Text, { dimColor: true, children: "Explicit \u2014 we show the exact change and only write on your confirm." })] }), _jsx(Box, { marginTop: 1, flexDirection: "column", children: AGENTS.map((a, i) => {
|
|
675
732
|
const on = sel[i];
|
|
676
733
|
const here = interactive && i === cursor;
|
|
677
734
|
return (_jsxs(Text, { color: on ? "green" : undefined, dimColor: !on, children: [here ? "❯ " : " ", on ? "[x]" : "[ ]", " ", a] }, a));
|
|
@@ -705,7 +762,7 @@ export function ManageProjects({ onDone }) {
|
|
|
705
762
|
};
|
|
706
763
|
}, []);
|
|
707
764
|
const onboardRow = projects?.length ?? 0; // the "+ onboard a new project" row sits after the projects
|
|
708
|
-
|
|
765
|
+
useGatedInput((_i, key) => {
|
|
709
766
|
if (!projects)
|
|
710
767
|
return;
|
|
711
768
|
if (key.upArrow)
|
|
@@ -809,7 +866,7 @@ export function ManageTables({ ctx }) {
|
|
|
809
866
|
}
|
|
810
867
|
})();
|
|
811
868
|
}
|
|
812
|
-
|
|
869
|
+
useGatedInput((input, key) => {
|
|
813
870
|
if (!tables || tables.length === 0)
|
|
814
871
|
return;
|
|
815
872
|
if (key.upArrow)
|
|
@@ -848,6 +905,7 @@ export function Home({ ctx, onDone }) {
|
|
|
848
905
|
const { exit } = useApp();
|
|
849
906
|
const { services, fast, interactive } = useWizard();
|
|
850
907
|
const [projects, setProjects] = useState(null);
|
|
908
|
+
const [identity, setIdentity] = useState(null);
|
|
851
909
|
const [cursor, setCursor] = useState(0);
|
|
852
910
|
useEffect(() => {
|
|
853
911
|
let on = true;
|
|
@@ -862,6 +920,17 @@ export function Home({ ctx, onDone }) {
|
|
|
862
920
|
setProjects([]); // no projects yet / offline — render the empty-state + menu
|
|
863
921
|
}
|
|
864
922
|
})();
|
|
923
|
+
// Who's signed in + which workspace — fetched alongside the report, never blocking it.
|
|
924
|
+
(async () => {
|
|
925
|
+
try {
|
|
926
|
+
const me = await services.whoami();
|
|
927
|
+
if (on)
|
|
928
|
+
setIdentity(me);
|
|
929
|
+
}
|
|
930
|
+
catch {
|
|
931
|
+
/* identity line is best-effort — the report still renders without it */
|
|
932
|
+
}
|
|
933
|
+
})();
|
|
865
934
|
return () => {
|
|
866
935
|
on = false;
|
|
867
936
|
};
|
|
@@ -874,7 +943,7 @@ export function Home({ ctx, onDone }) {
|
|
|
874
943
|
const t = setTimeout(() => exit(), fast ? 400 : 3200);
|
|
875
944
|
return () => clearTimeout(t);
|
|
876
945
|
}, [interactive]);
|
|
877
|
-
|
|
946
|
+
useGatedInput((_i, key) => {
|
|
878
947
|
if (key.upArrow)
|
|
879
948
|
setCursor((c) => Math.max(0, c - 1));
|
|
880
949
|
else if (key.downArrow)
|
|
@@ -894,7 +963,9 @@ export function Home({ ctx, onDone }) {
|
|
|
894
963
|
const monitors = list.reduce((a, p) => a + p.monitors, 0);
|
|
895
964
|
const rules = list.reduce((a, p) => a + p.rules, 0);
|
|
896
965
|
useFooter(_jsx(Text, { dimColor: true, children: "\u2191\u2193 move \u00B7 enter select \u00B7 esc to quit" }), []);
|
|
897
|
-
return (_jsxs(Box, { flexDirection: "column", paddingX: 2, marginTop: 1, alignItems: "center", children: [_jsx(Eyebrow, { children: watching ? "Sodabase is watching" : "Welcome to Sodabase" }), _jsx(Box, { marginTop: 1,
|
|
966
|
+
return (_jsxs(Box, { flexDirection: "column", paddingX: 2, marginTop: 1, alignItems: "center", children: [_jsx(Eyebrow, { children: watching ? "Sodabase is watching" : "Welcome to Sodabase" }), identity && (_jsx(Box, { marginTop: 1, children: identity.email ? (_jsxs(Text, { dimColor: true, children: ["Signed in as ", _jsx(Text, { color: WHITE, children: identity.email }), " \u00B7 workspace", " ", _jsx(Text, { color: WHITE, children: identity.workspaceName })] })) : (
|
|
967
|
+
// No email on the JWT — a role isn't an identity, so just name the workspace.
|
|
968
|
+
_jsxs(Text, { dimColor: true, children: ["Workspace ", _jsx(Text, { color: WHITE, children: identity.workspaceName })] })) })), _jsx(Box, { marginTop: 1, flexDirection: "column", children: projects === null ? (_jsx(Text, { dimColor: true, children: "loading your trust report\u2026" })) : watching ? (_jsxs(_Fragment, { children: [_jsxs(StatRow, { label: "Tables watched", children: [_jsx(Text, { color: "green", bold: true, children: tables }), " ", "across ", plural(list.length, "project")] }), _jsxs(StatRow, { label: "Issues", children: [_jsx(Text, { color: issues > 0 ? "yellow" : "green", bold: true, children: issues }), " ", issues > 0 ? (_jsxs(Text, { dimColor: true, children: ["\u00B7 ", anomalyLabel(anomalies), " & ", plural(brokenRules, "broken rule")] })) : (_jsx(Text, { dimColor: true, children: "\u00B7 all clear" }))] }), _jsxs(StatRow, { label: "Coverage", children: [_jsx(Text, { bold: true, children: plural(monitors, "monitor") }), _jsx(Text, { dimColor: true, children: " & " }), _jsx(Text, { bold: true, children: plural(rules, "rule") })] }), ctx.installed && ctx.installed.length > 0 && (_jsxs(StatRow, { label: "MCP", children: [_jsx(Text, { color: "green", children: "\u2714" }), " installed for ", ctx.installed.join(", ")] }))] })) : (_jsxs(_Fragment, { children: [_jsx(Text, { children: "You're not watching any projects yet." }), _jsx(Text, { dimColor: true, children: "Pick one below \u2014 Sodabase sets up read-only monitoring, no code changes." })] })) }), interactive && projects !== null && (_jsx(_Fragment, { children: _jsx(Box, { marginTop: 1, flexDirection: "column", children: HOME_MENU.map((m, i) => {
|
|
898
969
|
const here = i === cursor;
|
|
899
970
|
return (_jsxs(Text, { color: here ? "green" : undefined, children: [here ? "❯ " : " ", m.label, " ", _jsxs(Text, { dimColor: true, children: ["\u00B7 ", m.hint] })] }, m.id));
|
|
900
971
|
}) }) }))] }));
|