Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/parity/session.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/parity/transcript.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Status values: `todo`, `partial: <what is missing>`, `done`, `n/a: <reason and w
| `OpenCode/Transcript/TranscriptListViewController+NewMessages.swift` | 484 | `list/TranscriptList.kt` (`NewDividerState`, `decideNewMessages`) | done | Same decisions as iOS: at the end, what's new fits when the mark row's top is on screen (no divider, `NewMessagesFit`); otherwise the divider is drawn and scrolled to the top (`showRowTop`), holding earlier history until the reader drags; the divider is passed once it's above the top (`NewMessagesPlacement.isPassed`) and read when it's on screen at rest at the end (`NewMessagesPassed`). Android divergence (AGENTS.md): the transcript list is a bottom-anchored `LazyColumn(reverseLayout = true)` with standard Compose motion: no reveal glide. |
| `OpenCode/Transcript/TranscriptListViewController+RowGrowth.swift` | 385 | — | n/a: Android divergence (AGENTS.md): the transcript list is a bottom-anchored `LazyColumn(reverseLayout = true)` with standard Compose motion; rows lay out at their full height; a new row at the end expands in (`RowArrival`). | |
| `OpenCode/Transcript/TranscriptListViewController+RowPresentation.swift` | 197 | `list/TranscriptList.kt` (`RowArrival`) | n/a: Android divergence (AGENTS.md): the transcript list is a bottom-anchored `LazyColumn(reverseLayout = true)` with standard Compose motion; up to three rows that arrive at the end `expandVertically` + `fadeIn` (`ARRIVAL_SPRING`, M3 fast spatial); no row exits. | |
| `OpenCode/Transcript/TranscriptListViewController+ScrollFollow.swift` | 739 | `list/TranscriptList.kt`, `list/TranscriptListScroller.kt` | done | Android divergence (AGENTS.md): the transcript list is a bottom-anchored `LazyColumn(reverseLayout = true)` with standard Compose motion: following is the reversed list staying at index 0 (`requestScrollToItem(0)` when rows arrive); Jump to Latest and a send while browsing jump close (`JUMP_NEAR` rows) and `animateScrollToItem(0)`; the jump button shows past 120 dp (iOS `leaveDistance`) and hides as the glide starts; a selection holds the reader's place. |
| `OpenCode/Transcript/TranscriptListViewController+ScrollFollow.swift` | 739 | `list/TranscriptList.kt`, `list/TranscriptListScroller.kt` | done | Android divergence (AGENTS.md): the transcript list is a bottom-anchored `LazyColumn(reverseLayout = true)` with standard Compose motion: following is the reversed list staying at index 0 (`requestScrollToItem(0)` when rows arrive); Jump to Latest and a send while browsing jump close (`JUMP_NEAR` rows) and `animateScrollToItem(0)`; the jump button shows past 120 dp (iOS `leaveDistance`) and hides as the glide starts; a selection holds the reader's place. **Android addition (not on iOS):** `scrollToPreviousUserMessage()` glides the nearest loaded user message above the view to the visible top on Jump to latest's glide; older history loads as usual near the top. |
| `OpenCode/Transcript/TranscriptListViewController+BorrowedDrag.swift` | 238 | `list/TranscriptBorrowedDrag.kt`, `list/TranscriptListScroller.kt` (`handleBorrowedDrag`, `cancelBorrowedDrag`) | done | Sync timeline-motion. Android divergence: the drag scrolls the `LazyListState` itself and ends in the platform fling; no hand-rolled rubber band, coast or watchdog (a cancelled pointer ends the drag). iOS d8e26f81 (a coast caught past an end springs back) n/a: `LazyListState` never scrolls past its ends (the stretch overscroll is the platform's and always settles). Sync 03adf07a (d921863e): n/a, the coast bounce ω is iOS drag physics; Android flings with the platform. |
| `OpenCode/Transcript/TranscriptListViewController+SendFlights.swift` | 368 | — | n/a: Android divergence (AGENTS.md): the transcript list is a bottom-anchored `LazyColumn(reverseLayout = true)` with standard Compose motion; no send flight; the sent bubble arrives in the list (`RowArrival`) while the composer resets (`:feature:session` `ComposerSendReset`). | |
| `OpenCode/Transcript/TranscriptListViewController+SnapshotAnchoring.swift` | 385 | `list/TranscriptList.kt` | done | Keyed LazyColumn keeps the anchor row through prepends, regroups and updates; while browsing (or dragging) the reading anchor is the first transcript row below one only peeking from under the header (44 dp), restored after the update's layout; browsing window retention via stable keys; `markBrowsingRevisions(touched, isRepaint)` runs from `applySnapshot` with the message rows whose content changed (no repaint path here) |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ai.opencode.core.motion.motionBlurReveal
import ai.opencode.core.motion.rememberReduceMotion
import ai.opencode.core.ui.OpenCodeIcon
import ai.opencode.core.ui.OpenCodeShape
import ai.opencode.core.ui.OpenCodeSpacing
import ai.opencode.core.ui.OpenCodeTextStyles
import ai.opencode.core.ui.OpenCodeTheme
import ai.opencode.core.ui.RollingNumber
Expand Down Expand Up @@ -79,6 +80,7 @@ import androidx.compose.ui.input.pointer.PointerEventPass
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.layout.HorizontalAlignmentLine
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.layout.layout
import androidx.compose.ui.layout.Measurable
import androidx.compose.ui.layout.Placeable
import androidx.compose.ui.layout.layoutId
Expand Down Expand Up @@ -787,22 +789,82 @@ fun JumpToLatestPill(
isShown: Boolean,
onClick: () -> Unit,
modifier: Modifier = Modifier,
showsPrevious: Boolean = false,
onPrevious: () -> Unit = {},
collapsesSlot: Boolean = false,
veiled: () -> Boolean = { false },
) {
val reduceMotion = rememberReduceMotion()
val scrollToLatestDescription = stringResource(R.string.session_scroll_to_latest_description)
val presence = remember { Animatable(if (isShown) 1f else 0f) }
var mounted by remember { mutableStateOf(isShown) }
val presence = rememberJumpButtonPresence(isShown, reduceMotion)
val slotOpen = if (reduceMotion) (if (isShown) 1f else 0f) else presence.progress.value.coerceIn(0f, 1f)
val slotWidth = if (collapsesSlot) (48f + JumpToLatestPillMotion.gap) * slotOpen else 48f
val previousShown = isShown && showsPrevious
val previousPresence = rememberJumpButtonPresence(previousShown, reduceMotion)
Box(Modifier.width(slotWidth.dp).heightIn(min = 48.dp), contentAlignment = Alignment.CenterEnd) {
JumpButton(
presence = presence,
isShown = isShown,
onClick = onClick,
symbol = SFSymbol.ArrowDown,
description = stringResource(R.string.session_scroll_to_latest_description),
testTag = "scroll-to-latest",
veiled = veiled,
reduceMotion = reduceMotion,
modifier = modifier,
)
// Above the down arrow without taking layout space, so the down arrow never moves.
Box(
Modifier.align(Alignment.CenterEnd).layout { measurable, _ ->
val button = measurable.measure(Constraints())
val rise = (34.dp + OpenCodeSpacing.stack).roundToPx()
layout(0, 0) { button.place(-button.width, -rise - button.height / 2) }
},
) {
JumpButton(
presence = previousPresence,
isShown = previousShown,
onClick = onPrevious,
symbol = SFSymbol.ArrowUp,
description = stringResource(R.string.session_scroll_to_previous_message_description),
testTag = "scroll-to-previous-message",
veiled = veiled,
reduceMotion = reduceMotion,
modifier = modifier,
)
}
}
}

private class JumpButtonPresence(shown: Boolean) {
val progress = Animatable(if (shown) 1f else 0f)
var mounted by mutableStateOf(shown)
}

@Composable
private fun rememberJumpButtonPresence(isShown: Boolean, reduceMotion: Boolean): JumpButtonPresence {
val presence = remember { JumpButtonPresence(isShown) }
LaunchedEffect(isShown, reduceMotion) {
if (isShown) mounted = true
if (isShown) presence.mounted = true
val spec = Motion.microIn.animation<Float>(if (isShown) MotionPhase.Enter else MotionPhase.Exit, reduceMotion)
presence.animateTo(if (isShown) 1f else 0f, spec)
if (!isShown) mounted = false
presence.progress.animateTo(if (isShown) 1f else 0f, spec)
if (!isShown) presence.mounted = false
}
val slotOpen = if (reduceMotion) (if (isShown) 1f else 0f) else presence.value.coerceIn(0f, 1f)
return presence
}

@Composable
private fun JumpButton(
presence: JumpButtonPresence,
isShown: Boolean,
onClick: () -> Unit,
symbol: SFSymbol,
description: String,
testTag: String,
veiled: () -> Boolean,
reduceMotion: Boolean,
modifier: Modifier,
) {
val interactions = remember { MutableInteractionSource() }
val slotWidth = if (collapsesSlot) (48f + JumpToLatestPillMotion.gap) * slotOpen else 48f
// Only a shown pill takes touches. Leaving (its fade-out) or gone, a tap or a drag reaches the
// transcript under it; the 48 dp slot never takes any. A finger already down on the pill keeps
// [modifier] (the borrowed drag) to release as the pill leaves under it.
Expand All @@ -822,45 +884,41 @@ fun JumpToLatestPill(
}
}
}
Box(Modifier.width(slotWidth.dp).heightIn(min = 48.dp), contentAlignment = Alignment.CenterEnd) {
Box(if (isShown || touched) modifier.then(tracksTouch) else Modifier) {
if (mounted) {
val p = presence.value
Box(if (isShown || touched) modifier.then(tracksTouch) else Modifier) {
if (presence.mounted) {
val p = presence.progress.value
Box(
Modifier
.graphicsLayer { if (veiled()) alpha = 0f }
.scale(if (reduceMotion) 1f else 0.5f + 0.5f * p)
.alpha(p.coerceIn(0f, 1f))
.coveredByBackgroundWork()
.then(
if (isShown && !veiled()) {
Modifier
.clickable(interactionSource = interactions, indication = null, role = Role.Button, onClick = onClick)
.semantics { contentDescription = description }
.testTag(testTag)
} else {
Modifier.clearAndSetSemantics { }
},
)
.openCodeTapTarget(accessibility = false),
contentAlignment = Alignment.Center,
) {
// Not an M3 Surface: a plain one swallows every touch on it, fading or not.
Box(
Modifier
.graphicsLayer { if (veiled()) alpha = 0f }
.scale(if (reduceMotion) 1f else 0.5f + 0.5f * p)
.alpha(p.coerceIn(0f, 1f))
.coveredByBackgroundWork()
.then(
if (isShown && !veiled()) {
Modifier
.clickable(interactionSource = interactions, indication = null, role = Role.Button, onClick = onClick)
.semantics { contentDescription = scrollToLatestDescription }
.testTag("scroll-to-latest")
} else {
Modifier.clearAndSetSemantics { }
},
)
.openCodeTapTarget(accessibility = false),
.size(34.dp)
// The desktop's floating icon button: rounded square, hairline ring.
.shadow(OpenCodeSurfaces.raisedShadow, OpenCodeShape.control)
.clip(OpenCodeShape.control)
.background(OpenCodeSurfaces.color)
.openCodeHairline(OpenCodeShape.control)
.indication(interactions, ripple()),
contentAlignment = Alignment.Center,
) {
// Not an M3 Surface: a plain one swallows every touch on it, fading or not.
Box(
Modifier
.size(34.dp)
// The desktop's floating icon button: rounded square, hairline ring.
.shadow(OpenCodeSurfaces.raisedShadow, OpenCodeShape.control)
.clip(OpenCodeShape.control)
.background(OpenCodeSurfaces.color)
.openCodeHairline(OpenCodeShape.control)
.indication(interactions, ripple()),
contentAlignment = Alignment.Center,
) {
Box(contentAlignment = Alignment.Center) {
OpenCodeIcon(SFSymbol.ArrowDown, contentDescription = null, size = 18.dp, tint = OpenCodeTheme.colors.text)
}
}
OpenCodeIcon(symbol, contentDescription = null, size = 18.dp, tint = OpenCodeTheme.colors.text)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,19 @@ class SessionScrollEdgeBridge {
*/
var reportedShowsJumpButton = false

/** The same for the previous message button above it. */
var reportedShowsPreviousMessageButton = false

/** Content scrolled under the header (dp), capped at the reveal distance and rounded. */
var scrolledUnderHeader by mutableFloatStateOf(0f)
private set

/** Bumped to scroll the list to its latest row. */
var jumpRequest by mutableIntStateOf(0)

/** Bumped to scroll the list to the user message above what's shown. */
var previousMessageRequest by mutableIntStateOf(0)

/** iOS `onBorrowedDrag`: drags on the controls over the list (Jump to latest, queued, capsule) scroll it. */
val borrowedDrag = TranscriptBorrowedDrag()

Expand Down Expand Up @@ -78,11 +84,13 @@ class SessionScrollEdgeBridge {
* Jump to latest's last state goes with it within the same process.
*/
val Saver: Saver<SessionScrollEdgeBridge, Any> = listSaver(
save = { listOf(it.composerHeight, it.reportedShowsJumpButton, process) },
save = { listOf(it.composerHeight, it.reportedShowsJumpButton, process, it.reportedShowsPreviousMessageButton) },
restore = {
SessionScrollEdgeBridge().apply {
composerHeight = it[0] as Float
reportedShowsJumpButton = it[1] as Boolean && it.getOrNull(2) == process
val sameProcess = it.getOrNull(2) == process
reportedShowsJumpButton = it[1] as Boolean && sameProcess
reportedShowsPreviousMessageButton = it.getOrNull(3) == true && sameProcess
}
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,9 @@ fun SessionTranscriptView(
onDispose {
host?.showsJumpButton = false
host?.veilsJumpButton = false
host?.showsPreviousMessageButton = false
scrollEdgeBridge.reportedShowsJumpButton = false
scrollEdgeBridge.reportedShowsPreviousMessageButton = false
}
}

Expand All @@ -270,6 +272,11 @@ fun SessionTranscriptView(
onScrolledUnderHeader = { scrollEdgeBridge.scrolled(underHeader = it, revealDistance = top.revealDistance) },
borrowedDrag = scrollEdgeBridge.borrowedDrag,
onHidesChanged = { host?.veilsJumpButton = it },
previousMessageRequest = scrollEdgeBridge.previousMessageRequest,
onShowsPreviousMessageButtonChanged = {
host?.showsPreviousMessageButton = it
scrollEdgeBridge.reportedShowsPreviousMessageButton = it
},
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ fun SessionView(
SessionComposerHost().apply {
connection = listContext.connection
showsJumpButton = scrollEdgeBridge.reportedShowsJumpButton
showsPreviousMessageButton = scrollEdgeBridge.reportedShowsPreviousMessageButton
}
}
val importer = rememberSessionAttachmentImporter(store)
Expand Down Expand Up @@ -250,6 +251,7 @@ fun SessionView(
composerHost.connection = listContext.connection
composerHost.onConnectionAction = onConnectionAction
composerHost.onJumpToLatest = { scrollEdgeBridge.jumpRequest += 1 }
composerHost.onJumpToPreviousMessage = { scrollEdgeBridge.previousMessageRequest += 1 }
composerHost.borrowedDrag = scrollEdgeBridge.borrowedDrag
composerHost.isImportingAttachments = isImportingAttachments
composerHost.isImportingImages = isImportingImages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ class SessionComposerHost {
var veilsJumpButton by mutableStateOf(false)
/** iOS `scrollEdgeBridge.jumpRequest += 1`. */
var onJumpToLatest: () -> Unit by mutableStateOf({})
/** Android: the up arrow above the jump button, while a user message starts above the view. */
var showsPreviousMessageButton by mutableStateOf(false)
var onJumpToPreviousMessage: () -> Unit by mutableStateOf({})
/** iOS `passesDragsToTranscript(scrollEdgeBridge)`: the transcript a pill's drag scrolls. */
var borrowedDrag: TranscriptBorrowedDrag? by mutableStateOf(null)
/** Where [BackgroundWorkPresentation] draws the capsule (iOS `backgroundActivityAnchor()`). */
Expand Down Expand Up @@ -1043,6 +1046,8 @@ private fun SessionComposerEnv.ComposerAreaContent(modifier: Modifier) {
JumpToLatestPill(
isShown = jumpShown,
onClick = host.onJumpToLatest,
showsPrevious = host.showsPreviousMessageButton && !holdsClientToolCard,
onPrevious = host.onJumpToPreviousMessage,
veiled = { host.veilsJumpButton },
modifier = Modifier.passesDragsToTranscript(host.borrowedDrag, isEnabled = jumpShown && !host.veilsJumpButton),
)
Expand Down Expand Up @@ -1152,7 +1157,7 @@ private fun SessionComposerEnv.ComposerPills() {
// Beside the queued pill the jump slot carries its own gap, so the queued pill slides over as it closes.
Row(verticalAlignment = Alignment.CenterVertically) {
QueuedActivity(hasQueued)
JumpToLatestPill(isShown = showsJump, onClick = host.onJumpToLatest, collapsesSlot = hasQueued, veiled = { host.veilsJumpButton }, modifier = Modifier.passesDragsToTranscript(host.borrowedDrag, isEnabled = showsJump && !host.veilsJumpButton))
JumpToLatestPill(isShown = showsJump, onClick = host.onJumpToLatest, showsPrevious = host.showsPreviousMessageButton && !holdsClientToolCard, onPrevious = host.onJumpToPreviousMessage, collapsesSlot = hasQueued, veiled = { host.veilsJumpButton }, modifier = Modifier.passesDragsToTranscript(host.borrowedDrag, isEnabled = showsJump && !host.veilsJumpButton))
}
}
} else {
Expand All @@ -1161,7 +1166,7 @@ private fun SessionComposerEnv.ComposerPills() {
if (hasQueued || showsJump) {
Row(verticalAlignment = Alignment.CenterVertically) {
QueuedActivity(hasQueued)
JumpToLatestPill(isShown = showsJump, onClick = host.onJumpToLatest, collapsesSlot = hasQueued, veiled = { host.veilsJumpButton }, modifier = Modifier.passesDragsToTranscript(host.borrowedDrag, isEnabled = showsJump && !host.veilsJumpButton))
JumpToLatestPill(isShown = showsJump, onClick = host.onJumpToLatest, showsPrevious = host.showsPreviousMessageButton && !holdsClientToolCard, onPrevious = host.onJumpToPreviousMessage, collapsesSlot = hasQueued, veiled = { host.veilsJumpButton }, modifier = Modifier.passesDragsToTranscript(host.borrowedDrag, isEnabled = showsJump && !host.veilsJumpButton))
}
}
}
Expand Down
Loading
Loading