@kud/gh-ink 0.9.0 → 0.9.1

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/index.d.ts CHANGED
@@ -217,7 +217,7 @@ declare const ActionMenu: ({ item, actions, cursor, }: {
217
217
  actions: Action[];
218
218
  cursor: number;
219
219
  }) => React.JSX.Element;
220
- declare const App: ({ fetcher, cacheKey, title, detailFor, isWorkRepo, initialIncludeWork, jiraBase, jiraKeyRe, jiraTransitions, workToggle, hasCiStatus, ciJob, ciFetcher, ciPollMs, extensions, tabHelp, }: {
220
+ declare const App: ({ fetcher, cacheKey, title, detailFor, isWorkRepo, initialIncludeWork, jiraBase, jiraKeyRe, jiraTransitions, workToggle, hasCiStatus, ciJob, ciFetcher, ciPollMs, extensions, tabHelp, emptyHint, }: {
221
221
  fetcher: () => Promise<{
222
222
  sections: Section[];
223
223
  login: string;
@@ -229,6 +229,7 @@ declare const App: ({ fetcher, cacheKey, title, detailFor, isWorkRepo, initialIn
229
229
  isWorkRepo?: (repo: string) => boolean;
230
230
  initialIncludeWork?: boolean;
231
231
  tabHelp?: [string, string][];
232
+ emptyHint?: string;
232
233
  jiraBase?: string;
233
234
  jiraKeyRe?: RegExp;
234
235
  jiraTransitions?: JiraTransition[];
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import React2, { createContext, useState, useRef, useEffect, useContext } from 'react';
2
2
  import { useWindowSize, useInput, Text, Box } from 'ink';
3
- import { colors, ScrollView, TextInput, LoadingScreen, Switch, useListCursor, Tabs, FooterHints } from '@kud/ink-ui';
3
+ import { colors, ScrollView, TextInput, LoadingScreen, Switch, StatusMessage, FooterHints, useListCursor, Tabs } from '@kud/ink-ui';
4
4
  import { isPassCheck, isFailCheck, resolveThread, unresolveThread, replyToThread, rerunFailedRun, mergePr, reRequestReviewer } from '@kud/gh';
5
5
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
6
6
  import { $ } from 'zx';
@@ -1363,13 +1363,14 @@ var InboxHeader = ({
1363
1363
  brand,
1364
1364
  work,
1365
1365
  loading,
1366
+ quiet,
1366
1367
  refreshing,
1367
1368
  hasPending,
1368
1369
  fetchedAt
1369
1370
  }) => {
1370
1371
  const total = sections.reduce((n, s) => n + topLevelCount(s), 0);
1371
- const countSeg = loading ? " loading\u2026 " : ` ${String(total).padStart(3)} item${total !== 1 ? "s" : ""} \xB7 `;
1372
- const userSeg = loading ? "" : `@${login} `;
1372
+ const countSeg = loading ? " loading\u2026 " : quiet ? " " : ` ${String(total).padStart(3)} item${total !== 1 ? "s" : ""} \xB7 `;
1373
+ const userSeg = loading || quiet ? "" : `@${login} `;
1373
1374
  const workLabel = work === void 0 ? "" : " w work \u25CF\u2500\u25CB home ";
1374
1375
  const [statusText, statusColor] = hasPending ? ["\u25CF new \xB7 r apply", "#FF8700"] : refreshing ? ["\u21BB refreshing\u2026", "cyan"] : fetchedAt ? [`updated ${agoText(fetchedAt)}`, void 0] : ["", void 0];
1375
1376
  const statusSeg = statusText ? statusText + " " : "";
@@ -2280,6 +2281,29 @@ var BrowseScreen = ({
2280
2281
  }
2281
2282
  );
2282
2283
  };
2284
+ var NoRowsScreen = ({
2285
+ reason,
2286
+ detail,
2287
+ onRetry
2288
+ }) => {
2289
+ useInput((input) => {
2290
+ if (input === "q") process.exit(0);
2291
+ if (input === "r") onRetry();
2292
+ });
2293
+ return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
2294
+ /* @__PURE__ */ jsx(StatusMessage, { variant: reason === "empty" ? "info" : "error", children: reason === "empty" ? "Nothing open." : `Fetch failed \u2014 ${detail ?? "no reason reported"}` }),
2295
+ reason === "empty" && detail ? /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Text2, { dimColor: true, children: detail }) }) : null,
2296
+ /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(
2297
+ FooterHints,
2298
+ {
2299
+ hints: [
2300
+ ["r", "retry"],
2301
+ ["q", "quit"]
2302
+ ]
2303
+ }
2304
+ ) })
2305
+ ] });
2306
+ };
2283
2307
  var signatureOf = (sections) => JSON.stringify(sections, (k, v) => k === "age" ? void 0 : v);
