Skip to content

Commit b5b9d3a

Browse files
jakeleventhalclaude
andcommitted
feat(review): unify pull request and Git review across clients
Replayed onto d53873b as one commit: upstream reorganised the pull request panel, mobile navigation and test suites under all 39 commits. Adaptations to current main: - Range comments use main's review.rangeComment and draft startPosition; this branch's position.startLine/startSide and multilineComment are gone, and the server's range checks and mobile drafts use startPosition. - Review RPCs register in main's split RPC groups instead of a separate group. - Header actions port into PullRequestPrimaryAction/PullRequestActionsMenu: admin-override merge control, no Explain or Write guide items. - Remembered Files/Git workspace restores through main's thread route selection. - Change request terminology from main is kept across web and mobile. - Browser tests use main's disposable render helper; suites main pruned stay deleted apart from this branch's own new tests. - Convex _generated directories classify as generated output. Squashes: - 01ee501 feat(review): unify PR and Git reviews across desktop and mobile - 746465e fix(mobile): unify files and git workspace - 5e9100d fix(mobile): retain merge back in the thread toolbar - 42a9ecb fix(mobile): use live git status for the workspace badge - 575ea4c fix(mobile): open Git on the file tree - d4de385 docs: describe the mobile git overview and file navigation - b9eb9bf fix(mobile): stabilize Git staging and simplify PR review controls - ba713e7 fix(web): refine Git staging and chapter review - 9505138 fix(personal): keep review RPC handler inference bounded - 4548dd2 fix(review): preserve staging context and private review drafts - 37d9b28 feat(review): add PR-wide comment tracking and keep guide files together - 7224019 fix(review): keep staging context stable and resolve threads optimistically - 4e425ca fix(mobile): keep shared diff parsing free of browser globals - c0f849f feat(review): refine comment navigation and move guide context into chapter rail - 7f11433 fix(review): save pending comments to GitHub and simplify workspace tabs - 6b7c980 fix(review): refine desktop review layouts and partial reverts - 529f74b feat(mobile): align review comments, guides, and partial Git actions - 8cb9d37 fix(mobile): bundle shared diff icons and whitespace parser - 5d05095 fix(mobile): restore comments sheet layout and automatic guide loading - 5ea4915 fix(mobile): render review badges without oversized image frames - d70e915 fix(review): remove unused guide and timeline components - 44d579d fix(mobile): satisfy native diff static analysis - 35f0572 fix(review): address cross-client review findings - 19850f3 fix(review): keep guide generation glimmer running - 516c190 feat(review): add Git tree selection context menus - f92fe4d fix(review): preserve chapter totals when filtering files - 7c850dd feat(review): review selected files from the diff tree - 84dd3ef feat(review): widen and resize the Guide chapter panel - 6dbee49 fix(review): preserve upstream review behavior after rebase - bbed4aa fix(review): adapt source to current mobile components and generated GitHub API - 34e3f7d fix(review): preserve React Compiler rendering patterns - a7362ff fix(sync): preserve upstream behavior and compiler compatibility for PR 19703 - ba207f1 fix(review): refresh host marks after a partially failed batch - b079345 fix(mobile): stabilize PR chapter review counts and address review feedback - 2433ea1 fix: preserve source behavior against current upstream contracts - 21c9918 fix: retain complete review data and validate GitHub fixtures - 89d437a feat(review): reply to pending and inline PR conversations in Code and Guide - 1913168 test(review): complete private reply comment fixture - eb353fd fix(review): unify file categories and stabilize chapter counts Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent d53873b commit b5b9d3a

273 files changed

Lines changed: 25882 additions & 5673 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/mobile/modules/t3-review-diff/android/src/main/java/expo/modules/t3reviewdiff/ReviewDiffCanvasDrawing.kt‎

Lines changed: 196 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import kotlin.math.max
1515
import kotlin.math.min
1616

1717
internal class ReviewDiffCanvasDrawing(context: Context) {
18-
private val density = context.resources.displayMetrics.density
18+
val density = context.resources.displayMetrics.density
1919
var theme: DiffTheme = DiffTheme.fallback("light")
2020

2121
val backgroundPaint = Paint()
@@ -70,6 +70,188 @@ internal class ReviewDiffCanvasDrawing(context: Context) {
7070
)
7171
}
7272

