@dxos/plugin-github 0.13.0 → 0.16.0-next-60712ab191a99ba90316cc4be753e9e11b17100a

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 (114) hide show
  1. package/dist/lib/GitHubCapabilities.mjs +1 -10
  2. package/dist/lib/GitHubEvents.mjs +1 -15
  3. package/dist/lib/GitHubOperation.mjs +1 -358
  4. package/dist/lib/GitHubPlugin.mjs +1 -16
  5. package/dist/lib/Walkthrough.mjs +1 -59
  6. package/dist/lib/capabilities.browser.mjs +1 -2
  7. package/dist/lib/capabilities.browser.mjs.map +1 -1
  8. package/dist/lib/capabilities.mjs +1 -2
  9. package/dist/lib/capabilities.mjs.map +1 -1
  10. package/dist/lib/capabilities.tauri.mjs +1 -2
  11. package/dist/lib/capabilities.tauri.mjs.map +1 -1
  12. package/dist/lib/chunk-Extensions.mjs +18 -0
  13. package/dist/lib/chunk-Extensions.mjs.map +1 -0
  14. package/dist/lib/chunk-GitHubCapabilities.mjs +10 -0
  15. package/dist/lib/chunk-GitHubCapabilities.mjs.map +1 -0
  16. package/dist/lib/chunk-GitHubEvents.mjs +15 -0
  17. package/dist/lib/chunk-GitHubEvents.mjs.map +1 -0
  18. package/dist/lib/chunk-GitHubOperation.mjs +386 -0
  19. package/dist/lib/chunk-GitHubOperation.mjs.map +1 -0
  20. package/dist/lib/chunk-GitHubPlugin.mjs +16 -0
  21. package/dist/lib/chunk-GitHubPlugin.mjs.map +1 -0
  22. package/dist/lib/chunk-ImportPullRequestDialog.mjs.map +1 -1
  23. package/dist/lib/chunk-PLUGIN.mjs +1 -1
  24. package/dist/lib/chunk-PullRequestArticle.mjs +64 -21
  25. package/dist/lib/chunk-PullRequestArticle.mjs.map +1 -1
  26. package/dist/lib/chunk-PullRequestArticle2.mjs +1 -2
  27. package/dist/lib/chunk-PullRequestCardMenu.mjs +1 -1
  28. package/dist/lib/chunk-PullRequestsArticle.mjs +3 -3
  29. package/dist/lib/chunk-PullRequestsArticle.mjs.map +1 -1
  30. package/dist/lib/chunk-Walkthrough.mjs +59 -0
  31. package/dist/lib/chunk-Walkthrough.mjs.map +1 -0
  32. package/dist/lib/chunk-WalkthroughArticle.mjs +1 -1
  33. package/dist/lib/chunk-add-pull-request-comment.mjs.map +1 -1
  34. package/dist/lib/chunk-add-pull-request-review-comment.mjs.map +1 -1
  35. package/dist/lib/chunk-connector.mjs.map +1 -1
  36. package/dist/lib/chunk-generate-walkthrough.mjs.map +1 -1
  37. package/dist/lib/chunk-get-pull-request-diff.mjs.map +1 -1
  38. package/dist/lib/chunk-get-pull-request-status.mjs.map +1 -1
  39. package/dist/lib/chunk-get-repositories.mjs.map +1 -1
  40. package/dist/lib/chunk-github-api.mjs +1 -0
  41. package/dist/lib/chunk-github-api.mjs.map +1 -1
  42. package/dist/lib/chunk-import-pull-request.mjs +78 -3
  43. package/dist/lib/chunk-import-pull-request.mjs.map +1 -1
  44. package/dist/lib/chunk-link-resolver.mjs.map +1 -1
  45. package/dist/lib/chunk-pull-request2.mjs +1 -0
  46. package/dist/lib/chunk-pull-request2.mjs.map +1 -1
  47. package/dist/lib/chunk-react-surface.mjs +4 -4
  48. package/dist/lib/chunk-react-surface.mjs.map +1 -1
  49. package/dist/lib/chunk-refresh-pull-requests.mjs +49 -0
  50. package/dist/lib/chunk-refresh-pull-requests.mjs.map +1 -0
  51. package/dist/lib/chunk-submit-pull-request-approval.mjs.map +1 -1
  52. package/dist/lib/chunk-sync-pull-request.mjs +11 -9
  53. package/dist/lib/chunk-sync-pull-request.mjs.map +1 -1
  54. package/dist/lib/chunk-sync.mjs.map +1 -1
  55. package/dist/lib/index.mjs +2 -2
  56. package/dist/lib/meta.mjs.map +1 -1
  57. package/dist/lib/ns/Extensions.mjs +2 -16
  58. package/dist/lib/operations.mjs +2 -1
  59. package/dist/lib/operations.mjs.map +1 -1
  60. package/dist/lib/types.mjs +4 -4
  61. package/dist/types/src/capabilities/gen/browser.d.ts.map +1 -1
  62. package/dist/types/src/capabilities/gen/tauri.d.ts.map +1 -1
  63. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  64. package/dist/types/src/cards/GitHubCard.d.ts.map +1 -1
  65. package/dist/types/src/components/PullRequestOverview/CheckRunList.d.ts +6 -3
  66. package/dist/types/src/components/PullRequestOverview/CheckRunList.d.ts.map +1 -1
  67. package/dist/types/src/components/PullRequestOverview/CheckRunList.test.d.ts +2 -0
  68. package/dist/types/src/components/PullRequestOverview/CheckRunList.test.d.ts.map +1 -0
  69. package/dist/types/src/components/PullRequestOverview/PullRequestOverview.d.ts.map +1 -1
  70. package/dist/types/src/components/PullRequestStatus/PullRequestStatus.d.ts.map +1 -1
  71. package/dist/types/src/operations/import-pull-request.d.ts.map +1 -1
  72. package/dist/types/src/operations/index.d.ts.map +1 -1
  73. package/dist/types/src/operations/pull-request.d.ts.map +1 -1
  74. package/dist/types/src/operations/refresh-pull-requests.d.ts +5 -0
  75. package/dist/types/src/operations/refresh-pull-requests.d.ts.map +1 -0
  76. package/dist/types/src/operations/refresh.d.ts +37 -0
  77. package/dist/types/src/operations/refresh.d.ts.map +1 -0
  78. package/dist/types/src/operations/refresh.test.d.ts +2 -0
  79. package/dist/types/src/operations/refresh.test.d.ts.map +1 -0
  80. package/dist/types/src/operations/sync-pull-request.d.ts.map +1 -1
  81. package/dist/types/src/services/github-api.d.ts +1 -0
  82. package/dist/types/src/services/github-api.d.ts.map +1 -1
  83. package/dist/types/src/stories/PullRequestOverview.stories.d.ts +2 -0
  84. package/dist/types/src/stories/PullRequestOverview.stories.d.ts.map +1 -1
  85. package/dist/types/src/types/GitHubOperation.d.ts +14 -0
  86. package/dist/types/src/types/GitHubOperation.d.ts.map +1 -1
  87. package/dist/types/tsconfig.tsbuildinfo +1 -1
  88. package/package.json +47 -47
  89. package/src/capabilities/gen/browser.ts +1 -3
  90. package/src/capabilities/gen/tauri.ts +1 -3
  91. package/src/capabilities/index.ts +1 -4
  92. package/src/cards/GitHubCard.tsx +7 -3
  93. package/src/components/PullRequestOverview/ArtifactPill.tsx +1 -1
  94. package/src/components/PullRequestOverview/CheckRunList.test.ts +29 -0
  95. package/src/components/PullRequestOverview/CheckRunList.tsx +62 -13
  96. package/src/components/PullRequestOverview/PullRequestOverview.tsx +5 -1
  97. package/src/components/PullRequestStatus/PullRequestStatus.tsx +8 -5
  98. package/src/containers/PullRequestsArticle/PullRequestsArticle.tsx +12 -10
  99. package/src/operations/import-pull-request.ts +8 -0
  100. package/src/operations/index.ts +1 -0
  101. package/src/operations/pull-request.ts +1 -0
  102. package/src/operations/refresh-pull-requests.ts +69 -0
  103. package/src/operations/refresh.test.ts +112 -0
  104. package/src/operations/refresh.ts +111 -0
  105. package/src/operations/sync-pull-request.ts +10 -13
  106. package/src/services/github-api.ts +1 -0
  107. package/src/stories/PullRequestOverview.stories.tsx +22 -1
  108. package/src/types/GitHubOperation.ts +28 -0
  109. package/dist/lib/GitHubCapabilities.mjs.map +0 -1
  110. package/dist/lib/GitHubEvents.mjs.map +0 -1
  111. package/dist/lib/GitHubOperation.mjs.map +0 -1
  112. package/dist/lib/GitHubPlugin.mjs.map +0 -1
  113. package/dist/lib/Walkthrough.mjs.map +0 -1
  114. package/dist/lib/ns/Extensions.mjs.map +0 -1
