Slide the main screen over a session with a right swipe
Switching conversation was a step back to the list and a step down into another, which disposed the session being left and refetched its whole transcript over the tunnel on the way back. A right swipe now pulls MainScreen itself over the open session -- the screen Back would have shown, moved over the session instead of replacing it -- and swiping it back off returns to a live stream, an unsent draft and the scroll position it had. Tapping the session already open is that same swipe back; tapping another is a screen of its own; deleting the one underneath closes the screen, since there is nothing left to return to. One gesture drives both this and the subagent panel (SidePanels.kt, now the home of the drag and animation SubagentPanel had): two draggables over the same content cannot share a horizontal drag, so the position is a single signed reveal, negative left and positive right, which also makes it impossible to have both open. The panels exist only inside a session, so nothing on the main screen swipes anywhere. Full width and no tonal step for this one, because a screen standing in for another must be the same colour as it; the subagent panel keeps its 88% and its sliver. The list keeps its rows while it asks again -- the panel refetches on every open, and blanking it each time handed the reader an empty screen about something never in doubt -- with a bar over the top while an answer is outstanding. Where the panel has got to is read from draw lambdas only: it changes every frame of a drag, and a body that reads it recomposes the session beneath once per frame. Composition sees booleans that change twice per gesture, the same correction the keyboard inset needed. Verified on the emulator against the sandbox with ui-trace: the panel opens and closes on the two swipes, tapping another session replaces the screen, deleting the open one leaves for the list, the subagent panel is unchanged, and neither swipe does anything on the main screen. ktfmt, compile, lint and the unit tests are clean.
This commit is contained in:
1 parent
ef788b0405
commit
c8bfc958ad
8 files changed
+418
-126
No files matched your search
@@ -0,0 +1,53 @@
|
||||
package com.example.aiapp
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
|
||||
/**
|
||||
* The app's root screen, in the full-width panel [SidePanels] slides over a session from the left.
|
||||
*
|
||||
* Not a list of its own but [MainScreen] itself, and the whole width of the screen: what a right
|
||||
* swipe gets is the screen Back would have got, moved over the session instead of replacing it. The
|
||||
* session stays composed underneath, with its stream open and its draft and scroll position where
|
||||
* they were, so swiping the panel back off returns to it for nothing -- where Back and a tap costs
|
||||
* the whole transcript over the tunnel again.
|
||||
*
|
||||
* Tapping the session already open is that same swipe back rather than a fresh screen: reopening it
|
||||
* would hand [SessionScreen] a new summary for the conversation it is already showing.
|
||||
*
|
||||
* [onGone] is the one thing the list can do that this panel cannot survive -- deleting the very
|
||||
* session it is drawn over. There is nothing left to swipe back into, so that closes the screen.
|
||||
*/
|
||||
@Composable
|
||||
fun MainPanel(
|
||||
settings: ServerSettings,
|
||||
sessionId: String,
|
||||
active: Boolean,
|
||||
onOpen: (SessionSummary) -> Unit,
|
||||
onSpawn: () -> Unit,
|
||||
onImported: (SessionSummary) -> Unit,
|
||||
onSettings: () -> Unit,
|
||||
onProvider: (String, String) -> Unit,
|
||||
onClose: () -> Unit,
|
||||
onGone: () -> Unit,
|
||||
) {
|
||||
// Asked again each time the panel opens: who is working and who is waiting on an answer is
|
||||
// exactly what changed while the session underneath was being read.
|
||||
var reloadToken by remember(sessionId) { mutableIntStateOf(0) }
|
||||
LaunchedEffect(active) { if (active) reloadToken++ }
|
||||
|
||||
MainScreen(
|
||||
settings = settings,
|
||||
reloadToken = reloadToken,
|
||||
onOpen = { if (it.id == sessionId) onClose() else onOpen(it) },
|
||||
onSpawn = onSpawn,
|
||||
onImported = onImported,
|
||||
onSettings = onSettings,
|
||||
onProvider = onProvider,
|
||||
onDeleted = { if (it == sessionId) onGone() },
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user