Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7bafeff
feat(review): add missing Git and pull request review actions
jakeleventhal Nov 12, 2026
40ca732
fix(review): retain navigation and hosted review state after rebase
jakeleventhal Nov 12, 2026
04b236e
fix(review): preserve native overview and activity headers
jakeleventhal Nov 12, 2026
5059692
fix(review): retain composer notices and diff test coverage
jakeleventhal Nov 12, 2026
3c97167
fix(review): retain overview comment actions and composer availability
jakeleventhal Nov 12, 2026
ca65e79
perf(review): stop the guide shimmer after two passes
jakeleventhal Nov 12, 2026
74dbb22
fix(review): address draft privacy and review navigation findings
jakeleventhal Nov 12, 2026
dbfe49d
fix(review): validate outdated snapshots and isolate mobile accounts
jakeleventhal Nov 12, 2026
55a48af
fix(review): retain inline editor ownership across account changes
jakeleventhal Nov 12, 2026
b4eec92
fix(review): use one current account key for draft readers and writers
jakeleventhal Nov 12, 2026
33ad0bf
test(review): await merge confirmation dismissal
jakeleventhal Nov 12, 2026
9a1f4bb
fix(review): address remaining review and account transition findings
jakeleventhal Nov 12, 2026
f4ae642
fix(mobile): retain captured review completions during refresh
jakeleventhal Nov 12, 2026
79cff6e
fix(review): fit file tree and label composer shortcut
jakeleventhal Nov 12, 2026
01ffd78
fix(review): admin merges from the PR page send the confirmed head
jakeleventhal Nov 13, 2026
1ba26b4
fix(mobile): pull request code no longer snaps back while scrolling
jakeleventhal Nov 14, 2026
ad7feab
fix(review): preserve current client behavior and draft persistence
jakeleventhal Nov 17, 2026
7c0008a
fix(review): keep guide keyboard scope across both panes
jakeleventhal Nov 17, 2026
d6be620
test(review): use current diff content request contract
jakeleventhal Nov 17, 2026
9ccc29a
chore(review): merge main and preserve review actions
maria-rcks Nov 18, 2026
a748278
fix(review): preserve localized review actions after main merge
maria-rcks Nov 18, 2026
b29c54e
chore(review): merge current main and retain pending actions
maria-rcks Nov 18, 2026
8de813c
fix(review): scope activity readers to the current account
maria-rcks Nov 18, 2026
c8534ec
test(review): give merge action a repository target
maria-rcks Nov 18, 2026
feecb1d
Merge remote-tracking branch 'github/main' into takeover-35324
maria-rcks Nov 18, 2026
d5cb7b6
fix(mobile): clear private discussion pages on account changes
maria-rcks Nov 18, 2026
ff8f340
fix(mobile): resolve discussion viewer before keying its state
maria-rcks Nov 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import kotlin.math.max
import kotlin.math.min

internal class ReviewDiffCanvasDrawing(context: Context) {
private val density = context.resources.displayMetrics.density
val density = context.resources.displayMetrics.density
var theme: DiffTheme = DiffTheme.fallback("light")

val backgroundPaint = Paint()
Expand Down Expand Up @@ -70,90 +70,186 @@ internal class ReviewDiffCanvasDrawing(context: Context) {
)
}

