.
D 2026-08-17T19:35:29.458
J comment Diffs\sare\sthe\spage\sa\sforge\slives\sor\sdies\sby,\sand\sours\sis\sthe\sweakest\sthing\swe\srender.\sThe\swhole\srenderer\sis\s`classifyDiff`\s(internal/web/web.go:1217):\stwenty\slines\sthat\sprefix-match\seach\sline\sof\sa\sunified\sdiff\sand\stag\sit\s`add`/`del`/`hunk`/`head`/`ctx`.\sNothing\selse\shappens.\n\n##\sWhat\sthat\scosts,\sconcretely\n\nFrom\s`/r/pikchr/checkin/a7f1c35bc044.../diff`:\n\n\s\s\s\s-\s\s/*\sRemove\sleading\sand\strailing\swhitespace\sfrom\seach\sargument.\n\s\s\s\s+\s\s/*\sRemove\sleading\sand\strailing\swhitespace\sfrom\seach\sargument\s(including\n\nOnly\s`(including`\swas\sadded.\sThe\sreader\sgets\stwo\sfully-coloured\slines\sand\shas\sto\sdiff\sit\sby\seye.\sSame\shunk,\sa\sfew\slines\sdown,\sa\s`while`\scondition\sgains\sone\sset\sof\sparentheses\sand\sreads\sas\sa\swholesale\sreplacement.\n\nThe\sspecific\sgaps:\n\n-\s**No\ssyntax\shighlighting.**\schroma\sis\svendored\sand\salready\shighlights\sthe\sfile\spage\s(internal/api/register.go:1837).\sThe\sdiff\spage\snever\scalls\sit,\sso\severy\sdiff\sis\smonochrome\sregardless\sof\slanguage.\n-\s**No\sintra-line\sdiff**\sat\sword\sor\scharacter\sgranularity\s—\sthe\scase\sabove.\n-\s**No\sline\snumbers.**\sYou\scannot\ssay\s"look\sat\s5223".\n-\s**`+`/`-`\sare\sin\sthe\stext,\snot\sa\sgutter**,\sso\scopying\sa\shunk\scopies\sthe\smarkers.\n-\s**Raw\sunified-diff\schrome**\s(`---\sa/pikchr.y`,\s`+++\sb/pikchr.y`)\sinstead\sof\sa\sfile\sheader.\n-\s**No\scontext\sexpansion**,\sno\sper-file\snavigation\sfor\sa\smulti-file\schangeset,\sno\sunified/split\schoice.\n\n##\sThis\sis\san\sAPI\sproblem,\snot\sonly\sa\stemplate\sproblem\n\n`checkin.diff`\s(internal/api/register.go:1754)\sreturns:\n\n\s\s\s\stype\sdiffGetOut\sstruct\s{\n\s\s\s\s\s\s\s\sFrom,\sTo\sstring\n\s\s\s\s\s\s\s\sFiles\s\s\s\s[]zitcli.DiffEntry\n\s\s\s\s\s\s\s\sUnified\s\sstring\s\s\s//\s<-\sthe\sentire\sdiff,\sas\sone\sopaque\sblob\n\s\s\s\s\s\s\s\sNote\s\s\s\s\sstring\n\s\s\s\s}\n\nPrinciple\s5\ssays\sa\sfeature\sis\snot\sdone\suntil\sits\sfull\scapability\sis\sin\sthe\sAPI,\sand\sthat\sthe\sHTML\sand\sthe\sAPI\sshare\sone\squery\slayer.\sA\sstructured\sdiff\shas\sto\sland\sin\sthe\s**op**,\sor\swe\sbuild\sa\sgood\spage\son\stop\sof\sa\sstring\sand\sthe\sAPI\sstays\sscreen-scrape-only.\s`Unified`\sshould\sremain\s(it\sis\swhat\sa\sscript\swants)\sbut\sstop\sbeing\sthe\sonly\sshape.\n\n##\sProposed\smodel\n\nBuild\sit\sin\sGo.\sThe\sfactoring\sbelow\sis\sadapted\sfrom\s@pierre/diffs'\spublic\stypes\s(Apache-2.0)\s—\sworth\sborrowing\sbecause\sit\ssurvived\sa\ssecond,\swildly\sdifferent\srenderer\s(see\sreferences),\swhich\sis\sthe\sreal\sevidence\sthat\sthe\smodel\sis\sseparable\sfrom\sthe\smarkup:\n\n\s\s\s\stype\sFileDiff\sstruct\s{\n\s\s\s\s\s\s\s\sPath,\sPrevPath\sstring\n\s\s\s\s\s\s\s\sChange\s\sChangeKind\s\s\s//\schange\s|\snew\s|\sdeleted\s|\srename-pure\s|\srename-changed\n\s\s\s\s\s\s\s\sBinary\s\sbool\n\s\s\s\s\s\s\s\sHunks\s\s\s[]Hunk\n\s\s\s\s}\n\s\s\s\stype\sHunk\sstruct\s{\n\s\s\s\s\s\s\s\sOldStart,\sOldLines,\sNewStart,\sNewLines\sint\n\s\s\s\s\s\s\s\sHeader\sstring\s\s\s\s\s\s\s\s\s\s//\sthe\stext\safter\s@@\s…\s@@\n\s\s\s\s\s\s\s\sLines\s\s[]Line\n\s\s\s\s}\n\s\s\s\stype\sLine\sstruct\s{\n\s\s\s\s\s\s\s\sKind\s\s\s\sLineKind\s\s\s\s\s\s//\scontext\s|\saddition\s|\sdeletion\s|\sexpanded\s|\smetadata\n\s\s\s\s\s\s\s\sOldNum,\sNewNum\sint\s\s\s\s//\s0\swhen\sthe\sside\shas\sno\snumber\n\s\s\s\s\s\s\s\sTokens\s\s[]Token\s\s\s\s\s\s\s//\ssyntax\stokens,\spositional\n\s\s\s\s\s\s\s\sSpans\s\s\s[]Span\s\s\s\s\s\s\s\s//\sintra-line\schanged\sranges,\sin\sbyte\soffsets\n\s\s\s\s}\n\s\s\s\stype\sToken\sstruct\s{\sCol\sint;\sClass\sstring;\sText\sstring\s}\n\nTwo\sdetails\scarried\sover\sdeliberately:\n\n1.\s**A\stoken\sis\spositional\s—\s`(column,\sclass,\stext)`\s—\snot\snested\smarkup.**\sThis\sis\swhat\smakes\sthe\swhole\sthing\stractable,\sand\sit\sis\sthe\sone\sidea\sworth\staking\sabove\sall\sothers.\n2.\s**Rename\sis\ssplit\sinto\s`rename-pure`\sand\s`rename-changed`.**\sA\spure\srename\sshould\snot\srender\sa\sdiff\sbody\sat\sall.\n\n##\sThe\shard\spart\n\nSyntax\shighlighting\sand\sintra-line\sdiff\sboth\swant\sto\semit\sspans\sover\sthe\ssame\stext,\sand\sthey\sdo\snot\snest:\sa\schanged\srange\sroutinely\sstarts\sand\sends\smid-token.\sPierre\sresolves\sthis\sby\skeeping\shighlight\soutput\spositional\sand\ssplicing\sat\srender\stime;\sthat\sis\swhy\shunk\scan\sdrive\sthe\ssame\smodel\sinto\sa\sterminal\sgrid.\n\nWe\scan\sdo\sthe\ssame\sdirectly,\sbecause\schroma\shands\sus\stokens\srather\sthan\sonly\sHTML\s(internal/highlight/highlight.go:41):\n\n\s\s\s\sit,\serr\s:=\slexer.Tokenise(nil,\sstring(code))\n\nThat\siterator\syields\s`chroma.Token{Type,\sValue}`.\sThe\spipeline:\n\n1.\sParse\sthe\sunified\sdiff\sinto\sfiles/hunks/lines\s(replacing\s`classifyDiff`).\n2.\sPair\seach\sdeletion\srun\swith\sits\saddition\srun;\scompute\sa\sword-level\sdiff\sover\seach\spair\sto\sget\schanged\sbyte\sranges.\n3.\sTokenise\seach\sline\swith\schroma,\stracking\sbyte\soffsets.\n4.\sSplit\stokens\sat\sdiff-range\sboundaries\sso\severy\semitted\sspan\scarries\sexactly\sone\ssyntax\sclass\sand\sone\schange\sstate.\n5.\sRender\sthrough\sthe\sexisting\ssanitizer\sgate,\sas\s`highlight.Code`\salready\sdoes.\n\nStep\s2\sneeds\sa\sword-level\sdiff.\sEither\sa\ssmall\sdependency\sor\sa\sMyers\spass\sover\sword\stokens\s—\sdecide\swhen\swe\sget\sthere,\snot\snow.\n\n##\sScope\n\nIn:\n\n-\sstructured\sdiff\sin\sthe\sop,\s`Unified`\sretained\n-\ssyntax\shighlighting\svia\schroma,\sreusing\sthe\sexisting\sclass-based\sstylesheet\n-\sword-level\sintra-line\smarking\n-\sline\snumbers,\sand\s`+`/`-`\smoved\sto\sa\sgutter\sso\sselection\scopies\sclean\scode\n-\sproper\sfile\sheaders\swith\sthe\schange\skind,\sand\sper-file\snavigation\n-\scontext\sexpansion\n\nOut,\sdeliberately:\n\n-\s**Line-anchored\sreview\scomments.**\s0002\s§1\smakes\sthis\san\sexplicit\sdivergence:\sconversations\sanchor\sto\sartifacts,\sand\sthe\sUI\ssays\s"discuss\sthis\scheck-in",\snot\s"review".\sPierre\smodels\sannotations;\swe\sare\snot\staking\sthem.\n-\s**Merge-conflict\srendering.**\sPierre\smodels\sconflict\smarker\srows.\sNot\sa\sforge-display\sconcern\sfor\sus.\n-\s**Structural/AST\sdiffing.**\shunk's\sown\scomparison\snotes\sonly\sdifftastic\sdoes\sthis.\sOut\sof\sscope,\sand\sworth\sa\sseparate\sticket\sif\sever\swanted.\n-\s**Adopting\s@pierre/diffs\sor\shunkdiff\sas\sdependencies.**\sMeasured:\s@pierre/diffs\shas\sno\sdependency-free\sentry\spoint\s—\seven\s`./ssr`\sis\s115\sfiles\s/\s492\sKB\sand\sneeds\sShiki,\sa\sWASM-Oniguruma\shighlighter\swith\sTextMate\sgrammars.\sThat\smeans\sNode\sin\sthe\sbuild\splus\sa\ssecond\shighlighter,\sto\sget\swhat\swe\scan\sbuild\son\sthe\sone\salready\sin\sthe\sbinary.\shunkdiff\sis\s19.6\sMB\sand\stargets\sa\sterminal\svia\sOpenTUI.\n\n##\sReferences\n\n-\s@pierre/diffs\s—\sApache-2.0,\sv1.3.5,\shttps://diffs.com/\s—\sthe\sreference\simplementation\sand\sthe\ssource\sof\sthe\smodel\sfactoring\sabove.\sReading\sits\s`dist/types.d.ts`\sis\sthe\sfastest\sway\sinto\sthe\sdesign.\n-\shunk\s/\shunkdiff\s—\sMIT,\sv0.19.0,\shttps://hunk.dev/,\shttps://github.com/modem-dev/hunk\s—\sa\sterminal\sdiff\sviewer\sthat\spins\s`@pierre/[email protected]`\sand\srenders\sit\svia\sOpenTUI.\sUseful\sas\sproof\sthe\smodel\sis\srender-target-agnostic,\sand\sits\sfeature\slist\s(split/stack\sresponsive\slayout,\smulti-file\sreview\sstream,\ssidebar\snavigation)\sis\sa\sgood\srequirements\schecklist.\n\nLicensing\snote:\sboth\sare\spermissive\sand\scompatible.\sIf\swe\sadapt\sanything\sconcrete\sfrom\seither\s—\stype\sfactoring,\sCSS\smetrics,\slayout\svalues\s—\sit\sneeds\sa\s`third_party/PROVENANCE.md`\srow,\sthe\sway\sfossil's\s`default.css`\smetrics\salready\scarry\sone.\sNo\scode\sshould\scross;\sthis\sis\sthe\ssame\s[MAP]-not-[COPY]\srelationship\s0002\s§1\sdefines.\n
J status Open
J title Rebuild\sdiff\srendering:\sstructured\smodel,\ssyntax\shighlighting,\sword-level\smarking
K e16ad1d395752c1eb2ced0b324e096ffee618218
U dmestas
Z d88a2b31902a3fea76bc20c94382fdf8