paperclip-github-plugin 0.15.3 → 0.15.5

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/manifest.js CHANGED
@@ -675,7 +675,7 @@ var COMPANY_METRIC_API_ROUTE_URL_PATH = `/api/plugins/${GITHUB_SYNC_PLUGIN_ID}/a
675
675
  var require2 = createRequire(import.meta.url);
676
676
  var packageJson = require2("../package.json");
677
677
  var SCHEDULE_TICK_CRON = "* * * * *";
678
- var MANIFEST_VERSION = "0.15.3"?.trim() || typeof packageJson.version === "string" && packageJson.version.trim() || process.env.npm_package_version?.trim() || "0.0.0-dev";
678
+ var MANIFEST_VERSION = "0.15.5"?.trim() || typeof packageJson.version === "string" && packageJson.version.trim() || process.env.npm_package_version?.trim() || "0.0.0-dev";
679
679
  var manifest = {
680
680
  id: GITHUB_SYNC_PLUGIN_ID,
681
681
  apiVersion: 1,
package/dist/worker.js CHANGED
@@ -5999,6 +5999,11 @@ function normalizePaperclipIssueAssigneePrincipal(value) {
5999
5999
  return null;
6000
6000
  }
6001
6001
  const record = value;
6002
+ const normalizedKind = normalizeOptionalString2(record.kind);
6003
+ const normalizedId = normalizeOptionalString2(record.id);
6004
+ if ((normalizedKind === "agent" || normalizedKind === "user") && normalizedId) {
6005
+ return { kind: normalizedKind, id: normalizedId };
6006
+ }
6002
6007
  const principalType = normalizeOptionalString2(record.type);
6003
6008
  const agentId = normalizeOptionalString2(record.agentId);
6004
6009
  const userId = normalizeOptionalString2(record.userId);
@@ -6319,9 +6324,6 @@ function isClearableMaintainerWaitExecutionState(executionState) {
6319
6324
  }
6320
6325
  return !executionState.status || executionState.status === "idle" || executionState.status === "completed";
6321
6326
  }
6322
- function shouldClearCompletedSyncExecutionPolicy(params) {
6323
- return (params.nextStatus === "done" || params.nextStatus === "cancelled") && (params.syncContext.executionPolicy !== null || params.syncContext.executionState !== null);
6324
- }
6325
6327
  function shouldPreserveImportedTriageAssignee(params) {
6326
6328
  return params.wasImportedThisRun && params.maintainerAuthoredImportedIssue === true && params.currentStatus === "backlog" && params.nextStatus === "todo";
6327
6329
  }
@@ -8632,6 +8634,20 @@ async function unlinkPaperclipIssueFromGitHub(ctx, params) {
8632
8634
  (entry) => !(entry.paperclipIssueId === issueId && (!entry.companyId || entry.companyId === companyId))
8633
8635
  );
8634
8636
  const unlinkedAt = (/* @__PURE__ */ new Date()).toISOString();
8637
+ const shouldClearGitHubOrigin = issue.originKind === GITHUB_ISSUE_ORIGIN_KIND || issue.originKind === GITHUB_PULL_REQUEST_ORIGIN_KIND;
8638
+ const nextDescription = removeGitHubIssueLinkMetadataFromDescription(issue.description);
8639
+ const issuePatch = {};
8640
+ if (shouldClearGitHubOrigin) {
8641
+ issuePatch.originKind = GITHUB_SYNC_BASE_ORIGIN_KIND;
8642
+ issuePatch.originId = null;
8643
+ issuePatch.originRunId = null;
8644
+ }
8645
+ if (nextDescription !== void 0) {
8646
+ issuePatch.description = nextDescription;
8647
+ }
8648
+ if (Object.keys(issuePatch).length > 0) {
8649
+ await ctx.issues.update(issueId, issuePatch, companyId);
8650
+ }
8635
8651
  for (const record of issueLinkRecords) {
8636
8652
  await tombstoneGitHubIssueLinkRecord(ctx, record, unlinkedAt);
8637
8653
  invalidateGitHubLinkCachesForTarget({
@@ -8658,20 +8674,6 @@ async function unlinkPaperclipIssueFromGitHub(ctx, params) {
8658
8674
  if (removedImportRegistryEntries.length > 0) {
8659
8675
  await ctx.state.set(IMPORT_REGISTRY_SCOPE, nextImportRegistry);
8660
8676
  }
8661
- const shouldClearGitHubOrigin = issue.originKind === GITHUB_ISSUE_ORIGIN_KIND || issue.originKind === GITHUB_PULL_REQUEST_ORIGIN_KIND;
8662
- const nextDescription = removeGitHubIssueLinkMetadataFromDescription(issue.description);
8663
- const issuePatch = {};
8664
- if (shouldClearGitHubOrigin) {
8665
- issuePatch.originKind = GITHUB_SYNC_BASE_ORIGIN_KIND;
8666
- issuePatch.originId = null;
8667
- issuePatch.originRunId = null;
8668
- }
8669
- if (nextDescription !== void 0) {
8670
- issuePatch.description = nextDescription;
8671
- }
8672
- if (Object.keys(issuePatch).length > 0) {
8673
- await ctx.issues.update(issueId, issuePatch, companyId);
8674
- }
8675
8677
  await forgetExternalGitHubLinkCompanyIfEmpty(ctx, companyId);
8676
8678
  return {
8677
8679
  paperclipIssueId: issueId,
@@ -9650,6 +9652,23 @@ function classifyIssueInteractionReason(value) {
9650
9652
  if (reason.includes("open with no linked pull request")) return "issue_ready_for_triage";
9651
9653
  return "github_sync_status_decision";
9652
9654
  }
9655
+ function isPaperclipIssuePatchApplied(params) {
9656
+ const { currentStatus, syncContext, issuePatch } = params;
9657
+ if (issuePatch.status !== currentStatus) return false;
9658
+ const hasAgentAssignee = Object.prototype.hasOwnProperty.call(issuePatch, "assigneeAgentId");
9659
+ const hasUserAssignee = Object.prototype.hasOwnProperty.call(issuePatch, "assigneeUserId");
9660
+ if (hasAgentAssignee || hasUserAssignee) {
9661
+ const expectedAssignee = typeof issuePatch.assigneeAgentId === "string" ? { kind: "agent", id: issuePatch.assigneeAgentId } : typeof issuePatch.assigneeUserId === "string" ? { kind: "user", id: issuePatch.assigneeUserId } : null;
9662
+ if (JSON.stringify(syncContext.assignee) !== JSON.stringify(expectedAssignee)) return false;
9663
+ }
9664
+ if (Object.prototype.hasOwnProperty.call(issuePatch, "executionPolicy") && JSON.stringify(syncContext.executionPolicy) !== JSON.stringify(
9665
+ normalizePaperclipIssueExecutionPolicy(issuePatch.executionPolicy)
9666
+ )) return false;
9667
+ if (Object.prototype.hasOwnProperty.call(issuePatch, "executionState") && JSON.stringify(syncContext.executionState) !== JSON.stringify(
9668
+ normalizePaperclipIssueExecutionState(issuePatch.executionState)
9669
+ )) return false;
9670
+ return true;
9671
+ }
9653
9672
  async function updatePaperclipIssueState(ctx, params) {
9654
9673
  const {
9655
9674
  companyId,
@@ -9700,6 +9719,14 @@ async function updatePaperclipIssueState(ctx, params) {
9700
9719
  if (statusWillChange && typeof ctx.issues.createComment !== "function") {
9701
9720
  throw new Error("This Paperclip runtime does not expose issue comment creation, so GitHub Sync refused to update a Paperclip issue status without an explanatory comment.");
9702
9721
  }
9722
+ const liveIssue = await ctx.issues.get(issueId, companyId);
9723
+ const liveCurrentStatus = liveIssue?.status ?? currentStatus;
9724
+ const liveSyncContext = liveIssue ? getPaperclipIssueSyncContext(liveIssue) : syncContext;
9725
+ const issuePatchAlreadyApplied = isPaperclipIssuePatchApplied({
9726
+ currentStatus: liveCurrentStatus,
9727
+ syncContext: liveSyncContext,
9728
+ issuePatch
9729
+ });
9703
9730
  const reasonCode = classifyIssueInteractionReason(transitionCommentAnnotation?.reason ?? trimmedTransitionComment);
9704
9731
  const interactionDedupeBase = actionFingerprint ? `sync:${createHash("sha256").update(JSON.stringify({
9705
9732
  companyId,
@@ -9707,8 +9734,36 @@ async function updatePaperclipIssueState(ctx, params) {
9707
9734
  mutation: "status_transition",
9708
9735
  actionFingerprint,
9709
9736
  currentStatus,
9710
- nextStatus
9737
+ nextStatus,
9738
+ currentIssueState: syncContext,
9739
+ issuePatch
9711
9740
  })).digest("hex")}` : `sync:${issueId}:${interactionOccurredAt}:${currentStatus}:${nextStatus}`;
9741
+ const mutationFamilyBase = actionFingerprint ? `sync:${createHash("sha256").update(JSON.stringify({
9742
+ companyId,
9743
+ issueId,
9744
+ mutation: "status_transition",
9745
+ actionFingerprint,
9746
+ nextStatus
9747
+ })).digest("hex")}` : interactionDedupeBase;
9748
+ const hasAssigneePatch = Object.prototype.hasOwnProperty.call(issuePatch, "assigneeAgentId") || Object.prototype.hasOwnProperty.call(issuePatch, "assigneeUserId");
9749
+ const mutationExpectedState = {
9750
+ status: issuePatch.status ?? liveCurrentStatus,
9751
+ assignee: hasAssigneePatch ? normalizePaperclipIssueAssigneePrincipal({
9752
+ agentId: issuePatch.assigneeAgentId,
9753
+ userId: issuePatch.assigneeUserId
9754
+ }) : liveSyncContext.assignee,
9755
+ executionPolicy: Object.prototype.hasOwnProperty.call(issuePatch, "executionPolicy") ? normalizePaperclipIssueExecutionPolicy(issuePatch.executionPolicy) : liveSyncContext.executionPolicy,
9756
+ executionState: Object.prototype.hasOwnProperty.call(issuePatch, "executionState") ? normalizePaperclipIssueExecutionState(issuePatch.executionState) : liveSyncContext.executionState
9757
+ };
9758
+ const liveMutationState = {
9759
+ status: liveCurrentStatus,
9760
+ assignee: liveSyncContext.assignee,
9761
+ executionPolicy: liveSyncContext.executionPolicy,
9762
+ executionState: liveSyncContext.executionState
9763
+ };
9764
+ const mutationExpectedStateFingerprint = createHash("sha256").update(JSON.stringify(mutationExpectedState)).digest("hex").slice(0, 32);
9765
+ const liveMutationStateFingerprint = createHash("sha256").update(JSON.stringify(liveMutationState)).digest("hex").slice(0, 32);
9766
+ const mutationPatchBase = `${mutationFamilyBase}:patch:${createHash("sha256").update(JSON.stringify(issuePatch)).digest("hex").slice(0, 32)}:applied:${mutationExpectedStateFingerprint}`;
9712
9767
  let existingInteractionEvents = [];
9713
9768
  if (actionFingerprint) {
9714
9769
  const ledger = await listIssueInteractionEvents(ctx, companyId, issueId, {
@@ -9722,6 +9777,14 @@ async function updatePaperclipIssueState(ctx, params) {
9722
9777
  const existingIntent = existingInteractionEvents.find((event) => event.dedupeKey === `${interactionDedupeBase}:intent`);
9723
9778
  if (existingIntent) interactionOccurredAt = existingIntent.occurredAt;
9724
9779
  }
9780
+ const completedMutationForPatch = existingInteractionEvents.some(
9781
+ (event) => event.dedupeKey.startsWith(`${mutationPatchBase}:`) && event.dedupeKey.endsWith(":mutation:result:changed")
9782
+ );
9783
+ const mutationDedupeBase = !issuePatchAlreadyApplied && completedMutationForPatch ? `${mutationPatchBase}:drift:${createHash("sha256").update(JSON.stringify({
9784
+ currentStatus: liveCurrentStatus,
9785
+ currentIssueState: liveSyncContext,
9786
+ issuePatch
9787
+ })).digest("hex").slice(0, 32)}` : mutationPatchBase;
9725
9788
  await persistIssueInteractionEvent(ctx, {
9726
9789
  schemaVersion: 1,
9727
9790
  companyId,
@@ -9762,7 +9825,7 @@ async function updatePaperclipIssueState(ctx, params) {
9762
9825
  outcome,
9763
9826
  dedupeKey: `${interactionDedupeBase}:result:${outcome}`
9764
9827
  });
9765
- const persistMutationPhase = (outcome) => persistIssueInteractionEvent(ctx, {
9828
+ const persistMutationPhase = (outcome, dedupeBase = mutationDedupeBase) => persistIssueInteractionEvent(ctx, {
9766
9829
  schemaVersion: 1,
9767
9830
  companyId,
9768
9831
  paperclipIssueId: issueId,
@@ -9779,14 +9842,26 @@ async function updatePaperclipIssueState(ctx, params) {
9779
9842
  }
9780
9843
  } : {},
9781
9844
  outcome,
9782
- dedupeKey: `${interactionDedupeBase}:mutation:${outcome === "observed" ? "intent" : `result:${outcome}`}`
9845
+ dedupeKey: `${dedupeBase}:mutation:${outcome === "observed" ? "intent" : `result:${outcome}`}`
9783
9846
  });
9784
- const priorMutationIntent = existingInteractionEvents.find((event) => event.dedupeKey === `${interactionDedupeBase}:mutation:intent`);
9785
- const priorMutationChanged = existingInteractionEvents.find((event) => event.dedupeKey === `${interactionDedupeBase}:mutation:result:changed`);
9786
- const priorMutationFailed = existingInteractionEvents.find((event) => event.dedupeKey === `${interactionDedupeBase}:mutation:result:failed`);
9847
+ const priorMutationIntent = existingInteractionEvents.find((event) => event.dedupeKey === `${mutationDedupeBase}:mutation:intent`);
9848
+ const priorMutationChanged = existingInteractionEvents.find((event) => event.dedupeKey === `${mutationDedupeBase}:mutation:result:changed`);
9849
+ const priorMutationFailed = existingInteractionEvents.find((event) => event.dedupeKey === `${mutationDedupeBase}:mutation:result:failed`);
9787
9850
  let mutationAttemptStarted = false;
9788
9851
  let mutationReturned = false;
9789
- let mutationComplete = Boolean(priorMutationChanged);
9852
+ let mutationComplete = issuePatchAlreadyApplied;
9853
+ if (issuePatchAlreadyApplied) {
9854
+ const intentSuffix = ":mutation:intent";
9855
+ for (const intent of existingInteractionEvents.filter(
9856
+ (event) => event.dedupeKey.startsWith(`${mutationFamilyBase}:`) && event.dedupeKey.includes(`:applied:${liveMutationStateFingerprint}:`) && event.dedupeKey.endsWith(intentSuffix)
9857
+ )) {
9858
+ const dedupeBase = intent.dedupeKey.slice(0, -intentSuffix.length);
9859
+ const hasResult = existingInteractionEvents.some(
9860
+ (event) => event.dedupeKey === `${dedupeBase}:mutation:result:changed` || event.dedupeKey === `${dedupeBase}:mutation:result:failed`
9861
+ );
9862
+ if (!hasResult) await persistMutationPhase("changed", dedupeBase);
9863
+ }
9864
+ }
9790
9865
  try {
9791
9866
  if (statusWillChange) {
9792
9867
  const commentIntentKey = `${interactionDedupeBase}:comment:intent`;
@@ -9850,7 +9925,7 @@ async function updatePaperclipIssueState(ctx, params) {
9850
9925
  }
9851
9926
  }
9852
9927
  if (!mutationComplete) {
9853
- if (priorMutationIntent && !priorMutationFailed) {
9928
+ if (priorMutationIntent && !priorMutationChanged && !priorMutationFailed) {
9854
9929
  throw new Error("GitHub Sync refused to repeat an uncertain issue mutation; reconcile the durable mutation intent before retrying.");
9855
9930
  }
9856
9931
  await persistMutationPhase("observed");
@@ -10403,10 +10478,6 @@ async function cancelUnmappedTransferredGitHubIssue(ctx, params) {
10403
10478
  };
10404
10479
  }
10405
10480
  const paperclipIssueSyncContext = getPaperclipIssueSyncContext(paperclipIssue);
10406
- await unlinkPaperclipIssueFromGitHub(ctx, {
10407
- companyId,
10408
- issueId: params.importedIssue.paperclipIssueId
10409
- });
10410
10481
  const nextStatus = "cancelled";
10411
10482
  await updatePaperclipIssueState(ctx, {
10412
10483
  companyId,
@@ -10414,7 +10485,7 @@ async function cancelUnmappedTransferredGitHubIssue(ctx, params) {
10414
10485
  currentStatus: paperclipIssue.status,
10415
10486
  syncContext: paperclipIssueSyncContext,
10416
10487
  nextStatus,
10417
- transitionComment: buildUnmappedTransferredIssueCancellationComment({
10488
+ transitionComment: paperclipIssue.status === nextStatus ? "" : buildUnmappedTransferredIssueCancellationComment({
10418
10489
  previousStatus: paperclipIssue.status,
10419
10490
  nextStatus,
10420
10491
  transferredRepository: params.transferredRepository
@@ -10422,6 +10493,10 @@ async function cancelUnmappedTransferredGitHubIssue(ctx, params) {
10422
10493
  actionFingerprint: `transferred-unmapped:${params.transferredRepository.url}`,
10423
10494
  paperclipApiBaseUrl: params.paperclipApiBaseUrl
10424
10495
  });
10496
+ await unlinkPaperclipIssueFromGitHub(ctx, {
10497
+ companyId,
10498
+ issueId: params.importedIssue.paperclipIssueId
10499
+ });
10425
10500
  return {
10426
10501
  updatedStatusesCount: paperclipIssue.status === nextStatus ? 0 : 1
10427
10502
  };
@@ -10735,10 +10810,7 @@ async function synchronizePaperclipIssueStatuses(ctx, octokit, repository, mappi
10735
10810
  nextStatus,
10736
10811
  syncContext: paperclipIssueSyncContext
10737
10812
  });
10738
- const shouldClearCompletedExecutionPolicy = shouldClearCompletedSyncExecutionPolicy({
10739
- nextStatus,
10740
- syncContext: paperclipIssueSyncContext
10741
- });
10813
+ const shouldClearCompletedExecutionPolicy = nextStatus === "done" || nextStatus === "cancelled";
10742
10814
  const shouldPreserveImportedTriageRouting = shouldPreserveImportedTriageAssignee({
10743
10815
  currentStatus: paperclipIssue.status,
10744
10816
  nextStatus,
@@ -10751,7 +10823,7 @@ async function synchronizePaperclipIssueStatuses(ctx, octokit, repository, mappi
10751
10823
  syncContext: paperclipIssueSyncContext,
10752
10824
  advancedSettings
10753
10825
  });
10754
- const shouldClearTransitionAssignee = nextStatus === "in_review" && (nextTransitionAssignee === null || shouldPreserveMaintainerWaitRouting) && paperclipIssueSyncContext.assignee !== null;
10826
+ const shouldClearTransitionAssignee = nextStatus === "in_review" && (nextTransitionAssignee === null || shouldPreserveMaintainerWaitRouting);
10755
10827
  const nextAssigneeChanged = nextTransitionAssignee ? !doesPaperclipIssueAssigneeMatch(paperclipIssueSyncContext.assignee, nextTransitionAssignee.principal) : false;
10756
10828
  const shouldWakeImportedAssignee = wasImportedThisRun && nextStatus === "todo" && (paperclipIssue.status === nextStatus || shouldPreserveImportedTriageRouting) && paperclipIssueSyncContext.assignee?.kind === "agent";
10757
10829
  const shouldWakeTransitionAssignee = paperclipIssue.status !== nextStatus && nextTransitionAssignee?.principal.kind === "agent" && isActionablePaperclipIssueStatus(nextStatus) && (nextAssigneeChanged || paperclipIssue.status !== nextStatus);
@@ -10765,25 +10837,23 @@ async function synchronizePaperclipIssueStatuses(ctx, octokit, repository, mappi
10765
10837
  await persistImportRegistry();
10766
10838
  };
10767
10839
  if (paperclipIssue.status === nextStatus) {
10768
- if (shouldClearTransitionAssignee || shouldClearCompletedExecutionPolicy) {
10769
- updateSyncFailureContext(syncFailureContext, {
10770
- phase: "updating_paperclip_status",
10771
- repositoryUrl: repository.url,
10772
- githubIssueNumber: githubIssue.number
10773
- });
10774
- await updatePaperclipIssueState(ctx, {
10775
- companyId: mapping.companyId,
10776
- issueId: importedIssue.paperclipIssueId,
10777
- currentStatus: paperclipIssue.status,
10778
- syncContext: paperclipIssueSyncContext,
10779
- nextStatus,
10780
- ...shouldClearTransitionAssignee ? { clearAssignee: true } : {},
10781
- ...shouldPreserveMaintainerWaitRouting || shouldClearCompletedExecutionPolicy ? { clearExecutionPolicy: true } : {},
10782
- transitionComment: "",
10783
- actionFingerprint: actionJournalFingerprint,
10784
- paperclipApiBaseUrl
10785
- });
10786
- }
10840
+ updateSyncFailureContext(syncFailureContext, {
10841
+ phase: "updating_paperclip_status",
10842
+ repositoryUrl: repository.url,
10843
+ githubIssueNumber: githubIssue.number
10844
+ });
10845
+ await updatePaperclipIssueState(ctx, {
10846
+ companyId: mapping.companyId,
10847
+ issueId: importedIssue.paperclipIssueId,
10848
+ currentStatus: paperclipIssue.status,
10849
+ syncContext: paperclipIssueSyncContext,
10850
+ nextStatus,
10851
+ ...shouldClearTransitionAssignee ? { clearAssignee: true } : {},
10852
+ ...shouldPreserveMaintainerWaitRouting || shouldClearCompletedExecutionPolicy ? { clearExecutionPolicy: true } : {},
10853
+ transitionComment: "",
10854
+ actionFingerprint: actionJournalFingerprint,
10855
+ paperclipApiBaseUrl
10856
+ });
10787
10857
  if (shouldWakeImportedAssignee && paperclipIssueSyncContext.assignee?.kind === "agent") {
10788
10858
  const pendingWake2 = {
10789
10859
  fingerprint: remoteActionFingerprint,
@@ -11106,17 +11176,14 @@ async function synchronizePaperclipPullRequestIssueStatuses(ctx, octokit, mappin
11106
11176
  nextStatus,
11107
11177
  syncContext: paperclipIssueSyncContext
11108
11178
  });
11109
- const shouldClearCompletedExecutionPolicy = shouldClearCompletedSyncExecutionPolicy({
11110
- nextStatus,
11111
- syncContext: paperclipIssueSyncContext
11112
- });
11179
+ const shouldClearCompletedExecutionPolicy = nextStatus === "done" || nextStatus === "cancelled";
11113
11180
  const nextTransitionAssignee = resolveSyncTransitionAssignee({
11114
11181
  currentStatus: paperclipIssue.status,
11115
11182
  nextStatus,
11116
11183
  syncContext: paperclipIssueSyncContext,
11117
11184
  advancedSettings
11118
11185
  });
11119
- const shouldClearTransitionAssignee = nextStatus === "in_review" && (nextTransitionAssignee === null || shouldPreserveMaintainerWaitRouting) && paperclipIssueSyncContext.assignee !== null;
11186
+ const shouldClearTransitionAssignee = nextStatus === "in_review" && (nextTransitionAssignee === null || shouldPreserveMaintainerWaitRouting);
11120
11187
  const nextAssigneeChanged = nextTransitionAssignee ? !doesPaperclipIssueAssigneeMatch(paperclipIssueSyncContext.assignee, nextTransitionAssignee.principal) : false;
11121
11188
  const shouldWakeTransitionAssignee = paperclipIssue.status !== nextStatus && nextTransitionAssignee?.principal.kind === "agent" && isActionablePaperclipIssueStatus(nextStatus) && (nextAssigneeChanged || paperclipIssue.status !== nextStatus);
11122
11189
  if (paperclipIssue.status === nextStatus) {
@@ -17180,6 +17247,8 @@ var __testing = {
17180
17247
  formatPaperclipApiFetchErrorMessage,
17181
17248
  hasUnresolvedPaperclipIssueBlocker,
17182
17249
  isHealthyMaintainerWaitTransition,
17250
+ isPaperclipIssuePatchApplied,
17251
+ normalizePaperclipIssueAssigneePrincipal,
17183
17252
  normalizeImportRegistry,
17184
17253
  normalizeRemoteActionRegistry,
17185
17254
  persistIssueInteractionEvent,
@@ -17428,7 +17497,10 @@ var plugin = definePlugin({
17428
17497
  });
17429
17498
  ctx.actions.register("settings.updateBoardAccess", async (input, actionContext) => {
17430
17499
  const previous = normalizeSettings(await ctx.state.get(SETTINGS_SCOPE));
17431
- const config = await getResolvedConfig(ctx);
17500
+ const [config, trustedConfig] = await Promise.all([
17501
+ getResolvedConfig(ctx),
17502
+ ctx.config.get().then((value) => normalizeConfig(value))
17503
+ ]);
17432
17504
  const record = normalizeActionRecord(input, actionContext);
17433
17505
  const companyId = normalizeCompanyId(record.companyId);
17434
17506
  if (!companyId) {
@@ -17448,7 +17520,8 @@ var plugin = definePlugin({
17448
17520
  if (nextSecretRef) {
17449
17521
  nextPaperclipBoardApiTokenRefs[companyId] = nextSecretRef;
17450
17522
  if (nextBoardApiToken) {
17451
- if (await shouldSeedExternalPaperclipBoardTokenFallback(ctx, companyId, nextSecretRef)) {
17523
+ const configuredSecretRef = getConfiguredPaperclipBoardApiTokenRef(trustedConfig, companyId);
17524
+ if (configuredSecretRef !== nextSecretRef || await shouldSeedExternalPaperclipBoardTokenFallback(ctx, companyId, nextSecretRef)) {
17452
17525
  await writeExternalCompanyPaperclipBoardApiTokenFallback(ctx, companyId, nextBoardApiToken);
17453
17526
  } else {
17454
17527
  await clearExternalCompanyPaperclipBoardApiTokenFallback(ctx, companyId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paperclip-github-plugin",
3
- "version": "0.15.3",
3
+ "version": "0.15.5",
4
4
  "description": "Paperclip plugin for synchronizing GitHub issues into Paperclip projects.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",