Skip to content

#905 Session Chat: branch pill with changes popover - #916

Merged
ivanfenenko merged 3 commits into
mainfrom
feature/905-branch-pill-popover
Nov 1, 2026
Merged

ivanfenenko merged 3 commits into
mainfrom
feature/905-branch-pill-popover

Conversation

@ivanfenenko

@ivanfenenko ivanfenenko commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #905 (part of #899)

What

  • Pill: OpenCodeSessionBranchPill now uses the shared OpenCodeFloatingPill on 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 large radius 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 reuses OpenCodeBottomSheetEscape and its hosting controller. Android uses a focusable Popup with 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:

    • the branch name and "Based on "
    • "N uncommitted files" with totals
    • the top 3 files by lines added plus removed (ties sorted by path), with zero sides hidden and no counts for binary files
    • View all changes, which opens the existing Changes screen (what the pill tap did before)
    • Copy branch name, which copies and confirms with the Session Chat snackbar ("Branch name copied")

    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 (Lucide git-branch) through icons/manifest.yaml and npm 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-kept dragHandle case, 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

  • Base branch is the server's default branch: v1 GET /vcs default_branch and v2 GET /api/vcs branch.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.
  • Counts are the uncommitted working-tree changes from vcs/status, the same source the pill used before. They are not a diff against the base branch.
  • Worktree vs branch comes from the existing worktree-checkout mark that the title chrome uses (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; the SessionChatPillSlots tests are updated to match. The popover state lives inside the pill component.

Edits to SessionChatView.swift and SessionChatScreen.kt are one line each: passing onSessionBranchCopied → viewModel.branchNameCopied() for the snackbar.

Checks

  • iOS unit tests (simulator): OpenCodeAnchoredCardLayoutTests, SessionBranchPillLabelTests, SessionChatBranchPillTests, SessionChatPillSlotsTests, OpenCodeBottomSheetEscapeTests, OpenCodeFloatingPillStyleTests and the full SessionChatViewModelTests pass (264 Swift Testing + 4 XCTest). sendPrompt_postSendReloadMatchingUser_dropsOptimistic failed once in a full run and passed 4 times in isolation; it's a timing test unrelated to this change.
  • Android JVM tests: dev.opencode.mobile.ui.sessionchat.*, ui.components.* and ui.componentgallery.* pass (1013 tests, 0 failures), including OpenCodeAnchoredCardLayoutTest, OpenCodeSessionBranchSummaryTest and the view model copy test. ktlint is clean on the touched files, and assembleDebug succeeds.
  • Real apps against the scenario harness, on a dirty feature branch (4 files, +106 −6) and a clean server-created worktree, in light and dark, on both platforms. Screenshots are in the comment below. Copy branch name put feature/invoice-totals on the clipboard and showed the snackbar. View all changes opened the Changes screen.

Risks / follow-ups

  • Only the v2 server was exercised live. The opencode binary on this machine is 2.2.2 and there is no 1.x build. The v1 path only reads default_branch, which was already mapped before this change, and is covered by unit tests, not a live run.
  • The real-app evidence can't show the todos pill: the app shows todos only on v1, and the only server here is v2. The "next to todos" rows come from the Component Gallery, which uses the same components and gap.
  • I haven't tried hardware Escape on iOS on a device. It uses the same OpenCodeBottomSheetEscape path as bottom sheets.

🤖 Generated with Claude Code

@ivanfenenko

Copy link
Copy Markdown
Collaborator Author

Evidence (scenario harness, v2 server, harness data only)

Session A: dirty feature branch feature/invoice-totals (4 files, +106 −6). Session B: clean, server-created worktree feature/tax-rounding.

Step iOS Android
Pill with changes, light
Popover with changes, light
Copy branch name → snackbar
View all changes → Changes screen
Pill with changes, dark
Popover with changes, dark
Clean worktree pill (icon only), dark
Clean worktree popover, dark
Clean worktree pill, light
Clean worktree popover, light

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:251 medium: Popover DiffStat shows zero sides instead of omitting them (muse-spark-1.3-contributor)
  • ios/OpenCode Mobile/OpenCode Mobile/Components/Chat/OpenCodeSessionBranchPill.swift:202 medium: 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:1453 low: Side-question notice swallows the branch-copied confirmation (glm-5.3-flash)
  • ios/OpenCode Mobile/OpenCode Mobile/UI/SessionChat/SessionChatViewModel.swift:927 low: 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 ivanfenenko left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 + deletions descending, 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 vcs reports a branch. If vcs/status fails, the previous state stays. A 404 shows the icon-only pill.
  • Icon: node scripts/check-icons.mjs passes. Re-running npm run icons:sync on this branch produces the same GitBranch vector and lucide_git_branch asset; only the lucide-static version in the SVG license header differs, which depends on the local node_modules. The manifest, .manifest-hash, iOS enum and Android accessor names all agree. The sync dropping lucide_drag_handle is a pre-existing issue and not caused by this PR.
  • Android popover: DropdownMenu closes on back and on outside tap. Wrapping the action rows in DropdownMenuItem doesn't clip them: the 280 dp item max yields to the 288 dp column width.
  • #903 overlap: SessionChatView.swift and SessionChatScreen.kt have one-line edits each. The only overlap with #903 is the top-pill mount in the two SessionChatTimelineView files (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,

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@ivanfenenko ivanfenenko Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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? {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@ivanfenenko

Copy link
Copy Markdown
Collaborator Author

Re-captured after review (8ba5121)

The dirty branch now also has a deletion-only file (src/legacy-format.js, −42). The worktree has one binary change (logo.png, no line counts).

Step iOS Android
Popover: zero sides hidden, "5 uncommitted files", light
Same, dark
Binary-only worktree: no counts, dark
Binary-only worktree, light

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.

@ivanfenenko
ivanfenenko changed the base branch from main to feature/903-pill-corner-slots November 1, 2026 09:42
@ivanfenenko
ivanfenenko force-pushed the feature/905-branch-pill-popover branch from 8ba5121 to 41398c5 Compare November 1, 2026 09:42
@ivanfenenko

Copy link
Copy Markdown
Collaborator Author

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, acme-invoices on feature/invoice-totals (4 uncommitted files, +106 −6).

Step iOS Android
Branch pill in the top-left corner, light
Popover open: no arrow, left edges lined up, pill gap below, pill-matched corners, light
Copy branch name → snackbar
Corner pill, dark
Popover open, dark
Next to the todos pill (Component Gallery, real pill and popover)
Same, other appearance

Why the todos rows come from the gallery. The app shows todos only on v1 (session/:id/todo), and the only opencode on this machine is v2 2.2.2, which has no todo tool. So the real-app session can't show a todos pill. The gallery row uses the same components and the same 8 pt/dp corner-slot gap, with the branch pill first as in Session Chat.

Checked in the real apps:

  • iOS: tap outside dismisses the card.
  • Android: back and tap outside dismiss the card.
  • Both: View all changes and Copy branch name close it. Copy put feature/invoice-totals on the clipboard and showed the snackbar.

Base automatically changed from feature/903-pill-corner-slots to main November 1, 2026 10:19
ivanfenenko and others added 3 commits November 1, 2026 11:20
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]>
@ivanfenenko
ivanfenenko force-pushed the feature/905-branch-pill-popover branch from 4c91692 to c8fa73e Compare November 1, 2026 10:20
@ivanfenenko
ivanfenenko merged commit d78022e into main Nov 1, 2026
@ivanfenenko
ivanfenenko deleted the feature/905-branch-pill-popover branch November 1, 2026 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Session Chat: branch pill with changes popover

1 participant