Skip to content

#903 Session Chat: corner slots for floating pills - #918

Merged
ivanfenenko merged 2 commits into
mainfrom
feature/903-pill-corner-slots
Nov 1, 2026
Merged

ivanfenenko merged 2 commits into
mainfrom
feature/903-pill-corner-slots

Conversation

@ivanfenenko

@ivanfenenko ivanfenenko commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #903 (part of #899)

What

Session Chat places its floating pills in three corner slots, all on OpenCodeFloatingPill.

  • Top left, context (max 2): todos 2/5 (opens the todos sheet), then the branch pill. The branch pill is today's OpenCodeSessionBranchPill, called from the new slot; its internals are left to Session Chat: branch pill with changes popover #905.
  • Bottom left, live activity: one pill plus +N, which springs up the rest in priority order: needs input > error > btw answer ready > running > queued > finished. Finished items fade after 3 s, so beside other work they only show in the stack.
  • Bottom right, navigation: empty at the end of the chat. Scrolled up, it shows a round ↓, which becomes ↓ N new once rows arrive below where the reader left.
  • Keyboard up: the activity pill goes compact (round mark), unless it needs input. +N and the other corners hide.

Migrations:

  • btw running / answer ready / failed (Retry + ✕) → activity items.
  • The full-width pending-prompts strip → N queued, opens the existing Up next sheet.
  • New Request failed error pill with ✕. It shows for the last turn's non-neutral failure, unless the session is retrying (the countdown stays in the chat). Tapping it scrolls to the failure and flashes the row; ✕ dismisses it.
  • Scroll to end → bottom right.
  • The top-centre pill is removed. Syncing becomes a running activity item, with the same show delay and minimum time.
  • Collapsed permission/question pills: these fit the host naturally, so they are now needs input items (Review permission, Answer question, amber, no ✕), with the same tap (bring the panel back). This also makes the keyboard rule real: a needs-input pill keeps its label. Android used to show only one of the two when both were collapsed; it now shows both, like iOS. Session Chat: connect needs-input pill and prompt pills #906 can add paging and the pulse on top.

The timeline reserves the pill row: the list's bottom inset grows by pill height + gap while an activity pill shows. That is additionalSafeAreaInsets on iOS and LazyColumn bottom padding on Android, on top of the composer + snackbar inset from #897. The navigation pill only shows away from the end, so it reserves nothing.

Design for #904 / #906

The rules live in a pure SessionChatPillSlots (Swift enum / Kotlin object):

  • activity(items, keyboardVisible, now): priority sort, overflow, keyboard compaction and finished fade.
  • context(...), navigation(...), newMessageCount(...) and latestFailure(...).

A new kind of live work is one new case in SessionChatActivityItem with its priority, plus its layout/copy entry in the slot view. For example, #904's general needs input · 2 running counter is a .backgroundWork(...) case at .needsInput or .running. The Finished case and fade timer are in place for #904's completions; nothing in this PR produces one yet.

Screen-owned items (requests, btw, queued) come from the screen. The timeline adds the ones it owns (syncing, request failed) and handles scroll and reveal.

Checks

  • iOS: SessionChatPillSlotsTests (16), plus the existing TimelineScrollControllerTests, MessageListTimelineHostTests, SessionChatViewModelTests and SessionChatBranchPillTests. 258/259 passed in one run. sendPrompt_postSendReloadMatchingUser_dropsOptimistic failed once and passed when rerun alone; it is not related to this change.
  • Android: SessionChatPillSlotsTest (17) and the instrumented SessionChatTimelineActivitySlotTest (pills reachable while loading, empty or failed) and HiddenRequestPillTest (4, rewritten for the activity items) pass. assembleDebug builds. ktlint shows no new violations in the touched files.
  • Real apps against the scenario harness on v2: failure, busy run, queued, btw failed, the +N stack, keyboard, scrolled up + new messages, and tapping the failure to reveal it. Screenshots for both platforms are in a comment below.
  • Removed SessionChatTopPill and its tests on both platforms (replaced by the slot rules).