2284
2308
  var App = ({
2285
2309
  fetcher,
@@ -2297,7 +2321,8 @@ var App = ({
2297
2321
  ciFetcher,
2298
2322
  ciPollMs = 6e4,
2299
2323
  extensions,
2300
- tabHelp
2324
+ tabHelp,
2325
+ emptyHint
2301
2326
  }) => {
2302
2327
  const [state, setState] = useState({ phase: "loading" });
2303
2328
  const [pending, setPending] = useState(null);
@@ -2329,8 +2354,8 @@ var App = ({
2329
2354
  const freshKey = signatureOf(fresh.sections);
2330
2355
  if (!displayedKey.current) {
2331
2356
  if (fresh.sections.length === 0) {
2332
- console.log(`${title[0].toUpperCase()}${title.slice(1)} empty.`);
2333
- process.exit(0);
2357
+ setState({ phase: "empty" });
2358
+ return;
2334
2359
  }
2335
2360
  showData(fresh.sections, fresh.login);
2336
2361
  } else if (freshKey !== displayedKey.current) {
@@ -2342,8 +2367,8 @@ var App = ({
2342
2367
  setRefreshing(false);
2343
2368
  const message = err.message;
2344
2369
  if (!displayedKey.current) {
2345
- console.error("Error:", message);
2346
- process.exit(1);
2370
+ setState({ phase: "failed", message });
2371
+ return;
2347
2372
  }
2348
2373
  setRefreshError({ message, at: Date.now() });
2349
2374
  });
@@ -2387,7 +2412,7 @@ var App = ({
2387
2412
  clearInterval(id);
2388
2413
  };
2389
2414
  }, [hasCiStatus, ciFetcher, ciPollMs]);
2390
- if (state.phase === "loading")
2415
+ if (state.phase === "loading" || state.phase === "empty" || state.phase === "failed")
2391
2416
  return /* @__PURE__ */ jsxs(
2392
2417
  Box,
2393
2418
  {
@@ -2404,12 +2429,20 @@ var App = ({
2404
2429
  brand: brandOf(title),
2405
2430
  sections: [],
2406
2431
  login: "",
2407
- work: workToggle ? initialIncludeWork ?? true : void 0,
2408
- loading: true
2432
+ work: workToggle && state.phase === "loading" ? initialIncludeWork ?? true : void 0,
2433
+ loading: state.phase === "loading",
2434
+ quiet: state.phase !== "loading"
2409
2435
  }
2410
2436
  ),
2411
2437
  hasCiStatus ? /* @__PURE__ */ jsx(CiStatusLine, { state: ciStatusState, job: ciJob }) : null,
2412
- /* @__PURE__ */ jsx(LoadingScreen, { label: `Fetching ${title}\u2026` })
2438
+ state.phase === "loading" ? /* @__PURE__ */ jsx(LoadingScreen, { label: `Fetching ${title}\u2026` }) : /* @__PURE__ */ jsx(
2439
+ NoRowsScreen,
2440
+ {
2441
+ reason: state.phase === "empty" ? "empty" : "failed",
2442
+ detail: state.phase === "failed" ? state.message : emptyHint,
2443
+ onRetry: () => revalidate(true)
2444
+ }
2445
+ )
2413
2446
  ]
2414
2447
  }
2415
2448
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kud/gh-ink",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "Ink components for rendering GitHub PR review comments and health — controlled, presentation-only, built on @kud/ink-ui and fed by @kud/gh.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",