githubnext/chopinPublic

Let's compose rich plans together

Anchor decisions to the prose they produced

A questionnaire asks about something and produces something, and both are
passages of the plan rather than the questionnaire. Hovering a question now
lights up what it concerns; hovering its answer lights up the prose that answer
caused.

An anchor is a Yjs relative position and a digest of the block's canonical
source, and the two do different jobs. The position survives edits around the
block it names. The digest recovers it when the position cannot resolve at all
— a move rebuilds the block's collaborative identity, and an epoch rotation
throws away the history the position was expressed in — by matching content
instead. A digest matching two blocks recovers neither: identical paragraphs
give no way to tell which was meant, and pointing a decision at the wrong
passage is worse than admitting the link is lost.

Rewriting an anchored block is the one case neither layer carries, and the one
where recovering would be wrong. Whether the new text still concerns that
decision is a judgement, so the relationship is marked pending and the agent is
told it owes a review. Pending resolves to nothing on purpose: that is what
makes the text inert rather than offering a jump somewhere stale.

Highlights are written to the DOM, never the document. A highlight is one
reader's pointer, not a fact about the plan; in the document it would travel to
everyone else and land in their undo history.

Verified against the real agent, which asked a question, recorded the answer,
anchored the two blocks it had written and recorded that the question itself
related to nothing — the plan having been empty when it asked. A browser-side
document then resolved those anchors back to the heading and paragraph.
KCKrzysztof Cieslak authored
0f1f54dPatch
Parent791a620
15 files changed+940-9
StackedSplit
apps/server/src/agent/planner.ts+9 −0
apps/server/src/agent/tools.ts+96 −0
apps/server/src/chat/service.ts+1 −0
apps/server/src/plan/anchors.test.ts+201 −0
apps/server/src/plan/room.ts+117 −0
apps/server/src/plan/service.ts+15 −0
apps/server/src/questions/anchors.ts+118 −0
apps/server/src/questions/service.ts+91 −1
packages/editor/src/anchors.ts+93 −0
packages/editor/src/decisions.tsx+14 −0
packages/editor/src/plan-editor.tsx+13 −2
packages/editor/src/provider.ts+6 −0
packages/editor/src/questionnaires.ts+80 −1
packages/editor/src/widgets/questionnaire.tsx+28 −5
packages/protocol/plan.d.ts+58 −0