@@ -14,11 +14,11 @@ import * as Schema from "effect/Schema";
14
14
  import * as AppCapabilities from "@dxos/app-toolkit/AppCapabilities";
15
15
  import * as LayoutOperation from "@dxos/app-toolkit/LayoutOperation";
16
16
  import { log } from "@dxos/log";
17
+ import { useObject, useQuery } from "@dxos/echo-react";
17
18
  import * as Card from "@dxos/react-ui/Card";
18
19
  import * as Hooks from "@dxos/react-ui/Hooks";
19
20
  import * as Layout from "@dxos/react-ui/Layout";
20
21
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
21
- import { useObject, useQuery } from "@dxos/echo-react";
22
22
  import * as Hooks$1 from "@dxos/app-framework/Hooks";
23
23
  import * as ToolkitHooks from "@dxos/app-toolkit/Hooks";
24
24
  import * as EffectEx from "@dxos/effect/EffectEx";
@@ -40,6 +40,7 @@ import { TextEditor } from "@dxos/react-ui-editor";
40
40
  import { DxAnchor } from "@dxos/lit-ui/react";
41
41
  import { MarkdownLink, MarkdownView } from "@dxos/react-ui-markdown";
42
42
  import * as Icon from "@dxos/react-ui/Icon";
43
+ import * as Typography from "@dxos/react-ui/Typography";
43
44
  import { Masonry } from "@dxos/react-ui-masonry";
