sodabase 0.1.7 → 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.
Files changed (3) hide show
  1. package/dist/app.js +11 -6
  2. package/dist/ui.js +16 -8
  3. package/package.json +1 -1
package/dist/app.js CHANGED
@@ -1,5 +1,5 @@
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
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;
@@ -118,8 +118,13 @@ export function App({ services, fast, interactive, signedIn, demo, fullscreen })
118
118
  // Too-small guard (fullscreen only): below the minimum the frame clips/wraps, so show a resize prompt rather
119
119
  // than a broken layout. Reactive — useTerminalSize re-renders on resize, so enlarging restores the wizard.
120
120
  // Piped/CI (size null) is never gated: there's no window to resize and the output is plain and scrollable.
121
- if (size && (size.columns < MIN_COLS || size.rows < MIN_ROWS)) {
122
- return (_jsx(WizardProvider, { value: { services, fast, interactive, signedIn, demo }, children: _jsx(TooSmall, { size: size }) }));
123
- }
124
- return (_jsx(WizardProvider, { value: { services, fast, interactive, signedIn, demo }, children: _jsx(Chrome, { size: size, children: Current ? _jsx(Current, { ctx: ctx, onDone: onDone }) : null }) }));
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 }) })] }));
125
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
@@ -258,7 +266,7 @@ export function SignIn({ onDone }) {
258
266
  void go(); // non-interactive: env/default provider, no picker
259
267
  return () => void (on = false);
260
268
  }, []);
261
- useInput((input, key) => {
269
+ useGatedInput((input, key) => {
262
270
  // Escape steps back through the text-entry stages (so it never destroys a half-typed sign-in);
263
271
  // from the picker or a transient stage it quits. SignIn owns escape entirely — App's global
264
272
  // handler defers to the sign-in screen.
@@ -434,7 +442,7 @@ export function Connect({ onDone }) {
434
442
  // later pick of a NEW project resets the flag left over from a previous "manage" round.
435
443
  onDone({ connectionId: connId, projectRef: ref, alreadyWatching: !!project?.watching });
436
444
  }
437
- useInput((_i, key) => {
445
+ useGatedInput((_i, key) => {
438
446
  if (!projects || chosen)
439
447
  return;
440
448
  if (key.upArrow)
@@ -478,7 +486,7 @@ export function AgentView({ ctx, onDone }) {
478
486
  // completed step's line while the job sat on it, printing the same row several times over.
479
487
  const loggedRef = useRef(new Set());
480
488
  useFooter(_jsx(Text, { dimColor: true, children: finished ? "done · enter to continue" : "setting up… · esc to cancel" }), [finished]);
481
- useInput((_i, key) => {
489
+ useGatedInput((_i, key) => {
482
490
  if (key.return)
483
491
  onDone({});
484
492
  }, { isActive: interactive && finished });
@@ -593,7 +601,7 @@ export function ScopeAdjust({ onDone }) {
593
601
  setError(e instanceof Error ? e.message : String(e));
594
602
  }
595
603
  }
596
- useInput((_i, key) => {
604
+ useGatedInput((_i, key) => {
597
605
  if (!proposals || committed)
598
606
  return;
599
607
  if (key.upArrow)
@@ -689,7 +697,7 @@ export function McpInstall({ onDone }) {
689
697
  setError(e instanceof Error ? e.message : String(e));
690
698
  }
691
699
  }
692
- useInput((input, key) => {
700
+ useGatedInput((input, key) => {
693
701
  if (busy)
694
702
  return;
695
703
  if (ready) {
@@ -754,7 +762,7 @@ export function ManageProjects({ onDone }) {
754
762
  };
755
763
  }, []);
756
764
  const onboardRow = projects?.length ?? 0; // the "+ onboard a new project" row sits after the projects
757
- useInput((_i, key) => {
765
+ useGatedInput((_i, key) => {
758
766
  if (!projects)
759
767
  return;
760
768
  if (key.upArrow)
@@ -858,7 +866,7 @@ export function ManageTables({ ctx }) {
858
866
  }
859
867
  })();
860
868
  }
861
- useInput((input, key) => {
869
+ useGatedInput((input, key) => {
862
870
  if (!tables || tables.length === 0)
863
871
  return;
864
872
  if (key.upArrow)
@@ -935,7 +943,7 @@ export function Home({ ctx, onDone }) {
935
943
  const t = setTimeout(() => exit(), fast ? 400 : 3200);
936
944
  return () => clearTimeout(t);
937
945
  }, [interactive]);
938
- useInput((_i, key) => {
946
+ useGatedInput((_i, key) => {
939
947
  if (key.upArrow)
940
948
  setCursor((c) => Math.max(0, c - 1));
941
949
  else if (key.downArrow)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sodabase",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Sodabase onboarding wizard — interactive CLI (npx sodabase).",
5
5
  "license": "UNLICENSED",
6
6
  "homepage": "https://sodabase.io",