Risks / follow-ups

  • v1 not checked in the real apps: the machine has no v1 server binary. The slot code has no protocol branches.
  • Todos 2/5 was not seen in the real app (todo-list-progress is v1-only). It is covered by unit tests.
  • With the keyboard up, iOS content used to draw over the top bar. That came from this PR: the bottom pill row set a minimum height. Fixed in review; before (main) and after screenshots are in the review-fix comment.
  • Android emulator keyboard screenshots needed the Gboard IME switched in for the capture (restored afterwards).
  • OpenCodeSideQuestionPill, OpenCodePendingPromptsStrip, OpenCodeSessionTodosPill and OpenCodeSyncingPill are no longer used by Session Chat. They stay in the Component Gallery for now; they can be removed in a follow-up.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

Top left holds context (todos "2/5", branch), at most two. Bottom left holds
live activity: one pill by priority (needs input > error > btw answer ready >
running > queued > finished) plus "+N" that springs up the rest. Bottom right
shows a round ↓ away from the end, "↓ N new" once rows arrive. With the
keyboard up the activity pill goes compact unless it needs input, and "+N"
and the other corners hide. The rules live in a pure SessionChatPillSlots on
both platforms.

btw, the queued strip, the collapsed permission/question pills and scroll to
end move onto OpenCodeFloatingPill in the slots. A new "Request failed" pill
scrolls to the failure and flashes it; ✕ dismisses it. The top-centre pill is
gone; Syncing becomes a running item. The timeline reserves the pill row so no
pill covers the last message.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ivanfenenko

Copy link
Copy Markdown
Collaborator Author

Real-app evidence (scenario harness, v2)

Step iOS Android
Request failed pill (bottom left), branch top left ios request failed android request failed
Busy run: 2 queued above the composer, Working row kept clear ios queued
Error wins priority, +N ios error +N
+N stack open (priority order) ios stack android stack
Keyboard up: compact pill, no +N, corners hidden ios keyboard android keyboard
Scrolled up + new messages: ↓ N new ios new android new
Tap Request failed: scrolls to the failure and flashes it ios reveal android reveal

@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 2 passes agreed on.

5 finding(s) from a single pass, not posted
  • ios/OpenCode Mobile/OpenCode Mobile/UI/Scroll/MessageListTimelineHost.swift:808 medium: Reveal flash sticks to reused cell (muse-spark-1.3-contributor)
  • ios/OpenCode Mobile/OpenCode Mobile/UI/Scroll/MessageListTimelineHost.swift:791 medium: Reveal settles on fixed 0.4s delay (muse-spark-1.3-contributor)
  • android/app/src/main/java/dev/opencode/mobile/ui/sessionchat/view/SessionChatTimelineView.kt:723 medium: Failure tap dead while timeline hold is active (muse-spark-1.3-contributor)
  • android/app/src/main/java/dev/opencode/mobile/ui/sessionchat/view/SessionChatTimelineView.kt:201 medium: Android drops activity pills while not ready (muse-spark-1.3-contributor)
  • ios/OpenCode Mobile/OpenCode Mobile/UI/Scroll/MessageListTimelineHost.swift:787 medium: Reveal settle/flash uses a fixed 0.4 s delay, recording a mid-flight offset and flashing the wrong row (glm-5.3-flash)

opencode pr-review · passes: muse-spark-1.3-contributor, glm-5.3-flash, deepseek-v4.1-flash · $0.182 · 1 pass(es) failed

@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 #918 against #903 / #899. No blocking findings. Four should-fix and one nit are inline.

Ran: Android SessionChatPillSlotsTest (16), HiddenRequestPillTest (4), SessionBranchPillVisibilityTest (3): all pass. iOS SessionChatPillSlotsTests, SessionChatBranchPillTests, TimelineScrollControllerTests: 37/37 pass. No emulator or real-app run on my side.

