lazyreview 1.0.39 → 1.0.40

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 (2) hide show
  1. package/dist/cli.js +80 -0
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -86641,6 +86641,7 @@ var shortcutGroups = [
86641
86641
  { key: "E", description: "Request re-review" },
86642
86642
  { key: "m", description: "Merge PR" },
86643
86643
  { key: "T", description: "Edit PR title" },
86644
+ { key: "W", description: "Toggle draft / ready for review" },
86644
86645
  { key: "X", description: "Close / Reopen PR" },
86645
86646
  { key: "G", description: "Checkout PR branch locally" },
86646
86647
  { key: "] / [", description: "Next / Previous PR" }
@@ -117539,6 +117540,7 @@ var BranchRef = class extends Schema_exports.Class("BranchRef")({
117539
117540
  };
117540
117541
  var PullRequest = class extends Schema_exports.Class("PullRequest")({
117541
117542
  id: Schema_exports.Number,
117543
+ node_id: Schema_exports.optionalWith(Schema_exports.String, { default: () => "" }),
117542
117544
  number: Schema_exports.Number,
117543
117545
  title: Schema_exports.String,
117544
117546
  body: Schema_exports.optionalWith(Schema_exports.NullOr(Schema_exports.String), { default: () => null }),
@@ -118431,6 +118433,30 @@ var GitHubApiLive = Layer_exports.effect(
118431
118433
  { title }
118432
118434
  );
118433
118435
  }),
118436
+ convertToDraft: (nodeId) => Effect_exports.gen(function* () {
118437
+ const token = yield* auth.getToken();
118438
+ yield* graphqlGitHub(
118439
+ token,
118440
+ `mutation($pullRequestId: ID!) {
118441
+ convertPullRequestToDraft(input: { pullRequestId: $pullRequestId }) {
118442
+ pullRequest { isDraft }
118443
+ }
118444
+ }`,
118445
+ { pullRequestId: nodeId }
118446
+ );
118447
+ }),
118448
+ markReadyForReview: (nodeId) => Effect_exports.gen(function* () {
118449
+ const token = yield* auth.getToken();
118450
+ yield* graphqlGitHub(
118451
+ token,
118452
+ `mutation($pullRequestId: ID!) {
118453
+ markPullRequestAsReady(input: { pullRequestId: $pullRequestId }) {
118454
+ pullRequest { isDraft }
118455
+ }
118456
+ }`,
118457
+ { pullRequestId: nodeId }
118458
+ );
118459
+ }),
118434
118460
  getCurrentUser: () => Effect_exports.gen(function* () {
118435
118461
  const token = yield* auth.getToken();
118436
118462
  return yield* fetchGitHub(
@@ -118745,6 +118771,20 @@ var useEditReviewComment = createGitHubMutation({
118745
118771
  effect: (api, p) => api.editReviewComment(p.owner, p.repo, p.commentId, p.body),
118746
118772
  invalidateKeys: (p) => invalidatePRThreads(p.owner, p.repo, p.prNumber)
118747
118773
  });
118774
+ var useConvertToDraft = createGitHubMutation({
118775
+ effect: (api, p) => api.convertToDraft(p.nodeId),
118776
+ invalidateKeys: (p) => [
118777
+ ["pr", p.owner, p.repo, p.prNumber],
118778
+ ...invalidatePRLists()
118779
+ ]
118780
+ });
118781
+ var useMarkReadyForReview = createGitHubMutation({
118782
+ effect: (api, p) => api.markReadyForReview(p.nodeId),
118783
+ invalidateKeys: (p) => [
118784
+ ["pr", p.owner, p.repo, p.prNumber],
118785
+ ...invalidatePRLists()
118786
+ ]
118787
+ });
118748
118788
 
118749
118789
  // src/hooks/useGitHub.ts
118750
118790
  function usePullRequests(owner, repo, options) {
@@ -124632,6 +124672,7 @@ function PRDetailScreen({
124632
124672
  const theme14 = useTheme();
124633
124673
  const [currentTab, setCurrentTab] = (0, import_react87.useState)(0);
124634
124674
  const [showDiscardConfirm, setShowDiscardConfirm] = (0, import_react87.useState)(false);
124675
+ const [showDraftConfirm, setShowDraftConfirm] = (0, import_react87.useState)(false);
124635
124676
  const [initialFile, setInitialFile] = (0, import_react87.useState)(void 0);
124636
124677
  const contentHeight = Math.max(1, (stdout?.rows ?? 24) - PR_DETAIL_RESERVED_LINES);
124637
124678
  import_react87.default.useEffect(() => {
@@ -124691,6 +124732,8 @@ function PRDetailScreen({
124691
124732
  prNumber: pr.number,
124692
124733
  setStatusMessage
124693
124734
  });
124735
+ const convertToDraft = useConvertToDraft();
124736
+ const markReady = useMarkReadyForReview();
124694
124737
  const handleReviewSubmit = (0, import_react87.useCallback)(
124695
124738
  (body, event) => {
124696
124739
  if (pendingReview.isActive) {
@@ -124742,6 +124785,36 @@ function PRDetailScreen({
124742
124785
  }
124743
124786
  return;
124744
124787
  }
124788
+ if (showDraftConfirm) {
124789
+ if (input === "y" || input === "Y") {
124790
+ setShowDraftConfirm(false);
124791
+ const nodeId = activePR.node_id;
124792
+ if (!nodeId) {
124793
+ setStatusMessage("Cannot toggle draft: missing node_id");
124794
+ return;
124795
+ }
124796
+ if (activePR.draft) {
124797
+ markReady.mutate(
124798
+ { owner, repo, prNumber: pr.number, nodeId },
124799
+ {
124800
+ onSuccess: () => setStatusMessage("PR marked as ready for review"),
124801
+ onError: (err) => setStatusMessage(`Error: ${String(err)}`)
124802
+ }
124803
+ );
124804
+ } else {
124805
+ convertToDraft.mutate(
124806
+ { owner, repo, prNumber: pr.number, nodeId },
124807
+ {
124808
+ onSuccess: () => setStatusMessage("PR converted to draft"),
124809
+ onError: (err) => setStatusMessage(`Error: ${String(err)}`)
124810
+ }
124811
+ );
124812
+ }
124813
+ } else {
124814
+ setShowDraftConfirm(false);
124815
+ }
124816
+ return;
124817
+ }
124745
124818
  if (modals.showCloseConfirm) {
124746
124819
  if (input === "y" || input === "Y") {
124747
124820
  modals.handleClosePR();
@@ -124790,6 +124863,12 @@ function PRDetailScreen({
124790
124863
  onNavigate("next");
124791
124864
  } else if (input === "[" && onNavigate) {
124792
124865
  onNavigate("prev");
124866
+ } else if (input === "W") {
124867
+ if (activePR.state === "open") {
124868
+ setShowDraftConfirm(true);
124869
+ } else {
124870
+ setStatusMessage("Can only toggle draft on open PRs");
124871
+ }
124793
124872
  } else if (input === "T") {
124794
124873
  modals.handleOpenEditTitle({ title: activePR.title });
124795
124874
  } else if (input === "G") {
@@ -124951,6 +125030,7 @@ function PRDetailScreen({
124951
125030
  error: pendingReview.isActive ? pendingReview.error : modals.commentError
124952
125031
  }
124953
125032
  ),
125033
+ showDraftConfirm && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Box_default, { paddingX: 1, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Text, { color: theme14.colors.warning, bold: true, children: activePR.draft ? `Mark PR #${pr.number} as ready for review? (y/n)` : `Convert PR #${pr.number} to draft? (y/n)` }) }),
124954
125034
  modals.showCloseConfirm && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Box_default, { paddingX: 1, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(Text, { color: theme14.colors.warning, bold: true, children: [
124955
125035
  "Close PR #",
124956
125036
  pr.number,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lazyreview",
3
- "version": "1.0.39",
3
+ "version": "1.0.40",
4
4
  "description": "A TUI code review tool for GitHub PRs",
5
5
  "type": "module",
6
6
  "author": "Tauan Camargo",