@@ -26,6 +26,7 @@ import androidx.compose.foundation.layout.Row
2626import androidx.compose.foundation.layout.Spacer
2727import androidx.compose.foundation.layout.fillMaxSize
2828import androidx.compose.foundation.layout.fillMaxWidth
29+import androidx.compose.foundation.layout.heightIn
2930import androidx.compose.foundation.layout.PaddingValues
3031import androidx.compose.foundation.layout.WindowInsets
3132import androidx.compose.foundation.layout.ime
@@ -42,8 +43,10 @@ import androidx.compose.foundation.text.KeyboardOptions
4243import androidx.compose.material.icons.Icons
4344import androidx.compose.material.icons.automirrored.filled.ArrowBack
4445import androidx.compose.material.icons.automirrored.filled.Send
46+import androidx.compose.material.icons.filled.ChatBubbleOutline
4547import androidx.compose.material.icons.filled.Close
4648import androidx.compose.material.icons.filled.KeyboardArrowDown
49+import androidx.compose.material.icons.filled.KeyboardArrowUp
4750import androidx.compose.material.icons.filled.Stop
4851import androidx.compose.material3.CircularProgressIndicator
4952import androidx.compose.material3.ExperimentalMaterial3Api
@@ -58,6 +61,7 @@ import androidx.compose.material3.OutlinedTextField
5861import androidx.compose.material3.Scaffold
5962import androidx.compose.material3.Surface
6063import androidx.compose.material3.Text
64+import androidx.compose.material3.TextButton
6165import androidx.compose.material3.TopAppBar
6266import androidx.compose.runtime.Composable
6367import androidx.compose.runtime.LaunchedEffect
@@ -71,6 +75,7 @@ import androidx.compose.ui.Alignment
7175import androidx.compose.ui.Modifier
7276import androidx.compose.ui.draw.clip
7377import androidx.compose.ui.hapticfeedback.HapticFeedbackType
78+import androidx.compose.ui.platform.LocalClipboardManager
7479import androidx.compose.ui.platform.LocalContext
7580import androidx.compose.ui.platform.LocalDensity
7681import androidx.compose.ui.platform.LocalHapticFeedback
@@ -108,6 +113,12 @@ fun ChatScreen(state: UiState, dispatch: (Event) -> Unit) {
108113 }
109114 }
110115
116+ // Offer a jump-to-top shortcut once the conversation is long and the user has
117+ // scrolled a few messages down — saves flick-scrolling back through history.
118+ val showScrollTop by remember {
119+ derivedStateOf { state.messages.size > 10 && listState.firstVisibleItemIndex > 3 }
120+ }
121+
111122 // Track how many messages the user has "seen" (i.e. was at the bottom for). While
112123 // they're scrolled up, any messages beyond that count are unseen — flag the FAB.
113124 var lastSeenCount by remember { mutableStateOf(0) }
@@ -194,12 +205,24 @@ fun ChatScreen(state: UiState, dispatch: (Event) -> Unit) {
194205 }
195206 Box(Modifier.fillMaxWidth().weight(1f)) {
196207 if (state.messages.isEmpty() && !state.loading) {
197− Text(
198− text = "Send a message to start the conversation.",
199− style = MaterialTheme.typography.bodyMedium,
200− color = MaterialTheme.colorScheme.onSurfaceVariant,
208+ Column(
201209 modifier = Modifier.align(Alignment.Center).padding(32.dp),
202− )
210+ horizontalAlignment = Alignment.CenterHorizontally,
211+ ) {
212+ Icon(
213+ Icons.Filled.ChatBubbleOutline,
214+ contentDescription = null,
215+ modifier = Modifier.size(48.dp),
216+ tint = MaterialTheme.colorScheme.primary.copy(alpha = 0.5f),
217+ )
218+ Spacer(Modifier.size(16.dp))
219+ Text(
220+ text = "Send a message to start the conversation.",
221+ style = MaterialTheme.typography.bodyMedium,
222+ color = MaterialTheme.colorScheme.onSurfaceVariant,
223+ textAlign = TextAlign.Center,
224+ )
225+ }
203226 }
204227 LazyColumn(
205228 state = listState,
@@ -246,6 +269,14 @@ fun ChatScreen(state: UiState, dispatch: (Event) -> Unit) {
246269 }
247270 },
248271 )
272+ ScrollToTopButton(
273+ visible = showScrollTop,
274+ onClick = {
275+ coroutineScope.launch {
276+ listState.animateScrollToItem(0)
277+ }
278+ },
279+ )
249280 }
250281 }
251282 }
@@ -285,6 +316,30 @@ private fun BoxScope.ScrollToBottomButton(visible: Boolean, showBadge: Boolean,
285316 }
286317}
287318
319+// Mirror of ScrollToBottomButton, pinned to the top-start corner. Same BoxScope
320+// extension trick so the top-level AnimatedVisibility overload resolves cleanly.
321+@Composable
322+private fun BoxScope.ScrollToTopButton(visible: Boolean, onClick: () -> Unit) {
323+ AnimatedVisibility(
324+ visible = visible,
325+ modifier = Modifier.align(Alignment.TopStart),
326+ enter = scaleIn() + fadeIn(),
327+ exit = scaleOut() + fadeOut(),
328+ ) {
329+ Box(Modifier.padding(16.dp)) {
330+ FloatingActionButton(
331+ onClick = onClick,
332+ modifier = Modifier.size(44.dp),
333+ ) {
334+ Icon(
335+ Icons.Filled.KeyboardArrowUp,
336+ contentDescription = "Scroll to top",
337+ )
338+ }
339+ }
340+ }
341+}
342+
288343private fun copyToClipboard(context: Context, text: String) {
289344 val clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
290345 clipboard.setPrimaryClip(ClipData.newPlainText("session", text))
@@ -442,19 +497,41 @@ private fun ChatInputBar(
442497 onStop: () -> Unit,
443498) {
444499 val haptic = LocalHapticFeedback.current
500+ val clipboardManager = LocalClipboardManager.current
445501 Surface(tonalElevation = 3.dp) {
446− Row(
502+ Column(
447503 modifier = Modifier.fillMaxWidth().imePadding().padding(horizontal = 12.dp, vertical = 8.dp),
504+ ) {
505+ Row(
506+ modifier = Modifier.fillMaxWidth(),
448507 verticalAlignment = Alignment.Bottom,
449508 horizontalArrangement = Arrangement.spacedBy(8.dp),
450509 ) {
451510 OutlinedTextField(
452511 value = draft,
453512 onValueChange = onDraftChange,
454− modifier = Modifier.weight(1f),
513+ modifier = Modifier.weight(1f).heightIn(min = 48.dp),
455514 enabled = !loading,
456515 placeholder = { Text("Message opencode…") },
457516 maxLines = 5,
517+ // Offer a quick way to wipe the draft once there's something to clear
518+ // and we're not mid-generation (where the field is a poor place to fuss).
519+ trailingIcon = if (draft.isNotEmpty() && !generating) {
520+ {
521+ IconButton(
522+ onClick = { onDraftChange("") },
523+ modifier = Modifier.size(20.dp),
524+ ) {
525+ Icon(
526+ Icons.Filled.Close,
527+ contentDescription = "Clear draft",
528+ modifier = Modifier.size(16.dp),
529+ )
530+ }
531+ }
532+ } else {
533+ null
534+ },
458535 // Surface a running count once the draft gets long, so the user has a
459536 // sense of scale before sending a wall of text.
460537 supportingText = if (draft.length > 500) {
@@ -497,5 +574,17 @@ private fun ChatInputBar(
497574 }
498575 }
499576 }
577+ // With nothing typed yet, offer a one-tap way to drop in clipboard contents.
578+ if (draft.isEmpty() && !generating && !loading) {
579+ TextButton(
580+ onClick = {
581+ clipboardManager.getText()?.text?.let { onDraftChange(it) }
582+ },
583+ contentPadding = PaddingValues(0.dp),
584+ ) {
585+ Text("Paste")
586+ }
587+ }
588+ }
500589 }
501590}