Checked, no issue:

  • The slot rules match the issue on both platforms and between them: stable priority sort, +N overflow, keyboard compaction (a needs-input pill keeps its label), and the finished fade with a nextFade timer keyed by .task(id:) / LaunchedEffect, so it is cancelled and doesn't leak.
  • The stack closes when +N disappears (keyboard up, overflow emptied), and re-sorts in place when items change while it is open.
  • N new counts rows after the baseline, ignores history loaded above, and resets on reaching the end.
  • latestFailure ignores neutral marks, failures before a user row, and failures while retrying.
  • btw Retry/✕/open, N queued → Up next (iOS keeps the analytics screen view), and the collapsed permission/question taps are all wired the same as before.
  • The snackbar inset from #897 stays below the pill row (visible in the evidence).

Merge interplay

  • #916 will conflict, though not hard. It edits the branch-pill call inside the top-pill ZStack / AnimatedContent that this PR deletes. It also modifies SessionChatTopPillTest(s), which this PR deletes (modify/delete), and it threads a new onSessionBranchCopied. After the rebase, that callback has to go through SessionChatContextSlotView (new onBranchCopied param) on both platforms, and #916's SessionChatTopPillTest edits can be dropped.
  • #917: the extension point fits. Priority comes from the case, so a .backgroundWork(...) case with an associated value can switch between needs-input and running. Its pulsing-dot needs-input layout must exist as an OpenCodeFloatingPillLayout variant to map in layout(item) / SessionChatActivityPillCopy.layout. No API gap that forces rework.

Dead code: OpenCodeSideQuestionPill, OpenCodePendingPromptsStrip, OpenCodeSessionTodosPill and OpenCodeSyncingPill are now used only by the Component Gallery. Leaving them for a follow-up is fine, since removing them touches gallery entries unrelated to this slice. Please track it as an issue rather than only in the PR body.

Privacy: the code, tests and the evidence screenshots I opened show harness data only (seeded project, sk-test-****, temporary harness path).

Minor parity note, pre-existing and not inline: iOS shows /btw items even when a permission/question panel owns the composer. Android gates them on composerKind == Prompt, as both did before this PR.

/** Extra bottom inset so the timeline can scroll under a floating composer. */
val bottomOverlayInset: Dp = 0.dp,
/** Bottom-left live activity from the screen (requests, btw, queued). The timeline adds syncing and request failed. */
val activityItems: List<SessionChatActivityItem> = emptyList(),

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: Android drops every activity pill while the timeline is not Ready.

The slot only renders inside SessionChatTimelineReadyView. Creating, Loading, Error and Empty have no slot. iOS covers those states with SessionChatTimelineActivityOnlySlot. Before this PR, Android drew the collapsed-request pill, /btw chips and the queued strip in the composer column, so they showed in every timeline state.

Failure scenario: the user collapses a permission panel, then the timeline reload fails (Error) or the session is still Empty/Loading. Review permission is gone, and the composer shows the prompt because the dock is hidden. The request can't be reopened until the timeline loads. The same happens to N queued and /btw answer ready on a new session.

Fix: mirror iOS. Wrap the when (props.timeline) in a Box and, for the non-Ready branches, overlay SessionChatActivitySlotView with SessionChatPillSlots.activity(props.activityItems, props.keyboardVisible, now) at BottomStart, using the same rowBottom(props.bottomOverlayInset) padding.

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 825311d. SessionChatTimelineView now wraps every non-ready state (Creating, Loading, Empty, Error) in a Box with SessionChatTimelineActivityOnlySlot, matching iOS. Added the instrumented test SessionChatTimelineActivitySlotTest: in each of the four states, "Review permission request" shows and taps through, and "+1" (queued) is present. It passes on the emulator.

