Repository navigation
#905 Session Chat: branch pill with changes popover - #916
Conversation
There was a problem hiding this comment.
Automated review: no finding that 2+ of 3 passes agreed on.
4 finding(s) from a single pass, not posted
android/app/src/main/java/dev/opencode/mobile/ui/components/chat/OpenCodeSessionBranchPill.kt:251medium: Popover DiffStat shows zero sides instead of omitting them (muse-spark-1.3-contributor)ios/OpenCode Mobile/OpenCode Mobile/Components/Chat/OpenCodeSessionBranchPill.swift:202medium: Popover DiffStat shows zero sides instead of omitting them (muse-spark-1.3-contributor)android/app/src/main/java/dev/opencode/mobile/ui/sessionchat/SessionChatViewModel.kt:1453low: Side-question notice swallows the branch-copied confirmation (glm-5.3-flash)ios/OpenCode Mobile/OpenCode Mobile/UI/SessionChat/SessionChatViewModel.swift:927low: Side-question notice swallows the branch-copied confirmation (glm-5.3-flash)
opencode pr-review · passes: muse-spark-1.3-contributor, glm-5.3-flash, deepseek-v4.1-flash · $0.104 · 1 pass(es) stopped early
ivanfenenko
left a comment
There was a problem hiding this comment.
Review of the branch pill popover (#905). The findings are inline: 2 should-fix and 3 nits, none blocking.
Verified, no finding:
- Top 3: sorted by
additions + deletionsdescending, ties by path, the same on both platforms. Both test suites cover ties. - Base branch: hidden when the server reports none or it equals the current branch. The data comes from the domain
defaultBranch, so v1 and v2 share one UI path with nothing protocol-specific. - Worktree: the worktree flag reuses
isWorktreeCheckout, which the title chrome already uses. - Loading and errors: the pill is absent until
vcsreports a branch. Ifvcs/statusfails, the previous state stays. A 404 shows the icon-only pill. - Icon:
node scripts/check-icons.mjspasses. Re-runningnpm run icons:syncon this branch produces the sameGitBranchvector andlucide_git_branchasset; only the lucide-static version in the SVG license header differs, which depends on the localnode_modules. The manifest,.manifest-hash, iOS enum and Android accessor names all agree. The sync droppinglucide_drag_handleis a pre-existing issue and not caused by this PR. - Android popover:
DropdownMenucloses on back and on outside tap. Wrapping the action rows inDropdownMenuItemdoesn't clip them: the 280 dp item max yields to the 288 dp column width. - #903 overlap:
SessionChatView.swiftandSessionChatScreen.kthave one-line edits each. The only overlap with #903 is the top-pill mount in the twoSessionChatTimelineViewfiles (about 6 lines each), which #903 replaces anyway. The pill API (summary plus two callbacks) moves cleanly into a corner slot. - Private data: none found in the code, tests or evidence comment. The screenshots use harness branch names only.
Tests run on this branch:
- iOS:
SessionBranchPillLabelTests,SessionChatBranchPillTests,SessionChatTopPillTests, 17/17 pass. - Android:
OpenCodeSessionBranchSummaryTest,SessionBranchPillVisibilityTest,SessionChatTopPillTest,SessionChatViewModelTest, 265 tests with 0 failures.
There were no bot review comments to confirm or refute.
| text = summary.branch, | ||
| style = MaterialTheme.typography.bodyMedium.copy(fontFamily = FontFamily.Monospace), | ||
| color = textStrong, | ||
| maxLines = 2, |
There was a problem hiding this comment.
should-fix: On Android, TextOverflow.MiddleEllipsis only works for single-line text. With maxLines = 2, Compose falls back to Clip (see the TextOverflow.MiddleEllipsis KDoc in ui-text 1.12).
Scenario: a long branch such as the gallery's feature/very-long-worktree-branch-name-that-must-ellipsis (57 chars) in the 230 dp text column at 14 sp monospace fits about 27 chars per line, fewer once it wraps at - and /. The second line is cut off with no ellipsis, so the name looks complete but isn't. iOS truncates in the middle as intended, so the platforms differ.
Fix: either maxLines = 1 with MiddleEllipsis (and lineLimit(1) on iOS for parity), or keep 2 lines with TextOverflow.Ellipsis. Copy branch name still gives the full value either way.
There was a problem hiding this comment.
Fixed in 8ba5121. The branch name is now one line with middle truncation on both platforms (Android maxLines = 1 + TextOverflow.MiddleEllipsis, iOS .lineLimit(1) + .truncationMode(.middle)), so they behave the same.
| ) { | ||
| Text(label, style = MaterialTheme.typography.bodySmall, color = textWeak) | ||
| Spacer(Modifier.weight(1f)) | ||
| OpenCodeDiffStat(additions = summary.additions, deletions = summary.deletions) |
There was a problem hiding this comment.
should-fix: The pill and its accessibility label leave out a zero side (+106, "106 added"), but the popover totals row and the file rows pass both counts to Diff Stat, which shows zero when it is passed. A one-sided change set therefore reads +106 on the pill and 4 files changed +106 −0 in the popover, and a deleted file reads +0 −42. The file-row TalkBack/VoiceOver label also says "0 added" (line 258 here; Swift OpenCodeSessionBranchPill.swift:218).
The PR body calls this consistent with Diff Stat. But within one component, the pill and the popover now disagree about the same numbers. Hiding zeros also handles binary files (0/0), which today render +0 −0.
Fix: pass additions.takeIf { it > 0 } / deletions.takeIf { it > 0 } here and at line 271. On iOS, pass additions > 0 ? additions : nil at lines 202/214. Build the row a11y label the same way accessibilityLabel does. Add a topFiles test case with a deletion-only file.
There was a problem hiding this comment.
Fixed in 8ba5121 on both platforms. The popover totals and file rows now pass visibleAdditions / visibleDeletions (nil for a zero side) to the Diff Stat, so they read "+106" or "−42" like the pill, and a binary or no-line file shows no counts. Spoken labels come from one shared spokenCounts helper that leaves out zero sides ("src/old.ts, 42 removed"; a binary file reads only its path). New tests popoverHidesZeroSidesAndNeverSpeaksZero / popover_hidesZeroSidesAndNeverSpeaksZero cover a deletion-only file and a binary file and check that no label says "0 added" or "0 removed". Re-captured screenshots are in a new PR comment.
| } | ||
|
|
||
| /// "3 files changed"; nil without changes. | ||
| var fileCountLabel: String? { |
There was a problem hiding this comment.
nit (wording): The header says "Based on main" and the next section says "4 files changed +106 −6". Read together, that suggests a diff of the branch against main, but the counts are uncommitted working-tree changes from vcs/status. A branch with 10 commits ahead of main and a clean tree shows "Based on main" with no changes section and no View all changes, which looks like "nothing changed vs main".
Fix: say what is being counted, for example "4 uncommitted files" or "4 files changed (uncommitted)", here and in Kotlin fileCountLabel. The no-changes pill a11y label could say "no uncommitted changes" too.
There was a problem hiding this comment.
Changed in 8ba5121 on both platforms: the popover says "N uncommitted files" ("1 uncommitted file"), and so does the pill's spoken label for changes with no line counts. "Based on main" stays.
|
|
||
| private val SessionBranchPillShape = RoundedCornerShape(percent = 50) | ||
| private val BranchPopoverWidth = 288.dp | ||
| private val BranchPopoverShape = RoundedCornerShape(12.dp) |
There was a problem hiding this comment.
nit (design system): RoundedCornerShape(12.dp) repeats OpenCodeRadius.medium. Use OpenCodeMediumShape, as OpenCodeOverflowMenu uses OpenCodeRadius. Likewise, the branch name at line 218 uses bodyMedium.copy(fontFamily = FontFamily.Monospace) where the theme already has CodeTextStyle, which is the counterpart of iOS OpenCodeTypography.code used for the same text. Using the tokens keeps the two platforms in step.
There was a problem hiding this comment.
Done in 8ba5121: the popover uses OpenCodeMediumShape and the branch name uses CodeTextStyle. The gallery's "Popover open" surface uses OpenCodeMediumShape too, and on iOS it uses OpenCodeRadius.medium instead of a hard-coded 12.
|
|
||
| /// The branch pill copied the branch name; confirm it with a snackbar. | ||
| func branchNameCopied() { | ||
| branchCopiedNotice = Self.branchCopiedMessage |
There was a problem hiding this comment.
nit (parity): Android clears branchCopiedNotice in both bind paths. iOS bind (around line 238) clears turnDiffNotice and resets lastSnackbarKey, but not branchCopiedNotice.
Scenario: copy the branch name, then rebind (for example after session.moved) before the snackbar is consumed. "Branch name copied" shows again in the rebound session.
Fix: add branchCopiedNotice = nil next to turnDiffNotice = nil in bind.
There was a problem hiding this comment.
Done in 8ba5121: branchCopiedNotice is now cleared next to turnDiffNotice in the iOS bind path. iOS binds once, in init, so this matches Android rather than fixing a reachable bug.
Re-captured after review (8ba5121)The dirty branch now also has a deletion-only file (
Screen readers read "5 uncommitted files, 106 added, 48 removed", "src/invoice.ts, 61 added", "src/legacy-format.js, 42 removed" and, for the binary file, just "logo.png". Checked through the accessibility tree on both platforms. |
8ba5121 to
41398c5
Compare
Corner placement and prototype popover (4c91692)The earlier screenshots in this PR are out of date. They show the old centred pill, and on iOS the system popover with an arrow. These replace them. Harness data only: v2 server,
Why the todos rows come from the gallery. The app shows todos only on v1 ( Checked in the real apps:
|
Rework the Session Chat branch pill onto the shared floating pill: a branch icon (worktree icon for worktree checkouts) and "+128 −14", or the icon alone with no changes. Tapping it opens a popover with the branch, its base, the file count, the three most-changed files, View all changes and a new Copy branch name action that confirms with a snackbar. Content selection lives in a pure, unit-tested summary on both platforms. Adds a git_branch Lucide icon. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- One line with middle truncation for the branch name on both platforms. - Hide zero sides in the popover totals and file rows, and never speak "0 added" or "0 removed"; binary files show no counts. - "N uncommitted files" instead of "N files changed". - Android: OpenCodeMediumShape and CodeTextStyle tokens. - iOS: clear the branch-copied notice on bind, like Android. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Match the prototype: the branch pill takes the top-left corner (branch, then todos) and its popover is a plain card under it with no arrow. The card's leading edge lines up with the pill, it sits the corner slot's 8 pt pill gap below it, keeps the slot's 16 pt inset from the screen edge, and uses a new large radius token (half the pill height) so its corners match the pill capsule. iOS draws the card in a window-level overlay (tap outside, VoiceOver escape, modal focus and hardware Escape dismiss it); Android uses a focusable Popup with its own position provider (back and tap outside dismiss it). Layout math is pure and unit-tested on both platforms. Co-Authored-By: Claude Opus 5.5 <[email protected]>
4c91692 to
c8fa73e
Compare










































Fixes #905 (part of #899)
What
Pill:
OpenCodeSessionBranchPillnow uses the sharedOpenCodeFloatingPillon both platforms. It shows a branch icon, or the worktree icon (callSplit, as on Home and in Settings) for worktree checkouts, plus "+128 −14". It never shows the branch name. With no changes it is icon-only, and VoiceOver/TalkBack read e.g. "Branch feature-x, no changes" or "Worktree branch feature-x, 128 added, 14 removed". A side with zero lines is left out ("+5"), and changes with no line counts read "2 files".Popover: tapping the pill opens a plain card under it, matching the prototype. It has no pointing arrow, its leading edge lines up with the pill, and it sits the corner slot's 8 pt/dp pill gap below the pill. It keeps the slot's 16 pt/dp inset from the screen edge, and its corners use a new
largeradius token (18, half the pill height) so they match the pill capsule. iOS draws it in a window-level overlay (OpenCodeAnchoredCardHost): tap outside, the VoiceOver escape gesture and hardware Escape dismiss it, and VoiceOver focus moves into it. Escape reusesOpenCodeBottomSheetEscapeand its hosting controller. Android uses a focusablePopupwith its own position provider (OpenCodeAnchoredCard), so back and tap outside dismiss it. The layout math is pure and unit-tested on both platforms. The card shows:With no changes it shows only the branch, its base and Copy branch name.
Pure code:
OpenCodeSessionBranchSummary(Swift and Kotlin) owns content selection: icon (worktree vs branch), label, accessibility label, the no-changes case, visible base, file count and the top 3. It has unit tests on both platforms.Icon: adds
git_branch(Lucidegit-branch) throughicons/manifest.yamlandnpm run icons:sync. Only the new icon is committed: the sync also re-stamped every SVG with a newer lucide-static header and would have dropped the hand-keptdragHandlecase, so I reverted those changes.Gallery: the Session Branch Pill entry on both platforms now shows the pill with changes, without changes, as a worktree and with many files, plus a static "Popover open" view.
Data notes
GET /vcsdefault_branchand v2GET /api/vcsbranch.default. Both protocols already provide it through the domain layer, so no new API was needed. The base line is hidden when the server doesn't report a default branch or when it equals the current branch.vcs/status, the same source the pill used before. They are not a diff against the base branch.SessionChatProjectIdentity.isWorktreeCheckout). The view model passes it into the pill state.Placement and shared files
The branch pill is mounted through #918's corner slots (
SessionChatPillSlots.context/SessionChatContextSlotView), which gain one parameter,onBranchCopied. To match the prototype and put the branch pill in the top-left corner, the context slot now orders branch, then todos. #918 had todos first; theSessionChatPillSlotstests are updated to match. The popover state lives inside the pill component.Edits to
SessionChatView.swiftandSessionChatScreen.ktare one line each: passingonSessionBranchCopied→viewModel.branchNameCopied()for the snackbar.Checks
OpenCodeAnchoredCardLayoutTests,SessionBranchPillLabelTests,SessionChatBranchPillTests,SessionChatPillSlotsTests,OpenCodeBottomSheetEscapeTests,OpenCodeFloatingPillStyleTestsand the fullSessionChatViewModelTestspass (264 Swift Testing + 4 XCTest).sendPrompt_postSendReloadMatchingUser_dropsOptimisticfailed once in a full run and passed 4 times in isolation; it's a timing test unrelated to this change.dev.opencode.mobile.ui.sessionchat.*,ui.components.*andui.componentgallery.*pass (1013 tests, 0 failures), includingOpenCodeAnchoredCardLayoutTest,OpenCodeSessionBranchSummaryTestand the view model copy test. ktlint is clean on the touched files, andassembleDebugsucceeds.feature/invoice-totalson the clipboard and showed the snackbar. View all changes opened the Changes screen.Risks / follow-ups
opencodebinary on this machine is 2.2.2 and there is no 1.x build. The v1 path only readsdefault_branch, which was already mapped before this change, and is covered by unit tests, not a live run.OpenCodeBottomSheetEscapepath as bottom sheets.🤖 Generated with Claude Code