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/composer.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Status values: `todo`, `partial: <what is missing>`, `done`, `n/a: <reason and w
| `OpenCode/Composer/ComposerGlassHandoff.swift` | 88 | — | n/a: sinks the composer under the photo sheet | Android uses the system photo picker, so the in-app photo sheet is not ported. |
| `OpenCode/Composer/ComposerImageImport.swift` | 211 | `ComposerImageImport.kt` | done | `SharedImageEncoder` (local copy: 20 MB source cap, 1568 px long edge, JPEG 0.8, EXIF dropped by re-encode, orientation applied by `ImageDecoder`), `ImageAttachmentImporter.process`, `ComposerItemProviderLoader` (image bytes, video first frame ≤1600 px JPEG 0.85), `ComposerImageSource` (`ItemProvider`/`PhotosPickerItem` = URIs, `Data`, `Loader`; `Transferable` folds into `Data`), `ComposerImageImporter` (supersession, max 4, oversized flag, same callbacks). Sync f657969b: `start` takes a `limit` (default 4 for pastes, shares and quotes; the photo sheet passes `MAX_PHOTO_SELECTION`, 8), 300220d1. Sync 440b77f0 (1385761f): the import's default `limit` is a plain 4 (pastes, shares and quotes). iOS PR #335 (561854a, not on iOS main yet): `SharedImageEncoder`'s `MAX_PIXEL_SIZE`, `COMPRESSION_QUALITY` and `MIME` read `:feature:media`'s `PromptImageFormat`, which a drawing's export shares (media.md). If a system-picked movie takes the inline image path, retain its picker read grant and duration for local playback; only the JPEG is attached. |
| `OpenCode/Composer/ComposerKeyboardDismissal.swift` | 45 | | n/a: Android has no finger-driven keyboard dismissal from a scroll (no `keyboardDismissPadding`); the composer's own swipe down (`ComposerSwipeDown`) is already ported | |
| `OpenCode/Composer/ComposerKeyboardMorph.swift` | 413 | `ComposerKeyboardMorph.kt` | done | Session mounts it around `ComposerArea` (iOS `composerArea`: focused = the field or the model search holding the keys, `composerPinnedExpanded`), feeds `layoutProgress` to `ComposerLayout` and the field's `topInsetFraction`, pads with `composerKeyboardSpacing` (area bottom, row top with the dictation fold) and reveals the agent/model chips with `ComposerKeyboardReveal` (`ComposerAccessoryRow` and the `rowReveal*` tunables removed, as iOS). New in f0670c5d (row opens on focus), 8d73ba25, e8168e5f. `ComposerKeyboardTunables` (chipTravel 6, chipBlur 3, fade 0.18; iOS declares them on `ComposerTunables`, which lives in session). `ComposerKeyboardPose` + `expansion`, `ComposerKeyboardMorph` (focus opens the row on `DockedKeyboard.focusAnimation` = the keyboard spring, none under Reduce Motion or `excludesKeyboard`; keyboard up hands back to its frames; `pinned` on the same curve; Reduce Motion switches the layout at once), `LocalComposerKeyboardMorph`, `KeyboardDrivenComposerLayout`/`KeyboardDrivenTextInset` → `layoutProgress(inline)`, `ComposerKeyboardSpacing` → `Modifier.composerKeyboardSpacing` (tunable values passed in, as `ComposerTunables` is session's), `ComposerKeyboardReveal`. `ComposerKeyboardProgress` reads `WindowInsets.ime` (with `imeAnimationSource/Target` for travel and `isAnimating`) instead of a display link on a keyboard-layout-guide marker: Android's IME insets already move with the keys, finger-driven or animated; holds in the background (lifecycle RESUMED, iOS `appBecameActive`), 0 while `LocalDrawerKeyboardSignals.excludesKeyboard`. `isAnimating` also needs the keys off their target: after an animation the app controlled (the drawer's keyboard hold) Compose can leave `imeAnimationSource` at the keys' old height, which kept the shut row's controls mounted over the field for good. `ComposerKeyboardReveal` follows iOS `.allowsHitTesting(expanded && progress > 0.95 && !recording)`: shut (expansion 0) its controls let touches through to the field (`Modifier.passesTouchesThrough`: placed off-screen and drawn back, as Compose hit-tests by placement and a hit child ends the search among its siblings); visible on their way in or out they keep their place, as the model picker's flights read their frames, and only swallow touches. Android-only tests: `ComposerKeyboardProgressTests.kt` (Robolectric, 3). n/a: `ComposerKeyboardProbe`/notification observers (UIKit), `ComposerKeyboardTrace` (DEBUG), `nonisolated deinit` (361c8799). Sync 71e84d71 (d1a9e59f): `composerKeyboardSpacing(sides =)` takes `ComposerSideMargins` (rest, keyboard) and interpolates the side margins on the keyboard's progress in the same layout pass as the bottom gap. Sync 01eef583 (258a9424, 01eef583): `keyboardFade` dropped; under Reduce Motion the cross-fade runs on `Motion.reduced` and clears its fading flag on completion, not a timer. Android divergence (native list): `snapsUnpin` closes the row at once when a send unpins it, so the card's own resize carries the change. iOS #314's stop of idle keyboard sampling is n/a: progress reads the IME insets, with no display link to pause. |
| `OpenCode/Composer/ComposerKeyboardMorph.swift` | 413 | `ComposerKeyboardMorph.kt` | done | Session mounts it around `ComposerArea` (iOS `composerArea`: focused = the field or the model search holding the keys, `composerPinnedExpanded`), feeds `layoutProgress` to `ComposerLayout` and the field's `topInsetFraction`, pads with `composerKeyboardSpacing` (area bottom, row top with the dictation fold) and reveals the agent/model chips with `ComposerKeyboardReveal` (`ComposerAccessoryRow` and the `rowReveal*` tunables removed, as iOS). New in f0670c5d (row opens on focus), 8d73ba25, e8168e5f. `ComposerKeyboardTunables` (chipTravel 6, chipBlur 3, fade 0.18; iOS declares them on `ComposerTunables`, which lives in session). `ComposerKeyboardPose` + `expansion`, `ComposerKeyboardMorph` (focus opens the row on `DockedKeyboard.focusAnimation` = the keyboard spring, none under Reduce Motion or `excludesKeyboard`; keyboard up hands back to its frames; `pinned` on the same curve; Reduce Motion switches the layout at once), `LocalComposerKeyboardMorph`, `KeyboardDrivenComposerLayout`/`KeyboardDrivenTextInset` → `layoutProgress(inline)`, `ComposerKeyboardSpacing` → `Modifier.composerKeyboardSpacing` (tunable values passed in, as `ComposerTunables` is session's), `ComposerKeyboardReveal`. `ComposerKeyboardProgress` reads `WindowInsets.ime` (with `imeAnimationSource/Target` for travel and `isAnimating`) instead of a display link on a keyboard-layout-guide marker: Android's IME insets already move with the keys, finger-driven or animated; holds in the background (lifecycle RESUMED, iOS `appBecameActive`), 0 while `LocalDrawerKeyboardSignals.excludesKeyboard`. `isAnimating` also needs the keys off their target: after an animation the app controlled (the drawer's keyboard hold) Compose can leave `imeAnimationSource` at the keys' old height, which kept the shut row's controls mounted over the field for good. `ComposerKeyboardReveal` follows iOS `.allowsHitTesting(expanded && progress > 0.95 && !recording)`: shut (expansion 0) its controls let touches through to the field (`Modifier.passesTouchesThrough`: placed off-screen and drawn back, as Compose hit-tests by placement and a hit child ends the search among its siblings); visible on their way in or out they keep their place, as the model picker's flights read their frames, and only swallow touches. Android-only tests: `ComposerKeyboardProgressTests.kt` (Robolectric, 4). n/a: `ComposerKeyboardProbe`/notification observers (UIKit), `ComposerKeyboardTrace` (DEBUG), `nonisolated deinit` (361c8799). Sync 71e84d71 (d1a9e59f): `composerKeyboardSpacing(sides =)` takes `ComposerSideMargins` (rest, keyboard) and interpolates the side margins on the keyboard's progress in the same layout pass as the bottom gap. Sync 01eef583 (258a9424, 01eef583): `keyboardFade` dropped; under Reduce Motion the cross-fade runs on `Motion.reduced` and clears its fading flag on completion, not a timer. Android divergence (native list): `snapsUnpin` closes the row at once when a send unpins it, so the card's own resize carries the change. iOS #314's stop of idle keyboard sampling is n/a: progress reads the IME insets, with no display link to pause. |
| `OpenCode/Composer/ComposerKeyboardStep.swift` | 82 | `ComposerKeyboardStep.kt` | done | Session applies `Modifier.composerKeyboardStepHold()` to the composer column inside its IME padding (iOS `SessionView` after `readableColumn()`). `DockedKeyboard.unanimatedStep(begin, end, window, screenMaxY)` (iOS's in `TranscriptKeyboardMotion.swift`, its geometry in dp: docked, same width, 0.5 < | step | ≤ 80, only what the keys cover of the window), `ComposerKeyboardStep` (hold springs to 0 on `ComposerTextInputTunables.lineGrowth`, starting a frame later, keeping a running spring's velocity), `Modifier.composerKeyboardStepHold()`: an IME bottom change with no IME animation running (`imeAnimationSource == imeAnimationTarget`) is the unanimated step; the window is the root view. None under Reduce Motion. `DockedKeyboard.focusAnimation(reduceMotion, excludesKeyboard)` lives beside it (used by `ComposerKeyboardMorph`). Android perf: the hold reads the IME insets in a `snapshotFlow`, not in composition, so the keyboard's animation doesn't recompose the composer column each frame. Sync 01eef583 (258a9424): line growth rides `Motion.layout`. |
| `OpenCode/Composer/ComposerMorph.swift` | 1047 | — | n/a: grows the + menu into the photo sheet | Android uses the system photo picker, so the in-app photo sheet is not ported. |
| `OpenCode/Composer/ComposerMorphTrace.swift` | 110 | | n/a: DEBUG `-lab-glass-trace` UI-test tracing (and Motion X-Ray marks) | Lab tooling for iOS UI tests; Android has no `-lab-*` launch arguments (its tracing is `:devtools`). |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -868,10 +868,11 @@ fun ComposerTextInput(
val view = LocalView.current
DisposableEffect(view) {
val controller = view.windowInsetsController
var asked = false
val listener = object : WindowInsetsController.OnControllableInsetsChangedListener {
override fun onControllableInsetsChanged(controller: WindowInsetsController, types: Int) {
if (types and android.view.WindowInsets.Type.ime() == 0) return
controller.removeOnControllableInsetsChangedListener(this)
if (asked || types and android.view.WindowInsets.Type.ime() == 0) return
asked = true
if (hasFocus && !held) keyboard?.show()
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
package ai.opencode.feature.composer

import ai.opencode.core.ui.OpenCodeAppTheme
import android.graphics.Bitmap
import android.graphics.Canvas
import android.graphics.Insets
import android.graphics.Point
import android.os.Looper
import android.os.SystemClock
import android.view.MotionEvent
import android.view.SurfaceControl
import androidx.activity.ComponentActivity
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
Expand All @@ -21,6 +26,8 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.platform.SoftwareKeyboardController
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.dp
import org.junit.Assert.assertEquals
Expand Down Expand Up @@ -101,6 +108,56 @@ class ComposerKeyboardProgressTests {
}
}

@Test fun twoFieldsSurviveTheWindowGainingControlOfTheKeys() {
val activity = Robolectric.buildActivity(ComponentActivity::class.java).setup().get()
val view = ComposeView(activity)
activity.setContentView(view)
var shows = 0
val keys = object : SoftwareKeyboardController {
override fun show() { shows++ }
override fun hide() {}
}
view.setContent {
OpenCodeAppTheme {
CompositionLocalProvider(LocalSoftwareKeyboardController provides keys) {
Column {
ComposerTextInput(text = "", onTextChange = {}, isFocused = true, onFocusedChange = {}, expanded = false, onImagePaste = {})
ComposerTextInput(text = "", onTextChange = {}, isFocused = false, onFocusedChange = {}, expanded = false, onImagePaste = {})
}
}
}
}
shadowOf(Looper.getMainLooper()).idle()
val controller = view.windowInsetsController!!
val listeners = controller.javaClass.getDeclaredField("mControllableInsetsChangedListeners")
listeners.isAccessible = true
assertEquals(2, (listeners.get(controller) as List<*>).size)

val ime = android.view.WindowInsets.Type.ime()
val imeId = Class.forName("android.view.InsetsSource").getDeclaredField("ID_IME").getInt(null)
val stateField = controller.javaClass.getDeclaredField("mState")
stateField.isAccessible = true
val state = stateField.get(controller)
state.javaClass.getMethod("getOrCreateSource", Int::class.java, Int::class.java).invoke(state, imeId, ime)
val controlClass = Class.forName("android.view.InsetsSourceControl")
val control = controlClass
.getConstructor(Int::class.java, Int::class.java, SurfaceControl::class.java, Boolean::class.java, Point::class.java, Insets::class.java)
.newInstance(imeId, ime, null, false, Point(), Insets.NONE)
val controls = java.lang.reflect.Array.newInstance(controlClass, 1)
java.lang.reflect.Array.set(controls, 0, control)
val noControls = java.lang.reflect.Array.newInstance(controlClass, 0)
val onControlsChanged = controller.javaClass.getMethod("onControlsChanged", controls.javaClass)
val showsAfterFocus = shows
onControlsChanged.invoke(controller, controls)
assertEquals(showsAfterFocus + 1, shows)
onControlsChanged.invoke(controller, noControls)
onControlsChanged.invoke(controller, controls)
assertEquals(showsAfterFocus + 1, shows)

view.disposeComposition()
assertEquals(0, (listeners.get(controller) as List<*>).size)
}

private fun tap(view: ComposeView, x: Float, y: Float) {
val down = SystemClock.uptimeMillis()
for (action in listOf(MotionEvent.ACTION_DOWN, MotionEvent.ACTION_UP)) {
Expand Down
Loading