@@ -245,7 +245,7 @@ function buildPushedSet(commits: Commit[], hashIndex: Map<string, number>): Set<
245245 return pushed ;
246246}
247247
248- function pickColor ( unsolved : PathHelper [ ] ) : number {
248+ function pickColor ( unsolved : PathHelper [ ] , overflow : { n : number } ) : number {
249249 // Track used colors in a bitmask (palette is < 32 colors) instead of allocating an
250250 // array + Set on every call. O(lanes), allocation-free. This runs once per new
251251 // branch head and per merge parent, so it adds up on graphs with many lanes.
@@ -257,7 +257,10 @@ function pickColor(unsolved: PathHelper[]): number {
257257 for ( let i = 0 ; i < COLOR_PALETTE . length ; i ++ ) {
258258 if ( ( mask & ( 1 << i ) ) === 0 ) return i ;
259259 }
260- return 0 ;
260+ // All palette colors are in use by simultaneously-active lanes (more lanes
261+ // than colors). Keep cycling through the palette instead of always returning
262+ // 0, so overflow lanes stay visually distinct rather than all turning blue.
263+ return overflow . n ++ % COLOR_PALETTE . length ;
261264}
262265
263266// ── Main parse function (SourceGit CommitGraph.Parse port) ──
@@ -281,6 +284,9 @@ export function buildFullGraph(
281284
282285 const unsolved : PathHelper [ ] = [ ] ;
283286 const ended : PathHelper [ ] = [ ] ;
287+ // Rotating fallback index for pickColor: advances each time the palette is
288+ // fully in use so overflow lanes cycle through colors instead of all reusing 0.
289+ const colorOverflow = { n : 0 } ;
284290 // Track the rail (PathHelper) each dot sits on so we can backfill the dot's
285291 // pattern color after the loop. A rail's override may be set by a tip that
286292 // appears lower on the rail than commits already processed top-to-bottom;
@@ -363,7 +369,7 @@ export function buildFullGraph(
363369 if ( major === null ) {
364370 offsetX += UNIT_W ;
365371 if ( commit . parents . length > 0 ) {
366- major = new PathHelper ( commit . parents [ 0 ] , pickColor ( unsolved ) , { x : offsetX , y : offsetY } ) ;
372+ major = new PathHelper ( commit . parents [ 0 ] , pickColor ( unsolved , colorOverflow ) , { x : offsetX , y : offsetY } ) ;
367373 unsolved . push ( major ) ;
368374 trackNext ( major ) ;
369375 result . paths . push ( major . path ) ;
@@ -408,7 +414,7 @@ export function buildFullGraph(
408414 } else {
409415 // New path for merge parent
410416 offsetX += UNIT_W ;
411- const l = new PathHelper ( parentHash , pickColor ( unsolved ) , position , { x : offsetX , y : position . y + HALF_H } ) ;
417+ const l = new PathHelper ( parentHash , pickColor ( unsolved , colorOverflow ) , position , { x : offsetX , y : position . y + HALF_H } ) ;
412418 unsolved . push ( l ) ;
413419 trackNext ( l ) ;
414420 result . paths . push ( l . path ) ;
0 commit comments