gitoria
All repositories: gitoria
6.4 KB
# Differ from custom-ide — reuse assessmentResearch for ticket [gitoria.worldapi.org#2](https://tickets.worldapi.org/projects/gitoria.worldapi.org/2).Source inspected: `loreana:/media/STORAGE/projects/custom-ide` (renderer, vanilla JS + vendoredCodeJar, no framework), specifically `renderer/src/features/{editor,diff-review,hybriel}` and`docs/editor-split-and-diff.md` (the design log for the diff feature, approved 2026-07-30).## What the "differ" actually isNot one file — five pieces, ~3,400 LOC total, built up over several phases (see the design log):| Piece | File | LOC | DOM? ||---|---|---|---|| Diff algorithm | `editor/lineDiff.js` | 249 | **No** — pure, aligns two texts into rows (patience-diff anchors + LCS fallback, `MAX_LCS_CELLS` guard) || Live gutter bars | `editor/editorChangeBars.js` | 75 | No — reuses `lineDiff` || Diff widget shell | `diff-review/DiffReviewWidget.js` | 302 | Yes — two `EditorSurface`s side by side || Editor surface (gutter, spacers, highlight, scroll) | `editor/EditorSurface.js` | 614 | Yes, heavily || Canvas minimap | `editor/EditorMinimap.js` | 628 | Yes (canvas) || Syntax highlighters (per language, regex-based) | `editor/editorHighlighter.js` | 1,027 | No || Vendored editing library | `vendor/codejar.js` (npm `[email protected]`, MIT) | 499 | Yes |`EditorWidget.js` itself (2,770 LOC) is mostly file/LSP/dirty-tracking plumbing the differ doesn'tneed — excluded above.## Reusability, piece by piece**`lineDiff.js` — yes, directly.** Zero DOM dependency (the code comments say so explicitly: keptseparate *because* importing it into the widget would have dragged in CodeJar, which needs a`window`). It has its own Node smoke test. This is the actual "differ" and is the easiest, highest-valuepiece to make a shared component: a worldapi-wide `differ` module, callable from any project(gitoria diffs, but also e.g. a future review UI), with no browser coupling at all.**`editorHighlighter.js` — yes, and partly done already.** custom-ide already ships a **Hybrielsyntax highlighter** at `renderer/src/features/hybriel/highlight.js` (regex tokenizer overHybriel's keyword/type/operator set, ~70 LOC, no dependencies) — written for its own use, butdirectly reusable verbatim for `.hl` files in gitoria's diff/editor views.**CodeJar + `EditorSurface` + `EditorMinimap` — a large piece (not "easily rewritable") — to be ported natively.**This is where the ticket's premise ("codejar is quite simple and probably easily rewritable inhybriel") undersells the actual scope. CodeJar itself is small (499 LOC, MIT, plain`contenteditable` + `Range` API) and easy to read. But the feature built on top of it is not simple:the design log documents real trial-and-error to get there —- diff alignment uses `contenteditable="false"` DOM "spacer" elements inserted via `Range` (notblank text lines), so the editable side's `getCode()` stays byte-identical to the real file;- spacers must be re-inserted after **every** re-highlight because CodeJar rewrites `innerHTML`each time, or the two sides drift a line apart;- line-highlight bands are positioned from `getComputedStyle` line-height, deferred via`ResizeObserver` because a detached element reports no real metrics;- the minimap is a hand-rolled canvas renderer with its own tokenizer-output reuse, viewport slider,and marker ruler.None of that complexity is intrinsic to codejar — it's what "diff editor with a minimap, gutter,and an editable proposal side" costs regardless of implementation language.## Would a native Hybriel rewrite work today?Judged against the open Hybriel tickets already known to this project (see the worker brief's list),several are direct blockers for exactly this feature, not incidental:- **hybriel#32** (`hl:webex` re-creates elements, incl. `script src`, when an `if` in the same Viewflips) — the diff widget's "changed only" toggle and the read-only/editable swap are preciselythis pattern: conditional re-render of a live editing surface, which would blow away CodeJar'sDOM/caret state on every toggle if View re-creates the node.- **hybriel#33** (no conditional boolean attributes) — `contenteditable`/`aria-readonly` areboolean-attribute toggles core to `EditorSurface.setReadOnly()`.- **hybriel#31** (no custom DOM event binding) — CodeJar communicates through its own `onUpdate`callback and native `input`/`keydown` handling, not a framework event system; a native port needsa way to hand webex an escape hatch into the raw DOM.- **hybriel#17** (`if (!member)` renders nothing) and **hybriel#9** (manifest statics unreadable intheir own function routes) are the kind of "silent wrong render" bugs that are expensive to debuginside something this DOM-fiddly.None of these make a Hybriel differ *impossible* — but they make a **from-scratch native rewrite ofthe editing surface** premature until webex's conditional-rendering and DOM-event story is solid.The diff *algorithm* has no such dependency and is unaffected.## Recommendation (final, after gitoria#4)The creator rejected the JS-asset route: no foreign bundle is embedded. The plan is native Hybriel only:1. **Differ algorithm first** — port `lineDiff.js` (pure, 249 LOC, no DOM) as a native Hybriel module inlayouts.worldapi.org (shared components live there, gitoria#3). Unblocked; needs a ticket in that project.2. **Editing surface** — build natively (spacers, re-highlight, contenteditable toggling, custom DOMevents). Blocked on hybriel#31/#32/#33/#17 (and #41); fix or work around those in Hybriel itself.The custom-ide code stays a reference for the behaviours to reproduce.(An earlier "tier 1: ship the existing JS as a client asset" recommendation was removed; it is rejected.)## Questions- ~~Where should the `differ` module live?~~ Decided by the creator (gitoria#3): shared components(editor, differ, comments, design tokens) live in **layouts.worldapi.org**, not in gitoria and notin a separate project.- ~~Embed custom-ide's CodeJar bundle as a static JS asset for now?~~ **Rejected by the creator(gitoria#4):** the original ticket (#2) already answered it — editor and differ are to be built asreusable **native Hybriel components** in layouts.worldapi.org, not embedded as a foreign JS bundle.Do not build the JS-asset route.Remaining work is the native port (differ algorithm first — unblocked; editing surface — see theopen Hybriel tickets #31/#32/#33/#17 above, which must be fixed or worked around in Hybriel itself).
Branches
- f1-broken-json
- f2-api-bugs
- gp-gate-ports
- heap-revert
- hl25-records
- ident-chooser-selector
- mainmain branch
- p51-public-pr-reads
- records-1112
- s25-no-session-on-login-error
- v59
- w52-person-approval
- w52b-approval-followup
- w52c-header-phone
- w53-pulls-speed-pr
- w54-repo-rename-pr
- w55-rename-org
- w56-owner-members
- w62-pr-close
- w63-force-push
Latest commits
- 3a95252dG3: cache parsed README blocks by sha256 of the text (bounded LRU), reportmre
- 570138cddeploy: security gate (tests/security.mjs)mre
- da6b20fcgitoria SG: security audit fixes (uploadMax 0, Secure cookie on https, session rotation at login, nosniff on function routes, no identity in page data) + tests/security.mjs gate + reportmre
- f98c981fgitoria B1: report wordingmre
- c6364cedgitoria B1: compact Markdown blocks (one kind flag per block/span, empty and false fields omitted); same rendered HTML, page values -67%mre
- cd99d2feWIP gitoria#22: always render the repo level's slot (missing-repo boot hang), pages render nothing without a repo; hydration diagnosis in reports/G2-hydrate.mdmre
- e5404b9breport: commit idsmre
- 63cfa21ereports/G2-repotabs.mdmre
- 9b0516fdgitoria#22: mark the tab underline functional (check-theme), chain E2E: serve/measure split, bring the lisbeth tab to frontmre
- 19bc1df8gitoria#22: all repo pages under ONE layout level (components/repo.hl, hl:web D-CHAIN): a tab click replaces only the page in the slot; head and tab nav stay the same DOM nodesmre
- 40658417tests/browser.mjs: wait for the page to be live (hydrated) before clicking Merge — a click on the server-rendered button before the client mounted was lost (flaky 'Clashing change' under load)mre
- 48a6154bre-vendor Hybriel 5406d146 (hl:web batches 9+10: #72 emits while the socket is closed delivered after reconnect, browser boot linear, faster list appends; contains int 6–14 + m406)mre
- e972e8d7tests: short-id-switch (GITORIA_SWITCH_IDENT_PORT/_PORT) and ssh tunnel (GITORIA_GATE_TUNNEL_PORT) ports from env, defaults unchangedmre
- f06f5349re-vendor Hybriel 6f8a0689 (int 6–11: streaming cursors, #203 index heal + close() fix, fd403 listDir/cursor fds, hl:time browser side, hl:web batches 5+6)mre
- c7d3cc87docker-compose: nofile 65536 (Hybriel int 6+ boot opened >1024 files in the tracker)mre
- f0e7ff8cdeploy: backup copies index files first and *.mpack data last (hot-copy skew, hybriel #203)mre
- fe5f707cgitoria 010: report, mission, comment on why current = true staysmre
- 9705ca86gitoria 010: gate: menu marker in the server HTMLmre
- 8cff663agitoria 010: main-menu.hl from layouts 0bcc629 (route marker)mre
- 359c79f7gitoria 010: re-vendor Hybriel master f9614007 (plugins whole, bin/ git-ignored)mre