delay((fadeAt - System.currentTimeMillis()).coerceAtLeast(0L))
activityClockMs = System.currentTimeMillis()
}
val listBottomInset =

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, reserving the pill row moves the reading position when away from the end. iOS does not.

listBottomInset is the LazyColumn's contentPadding.bottom, and with reverseLayout that is the before-content padding. LazyList keeps firstVisibleItemIndex/ScrollOffset across a padding change, so every visible row moves by the delta (36 + 8 dp) when an activity pill appears or disappears. On iOS the same reserve goes through additionalSafeAreaInsets.bottom, which leaves contentOffset alone when unpinned.

Failure scenario: the user is reading mid-history during a busy run. A catch-up shows Syncing (400 ms delay, 600 ms minimum), a /btw answer lands, or they ✕ the failure pill. The text under their eye jumps about 44 dp, and with Syncing it jumps back within a second.

Fix: animate the reserve (animateDpAsState, as animatedSnackbarOverlayHeight does for #897). Or only grow the reserve while pinned to the end, which is the only time a pill can cover the last message.

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 825311d. The reserve no longer follows the pill directly. SessionChatPillSlots.reservesActivityRow(reserved, hasActivity, pinnedToEnd) updates it only at the end of the chat and holds it while scrolled away, so a pill coming or going (Syncing, a dismissed Request failed) no longer moves the rows. At the end it still follows the pill, so the last message stays clear, the same as the iOS inset re-pin. Unit test: reservedRowFollowsThePillOnlyAtTheEnd. Checked in the real app: dismissing the pill while scrolled up leaves the visible rows at identical positions. Screenshots are in the new evidence comment.

}
},
) { message, isNewestMessage, onContentSizeSettled ->
val revealAlpha = rememberREVEAL_HIGHLIGHT_ALPHA(revealed?.takeIf { it.messageId == message.id }?.token)

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 failure row flashes again every time it scrolls back into view (plus a naming nit).

revealed is never cleared, and rememberREVEAL_HIGHLIGHT_ALPHA keeps its Animatable in item-scoped remember. When the row leaves the LazyColumn and comes back, it recomposes with a fresh Animatable(0f), and LaunchedEffect(token) runs again with the same non-null token.

Failure scenario: tap Request failed, the row flashes. Scroll up a few screens and back down, and the row flashes red again with no tap, every time.

Fix: clear revealed after the animation, e.g. keep the flash in the parent (revealed plus one Animatable hoisted next to it) and set revealed = null when it ends. Or store the reveal time and skip the animation once it is older than about 2 s. Nit: the function name rememberREVEAL_HIGHLIGHT_ALPHA looks like a rename accident and should be rememberRevealHighlightAlpha (ktlint function-naming).

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 825311d. rememberRevealHighlightAlpha(token, onFinished) (renamed) reports when its flash ends, and the view then clears revealed if the token still matches. A row that leaves the list and comes back recomposes with no token and stays untinted. Checked in the real app: flash on tap, then scrolled away and back, no second flash.

? (props.sessionTodoCompletedCount, props.sessionTodoTotalCount)
: nil,
branch: props.sessionBranchPill,
keyboardVisible: props.keyboardVisible

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 keyboard now zeroes the top inset in every session, which may be the cause of the overlap the PR calls pre-existing.

context(..., keyboardVisible:) returns [] with the keyboard up. Then showTopOverlayStack turns false, updateMeasuredTopOverlayInset(0) runs, and additionalSafeAreaInsets.top drops from the measured pill height to 0. On main the top pill ignored the keyboard, so any session with a branch or todos kept that inset while typing. The risk note says the overlap showed up with no activity pill, but the activity pill is at the bottom and doesn't affect the top inset. With this PR, every keyboard-up state has a top inset of 0, which on main only happened in sessions without a branch/todos pill.

Fix / ask: compare against main on a session that has a branch pill, keyboard up. If the overlap only shows here, keep the reserved top inset while the keyboard is up (hide the pills but keep topOverlayInset, or freeze it to the last measured value until the keyboard goes down). If it also shows on main, file it separately and drop the claim that this PR doesn't touch keyboard layout.

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.

You were right that this PR caused it; it wasn't pre-existing. On main (same session, keyboard up) there is no overlap. The main cause turned out to be the bottom pill row, not the top inset. It was a ZStack child whose bottom padding (composer + keyboard) set a minimum height taller than the keyboard-shrunk area, so keyboardOverlapPadding's bottom-aligned frame pushed the timeline up under the top bar. It also happened with no pill showing. Fixed in 825311d: the row is now an .overlay(alignment: .bottom), so it can't size the timeline. As asked, the keyboard now hides the top-left pills (opacity 0, no hit testing, hidden from VoiceOver) instead of removing them, so the top inset stays (SessionChatPillSlots.showsContext). Android does the same: the measured inset stays. Before (main) / after screenshots are in the new evidence comment.


/// Brief tint behind a revealed row so the eye finds it.
private func flashItem(at indexPath: IndexPath) {
guard let cell = collectionView.cellForItem(at: indexPath) else { return }

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: the flash can land on the wrong row.

The tint UIView goes into the cell's contentView and lives for about 1.9 s. If the user flicks during that time, the cell can be reused for another row, which then shows the red tint until the animation ends. revealItem also gives up silently if the cell is off-screen after the fixed 0.4 s (e.g. a long smooth scroll from far up), so there is no flash.

Fix: remove the flash in prepareForReuse/didEndDisplaying (tag the view), or drive the tint from row state the way Android does. Optional: flash from scrollViewDidEndScrollingAnimation instead of a fixed delay.

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 825311d. The reveal keeps a pendingRevealID. If the row is already fully visible it flashes at once; otherwise it flashes in scrollViewDidEndScrollingAnimation, when the scroll lands, instead of after a fixed 0.4 s. A user drag cancels it. The tint is a view in the collection view at the row's layout frame, not in the reusable cell, so cell reuse can't carry it to another row. Checked in the real app with both an on-screen and a scrolled-away failure.

- Android: show the activity slot in every timeline state, so a collapsed
  request or queued prompts stay reachable while loading, empty or failed.
- Android: the pill row reserve follows the pill only at the end of the chat;
  away from it, it holds, so a pill coming or going no longer moves the rows.
- Android: a revealed failure flashes once; scrolling back does not flash it
  again.
- iOS: the bottom pill row is an overlay, so its composer + keyboard padding
  no longer sets a minimum height that pushed the timeline under the top bar
  with the keyboard up. The keyboard hides the top-left pills without dropping
  their inset (both platforms).
- iOS: the failure flash is keyed to the row id, drawn in the collection view
  rather than a reusable cell, and runs when the scroll lands.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ivanfenenko

Copy link
Copy Markdown
Collaborator Author

Review fixes: real-app evidence (scenario harness, v2)

iOS: keyboard up, timeline vs top bar. Same session as before; the pre-fix capture is ios-05 in the first evidence comment.

main (before this PR) this PR, fixed
main keyboard fixed keyboard

iOS: tapping Request failed while scrolled away. It scrolls, then flashes when the scroll lands.

ios reveal after scroll

Android: a pill leaving while scrolled up does not move the rows.

Request failed shown after ✕ (rows unchanged)
shown dismissed

Android: the reveal flashes once.

flash on tap scrolled away and back: no flash
flash no reflash

Android: keyboard up. The top-left pills are hidden and the inset is kept.

android keyboard

Activity slot in non-ready states (Android): covered by the instrumented SessionChatTimelineActivitySlotTest, which passes on the emulator. Loading and empty states don't last long enough in the real app to capture.

@ivanfenenko
ivanfenenko merged commit 9ed8591 into main Nov 1, 2026
@ivanfenenko
ivanfenenko deleted the feature/903-pill-corner-slots branch November 1, 2026 10:19
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: corner slots for floating pills

1 participant