fun drawDisclosureChevron(
fun drawFileHeader(
canvas: Canvas,
row: DiffRow,
rect: RectF,
color: Int,
collapsed: Boolean
style: DiffStyle,
state: FileHeaderDrawingState
) {
borderPaint.style = Paint.Style.STROKE
borderPaint.color = color
borderPaint.strokeWidth = 2f * density
borderPaint.strokeCap = Paint.Cap.ROUND
borderPaint.strokeJoin = Paint.Join.ROUND
val path = Path()
if (collapsed) {
path.moveTo(rect.left + rect.width() * 0.4f, rect.top + rect.height() * 0.28f)
path.lineTo(rect.left + rect.width() * 0.6f, rect.centerY())
path.lineTo(rect.left + rect.width() * 0.4f, rect.bottom - rect.height() * 0.28f)
val top = rect.top.toInt()
val bottom = rect.bottom.toInt()
val width = rect.width().toInt()
backgroundPaint.color = theme.headerBackground
canvas.drawRect(rect, backgroundPaint)

val chevronRect = fileHeaderChevronRect(top, bottom, style)
val iconRect = fileHeaderIconRect(top, bottom, style)
val checkboxRect = fileHeaderCheckboxRect(top, bottom, width, style)
drawDisclosureChevron(
canvas,
chevronRect,
theme.mutedText,
collapsed = state.collapsed,
)
drawFileIcon(canvas, iconRect, row.changeType)
if (state.showViewedCheckbox) {
val saved = canvas.saveLayerAlpha(checkboxRect, if (state.viewedCheckboxEnabled) 255 else 102)
drawViewedCheckbox(
canvas,
checkboxRect,
state.viewed,
)
canvas.restoreToCount(saved)
}

configureUiPaint(
paint = uiPaint,
color = theme.deleteText,
size = style.fileHeaderMetaFontSizePx,
weight = style.fileHeaderMetaFontWeight,
)
val deleteText = "-${row.deletions}"
val deleteWidth = uiPaint.measureText(deleteText)
val addText = "+${row.additions}"
val addWidth = uiPaint.measureText(addText)
val countGap = 4f * density
val countsRight = if (row.fileAction != null) {
width - 110f * density
} else if (state.showViewedCheckbox) {
checkboxRect.left - 10f * density
} else {
path.moveTo(rect.left + rect.width() * 0.28f, rect.top + rect.height() * 0.42f)
path.lineTo(rect.centerX(), rect.top + rect.height() * 0.62f)
path.lineTo(rect.right - rect.width() * 0.28f, rect.top + rect.height() * 0.42f)
width - 16f * density
}
canvas.drawPath(path, borderPaint)
borderPaint.style = Paint.Style.FILL
val countsX = countsRight - deleteWidth - countGap - addWidth
val baseline = centeredBaseline(top, bottom, uiPaint)
canvas.drawText(deleteText, countsX, baseline, uiPaint)
uiPaint.color = theme.addText
canvas.drawText(addText, countsX + deleteWidth + countGap, baseline, uiPaint)

val pathLayout = fileHeaderPathLayout(row, iconRect, countsX, style)
val maxPathOffset = maxHeaderPathOffset(pathLayout)
val pathOffset = state.pathOffset
.coerceIn(0, maxPathOffset)
drawFileHeaderPath(canvas, row, pathLayout, pathOffset, maxPathOffset)
drawFileHeaderAction(canvas, row, rect)
borderPaint.color = theme.border
borderPaint.strokeWidth = density
canvas.drawLine(0f, bottom - density / 2f, width.toFloat(), bottom - density / 2f, borderPaint)
}

private fun drawFileHeaderPath(
canvas: Canvas,
row: DiffRow,
pathLayout: FileHeaderPathLayout,
pathOffset: Int,
maxPathOffset: Int
) {
canvas.save()
canvas.clipRect(pathLayout.rect)
val metrics = uiPaint.fontMetrics
val baseline = pathLayout.rect.centerY() - (metrics.ascent + metrics.descent) / 2f
if (row.renameSegments.isNotEmpty()) {
drawRenamePath(canvas, row, pathLayout, pathOffset, baseline)
} else {
canvas.drawText(pathLayout.displayPath, pathLayout.rect.left - pathOffset, baseline, uiPaint)
}
canvas.restore()
drawFileHeaderPathScrollFades(canvas, pathLayout.rect, pathOffset, maxPathOffset)
}

fun drawFileIcon(canvas: Canvas, rect: RectF, changeType: String) {
val color = when (changeType) {
"new" -> theme.addText
"deleted" -> theme.deleteText
else -> theme.hunkText
private fun drawRenamePath(
canvas: Canvas,
row: DiffRow,
pathLayout: FileHeaderPathLayout,
pathOffset: Int,
baseline: Float
) {
var x = pathLayout.rect.left - pathOffset
for (segment in row.renameSegments) {
val segmentWidth = uiPaint.measureText(segment.text)
if (segment.kind == "removed" || segment.kind == "added") {
backgroundPaint.color =
if (segment.kind == "removed") theme.deleteBackground else theme.addBackground
canvas.drawRect(
x,
pathLayout.rect.top,
x + segmentWidth,
pathLayout.rect.bottom,
backgroundPaint
)
}
uiPaint.color = if (segment.kind == "context") theme.mutedText else theme.text
canvas.drawText(segment.text, x, baseline, uiPaint)
x += segmentWidth
}
borderPaint.style = Paint.Style.STROKE
borderPaint.color = color
borderPaint.strokeWidth = 2f * density
canvas.drawRoundRect(rect, 6f * density, 6f * density, borderPaint)
}

if (changeType == "rename-pure" || changeType == "rename-changed" || changeType == "renamed") {
drawRenameChevronIcon(canvas, rect, color)
} else {
backgroundPaint.color = color
canvas.drawCircle(rect.centerX(), rect.centerY(), 3f * density, backgroundPaint)
private fun drawFileHeaderAction(canvas: Canvas, row: DiffRow, rect: RectF) {
val top = rect.top.toInt()
val bottom = rect.bottom.toInt()
val width = rect.width().toInt()
row.fileAction?.let { label ->
val rect = RectF(
width - 96 * density,
top + 7 * density,
width - 10 * density,
bottom - 7 * density
)
backgroundPaint.color = theme.border
backgroundPaint.style = Paint.Style.STROKE
backgroundPaint.strokeWidth = density
canvas.drawRoundRect(rect, 6 * density, 6 * density, backgroundPaint)
backgroundPaint.style = Paint.Style.FILL
configureUiPaint(
uiPaint,
if (row.fileActionDisabled) theme.mutedText else theme.hunkText,
12 * density,
"semibold"
)
canvas.drawText(
label,
rect.centerX() - uiPaint.measureText(label) / 2,
centeredBaseline(top, bottom, uiPaint),
uiPaint
)
}
borderPaint.style = Paint.Style.FILL
}

fun drawViewedCheckbox(canvas: Canvas, rect: RectF, checked: Boolean) {
if (checked) {
backgroundPaint.color = theme.hunkText
canvas.drawRoundRect(rect, 6f * density, 6f * density, backgroundPaint)
}
borderPaint.style = Paint.Style.STROKE
borderPaint.color = if (checked) theme.hunkText else theme.mutedText
borderPaint.strokeWidth = 1.8f * density
canvas.drawRoundRect(rect, 6f * density, 6f * density, borderPaint)
if (checked) {
borderPaint.color = theme.background
borderPaint.strokeWidth = 2f * density
borderPaint.strokeCap = Paint.Cap.ROUND
borderPaint.strokeJoin = Paint.Join.ROUND
val path = Path().apply {
moveTo(rect.left + rect.width() * 0.28f, rect.centerY())
lineTo(rect.left + rect.width() * 0.44f, rect.bottom - rect.height() * 0.3f)
lineTo(rect.right - rect.width() * 0.25f, rect.top + rect.height() * 0.3f)
}
canvas.drawPath(path, borderPaint)
fun fileHeaderPathLayout(
row: DiffRow,
iconRect: RectF,
countsX: Float,
style: DiffStyle
): FileHeaderPathLayout {
configureUiPaint(
paint = uiPaint,
color = theme.text,
size = style.fileHeaderFontSizePx,
weight = style.fileHeaderFontWeight,
)
val pathX = iconRect.right + 10f * density
val pathWidth = max(24f * density, countsX - pathX - 12f * density)
val centerY = iconRect.centerY()
val displayPath = if (row.renameSegments.isNotEmpty()) {
row.renameSegments.joinToString("") { it.text }
} else {
row.filePath
}
borderPaint.style = Paint.Style.FILL
}

fun drawNoticeIcon(canvas: Canvas, rect: RectF, color: Int) {
borderPaint.style = Paint.Style.STROKE
borderPaint.color = color
borderPaint.strokeWidth = 1.7f * density
borderPaint.strokeCap = Paint.Cap.ROUND
canvas.drawOval(rect, borderPaint)
canvas.drawLine(
rect.centerX(),
rect.top + rect.height() * 0.3f,
rect.centerX(),
rect.top + rect.height() * 0.58f,
borderPaint,
return FileHeaderPathLayout(
displayPath = displayPath,
rect = RectF(pathX, centerY - 10f * density, pathX + pathWidth, centerY + 10f * density),
)
borderPaint.style = Paint.Style.FILL
canvas.drawCircle(rect.centerX(), rect.bottom - rect.height() * 0.24f, density, borderPaint)
}

private fun maxHeaderPathOffset(layout: FileHeaderPathLayout): Int = max(
0,
ceil(uiPaint.measureText(layout.displayPath) - layout.rect.width()).toInt(),
)

private fun centeredBaseline(top: Int, bottom: Int, paint: Paint): Float {
val metrics = paint.fontMetrics
return (top + bottom) / 2f - (metrics.ascent + metrics.descent) / 2f
}

fun configureUiPaint(paint: Paint, color: Int, size: Float, weight: String) {
Expand Down Expand Up @@ -488,25 +584,6 @@ internal class ReviewDiffCanvasDrawing(context: Context) {
}
}

private fun drawRenameChevronIcon(canvas: Canvas, rect: RectF, color: Int) {
borderPaint.style = Paint.Style.STROKE
borderPaint.color = color
borderPaint.strokeWidth = 1.8f * density
borderPaint.strokeCap = Paint.Cap.ROUND
borderPaint.strokeJoin = Paint.Join.ROUND
val chevronWidth = 3.6f * density
val chevronHeight = 8f * density
val gap = 2.4f * density
val startX = rect.centerX() - (chevronWidth * 2f + gap) / 2f
val path = Path()
for (x in listOf(startX, startX + chevronWidth + gap)) {
path.moveTo(x, rect.centerY() - chevronHeight / 2f)
path.lineTo(x + chevronWidth, rect.centerY())
path.lineTo(x, rect.centerY() + chevronHeight / 2f)
}
canvas.drawPath(path, borderPaint)
}

private fun configureTextPaint(paint: Paint, color: Int, size: Float) {
paint.textSize = size
paint.color = color
Expand Down Expand Up @@ -574,3 +651,15 @@ private fun splitAtNote(runs: List<DiffToken>, noteStart: Int?): List<Pair<DiffT
}
}
}
internal data class FileHeaderDrawingState(
val collapsed: Boolean,
val viewed: Boolean,
val showViewedCheckbox: Boolean,
val viewedCheckboxEnabled: Boolean,
val pathOffset: Int
)

internal data class FileHeaderPathLayout(
val displayPath: String,
val rect: RectF
)
Loading
Loading