44
45
  //#region src/components/PullRequestFiles/files.ts
45
46
  /** Id of the synthetic root the tree model anchors its top-level rows to; never rendered. */
@@ -575,7 +576,7 @@ var ArtifactPill = ({ artifact, children }) => {
575
576
  size: "sm",
576
577
  classNames: "bg-input-surface text-fg font-normal ring-inset ring ring-neutral-border hover:bg-hover-surface hover:ring-info-border align-baseline",
577
578
  icon: artifactIcon[artifact.kind],
578
- iconClassNames: artifact.kind === "video" ? "text-violet-500" : "text-sky-500",
579
+ iconClassNames: artifact.kind === "video" ? "text-violet-text" : "text-sky-text",
579
580
  label,
580
581
  "data-testid": "pull-request.artifact.pill"
581
582
  })
@@ -619,50 +620,85 @@ var outcomeOrder = [
619
620
  "neutral",
620
621
  "skipped"
621
622
  ];
622
- /** `4m 12s`, or undefined for a run that has not both started and finished. */
623
- var formatDuration = (startedAt, completedAt) => {
624
- if (!startedAt || !completedAt) return;
625
- const seconds = Math.max(0, Math.round((Date.parse(completedAt) - Date.parse(startedAt)) / 1e3));
623
+ /**
624
+ * `4m 12s` from start to finish, or to `now` for a run still in progress;
625
+ * undefined for a run that has not started, or has not finished when no `now` is given.
626
+ */
627
+ var formatDuration = (startedAt, completedAt, now) => {
628
+ const end = completedAt ? Date.parse(completedAt) : now;
629
+ if (!startedAt || end === void 0) return;
630
+ const seconds = Math.max(0, Math.round((end - Date.parse(startedAt)) / 1e3));
626
631
  if (Number.isNaN(seconds)) return;
627
632
  const minutes = Math.floor(seconds / 60);
628
633
  return minutes > 0 ? `${minutes}m ${seconds % 60}s` : `${seconds}s`;
629
634
  };
635
+ /** The current time, re-rendering once a second while `active` so elapsed times stay current. */
636
+ var useNow = (active) => {
637
+ const [now, setNow] = useState(() => Date.now());
638
+ useEffect(() => {
639
+ if (!active) return;
640
+ setNow(Date.now());
641
+ const interval = setInterval(() => setNow(Date.now()), 1e3);
642
+ return () => clearInterval(interval);
643
+ }, [active]);
644
+ return now;
645
+ };
646
+ /** The row's value: GitHub's run id, or its name and URL for a run recorded without one. */
647
+ var checkRunId = (run) => run.id !== void 0 ? String(run.id) : `${run.name}-${run.url ?? ""}`;
630
648
  /** Sorts runs by what needs attention, then by name so shards read in order. */
631
649
  var sortCheckRuns = (runs) => [...runs].sort((a, b) => outcomeOrder.indexOf(a.outcome) - outcomeOrder.indexOf(b.outcome) || a.name.localeCompare(b.name, void 0, { numeric: true }));
632
- /** Every check on the head commit: its outcome, how long it took, and its logs a click away. */
650
+ /** Every check on the head commit: its outcome, how long it took, and a button to its logs. */
633
651
  var CheckRunList = ({ runs }) => {
634
652
  const { t } = Hooks.useTranslation(meta.profile.key);
635
653
  const sorted = useMemo(() => runs ? sortCheckRuns(runs) : void 0, [runs]);
636
654
  const summary = useCheckSummary(runs);
655
+ const now = useNow(runs?.some((run) => run.outcome === "pending" && run.startedAt) ?? false);
656
+ const [current, setCurrent] = useState();
637
657
  if (!sorted || sorted.length === 0) return /* @__PURE__ */ jsx(Status.Empty, { children: t(sorted ? "no-checks.message" : "checks-loading.message") });
638
658
  return /* @__PURE__ */ jsx(Listbox.Root, {
639
659
  items: sorted.map((run) => ({
640
- value: `${run.name}-${run.url ?? ""}`,
660
+ value: checkRunId(run),
641
661
  label: run.name
642
662
  })),
663
+ columns: "var(--dx-block-size) minmax(0, 1fr) max-content var(--dx-block-size)",
664
+ onHighlightChange: (value) => value && setCurrent(value),
643
665
  children: /* @__PURE__ */ jsx(Listbox.Content, {
644
666
  "aria-label": summary,
645
667
  "data-testid": "pull-request.checks",
646
668
  children: sorted.map((run) => {
647
669
  const { icon, classNames } = outcomeIcon[run.outcome];
648
- const duration = formatDuration(run.startedAt, run.completedAt);
670
+ const duration = formatDuration(run.startedAt, run.completedAt, run.outcome === "pending" ? now : void 0);
649
671
  const detail = run.conclusion && run.conclusion !== run.outcome && run.conclusion !== "failure" ? run.conclusion.replace(/_/g, " ") : void 0;
650
- const outcome = run.outcome === "skipped" ? t("check-outcome.skipped.label") : duration ?? t(`check-outcome.${run.outcome}.label`);
672
+ const outcome = run.outcome === "skipped" ? t("check-outcome.skipped.label") : run.outcome === "pending" ? [t("check-outcome.pending.label"), duration].filter(Boolean).join(" · ") : duration ?? t(`check-outcome.${run.outcome}.label`);
651
673
  const url = run.url;
674
+ const id = checkRunId(run);
652
675
  return /* @__PURE__ */ jsxs(Listbox.Item, {
653
- id: `${run.name}-${url ?? ""}`,
676
+ id,
677
+ current: id === current,
678
+ highlightOnHover: false,
679
+ classNames: "dx-hover",
654
680
  "data-outcome": run.outcome,
655
681
  "data-testid": "pull-request.check",
656
- onClick: url ? () => window.open(url, "_blank", "noopener,noreferrer") : void 0,
657
682
  children: [
658
683
  /* @__PURE__ */ jsx(Listbox.ItemIcon, {
659
684
  icon,
660
685
  classNames
661
686
  }),
662
687
  /* @__PURE__ */ jsx(Listbox.ItemText, { children: run.name }),
663
- /* @__PURE__ */ jsx(Listbox.ItemDescription, { children: [detail, outcome].filter(Boolean).join(" · ") })
688
+ /* @__PURE__ */ jsx(Listbox.ItemDescription, {
689
+ classNames: "text-right tabular-nums",
690
+ children: [detail, outcome].filter(Boolean).join(" · ")
691
+ }),
692
+ url ? /* @__PURE__ */ jsx(Button.Root, {
693
+ iconOnly: true,
694
+ variant: "ghost",
695
+ icon: "ph--arrow-square-out--regular",
696
+ label: t("open-link.label"),
697
+ "data-testid": "pull-request.check.open",
698
+ onClick: () => window.open(url, "_blank", "noopener,noreferrer")
699
+ }) : /* @__PURE__ */ jsx("span", {})
664
700
  ]
665
- }, `${run.name}-${url ?? ""}`);
701
+ }, id);
666
702
  })
667
703
  })
668
704
  });
