sodabase 0.1.2 → 0.1.4
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 +3 -0
- package/dist/api/fakeClient.js +2 -2
- package/dist/api/gotrueAuth.js +7 -3
- package/dist/api/types.js +2 -0
- package/dist/app.js +27 -6
- package/dist/cli.js +39 -1
- package/dist/ui.js +165 -32
- package/package.json +1 -1
package/dist/api/client.js
CHANGED
|
@@ -185,6 +185,9 @@ export class SodabaseClient {
|
|
|
185
185
|
openIssues: p.open_issues ?? 0,
|
|
186
186
|
dataQualityIssues: p.data_quality_issues ?? 0,
|
|
187
187
|
watched: p.watched ?? 0,
|
|
188
|
+
monitors: p.monitors ?? 0,
|
|
189
|
+
rules: p.rules ?? 0,
|
|
190
|
+
brokenRules: p.broken_rules ?? 0,
|
|
188
191
|
status: p.status ?? "ready",
|
|
189
192
|
}));
|
|
190
193
|
}
|
package/dist/api/fakeClient.js
CHANGED
|
@@ -82,8 +82,8 @@ export class FakeClient {
|
|
|
82
82
|
async dashboardProjects() {
|
|
83
83
|
await this.tick(300);
|
|
84
84
|
return [
|
|
85
|
-
{ ref: "supabase-demo", name: "Supabase Demo", openIssues:
|
|
86
|
-
{ ref: "analytics", name: "Analytics", openIssues: 0, dataQualityIssues: 0, watched: 4, status: "ready" },
|
|
85
|
+
{ ref: "supabase-demo", name: "Supabase Demo", openIssues: 5, dataQualityIssues: 13, watched: 7, monitors: 28, rules: 15, brokenRules: 1, status: "ready" },
|
|
86
|
+
{ ref: "analytics", name: "Analytics", openIssues: 0, dataQualityIssues: 0, watched: 4, monitors: 18, rules: 10, brokenRules: 0, status: "ready" },
|
|
87
87
|
];
|
|
88
88
|
}
|
|
89
89
|
async jobStatus(jobId) {
|
package/dist/api/gotrueAuth.js
CHANGED
|
@@ -99,9 +99,13 @@ export async function loopbackSignIn(cfg = resolveGoTrueConfig(), opts = {}) {
|
|
|
99
99
|
res.end();
|
|
100
100
|
return;
|
|
101
101
|
}
|
|
102
|
-
//
|
|
103
|
-
//
|
|
104
|
-
|
|
102
|
+
// Supabase's PKCE redirect does NOT echo our `state` back, so we can't require it — PKCE
|
|
103
|
+
// (code_challenge/verifier) is the real anti-injection guarantee: an injected code can't be
|
|
104
|
+
// exchanged without our verifier, which never leaves this process. We still reject a callback
|
|
105
|
+
// that echoes a DIFFERENT state (a stray hit from another in-flight flow); a missing state is
|
|
106
|
+
// the normal Supabase case and must be accepted, or sign-in would 404 the real redirect and hang.
|
|
107
|
+
const returnedState = u.searchParams.get("state");
|
|
108
|
+
if (returnedState !== null && returnedState !== state) {
|
|
105
109
|
res.writeHead(404);
|
|
106
110
|
res.end();
|
|
107
111
|
return;
|
package/dist/api/types.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// Wire types for the Sodabase /api/v1 API, as the v2 CLI consumes them.
|
|
2
2
|
// Verified against the real route definitions on main. The CLI is a GoTrue client:
|
|
3
3
|
// every /api/v1 call needs Authorization: Bearer <GoTrue JWT, aud="authenticated">.
|
|
4
|
+
/** Open issues split: anomalies are the open signals that aren't broken rules (openIssues − brokenRules). */
|
|
5
|
+
export const anomalyCount = (p) => Math.max(0, p.openIssues - p.brokenRules);
|
|
4
6
|
/** The single "issues" number the CLI shows = monitor signals + data-quality findings. */
|
|
5
7
|
export const totalIssues = (p) => p.openIssues + p.dataQualityIssues;
|
|
6
8
|
export class ApiError extends Error {
|
package/dist/app.js
CHANGED
|
@@ -1,7 +1,25 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
2
|
-
import {
|
|
3
|
-
import { useCallback, useRef, useState } from "react";
|
|
4
|
-
import { AgentView,
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useApp, useInput, useStdout } from "ink";
|
|
3
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
|
+
import { AgentView, Chrome, Connect, Home, ManageProjects, ManageTables, McpInstall, ScopeAdjust, SignIn, WizardProvider, } from "./ui.js";
|
|
5
|
+
// The alternate-screen takeover and dark theming (OSC 11/10) are set up in cli.tsx before the first render;
|
|
6
|
+
// here we only track the terminal size so the frame can fill its full height.
|
|
7
|
+
/** Track the terminal size for the full-height frame; null when stdout isn't a sized TTY (piped output). */
|
|
8
|
+
function useTerminalSize() {
|
|
9
|
+
const { stdout } = useStdout();
|
|
10
|
+
const [size, setSize] = useState(() => stdout?.rows ? { rows: stdout.rows, columns: stdout.columns } : null);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (!stdout?.rows)
|
|
13
|
+
return;
|
|
14
|
+
const onResize = () => setSize({ rows: stdout.rows, columns: stdout.columns });
|
|
15
|
+
stdout.on("resize", onResize);
|
|
16
|
+
onResize();
|
|
17
|
+
return () => {
|
|
18
|
+
stdout.off("resize", onResize);
|
|
19
|
+
};
|
|
20
|
+
}, [stdout]);
|
|
21
|
+
return size;
|
|
22
|
+
}
|
|
5
23
|
// The screens, by name. Unlike the old linear wizard, navigation is a hub: sign-in lands on `home`
|
|
6
24
|
// (the trust report + action menu), and each action returns there when it finishes.
|
|
7
25
|
const SCREENS = {
|
|
@@ -52,7 +70,7 @@ function backTarget(name) {
|
|
|
52
70
|
return null; // signin / home → quit
|
|
53
71
|
}
|
|
54
72
|
}
|
|
55
|
-
export function App({ services, fast, interactive, signedIn, demo }) {
|
|
73
|
+
export function App({ services, fast, interactive, signedIn, demo, fullscreen }) {
|
|
56
74
|
const [screen, setScreen] = useState("signin");
|
|
57
75
|
const [ctx, setCtx] = useState({});
|
|
58
76
|
// onDone reads the current screen + ctx to compute the default next screen; refs keep those reads
|
|
@@ -94,5 +112,8 @@ export function App({ services, fast, interactive, signedIn, demo }) {
|
|
|
94
112
|
setScreen(target ?? "home");
|
|
95
113
|
}, [interactive]);
|
|
96
114
|
const Current = SCREENS[screen];
|
|
97
|
-
|
|
115
|
+
// Full-height frame only when cli.tsx put us in fullscreen (interactive TTY); otherwise inline (size null).
|
|
116
|
+
const termSize = useTerminalSize();
|
|
117
|
+
const size = fullscreen ? termSize : null;
|
|
118
|
+
return (_jsx(WizardProvider, { value: { services, fast, interactive, signedIn, demo }, children: _jsx(Chrome, { size: size, children: Current ? _jsx(Current, { ctx: ctx, onDone: onDone }) : null }) }));
|
|
98
119
|
}
|
package/dist/cli.js
CHANGED
|
@@ -80,4 +80,42 @@ const services = demo
|
|
|
80
80
|
}
|
|
81
81
|
return c;
|
|
82
82
|
})();
|
|
83
|
-
|
|
83
|
+
// Fullscreen: take over the terminal (alternate screen) and theme it dark by setting the terminal's OWN
|
|
84
|
+
// default background + foreground (OSC 11/10), so every cell is dark with light text without colouring each
|
|
85
|
+
// element — then restore the user's colours and scrollback on exit (OSC 111/110 + leave the alt buffer). Only
|
|
86
|
+
// in an interactive TTY; piped/CI output stays plain inline. Done here, before the first render, so Ink paints
|
|
87
|
+
// straight into the themed alt buffer with no repaint flash.
|
|
88
|
+
// Require a known size too: if stdout is a TTY but reports no rows, the frame can't lay out full-height, so we
|
|
89
|
+
// stay inline rather than enter the alt screen and then render an inline layout into it.
|
|
90
|
+
const fullscreen = interactive && !!process.stdout.isTTY && !!process.stdout.rows;
|
|
91
|
+
if (fullscreen) {
|
|
92
|
+
process.stdout.write("\u001B[?1049h\u001B]11;#0e1218\u0007\u001B]10;#cdd5dd\u0007\u001B[2J\u001B[H");
|
|
93
|
+
let restored = false;
|
|
94
|
+
const restore = () => {
|
|
95
|
+
if (restored)
|
|
96
|
+
return;
|
|
97
|
+
restored = true;
|
|
98
|
+
process.stdout.write("\u001B]110\u0007\u001B]111\u0007\u001B[?1049l");
|
|
99
|
+
};
|
|
100
|
+
// Leave the terminal exactly as we found it on EVERY exit path:
|
|
101
|
+
// • `exit` covers normal completion + process.exit() (the esc handler, Ink's Ctrl+C keypress);
|
|
102
|
+
// • a signal (SIGTERM from a kill/process-manager, SIGHUP on tab close, a raw SIGINT) terminates WITHOUT
|
|
103
|
+
// firing `exit`, so without these handlers the terminal is stranded in the dark alt buffer;
|
|
104
|
+
// • an uncaught error would otherwise print its stack into the alt buffer we immediately discard — hiding
|
|
105
|
+
// it — so restore first, then surface the error on the normal screen.
|
|
106
|
+
process.on("exit", restore);
|
|
107
|
+
for (const sig of ["SIGINT", "SIGTERM", "SIGHUP"]) {
|
|
108
|
+
process.on(sig, () => {
|
|
109
|
+
restore();
|
|
110
|
+
process.exit(sig === "SIGINT" ? 130 : sig === "SIGTERM" ? 143 : 129);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
const onFatal = (err) => {
|
|
114
|
+
restore();
|
|
115
|
+
process.stderr.write(`${err instanceof Error ? (err.stack ?? err.message) : String(err)}\n`);
|
|
116
|
+
process.exit(1);
|
|
117
|
+
};
|
|
118
|
+
process.on("uncaughtException", onFatal);
|
|
119
|
+
process.on("unhandledRejection", onFatal);
|
|
120
|
+
}
|
|
121
|
+
render(_jsx(App, { services: services, fast: fast, interactive: interactive, signedIn: signedIn, demo: demo, fullscreen: fullscreen }));
|
package/dist/ui.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Text, useApp, useInput } from "ink";
|
|
3
|
-
import {
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import React, { createContext, useContext, useEffect, useRef, useState } from "react";
|
|
4
5
|
import { totalIssues } from "./api/types.js";
|
|
5
6
|
import { saveCreds } from "./config/tokenStore.js";
|
|
6
7
|
// ── utils ─────────────────────────────────────────────────────────────────────
|
|
@@ -24,12 +25,95 @@ function useWizard() {
|
|
|
24
25
|
throw new Error("WizardProvider missing");
|
|
25
26
|
return w;
|
|
26
27
|
}
|
|
27
|
-
// ──
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
// ── Fullscreen chrome ─────────────────────────────────────────────────────────
|
|
29
|
+
// A persistent top bar (brand + version) and a bottom key-hint bar, with the active screen centered
|
|
30
|
+
// between them — the whole wizard takes over the terminal (alternate screen; see app.tsx). Screens publish
|
|
31
|
+
// their own key hints into the bottom bar with useFooter(); the frame owns where they go.
|
|
32
|
+
// Read the real version from package.json (one level up from dist/ui.js, shipped in the tarball) so the top
|
|
33
|
+
// bar never goes stale — same source the `--version` flag uses.
|
|
34
|
+
const VERSION = (() => {
|
|
35
|
+
try {
|
|
36
|
+
return createRequire(import.meta.url)("../package.json").version;
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return "";
|
|
40
|
+
}
|
|
41
|
+
})();
|
|
42
|
+
const ChromeCtx = createContext({ setFooter: () => { }, bodyRows: 0 });
|
|
43
|
+
/** Publish this screen's key hints into the frame's bottom bar for as long as it (or `deps`) is mounted. */
|
|
44
|
+
export function useFooter(hint, deps) {
|
|
45
|
+
const { setFooter } = useContext(ChromeCtx);
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
setFooter(hint);
|
|
48
|
+
return () => setFooter(null);
|
|
49
|
+
// `hint` is intentionally excluded — the caller lists the state the hint depends on in `deps`.
|
|
50
|
+
}, deps); // eslint-disable-line react-hooks/exhaustive-deps
|
|
51
|
+
}
|
|
52
|
+
/** Rows available to a screen's body inside the fullscreen frame (0 inline). Screens with a potentially long
|
|
53
|
+
* list use this to window the list so the cursor stays on screen rather than scrolling off the fixed height. */
|
|
54
|
+
export function useBodyRows() {
|
|
55
|
+
return useContext(ChromeCtx).bodyRows;
|
|
56
|
+
}
|
|
57
|
+
/** Window `items` to at most `max` rows, kept centered on `cursor`, with flags for hidden items above/below.
|
|
58
|
+
* `max <= 0` or a short-enough list returns everything. Keeps a navigable list within a fixed-height frame. */
|
|
59
|
+
export function windowList(items, cursor, max) {
|
|
60
|
+
if (max <= 0 || items.length <= max)
|
|
61
|
+
return { slice: items, start: 0, moreUp: 0, moreDown: 0 };
|
|
62
|
+
const start = Math.max(0, Math.min(cursor - Math.floor(max / 2), items.length - max));
|
|
63
|
+
return { slice: items.slice(start, start + max), start, moreUp: start, moreDown: items.length - (start + max) };
|
|
64
|
+
}
|
|
65
|
+
/** The full-width brand bar: `Sodabase Wizard vX.Y.Z` on the left, `sodabase.io` on the right, green so it
|
|
66
|
+
* reads on any terminal background (we don't paint the whole screen). Built as padded spans so the green
|
|
67
|
+
* fills edge to edge. */
|
|
68
|
+
const BG = "#0e1218"; // the dark body surface (painted by Ink, so it survives terminals that ignore OSC 11)
|
|
69
|
+
const CHROME = "#171d26"; // the top-bar strip, a touch lighter than the dark body
|
|
70
|
+
const BORDER = "#262f3b"; // hairline rules under the top bar and above the bottom bar
|
|
71
|
+
const ACCENT = "#39c6d6"; // cyan — headings and pointers, matching the design
|
|
72
|
+
const GREEN = "#52ca88"; // success / the brand mark
|
|
73
|
+
const WHITE = "#f2f6fa"; // emphasis — the wordmark, selected rows
|
|
74
|
+
const MUTED = "#69747f"; // secondary text
|
|
75
|
+
/** The centered brand lockup shown at the top of every screen: the dot mark + the Sodabase wordmark. */
|
|
76
|
+
function BrandMark() {
|
|
77
|
+
return (_jsx(Box, { marginBottom: 1, children: _jsxs(Text, { children: [_jsx(Text, { color: GREEN, bold: true, children: "\u22F1" }), " ", _jsx(Text, { color: WHITE, bold: true, children: "Sodabase" })] }) }));
|
|
78
|
+
}
|
|
79
|
+
function TopBar({ columns }) {
|
|
80
|
+
const name = " Sodabase Wizard ";
|
|
81
|
+
const ver = `v${VERSION}`;
|
|
82
|
+
const right = "sodabase.io ";
|
|
83
|
+
// Degrade on a narrow terminal: drop the right link, then the version, before the bar would overflow/wrap.
|
|
84
|
+
const showVer = columns >= name.length + ver.length + 2;
|
|
85
|
+
const showRight = columns >= name.length + ver.length + right.length + 2;
|
|
86
|
+
const used = name.length + (showVer ? ver.length : 0) + (showRight ? right.length : 0);
|
|
87
|
+
const pad = Math.max(0, columns - used);
|
|
88
|
+
return (_jsxs(Box, { flexDirection: "column", backgroundColor: BG, children: [_jsxs(Box, { children: [_jsx(Text, { backgroundColor: CHROME, color: WHITE, bold: true, children: name }), showVer && (_jsx(Text, { backgroundColor: CHROME, color: MUTED, children: ver })), _jsx(Text, { backgroundColor: CHROME, children: " ".repeat(pad) }), showRight && (_jsx(Text, { backgroundColor: CHROME, color: MUTED, children: right }))] }), _jsx(Text, { color: BORDER, children: "─".repeat(Math.max(1, columns)) })] }));
|
|
30
89
|
}
|
|
90
|
+
/** The bottom key-hint strip: a full-width rule, then the current screen's hints centered under it. */
|
|
91
|
+
function BottomBar({ columns, children }) {
|
|
92
|
+
return (_jsxs(Box, { flexDirection: "column", backgroundColor: BG, children: [_jsx(Text, { color: BORDER, children: "─".repeat(Math.max(1, columns)) }), _jsx(Box, { justifyContent: "center", paddingX: 2, backgroundColor: BG, children: children ?? _jsx(Text, { dimColor: true, children: "esc to quit" }) })] }));
|
|
93
|
+
}
|
|
94
|
+
/** The wizard frame. When `size` is known (an interactive TTY), it fills the terminal: top bar, the screen
|
|
95
|
+
* centered in a flex-grow body, and the bottom hint bar. Without a size (piped / non-interactive), it falls
|
|
96
|
+
* back to an inline render (top bar + content) so demo/CI output stays plain and scrollable. */
|
|
97
|
+
export function Chrome({ size, children, }) {
|
|
98
|
+
const [footer, setFooter] = useState(null);
|
|
99
|
+
const columns = size?.columns ?? 80;
|
|
100
|
+
// Rows a screen's body may use before it would overflow the frame: terminal rows minus the top bar (2),
|
|
101
|
+
// bottom bar (2) and brand lockup (2). Screens with long lists window to this (less their own header).
|
|
102
|
+
const bodyRows = size ? Math.max(0, size.rows - 6) : 0;
|
|
103
|
+
const api = React.useMemo(() => ({ setFooter, bodyRows }), [bodyRows]);
|
|
104
|
+
if (!size) {
|
|
105
|
+
return (_jsx(ChromeCtx.Provider, { value: api, children: _jsxs(Box, { flexDirection: "column", children: [_jsx(TopBar, { columns: columns }), _jsx(Box, { flexDirection: "column", paddingX: 2, marginTop: 1, children: children }), footer != null && (_jsx(Box, { paddingX: 2, marginTop: 1, children: footer }))] }) }));
|
|
106
|
+
}
|
|
107
|
+
// Paint the body dark with Ink itself (not just the OSC 11 default-bg from cli.tsx): some terminals honor
|
|
108
|
+
// OSC 10 (foreground) but ignore OSC 11 (background), which would leave light text on a white ground. A Box
|
|
109
|
+
// backgroundColor fills every cell, so the dark surface is reliable regardless of OSC 11 support.
|
|
110
|
+
// Vertical placement uses flex-grow spacers rather than justifyContent:center so that content TALLER than the
|
|
111
|
+
// frame top-aligns (its start stays visible) instead of centering and pushing the top off-screen.
|
|
112
|
+
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
|
+
}
|
|
114
|
+
// ── presentational bits ─────────────────────────────────────────────────────────
|
|
31
115
|
function Eyebrow({ children }) {
|
|
32
|
-
return (
|
|
116
|
+
return (_jsx(Text, { color: ACCENT, bold: true, children: children }));
|
|
33
117
|
}
|
|
34
118
|
// ── Phase: detect + GoTrue sign-in (one screen) ──────────────────────────────────
|
|
35
119
|
/** The detection facts block, with labels aligned in a left column (Directory / Framework / …). */
|
|
@@ -234,10 +318,22 @@ export function SignIn({ onDone }) {
|
|
|
234
318
|
// states (where it quits); the per-stage branches above guard the non-escape keys.
|
|
235
319
|
{ isActive: interactive });
|
|
236
320
|
const providerLabel = PROVIDERS.find((p) => p.id === chosen)?.label ?? chosen ?? "your provider";
|
|
237
|
-
|
|
321
|
+
const footerHint = signedIn
|
|
322
|
+
? "esc to quit"
|
|
323
|
+
: stage === "pick"
|
|
324
|
+
? "↑↓ move · enter to continue · GitHub/Google open your browser · esc to quit"
|
|
325
|
+
: stage === "email"
|
|
326
|
+
? "type to edit · backspace to delete · enter to send · esc to go back"
|
|
327
|
+
: stage === "code"
|
|
328
|
+
? "enter to verify · backspace to delete · esc to go back"
|
|
329
|
+
: stage === "error"
|
|
330
|
+
? "press r to start over · esc to go back"
|
|
331
|
+
: "esc to quit";
|
|
332
|
+
useFooter(_jsx(Text, { dimColor: true, children: footerHint }), [stage, signedIn]);
|
|
333
|
+
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) => {
|
|
238
334
|
const here = i === cursor;
|
|
239
335
|
return (_jsxs(Text, { color: here ? "green" : undefined, children: [here ? "❯ " : " ", p.label] }, p.id));
|
|
240
|
-
}) })
|
|
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 })] })) : (_jsx(Box, { marginTop: 1, children: _jsxs(Text, { children: [_jsx(Text, { color: "green", children: spin }), " Opening your browser to sign in with ", providerLabel, "\u2026"] }) }))] }))] }));
|
|
241
337
|
}
|
|
242
338
|
// ── Phase: connect (multi-step: authorize → list → pick project) ─────────────────
|
|
243
339
|
/** Short status tags shown next to a project in the picker: "watching" (already set up in this workspace) and
|
|
@@ -259,6 +355,8 @@ function isWatchable(p) {
|
|
|
259
355
|
}
|
|
260
356
|
const issuesLabel = (n) => `${n} ${n === 1 ? "issue" : "issues"}`;
|
|
261
357
|
export function Connect({ onDone }) {
|
|
358
|
+
useFooter(_jsx(Text, { dimColor: true, children: "\u2191\u2193 move \u00B7 enter select \u00B7 green = watching \u00B7 yellow = offline \u00B7 esc to go back" }), []);
|
|
359
|
+
const bodyRows = useBodyRows();
|
|
262
360
|
const { services, interactive } = useWizard();
|
|
263
361
|
const spin = useSpinner();
|
|
264
362
|
const [connectionId, setConnectionId] = useState(null);
|
|
@@ -331,7 +429,13 @@ export function Connect({ onDone }) {
|
|
|
331
429
|
finish(connectionId, projects[cursor]);
|
|
332
430
|
}, { isActive: interactive && !!projects && !chosen });
|
|
333
431
|
const picking = interactive && projects && projects.length > 1 && !chosen;
|
|
334
|
-
return (_jsxs(Box, { flexDirection: "column", paddingX: 2, marginTop: 1, children: [_jsx(Eyebrow, { children: "Authorize your database" }), _jsx(Box, { marginTop: 1, flexDirection: "column", children: error ? (_jsx(Text, { color: "red", children: error })) : !connectionId ? (_jsxs(_Fragment, { children: [_jsxs(Text, { children: [_jsx(Text, { color: "green", children: spin }), " Opening your browser to authorize\u2026"] }), _jsx(Text, { dimColor: true, children: "Read-only \u2014 no connection string to paste. Approve on Supabase, then return here." })] })) : !projects ? (_jsxs(Text, { children: [_jsx(Text, { color: "green", children: spin }), " Loading your projects\u2026"] })) : picking ? (
|
|
432
|
+
return (_jsxs(Box, { flexDirection: "column", paddingX: 2, marginTop: 1, alignItems: "center", children: [_jsx(Eyebrow, { children: "Authorize your database" }), _jsx(Box, { marginTop: 1, flexDirection: "column", children: error ? (_jsx(Text, { color: "red", children: error })) : !connectionId ? (_jsxs(_Fragment, { children: [_jsxs(Text, { children: [_jsx(Text, { color: "green", children: spin }), " Opening your browser to authorize\u2026"] }), _jsx(Box, { width: 62, children: _jsx(Text, { dimColor: true, children: "Read-only \u2014 no connection string to paste. Approve on Supabase, then return here." }) })] })) : !projects ? (_jsxs(Text, { children: [_jsx(Text, { color: "green", children: spin }), " Loading your projects\u2026"] })) : picking ? ((() => {
|
|
433
|
+
const win = windowList(projects, cursor, Math.max(3, bodyRows - 6));
|
|
434
|
+
return (_jsxs(_Fragment, { children: [_jsx(Text, { children: "Pick the project to watch:" }), win.moreUp > 0 && _jsx(Text, { dimColor: true, children: ` ↑ ${win.moreUp} more` }), win.slice.map((p, idx) => {
|
|
435
|
+
const i = win.start + idx;
|
|
436
|
+
return (_jsxs(Text, { color: i === cursor ? "green" : undefined, children: [i === cursor ? "❯ " : " ", p.name, " ", _jsxs(Text, { dimColor: true, children: ["(", p.ref, ")"] }), projectTags(p).map((t) => (_jsxs(Text, { color: t.color, children: [" ", "\u00B7 ", t.label] }, t.label)))] }, p.ref));
|
|
437
|
+
}), win.moreDown > 0 && _jsx(Text, { dimColor: true, children: ` ↓ ${win.moreDown} more` })] }));
|
|
438
|
+
})()) : (_jsxs(_Fragment, { children: [alreadyConnected && (_jsxs(Text, { dimColor: true, children: [_jsx(Text, { color: "green", children: "\u2713" }), " Already connected \u2014 continuing on your existing connection."] })), _jsxs(Text, { children: [_jsx(Text, { color: "green", children: "\u2714" }), " Connected \u00B7 project ", _jsx(Text, { bold: true, children: chosen ?? projects[0]?.ref ?? "—" }), _jsx(Text, { color: "green", children: " 🔒 read-only, audited" })] })] })) })] }));
|
|
335
439
|
}
|
|
336
440
|
// ── Phase: the server-side onboarding job (two-panel) ─────────────────────────────
|
|
337
441
|
// Human labels for the backend onboarding job's step names (machine keys). Unknown names fall back to the raw
|
|
@@ -347,6 +451,7 @@ const STEP_LABELS = {
|
|
|
347
451
|
};
|
|
348
452
|
const stepLabel = (name) => STEP_LABELS[name] ?? name;
|
|
349
453
|
export function AgentView({ ctx, onDone }) {
|
|
454
|
+
useFooter(_jsx(Text, { dimColor: true, children: "setting up\u2026 \u00B7 esc to cancel" }), []);
|
|
350
455
|
const { services, fast } = useWizard();
|
|
351
456
|
const [steps, setSteps] = useState([]);
|
|
352
457
|
const [logs, setLogs] = useState(["Planning the trust setup."]);
|
|
@@ -386,7 +491,7 @@ export function AgentView({ ctx, onDone }) {
|
|
|
386
491
|
}, []);
|
|
387
492
|
const done = steps.filter((s) => s.status === "done").length;
|
|
388
493
|
const total = steps.filter((s) => s.status !== "skipped").length || steps.length;
|
|
389
|
-
return (_jsxs(Box, { flexDirection: "column", paddingX: 2, marginTop: 1, children: [_jsx(Eyebrow, { children: "Setting up \u2014 agent at work" }), error ? (_jsx(Box, { marginTop: 1, children: _jsx(Text, { color: "red", children: error }) })) : (_jsxs(_Fragment, { children: [_jsxs(Box, { marginTop: 1, flexDirection: "row", children: [_jsxs(Box, { flexDirection: "column", width: 40, children: [_jsx(Text, { bold: true, children: "Learn" }), _jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { dimColor: true, children: "Sodabase is setting up your monitors" }), _jsx(Text, { dimColor: true, children: "and baselines on the server \u2014 the same" }), _jsx(Text, { dimColor: true, children: "job the web onboarding runs. This panel" }), _jsx(Text, { dimColor: true, children: "just renders it; the CLI owns no" }), _jsx(Text, { dimColor: true, children: "orchestration." })] })] }), _jsxs(Box, { flexDirection: "column", flexGrow: 1, children: [_jsx(Text, { bold: true, children: "Tasks" }), steps.map((s) => {
|
|
494
|
+
return (_jsxs(Box, { flexDirection: "column", paddingX: 2, marginTop: 1, alignItems: "center", children: [_jsx(Eyebrow, { children: "Setting up \u2014 agent at work" }), error ? (_jsx(Box, { marginTop: 1, children: _jsx(Text, { color: "red", children: error }) })) : (_jsxs(_Fragment, { children: [_jsxs(Box, { marginTop: 1, flexDirection: "row", children: [_jsxs(Box, { flexDirection: "column", width: 40, children: [_jsx(Text, { bold: true, children: "Learn" }), _jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { dimColor: true, children: "Sodabase is setting up your monitors" }), _jsx(Text, { dimColor: true, children: "and baselines on the server \u2014 the same" }), _jsx(Text, { dimColor: true, children: "job the web onboarding runs. This panel" }), _jsx(Text, { dimColor: true, children: "just renders it; the CLI owns no" }), _jsx(Text, { dimColor: true, children: "orchestration." })] })] }), _jsxs(Box, { flexDirection: "column", flexGrow: 1, children: [_jsx(Text, { bold: true, children: "Tasks" }), steps.map((s) => {
|
|
390
495
|
const mk = s.status === "done" ? "✔" : s.status === "running" ? "▶" : s.status === "skipped" ? "—" : "□";
|
|
391
496
|
const color = s.status === "done" || s.status === "running" ? "green" : undefined;
|
|
392
497
|
return (_jsxs(Text, { color: color, dimColor: s.status === "pending" || s.status === "queued" || s.status === "skipped", children: [" ", mk, " ", stepLabel(s.name)] }, s.name));
|
|
@@ -464,11 +569,17 @@ export function ScopeAdjust({ onDone }) {
|
|
|
464
569
|
else if (key.return)
|
|
465
570
|
void commit(proposals, sel);
|
|
466
571
|
}, { isActive: interactive && !!proposals && !committed });
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
572
|
+
useFooter(interactive && !committed && proposals && proposals.length > 0 ? (_jsx(Text, { dimColor: true, children: "\u2191\u2193 move \u00B7 space toggle \u00B7 enter confirm \u00B7 esc to go back" })) : (_jsx(Text, { dimColor: true, children: committed ? "saved" : "accepting recommended…" })), [interactive, committed, proposals]);
|
|
573
|
+
const bodyRows = useBodyRows();
|
|
574
|
+
return (_jsxs(Box, { flexDirection: "column", paddingX: 2, marginTop: 1, alignItems: "center", children: [_jsx(Eyebrow, { children: "What matters most" }), _jsx(Box, { marginTop: 1, children: _jsx(Box, { width: 62, children: _jsx(Text, { dimColor: true, children: "Monitoring what discovery proposed. Adjust below \u2014 unpicked ones won't run." }) }) }), _jsx(Box, { marginTop: 1, flexDirection: "column", children: error ? (_jsx(Text, { color: "red", children: error })) : !proposals ? (_jsx(Text, { dimColor: true, children: "loading proposals\u2026" })) : proposals.length === 0 ? (_jsx(Text, { dimColor: true, children: "Nothing to adjust \u2014 these are already set up." })) : ((() => {
|
|
575
|
+
const win = windowList(proposals, cursor, Math.max(3, bodyRows - 5));
|
|
576
|
+
return (_jsxs(_Fragment, { children: [win.moreUp > 0 && _jsx(Text, { dimColor: true, children: ` ↑ ${win.moreUp} more` }), win.slice.map((p, idx) => {
|
|
577
|
+
const i = win.start + idx;
|
|
578
|
+
const on = sel[i];
|
|
579
|
+
const here = interactive && i === cursor;
|
|
580
|
+
return (_jsxs(Text, { color: on ? "green" : undefined, dimColor: !on, children: [here ? "❯ " : " ", on ? "[x]" : "[ ]", " ", p.dataset, " ", _jsxs(Text, { dimColor: true, children: ["\u00B7 ", p.type] })] }, p.id));
|
|
581
|
+
}), win.moreDown > 0 && _jsx(Text, { dimColor: true, children: ` ↓ ${win.moreDown} more` })] }));
|
|
582
|
+
})()) })] }));
|
|
472
583
|
}
|
|
473
584
|
// ── Phase: consented in-flow MCP install ─────────────────────────────────────────
|
|
474
585
|
// These ids are forwarded verbatim to BOTH `add-mcp -a` and `skills -a` (see client.ts).
|
|
@@ -490,6 +601,7 @@ export function McpInstall({ onDone }) {
|
|
|
490
601
|
// mid-install, so guard every post-await state update.
|
|
491
602
|
const mounted = useRef(true);
|
|
492
603
|
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]);
|
|
493
605
|
async function run(choices) {
|
|
494
606
|
if (choices.length === 0) {
|
|
495
607
|
onDone({ installed: [] });
|
|
@@ -559,16 +671,18 @@ export function McpInstall({ onDone }) {
|
|
|
559
671
|
else if (key.return)
|
|
560
672
|
void run(AGENTS.filter((_, i) => sel[i]));
|
|
561
673
|
}, { isActive: interactive && !busy && (!result || skillError !== null) });
|
|
562
|
-
return (_jsxs(Box, { flexDirection: "column", paddingX: 2, marginTop: 1, 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) => {
|
|
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) => {
|
|
563
675
|
const on = sel[i];
|
|
564
676
|
const here = interactive && i === cursor;
|
|
565
677
|
return (_jsxs(Text, { color: on ? "green" : undefined, dimColor: !on, children: [here ? "❯ " : " ", on ? "[x]" : "[ ]", " ", a] }, a));
|
|
566
|
-
}) })
|
|
678
|
+
}) })] }))] }));
|
|
567
679
|
}
|
|
568
680
|
// ── Phase: manage projects (the hub's "Manage projects" entry) ───────────────────
|
|
569
681
|
// A picker over the projects already being watched; selecting one drills into its watched tables.
|
|
570
682
|
// A final row onboards a brand-new project (the Supabase authorize + pick flow).
|
|
571
683
|
export function ManageProjects({ onDone }) {
|
|
684
|
+
useFooter(_jsx(Text, { dimColor: true, children: "\u2191\u2193 move \u00B7 enter select \u00B7 esc to go back" }), []);
|
|
685
|
+
const bodyRows = useBodyRows();
|
|
572
686
|
const { services, interactive } = useWizard();
|
|
573
687
|
const [projects, setProjects] = useState(null);
|
|
574
688
|
const [cursor, setCursor] = useState(0);
|
|
@@ -606,16 +720,24 @@ export function ManageProjects({ onDone }) {
|
|
|
606
720
|
onDone({}, { to: "connect" }); // onboard a new project
|
|
607
721
|
}
|
|
608
722
|
}, { isActive: interactive && !!projects });
|
|
609
|
-
return (_jsxs(Box, { flexDirection: "column", paddingX: 2, marginTop: 1, children: [_jsx(Eyebrow, { children: "Manage projects" }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "Pick a project to manage its tables, or onboard a new one." }) }), _jsx(Box, { marginTop: 1, flexDirection: "column", children: error ? (_jsx(Text, { color: "red", children: error })) : !projects ? (_jsx(Text, { dimColor: true, children: "loading your projects\u2026" })) : (
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
723
|
+
return (_jsxs(Box, { flexDirection: "column", paddingX: 2, marginTop: 1, alignItems: "center", children: [_jsx(Eyebrow, { children: "Manage projects" }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "Pick a project to manage its tables, or onboard a new one." }) }), _jsx(Box, { marginTop: 1, flexDirection: "column", children: error ? (_jsx(Text, { color: "red", children: error })) : !projects ? (_jsx(Text, { dimColor: true, children: "loading your projects\u2026" })) : (
|
|
724
|
+
// Window the project list to the frame height; the "onboard" row stays pinned below it.
|
|
725
|
+
(() => {
|
|
726
|
+
const win = windowList(projects, cursor, Math.max(3, bodyRows - 5));
|
|
727
|
+
return (_jsxs(_Fragment, { children: [win.moreUp > 0 && _jsx(Text, { dimColor: true, children: ` ↑ ${win.moreUp} more` }), win.slice.map((p, idx) => {
|
|
728
|
+
const i = win.start + idx;
|
|
729
|
+
const here = i === cursor;
|
|
730
|
+
const n = totalIssues(p);
|
|
731
|
+
return (_jsxs(Text, { color: here ? "green" : undefined, children: [here ? "❯ " : " ", p.name, " ", _jsxs(Text, { color: n > 0 ? "yellow" : "green", children: ["\u00B7 ", issuesLabel(n)] })] }, p.ref));
|
|
732
|
+
}), win.moreDown > 0 && _jsx(Text, { dimColor: true, children: ` ↓ ${win.moreDown} more` }), _jsxs(Text, { color: cursor === onboardRow ? "green" : undefined, children: [cursor === onboardRow ? "❯ " : " ", "+ Onboard a new project"] })] }));
|
|
733
|
+
})()) })] }));
|
|
614
734
|
}
|
|
615
735
|
// ── Phase: manage a project's table monitoring ───────────────────────────────────
|
|
616
736
|
// Lists the selected project's tables with their current watch state (one row per table, watched or
|
|
617
737
|
// not), each toggleable. Toggles commit immediately via the per-table watch endpoint (toggleDataset).
|
|
618
738
|
export function ManageTables({ ctx }) {
|
|
739
|
+
useFooter(_jsx(Text, { dimColor: true, children: "\u2191\u2193 move \u00B7 space/enter toggle watch \u00B7 esc to go back" }), []);
|
|
740
|
+
const bodyRows = useBodyRows();
|
|
619
741
|
const { services, interactive } = useWizard();
|
|
620
742
|
const projectRef = ctx.projectRef ?? "";
|
|
621
743
|
const [tables, setTables] = useState(null);
|
|
@@ -697,10 +819,16 @@ export function ManageTables({ ctx }) {
|
|
|
697
819
|
else if (input === " " || key.return)
|
|
698
820
|
toggle(cursor);
|
|
699
821
|
}, { isActive: interactive && !!tables });
|
|
700
|
-
return (_jsxs(Box, { flexDirection: "column", paddingX: 2, marginTop: 1, children: [_jsx(Eyebrow, { children: "Table monitoring" }), _jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { dimColor: true, children: "Toggle a table to watch or unwatch it \u2014 changes save as you go." }), projectRef && (_jsxs(Text, { dimColor: true, children: ["Project ", _jsx(Text, { color: "green", children: projectRef })] }))] }), _jsxs(Box, { marginTop: 1, flexDirection: "column", children: [error && _jsx(Text, { color: "red", children: error }), !tables ? (_jsx(Text, { dimColor: true, children: "loading this project's tables\u2026" })) : tables.length === 0 ? (_jsx(Text, { dimColor: true, children: "No tables discovered for this project yet." })) : (
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
822
|
+
return (_jsxs(Box, { flexDirection: "column", paddingX: 2, marginTop: 1, alignItems: "center", children: [_jsx(Eyebrow, { children: "Table monitoring" }), _jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { dimColor: true, children: "Toggle a table to watch or unwatch it \u2014 changes save as you go." }), projectRef && (_jsxs(Text, { dimColor: true, children: ["Project ", _jsx(Text, { color: "green", children: projectRef })] }))] }), _jsxs(Box, { marginTop: 1, flexDirection: "column", children: [error && _jsx(Text, { color: "red", children: error }), !tables ? (_jsx(Text, { dimColor: true, children: "loading this project's tables\u2026" })) : tables.length === 0 ? (_jsx(Text, { dimColor: true, children: "No tables discovered for this project yet." })) : (
|
|
823
|
+
// Window the list to the frame height so the cursor stays on screen on a project with many tables.
|
|
824
|
+
(() => {
|
|
825
|
+
const win = windowList(tables, cursor, Math.max(3, bodyRows - 5));
|
|
826
|
+
return (_jsxs(_Fragment, { children: [win.moreUp > 0 && _jsx(Text, { dimColor: true, children: ` ↑ ${win.moreUp} more` }), win.slice.map((t, idx) => {
|
|
827
|
+
const i = win.start + idx;
|
|
828
|
+
const here = i === cursor;
|
|
829
|
+
return (_jsxs(Text, { color: t.monitored ? "green" : undefined, dimColor: !t.monitored, children: [here ? "❯ " : " ", t.monitored ? "[x]" : "[ ]", " ", t.name] }, t.id));
|
|
830
|
+
}), win.moreDown > 0 && _jsx(Text, { dimColor: true, children: ` ↓ ${win.moreDown} more` })] }));
|
|
831
|
+
})())] })] }));
|
|
704
832
|
}
|
|
705
833
|
// ── Phase: home (trust report + hub menu) ────────────────────────────────────────
|
|
706
834
|
// The post-sign-in landing. Shows a trust report built ONLY from real backend data (no invented
|
|
@@ -714,6 +842,8 @@ function StatRow({ label, children }) {
|
|
|
714
842
|
return (_jsxs(Text, { children: [_jsx(Text, { dimColor: true, children: label.padEnd(16) }), children] }));
|
|
715
843
|
}
|
|
716
844
|
const plural = (n, s) => `${n} ${s}${n === 1 ? "" : "s"}`;
|
|
845
|
+
// "anomaly" has an irregular plural, so the generic -s pluralizer can't render it.
|
|
846
|
+
const anomalyLabel = (n) => `${n} ${n === 1 ? "anomaly" : "anomalies"}`;
|
|
717
847
|
export function Home({ ctx, onDone }) {
|
|
718
848
|
const { exit } = useApp();
|
|
719
849
|
const { services, fast, interactive } = useWizard();
|
|
@@ -758,11 +888,14 @@ export function Home({ ctx, onDone }) {
|
|
|
758
888
|
const list = projects ?? [];
|
|
759
889
|
const watching = list.length > 0;
|
|
760
890
|
const tables = list.reduce((a, p) => a + p.watched, 0);
|
|
761
|
-
const
|
|
762
|
-
const
|
|
763
|
-
const
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
891
|
+
const issues = list.reduce((a, p) => a + p.openIssues, 0); // all open signals = anomalies + broken rules
|
|
892
|
+
const brokenRules = list.reduce((a, p) => a + p.brokenRules, 0);
|
|
893
|
+
const anomalies = Math.max(0, issues - brokenRules);
|
|
894
|
+
const monitors = list.reduce((a, p) => a + p.monitors, 0);
|
|
895
|
+
const rules = list.reduce((a, p) => a + p.rules, 0);
|
|
896
|
+
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, 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
|
+
const here = i === cursor;
|
|
899
|
+
return (_jsxs(Text, { color: here ? "green" : undefined, children: [here ? "❯ " : " ", m.label, " ", _jsxs(Text, { dimColor: true, children: ["\u00B7 ", m.hint] })] }, m.id));
|
|
900
|
+
}) }) }))] }));
|
|
768
901
|
}
|