73+
fun drawFileHeader(
74+
canvas: Canvas,
75+
row: DiffRow,
76+
rect: RectF,
77+
style: DiffStyle,
78+
state: FileHeaderDrawingState
79+
) {
80+
val top = rect.top.toInt()
81+
val bottom = rect.bottom.toInt()
82+
val width = rect.width().toInt()
83+
backgroundPaint.color = theme.headerBackground
84+
canvas.drawRect(rect, backgroundPaint)
85+
86+
val chevronRect = fileHeaderChevronRect(top, bottom, style)
87+
val iconRect = fileHeaderIconRect(top, bottom, style)
88+
val checkboxRect = fileHeaderCheckboxRect(top, bottom, width, style)
89+
drawDisclosureChevron(
90+
canvas,
91+
chevronRect,
92+
theme.mutedText,
93+
collapsed = state.collapsed,
94+
)
95+
drawFileIcon(canvas, iconRect, row.changeType)
96+
if (state.showViewedCheckbox) {
97+
val saved = canvas.saveLayerAlpha(checkboxRect, if (state.viewedCheckboxEnabled) 255 else 102)
98+
drawViewedCheckbox(
99+
canvas,
100+
checkboxRect,
101+
state.viewed,
102+
)
103+
canvas.restoreToCount(saved)
104+
}
105+
106+
configureUiPaint(
107+
paint = uiPaint,
108+
color = theme.deleteText,
109+
size = style.fileHeaderMetaFontSizePx,
110+
weight = style.fileHeaderMetaFontWeight,
111+
)
112+
val deleteText = "-${row.deletions}"
113+
val deleteWidth = uiPaint.measureText(deleteText)
114+
val addText = "+${row.additions}"
115+
val addWidth = uiPaint.measureText(addText)
116+
val countGap = 4f * density
117+
val countsRight = if (row.fileAction != null) {
118+
width - 110f * density
119+
} else if (state.showViewedCheckbox) {
120+
checkboxRect.left - 10f * density
121+
} else {
122+
width - 16f * density
123+
}
124+
val countsX = countsRight - deleteWidth - countGap - addWidth
125+
val baseline = centeredBaseline(top, bottom, uiPaint)
126+
canvas.drawText(deleteText, countsX, baseline, uiPaint)
127+
uiPaint.color = theme.addText
128+
canvas.drawText(addText, countsX + deleteWidth + countGap, baseline, uiPaint)
129+
130+
val pathLayout = fileHeaderPathLayout(row, iconRect, countsX, style)
131+
val maxPathOffset = maxHeaderPathOffset(pathLayout)
132+
val pathOffset = state.pathOffset
133+
.coerceIn(0, maxPathOffset)
134+
drawFileHeaderPath(canvas, row, pathLayout, pathOffset, maxPathOffset)
135+
drawFileHeaderAction(canvas, row, rect)
136+
borderPaint.color = theme.border
137+
borderPaint.strokeWidth = density
138+
canvas.drawLine(0f, bottom - density / 2f, width.toFloat(), bottom - density / 2f, borderPaint)
139+
}
140+
141+
private fun drawFileHeaderPath(
142+
canvas: Canvas,
143+
row: DiffRow,
144+
pathLayout: FileHeaderPathLayout,
145+
pathOffset: Int,
146+
maxPathOffset: Int
147+
) {
148+
canvas.save()
149+
canvas.clipRect(pathLayout.rect)
150+
val metrics = uiPaint.fontMetrics
151+
val baseline = pathLayout.rect.centerY() - (metrics.ascent + metrics.descent) / 2f
152+
if (row.renameSegments.isNotEmpty()) {
153+
drawRenamePath(canvas, row, pathLayout, pathOffset, baseline)
154+
} else {
155+
canvas.drawText(pathLayout.displayPath, pathLayout.rect.left - pathOffset, baseline, uiPaint)
156+
}
157+
canvas.restore()
158+
drawFileHeaderPathScrollFades(canvas, pathLayout.rect, pathOffset, maxPathOffset)
159+
}
160+
161+
private fun drawRenamePath(
162+
canvas: Canvas,
163+
row: DiffRow,
164+
pathLayout: FileHeaderPathLayout,
165+
pathOffset: Int,
166+
baseline: Float
167+
) {
168+
var x = pathLayout.rect.left - pathOffset
169+
for (segment in row.renameSegments) {
170+
val segmentWidth = uiPaint.measureText(segment.text)
171+
if (segment.kind == "removed" || segment.kind == "added") {
172+
backgroundPaint.color =
173+
if (segment.kind == "removed") theme.deleteBackground else theme.addBackground
174+
canvas.drawRect(
175+
x,
176+
pathLayout.rect.top,
177+
x + segmentWidth,
178+
pathLayout.rect.bottom,
179+
backgroundPaint
180+
)
181+
}
182+
uiPaint.color = if (segment.kind == "context") theme.mutedText else theme.text
183+
canvas.drawText(segment.text, x, baseline, uiPaint)
184+
x += segmentWidth
185+
}
186+
}
187+
188+
private fun drawFileHeaderAction(canvas: Canvas, row: DiffRow, rect: RectF) {
189+
val top = rect.top.toInt()
190+
val bottom = rect.bottom.toInt()
191+
val width = rect.width().toInt()
192+
row.fileAction?.let { label ->
193+
val rect = RectF(
194+
width - 96 * density,
195+
top + 7 * density,
196+
width - 10 * density,
197+
bottom - 7 * density
198+
)
199+
backgroundPaint.color = theme.border
200+
backgroundPaint.style = Paint.Style.STROKE
201+
backgroundPaint.strokeWidth = density
202+
canvas.drawRoundRect(rect, 6 * density, 6 * density, backgroundPaint)
203+
backgroundPaint.style = Paint.Style.FILL
204+
configureUiPaint(
205+
uiPaint,
206+
if (row.fileActionDisabled) theme.mutedText else theme.hunkText,
207+
12 * density,
208+
"semibold"
209+
)
210+
canvas.drawText(
211+
label,
212+
rect.centerX() - uiPaint.measureText(label) / 2,
213+
centeredBaseline(top, bottom, uiPaint),
214+
uiPaint
215+
)
216+
}
217+
}
218+
219+
fun fileHeaderPathLayout(
220+
row: DiffRow,
221+
iconRect: RectF,
222+
countsX: Float,
223+
style: DiffStyle
224+
): FileHeaderPathLayout {
225+
configureUiPaint(
226+
paint = uiPaint,
227+
color = theme.text,
228+
size = style.fileHeaderFontSizePx,
229+
weight = style.fileHeaderFontWeight,
230+
)
231+
val pathX = iconRect.right + 10f * density
232+
val pathWidth = max(24f * density, countsX - pathX - 12f * density)
233+
val centerY = iconRect.centerY()
234+
val displayPath = if (row.renameSegments.isNotEmpty()) {
235+
row.renameSegments.joinToString("") { it.text }
236+
} else {
237+
row.filePath
238+
}
239+
return FileHeaderPathLayout(
240+
displayPath = displayPath,
241+
rect = RectF(pathX, centerY - 10f * density, pathX + pathWidth, centerY + 10f * density),
242+
)
243+
}
244+
245+
private fun maxHeaderPathOffset(layout: FileHeaderPathLayout): Int = max(
246+
0,
247+
ceil(uiPaint.measureText(layout.displayPath) - layout.rect.width()).toInt(),
248+
)
249+
250+
private fun centeredBaseline(top: Int, bottom: Int, paint: Paint): Float {
251+
val metrics = paint.fontMetrics
252+
return (top + bottom) / 2f - (metrics.ascent + metrics.descent) / 2f
253+
}
254+
73255
fun drawDisclosureChevron(
74256
canvas: Canvas,
75257
rect: RectF,
@@ -466,3 +648,16 @@ private object ReviewDiffTypefaces {
466648
else -> regular
467649
}
468650
}
651+
652+
internal data class FileHeaderDrawingState(
653+
val collapsed: Boolean,
654+
val viewed: Boolean,
655+
val showViewedCheckbox: Boolean,
656+
val viewedCheckboxEnabled: Boolean,
657+
val pathOffset: Int
658+
)
659+
660+
internal data class FileHeaderPathLayout(
661+
val displayPath: String,
662+
val rect: RectF
663+
)
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
package expo.modules.t3reviewdiff
2+
3+
import android.graphics.Canvas
4+
import android.graphics.Color
5+
import android.graphics.Paint
6+
import android.graphics.RectF
7+
8+
internal fun ReviewDiffCanvasDrawing.drawCommentRow(
9+
canvas: Canvas,
10+
row: DiffRow,
11+
rect: RectF,
12+
style: DiffStyle,
13+
collapsed: Boolean
14+
) {
15+
val top = rect.top.toInt()
16+
val bottom = rect.bottom.toInt()
17+
val width = rect.width().toInt()
18+
backgroundPaint.color = theme.background
19+
canvas.drawRect(rect, backgroundPaint)
20+
val cardRect = RectF(
21+
8f * density,
22+
top + 5f * density,
23+
width - 8f * density,
24+
bottom - 5f * density,
25+
)
26+
backgroundPaint.color = theme.headerBackground
27+
canvas.drawRoundRect(cardRect, 10f * density, 10f * density, backgroundPaint)
28+
borderPaint.style = Paint.Style.STROKE
29+
borderPaint.color = commentColorAlpha(theme.border, 217)
30+
borderPaint.strokeWidth = density
31+
canvas.drawRoundRect(cardRect, 10f * density, 10f * density, borderPaint)
32+
borderPaint.style = Paint.Style.FILL
33+
34+
val chevronRect = RectF(
35+
cardRect.left + 10f * density,
36+
cardRect.top + 11f * density,
37+
cardRect.left + 26f * density,
38+
cardRect.top + 27f * density,
39+
)
40+
drawDisclosureChevron(canvas, chevronRect, theme.mutedText, collapsed)
41+
configureUiPaint(
42+
paint = textPaint,
43+
color = theme.mutedText,
44+
size = style.fileHeaderSubtextFontSizePx,
45+
weight = style.fileHeaderSubtextFontWeight,
46+
)
47+
val title =
48+
row.commentResolvedSummary ?: "Comment on ${row.commentRangeLabel.ifEmpty { "line" }}"
49+
val titleRight = cardRect.right - (if (row.commentPending) 98f else 20f) * density
50+
canvas.drawText(
51+
ellipsizeDiffText(title, textPaint, titleRight - chevronRect.right),
52+
chevronRect.right + 10f * density,
53+
cardRect.top + 22f * density,
54+
textPaint,
55+
)
56+
if (row.commentPending) drawCommentPendingBadge(canvas, cardRect)
57+
if (!collapsed) {
58+
textPaint.color = theme.text
59+
val bodyX = cardRect.left + 18f * density
60+
canvas.drawText(
61+
ellipsizeDiffText(
62+
row.commentText.ifEmpty { "Comment" },
63+
textPaint,
64+
cardRect.right - bodyX - 18f * density
65+
),
66+
bodyX,
67+
cardRect.top + 58f * density,
68+
textPaint,
69+
)
70+
}
71+
}
72+
73+
private fun ReviewDiffCanvasDrawing.drawCommentPendingBadge(canvas: Canvas, cardRect: RectF) {
74+
val badge = RectF(
75+
cardRect.right - 88f * density,
76+
cardRect.top + 7f * density,
77+
cardRect.right - 10f * density,
78+
cardRect.top + 31f * density
79+
)
80+
val amber = Color.rgb(217, 119, 6)
81+
backgroundPaint.color = commentColorAlpha(amber, 35)
82+
canvas.drawRoundRect(badge, 5f * density, 5f * density, backgroundPaint)
83+
borderPaint.color = amber
84+
borderPaint.style = Paint.Style.STROKE
85+
borderPaint.strokeWidth = density
86+
val cx = badge.left + 12f * density
87+
val cy = badge.top + 12f * density
88+
canvas.drawCircle(cx, cy, 6f * density, borderPaint)
89+
canvas.drawLine(cx, cy - 3f * density, cx, cy, borderPaint)
90+
canvas.drawLine(cx, cy, cx + 3f * density, cy + density, borderPaint)
91+
borderPaint.style = Paint.Style.FILL
92+
textPaint.color = amber
93+
canvas.drawText("Pending", badge.left + 23f * density, badge.top + 17f * density, textPaint)
94+
}
95+
96+
private fun commentColorAlpha(color: Int, alpha: Int): Int =
97+
Color.argb(alpha, Color.red(color), Color.green(color), Color.blue(color))

0 commit comments

Comments
 (0)