@@ -944,9 +980,12 @@ var PullRequestOverview = ({ body, details, runs }) => {
944
980
  label: t("related.label"),
945
981
  children: /* @__PURE__ */ jsx(RelatedCards, { items: related })
946
982
  }),
947
- /* @__PURE__ */ jsx(Form.FieldSet, {
948
- label: checkSummary,
949
- children: /* @__PURE__ */ jsx(CheckRunList, { runs })
983
+ /* @__PURE__ */ jsxs(Form.FieldSet, {
984
+ label: t("checks.label"),
985
+ children: [runs && runs.length > 0 && /* @__PURE__ */ jsx(Typography.Text, {
986
+ "data-testid": "pull-request.checks.summary",
987
+ children: checkSummary
988
+ }), /* @__PURE__ */ jsx(CheckRunList, { runs })]
950
989
  })
951
990
  ] })
952
991
  })
@@ -1004,9 +1043,11 @@ var ciHue = {
1004
1043
  /** One line answering where the pull request stands: open or merged, approved or not, CI green or red. */
1005
1044
  var PullRequestStatus = ({ reference, title, state, review, ci }) => {
1006
1045
  const { t } = Hooks.useTranslation(meta.profile.key);
1007
- return /* @__PURE__ */ jsxs("div", {
1046
+ return /* @__PURE__ */ jsxs(Layout.Flex, {
1047
+ align: "center",
1048
+ gap: "sm",
1008
1049
  role: "status",
1009
- className: "flex items-center gap-2 px-3 py-1.5 border-b border-separator-subtle text-sm min-w-0",
1050
+ classNames: "px-3 py-1.5 border-b border-separator-subtle text-sm min-w-0",
1010
1051
  "data-testid": "pull-request.status",
1011
1052
  children: [
1012
1053
  /* @__PURE__ */ jsx("span", {
@@ -1018,8 +1059,10 @@ var PullRequestStatus = ({ reference, title, state, review, ci }) => {
1018
1059
  className: "truncate grow",
1019
1060
  children: title
1020
1061
  }),
1021
- /* @__PURE__ */ jsxs("div", {
1022
- className: "flex items-center gap-2 shrink-0 ml-auto",
1062
+ /* @__PURE__ */ jsxs(Layout.Flex, {
1063
+ align: "center",
1064
+ gap: "sm",
1065
+ classNames: "shrink-0 ml-auto",
1023
1066
  children: [
1024
1067
  state && /* @__PURE__ */ jsx("span", {
1025
1068
  className: "dx-tag dx-tag-inline",