githubnext/chopinPublic

Let's compose rich plans together

Colour a fence, and draw a patch as the change it is

A fence is rendered beside the source it came from, by `@pierre/diffs` over
Shiki, loaded on demand. The source stays where it was — Lexical text children
under Yjs, editable by everyone at once — and the rendering is a second reading
of it, never the document: the library's own edit mode would put a character
model beside the one the room is collaborating in.

A `diff` fence is a unified patch. It is repaired on the way to the renderer,
because nobody writes a hunk header correctly and the counts in one are how a
parser knows where the hunk ends: too low, and the change is truncated
silently. What cannot be repaired is refused and drawn as coloured text, which
is the honest rendering of something that was never a patch.

A fence with no language draws nothing, so the language selector in the block's
chrome is what turns a grey box into coloured code. Enter inside a fence is now
a newline — it did nothing at all before, because Lexical asks a block to make
its own successor and a code block cannot — and pressing it on a blank line
leaves, which is the only way past a fence at the end of a plan.
KCKrzysztof Cieslak authored
060ba79Patch
Parent0763402
18 files changed+1331-60
StackedSplit
agents.md+65 −5
apps/server/src/agent/planner.ts+14 −1
bun.lock+69 −1
e2e/code.e2e.ts+140 −0
package.json+3 −0
packages/dialect/src/dialect.ts+9 −0
packages/dialect/src/index.ts+1 −0
packages/dialect/src/nodes/content.test.ts+13 −0
packages/editor/package.json+1 −0
packages/editor/src/styles.css+38 −1
packages/editor/src/toolbar/slash.tsx+8 −0
packages/editor/src/widgets-plugin.tsx+2 −1
packages/editor/src/widgets/code-view.tsx+245 −0
packages/editor/src/widgets/code.test.ts+204 −0
packages/editor/src/widgets/code.ts+243 −0
packages/editor/src/widgets/enter.tsx+115 −0
packages/editor/src/widgets/index.ts+1 −0
packages/editor/src/widgets/render-blocks.tsx+160 −51