Skip to content

Commit 35e901a

Browse files
Marfuenclaude
andauthored
fix(onboarding): prevent mitigation steps flashing complete (#2786)
* fix: address cubic review findings on onboarding PR P1: Add metadata.set('policies', true) after policy fan-out so the tracker boolean flag is set. P1: Log batchTriggerAndWait failures in vendor/risk mitigation fan-outs instead of silently ignoring them. P2: Strip {{#if}}/{{/if}} markers from mixed-content nodes so template syntax doesn't leak into rendered policies. P2: Fix stale onboardingTriggerJobId locking publish button in ToDoOverview. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix: strip only first marker occurrence to preserve nested conditionals The global regex flag in stripMarkerText would remove ALL matching {{#if}}/{{/if}} markers in a subtree, corrupting boundaries of nested conditional blocks. Removed the g flag so only the first occurrence (the one that triggered the match) is stripped. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * test(onboarding): add comprehensive tests for policy template processor Covers placeholder replacement, inline/multi-node/nested conditionals, mixed content nodes, edge cases, buildVariables, buildFlags, processTemplate. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(onboarding): treat zero-item steps as complete in tracker When an org has no vendors or risks, `total > 0 && completed >= total` evaluates to false, causing those steps to appear stuck forever. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(onboarding): prevent mitigation steps from flashing complete on load Revert zero-item guard (total === 0 ||) back to (total > 0 &&) — before totals metadata is set, the default of 0 caused steps to appear complete then flip back to in-progress once actual totals arrived. Also add missing risksTotal/risksInfo metadata alongside vendorsTotal so risk mitigation progress tracks correctly in the UI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(onboarding): show created/total format for vendor and risk creation steps Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent a196339 commit 35e901a

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

apps/app/src/app/(app)/[orgId]/components/OnboardingTracker.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -666,15 +666,18 @@ export const OnboardingTracker = ({ onboarding }: { onboarding: Onboarding }) =>
666666
}
667667

668668
// Simple step row (creation, linkage)
669-
const count = step.key === 'vendors' ? uniqueVendorsCounts.total
669+
const total = step.key === 'vendors' ? uniqueVendorsCounts.total
670670
: step.key === 'risk' ? stepStatus.risksTotal
671671
: null;
672+
const created = step.key === 'vendors' && stepStatus.vendors ? uniqueVendorsCounts.total
673+
: step.key === 'risk' && stepStatus.risk ? stepStatus.risksTotal
674+
: 0;
672675
return (
673676
<div key={step.key} className="flex items-center gap-2">
674677
{stepIcon}
675678
<span className={`${stepTextClass} flex-1`}>{step.label}</span>
676-
{count !== null && count > 0 && (
677-
<span className="text-muted-foreground text-sm">{count}</span>
679+
{total !== null && total > 0 && (
680+
<span className="text-muted-foreground text-sm">{created}/{total}</span>
678681
)}
679682
</div>
680683
);

apps/app/src/trigger/tasks/onboarding/onboard-organization.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,13 @@ export const onboardOrganization = task({
151151
payload.organizationId,
152152
organization.name,
153153
);
154+
metadata.set('risksTotal', created.length);
155+
metadata.set('risksCompleted', 0);
156+
metadata.set('risksRemaining', created.length);
157+
metadata.set(
158+
'risksInfo',
159+
created.map((r) => ({ id: r.id, name: r.description?.slice(0, 80) ?? r.id })),
160+
);
154161
if (created.length > 0) {
155162
created.forEach((risk) => {
156163
metadata.set(`risk_${risk.id}_status`, 'assessing');

0 commit comments

Comments
 (0)