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
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,16 @@ class AndroidOutlinerToolbarTest {

@After fun closeBridge() { bridge?.let { ui.runOnIdle { it.close() } } }

private fun snapshot(editing: Boolean, caret: Int = title.length, taskSelected: Boolean = false): String {
private fun snapshot(
editing: Boolean,
caret: Int = title.length,
taskSelected: Boolean = false,
selected: Boolean = !editing,
): String {
val state = if (editing) JSONObject().put("editing", JSONObject().put("uuid", "toolbar-block")
.put("title", title).put("caretUTF16Offset", caret))
else JSONObject().put("selectedBlockIds", org.json.JSONArray().put("toolbar-block"))
else if (selected) JSONObject().put("selectedBlockIds", org.json.JSONArray().put("toolbar-block"))
else JSONObject()
if (taskSelected) state.put("selectedTaskBlockIds", org.json.JSONArray().put("toolbar-block"))
return JSONObject().put("ok", true).put("result", JSONObject()
.put("graphName", "Toolbar test").put("selectedGraphId", "toolbar-test")
Expand Down Expand Up @@ -93,6 +99,18 @@ class AndroidOutlinerToolbarTest {
capture("editor-toolbar")
}

@Test fun editorChromeDoesNotResizeTheOutlinerViewport() {
toolbar()
val outliner = ui.onNodeWithTag("list.outliner").assertIsDisplayed()
val editingHeight = outliner.fetchSemanticsNode().boundsInRoot.height
ui.runOnIdle {
filter.applyJson(requireNotNull(bridge).applySnapshot(snapshot(editing = false, selected = false)))
}
ui.waitForIdle()
ui.onNodeWithTag("toolbar.outliner.editor").assertDoesNotExist()
assertEquals(editingHeight, outliner.fetchSemanticsNode().boundsInRoot.height, 1f)
}

@Test fun blockSelectionUsesTheNativeFloatingToolbarContainer() {
toolbar(editing = false)
ui.onNodeWithTag("toolbar.outliner.selection").assertHeightIsAtLeast(64.dp)
Expand Down
34 changes: 34 additions & 0 deletions android/app/src/main/kotlin/com/logseq/logseq/ui/LogseqApp.kt

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔍 Required inline video attachment missing

The PR provides external WebP embeds, not the required GitHub video attachment with verified inline playback.

Devin left this for you to triage: The PR includes inline animated evidence, but not the repo-required GitHub mp4 attachment: both available GitHub tokens were rejected with 403 when gh --attach tried to upload the videos. A human with repository upload access should attach the mp4s or grant the automation permission.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.collectAsState
Expand All @@ -34,6 +35,7 @@ import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.res.stringResource
import android.content.Context
Expand All @@ -59,8 +61,13 @@ import androidx.compose.ui.semantics.testTagsAsResourceId
import androidx.compose.ui.unit.dp
import com.logseq.logseq.applyAndroidSystemBarAppearance
import androidx.core.content.edit
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsAnimationCompat
import androidx.core.view.WindowInsetsCompat
import com.logseq.logseq.runtime.LogseqRuntime
import com.logseq.logseq.runtime.RecordedAudioAsset
import com.logseq.logseq.ui.extensions.ImeDismissalSignal
import com.logseq.logseq.ui.extensions.LocalImeDismissalSignal
import com.logseq.logseq.ui.extensions.LogseqDialogs
import kotlinx.coroutines.launch

Expand Down Expand Up @@ -94,9 +101,36 @@ internal fun LogseqApp(runtime: LogseqRuntime) {
colorScheme = colorScheme,
typography = LogseqTheme.typography,
) {
val imeDismissal = remember { ImeDismissalSignal() }
// Compose owns insets callbacks on its owner view, so listen at the
// window root where the IME animation callback remains registered.
val hostView = LocalView.current.rootView
DisposableEffect(hostView, imeDismissal) {
val callback = object : WindowInsetsAnimationCompat.Callback(
WindowInsetsAnimationCompat.Callback.DISPATCH_MODE_CONTINUE_ON_SUBTREE,
) {
override fun onPrepare(animation: WindowInsetsAnimationCompat) {
val insets = ViewCompat.getRootWindowInsets(hostView)
val hidingIme = insets != null &&
insets.isVisible(WindowInsetsCompat.Type.ime()) &&
insets.getInsets(WindowInsetsCompat.Type.ime()).bottom > 0
if ((animation.typeMask and WindowInsetsCompat.Type.ime()) != 0 && hidingIme) {
imeDismissal.notifyStarted()
}
}

override fun onProgress(
insets: WindowInsetsCompat,
runningAnimations: MutableList<WindowInsetsAnimationCompat>,
): WindowInsetsCompat = insets
}
ViewCompat.setWindowInsetsAnimationCallback(hostView, callback)
onDispose { ViewCompat.setWindowInsetsAnimationCallback(hostView, null) }
}
androidx.compose.runtime.CompositionLocalProvider(
dev.lui.LocalLuiThemeDark provides dark,
dev.lui.LocalLuiSemanticColors provides LogseqTheme.semanticColors(MaterialTheme.colorScheme),
LocalImeDismissalSignal provides imeDismissal,
) {
if (BuildConfig.DEBUG) {
LaunchedEffect(Unit) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.logseq.logseq.ui.extensions

import androidx.compose.runtime.compositionLocalOf
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.SharedFlow

internal class ImeDismissalSignal {
private val mutableStarted = MutableSharedFlow<Unit>(extraBufferCapacity = 1)
val started: SharedFlow<Unit> = mutableStarted

fun notifyStarted() {
mutableStarted.tryEmit(Unit)
}
}

internal val LocalImeDismissalSignal = compositionLocalOf<ImeDismissalSignal?> { null }
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,6 @@ private fun NavigationBoundary(context: LuiExtensionContext) {
// route; count=0 asks the core to settle instead of popping.
val backDepth = context.int("back-depth") ?: depth
val dismissesComposer = context.flag("composer-dismissal-enabled")
val occupies = context.flag("bottom-occupies-layout-space")
BackHandler(enabled = !LocalSidebarBlocksMain.current && (backDepth > 0 || dismissesComposer)) {
if (dismissesComposer) {
context.emit("dismiss-composer")
Expand All @@ -431,26 +430,20 @@ private fun NavigationBoundary(context: LuiExtensionContext) {
if (childIds.size == 2) {
// Second child is the bottom chrome. Hoist it out of the content
// column like iOS's safeAreaInset/overlay so the composer's
// internal `grow` props can't starve the journal. Unbounded
// height keeps it at natural size without querying intrinsic
// measurements unsupported by subcomposed LUI layouts.
if (occupies) {
Column(Modifier.fillMaxSize()) {
Box(Modifier.weight(1f)) { NavigationContent(context, childIds[0], dismissesComposer) }
Box(Modifier.wrapContentHeight(unbounded = true)) {
context.child(childIds[1])
}
}
} else {
Box(Modifier.fillMaxSize()) {
Column(Modifier.fillMaxSize()) { NavigationContent(context, childIds[0], dismissesComposer) }
Box(
Modifier
.align(Alignment.BottomCenter)
.wrapContentHeight(unbounded = true),
) {
context.child(childIds[1])
}
// internal `grow` props can't starve the journal. Keep the
// content viewport full-size even when the core reserves space
// for editor chrome; resizing it during IME dismissal moves the
// edited block while the keyboard is still animating. Unbounded
// height keeps the chrome at natural size without querying
// intrinsic measurements unsupported by subcomposed LUI layouts.
Box(Modifier.fillMaxSize()) {
Column(Modifier.fillMaxSize()) { NavigationContent(context, childIds[0], dismissesComposer) }
Box(
Modifier
.align(Alignment.BottomCenter)
.wrapContentHeight(unbounded = true),
) {
context.child(childIds[1])
Comment on lines +439 to +446

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Autocomplete covers the final block

When a user types / in the final short block of a long page, NavigationBoundary overlays that block with suggestions. The 120 dp end spacer cannot scroll the block clear of the 220 dp suggestions panel.

Devin left this for you to triage: Autocomplete can still overlay the final block because Android now overlays chrome without giving the scroll content a matching bottom inset. I recommend a human decide whether this blocks the PR; the correct fix is a measured scroll-content inset/dynamic spacer rather than restoring viewport resize during IME dismissal.

Learn more

The Android navigation stack puts editor chrome in its second child. That chrome stacks autocomplete above the editor toolbar. The outliner ends with a spacer that measures 120 dp on Android, while the suggestions panel measures 220 dp before counting the toolbar. When the chrome overlays the list, a short final row on a long page cannot scroll high enough to clear the suggestions. The previous reserved-height layout placed the list above the panel.

Example: Scroll to the end of a long page, edit its final one-line block, and type / after a space. The suggestions overlay the block even at the end of the scroll range, where the user needs to see and place the caret.

Recommended fix: Keep the viewport size stable, but give the scrollable content enough bottom clearance for the actual overlay height. Ensure caret reveal accounts for that occluded region when suggestions open. Add a test that edits the last row of a long page with suggestions visible.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import androidx.annotation.RequiresApi
import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.isImeVisible
import androidx.compose.foundation.layout.ime
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.foundation.text.KeyboardOptions
Expand Down Expand Up @@ -53,6 +53,7 @@ import androidx.compose.foundation.text.contextmenu.builder.item
import androidx.compose.foundation.text.contextmenu.modifier.appendTextContextMenuComponents
import androidx.compose.foundation.text.contextmenu.modifier.filterTextContextMenuComponents
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.InterceptPlatformTextInput
import androidx.compose.ui.platform.PlatformTextInputInterceptor
import androidx.compose.ui.platform.PlatformTextInputMethodRequest
Expand Down Expand Up @@ -328,20 +329,84 @@ internal fun OutlinerEditor(
}
// When the system dismisses the IME while this editor still owns focus,
// end the editing session so the editor toolbar doesn't stay orphaned.
// Only fire after the IME was actually shown for this editor — with a
// hardware keyboard it is never visible.
val imeVisible = WindowInsets.isImeVisible
var imeWasVisible by remember { mutableStateOf(false) }
LaunchedEffect(focusEnabled, imeVisible) {
if (imeVisible) {
imeWasVisible = true
return@LaunchedEffect
// The root host signals IME hide animations as they start. Keep an inset
// watcher as a fallback for hosts/tests without that signal: visibility
// itself clears too late, while the animated inset starts shrinking in the
// first frames. Debounce input-connection flicker briefly, but keep the
// bottom chrome transition inside the IME animation. Only fire after the
// IME was actually shown for this editor — with a hardware keyboard it is
// never visible.
val ime = WindowInsets.ime
val density = LocalDensity.current
var dismissalEmitted by remember { mutableStateOf(false) }
var dismissalInProgress by remember { mutableStateOf(false) }
val dismissalSignal = LocalImeDismissalSignal.current
suspend fun emitImeDismissed(): Boolean {
// Structural handoffs buffer typing until the core acknowledges them.
// Wait for that reconciliation before flushing; publishing early can
// either drop those keystrokes or overwrite the pre-split block.
var lastBottom = ime.getBottom(density)
while (awaitingHandoff) {
delay(16)
val bottom = ime.getBottom(density)
// A rising inset means the close was canceled or the editor was
// reopened; don't emit a stale dismissal after the handoff.
if (bottom > lastBottom + 4) return false
lastBottom = bottom
}
if (!focusEnabled || !imeWasVisible) return@LaunchedEffect
delay(300)
if (imeWasVisible) {
imeWasVisible = false
context.emit("ime-dismissed")
NativeEditorInput.flush()
context.emit("ime-dismissed")
return true
}
LaunchedEffect(focusEnabled, dismissalSignal) {
if (!focusEnabled || dismissalSignal == null) return@LaunchedEffect
dismissalSignal.started.collect {
if (!dismissalEmitted && !dismissalInProgress) {
dismissalInProgress = true
try {
dismissalEmitted = emitImeDismissed()
} finally {
dismissalInProgress = false
}
}
}
}
LaunchedEffect(focusEnabled, ime, density) {
var imeWasVisible = false
var shownBottom = 0
var dismissalPending = false
snapshotFlow { ime.getBottom(density) }.collect { bottom ->
val shrinking = imeWasVisible && bottom < shownBottom - 4
if (bottom > 0 && !shrinking) {
imeWasVisible = true
shownBottom = maxOf(shownBottom, bottom)
dismissalPending = false
dismissalEmitted = false
return@collect
}
if (!shrinking) return@collect
// A predictive Back preview can lower the IME briefly and then
// restore it. When the root animation signal is available, this
// watcher only cleans up a missed signal after the IME reaches
// zero; without that signal, the first shrink is the early path.
if (dismissalSignal != null && bottom > 4) return@collect
if (dismissalPending) return@collect
dismissalPending = true
launch {
delay(32)
if (dismissalPending) {
imeWasVisible = false
shownBottom = 0
if (!dismissalEmitted && !dismissalInProgress) {
dismissalInProgress = true
try {
dismissalEmitted = emitImeDismissed()
} finally {
dismissalInProgress = false
}
}
}
}
}
}
val inputOwner = remember { Any() }
Expand Down
Loading