Stop seeding 75% consensus on custom decision cards so wizard copy shows on the published rule.
Wire Back on the final-review chip editor to the same dismiss path as close, instead of a no-op. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -78,6 +78,8 @@ export function labeledBlocksFromCustomMethodCardFieldBlocks(
|
||||
export type CommunityRuleEntryFromChipOptions = {
|
||||
consensusLevelKey?: string;
|
||||
customFieldBlocks?: CustomMethodCardFieldBlock[];
|
||||
/** Wizard step-2 policy description (`customMethodCardMetaById.supportText`). */
|
||||
supportText?: string;
|
||||
};
|
||||
|
||||
/** Canonical `categoryName` strings for method groups in published documents. */
|
||||
@@ -195,8 +197,64 @@ export function communityRuleEntryFromMethodChip(
|
||||
? labeledBlocksFromCustomMethodCardFieldBlocks(options.customFieldBlocks)
|
||||
: [];
|
||||
const blocks = [...presetBlocks, ...wizardBlocks];
|
||||
if (blocks.length === 0) return null;
|
||||
return { title, body: "", blocks };
|
||||
const description = nonEmptyTrimmed(options?.supportText);
|
||||
if (blocks.length === 0) {
|
||||
if (!description) return null;
|
||||
return { title, body: description };
|
||||
}
|
||||
return {
|
||||
title,
|
||||
body: description ?? "",
|
||||
blocks,
|
||||
};
|
||||
}
|
||||
|
||||
function decisionApproachHasPublishableFacetCopy(
|
||||
sections: Record<string, unknown>,
|
||||
): boolean {
|
||||
return Boolean(
|
||||
nonEmptyTrimmed(sections.corePrinciple) ||
|
||||
nonEmptyTrimmed(sections.stepByStepInstructions) ||
|
||||
nonEmptyTrimmed(sections.objectionsDeadlocks) ||
|
||||
formatScopePayload(sections.applicableScope) ||
|
||||
formatScopePayload(sections.selectedApplicableScope),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Catalog methods publish their consensus figure. User-authored custom cards
|
||||
* often seed `75` with empty facet copy — skip that unless the author actually
|
||||
* filled decision sections. Wizard field blocks (including proportion) are the
|
||||
* source of truth when present.
|
||||
*/
|
||||
function shouldPublishDecisionConsensusLevel(
|
||||
sections: Record<string, unknown>,
|
||||
customFieldBlocks?: CustomMethodCardFieldBlock[],
|
||||
): boolean {
|
||||
if (
|
||||
typeof sections.consensusLevel !== "number" ||
|
||||
Number.isNaN(sections.consensusLevel)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
if (customFieldBlocks && customFieldBlocks.length > 0) {
|
||||
return false;
|
||||
}
|
||||
return decisionApproachHasPublishableFacetCopy(sections);
|
||||
}
|
||||
|
||||
/** Drop seeded / wizard-superseded `consensusLevel` before publish or hydrate. */
|
||||
export function withoutUnpublishedDecisionConsensus(
|
||||
sections: Record<string, unknown>,
|
||||
customFieldBlocks?: CustomMethodCardFieldBlock[],
|
||||
): Record<string, unknown> {
|
||||
if (shouldPublishDecisionConsensusLevel(sections, customFieldBlocks)) {
|
||||
return sections;
|
||||
}
|
||||
if (!("consensusLevel" in sections)) return sections;
|
||||
const next = { ...sections };
|
||||
delete next.consensusLevel;
|
||||
return next;
|
||||
}
|
||||
|
||||
export function sectionFromCommunication(
|
||||
@@ -209,6 +267,7 @@ export function sectionFromCommunication(
|
||||
const sec = m.sections as unknown as Record<string, unknown>;
|
||||
const e = communityRuleEntryFromMethodChip(m.label, sec, COMM_LABELS, {
|
||||
customFieldBlocks: customFieldBlocksById?.[m.id],
|
||||
supportText: m.supportText,
|
||||
});
|
||||
if (e) entries.push(e);
|
||||
}
|
||||
@@ -227,6 +286,7 @@ export function sectionFromMembership(
|
||||
const sec = m.sections as unknown as Record<string, unknown>;
|
||||
const e = communityRuleEntryFromMethodChip(m.label, sec, MEM_LABELS, {
|
||||
customFieldBlocks: customFieldBlocksById?.[m.id],
|
||||
supportText: m.supportText,
|
||||
});
|
||||
if (e) entries.push(e);
|
||||
}
|
||||
@@ -254,10 +314,19 @@ export function sectionFromDecision(
|
||||
);
|
||||
if (scope) merged.applicableScope = scope;
|
||||
delete merged.selectedApplicableScope;
|
||||
const e = communityRuleEntryFromMethodChip(m.label, merged, DEC_LABELS, {
|
||||
consensusLevelKey: "consensusLevel",
|
||||
customFieldBlocks: customFieldBlocksById?.[m.id],
|
||||
});
|
||||
const e = communityRuleEntryFromMethodChip(
|
||||
m.label,
|
||||
withoutUnpublishedDecisionConsensus(
|
||||
merged,
|
||||
customFieldBlocksById?.[m.id],
|
||||
),
|
||||
DEC_LABELS,
|
||||
{
|
||||
consensusLevelKey: "consensusLevel",
|
||||
customFieldBlocks: customFieldBlocksById?.[m.id],
|
||||
supportText: m.supportText,
|
||||
},
|
||||
);
|
||||
if (e) entries.push(e);
|
||||
}
|
||||
return entries.length > 0
|
||||
@@ -281,6 +350,7 @@ export function sectionFromConflict(
|
||||
delete merged.selectedApplicableScope;
|
||||
const e = communityRuleEntryFromMethodChip(m.label, merged, CM_LABELS, {
|
||||
customFieldBlocks: customFieldBlocksById?.[m.id],
|
||||
supportText: m.supportText,
|
||||
});
|
||||
if (e) entries.push(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user