feat(proposalModel): setProposalApplied re-anchors + stores original (#64)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -37,6 +37,25 @@ export function removeProposal(artifact: Artifact, proposalId: string): boolean
|
||||
return artifact.proposals.length < before;
|
||||
}
|
||||
|
||||
/**
|
||||
* F12/#64 (INV-48): record a proposal as optimistically applied — store the
|
||||
* pre-apply `original` (for revert + the struck `<del>`) and re-point its anchor
|
||||
* fingerprint to the now-in-buffer applied text so `resolve()` finds it. Idempotent
|
||||
* shape: a second call simply overwrites with the same values.
|
||||
*/
|
||||
export function setProposalApplied(
|
||||
artifact: Artifact,
|
||||
proposalId: string,
|
||||
appliedFp: Fingerprint,
|
||||
original: string,
|
||||
): boolean {
|
||||
const p = artifact.proposals.find((x) => x.id === proposalId);
|
||||
if (!p) return false;
|
||||
p.original = original;
|
||||
artifact.anchors[p.anchorId] = { fingerprint: appliedFp };
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Markdown comment body: instruction header + fenced whole-range diff. */
|
||||
export function proposalBody(targetText: string, p: Proposal): string {
|
||||
const header = p.instruction ? `**Claude proposes** — _${p.instruction}_` : "**Claude proposes**";
|
||||
|
||||
Reference in New Issue
Block a user