Add manual re-anchor for orphaned comments - #26
Draft
tnsardesai wants to merge 2 commits into
Draft
Conversation
Automatic re-anchoring only un-orphans a thread when its original quote comes back verbatim; a thread whose text was rewritten stays orphaned forever. PATCH /comments/:id now accepts an anchor field: a new quote re-resolves against the current doc text (un-orphaning on success), and null detaches the thread to a doc-level comment. Author-only, root comments only — same rules as body edit and POST /comments. The viewer shows a re-anchor action on the author's own orphaned cards: pick a replacement passage in the doc, confirm in a floating bar, and the thread re-anchors in place. Spec + skill artifacts regenerated; e2e covers orphan -> re-anchor -> detach.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Mirrors the delete rule (author own, owner any): the owner can repair orphaned threads on their document regardless of who authored them. The viewer shows the re-anchor action to the owner on every orphaned card; e2e covers owner-reanchors-grantee's-thread and non-author-editor 403.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Automatic re-anchoring (tier 1/2/3 on every doc write) only un-orphans a thread when its original quote is restored verbatim. When the quoted text is rewritten — the common case — the thread stays orphaned forever with no way to point it at the replacement passage.
This adds manual re-anchoring:
PATCH /api/v1/docs/:slug/comments/:idgains ananchorfield.{"anchor":{"exact":"the new passage","prefix":"...","suffix":"..."}}re-anchors the thread: the new selector is resolved against the current doc text via the sameresolveInitialAnchorpath used at creation (offsets re-stamped,anchored_versionset,orphanedrecomputed — a quote that doesn't resolve yet keeps the thread orphaned with the new selector, so a later restoring edit can still un-orphan it).{"anchor":null}detaches the thread to a doc-level comment.re-anchoraction on orphaned cards (your own threads, or any thread if you own the doc) starts a pick-a-passage flow — rail banner explains, the next doc selection shows a confirm bar, confirm PATCHes and the thread re-anchors in place. Server enforces either way.llms.txt/ SKILL.md and the OpenAPI spec updated (artifacts regenerated viagen:skill/gen:spec;spec:checkpasses).Testing
npx tsc --noEmit,npm run build,npm test(174 unit tests),npm run spec:check— all pass.scripts/e2e.tsextended: rewrite the doc so the quote disappears → thread orphaned → re-anchor to a surviving quote → un-orphaned →anchor:null→ doc-level; plus permission coverage (owner re-anchors a grantee's thread → 200; non-author editor → 403). Not run — it exercises the real email path against production and needs local env secrets I don't have here.