git.iko.soy/opencode-android
on 7571397 help sign in
10 files changed+35−623
since splitsnapshots
unifiedsplit
app/src/main/java/soy/iko/opencode/CoreViewModel.kt−5 app/src/main/java/soy/iko/opencode/core/HttpClient.kt−1 app/src/main/java/soy/iko/opencode/core/OpencodeCore.kt+6−69 app/src/main/java/soy/iko/opencode/core/SseClient.kt−1 app/src/main/java/soy/iko/opencode/ui/OpencodeApp.kt+2−55 app/src/main/java/soy/iko/opencode/ui/components/MessageBubble.kt+5−225 app/src/main/java/soy/iko/opencode/ui/screens/ChatScreen.kt+11−145 app/src/main/java/soy/iko/opencode/ui/screens/ConnectScreen.kt+2−37 app/src/main/java/soy/iko/opencode/ui/screens/SessionsScreen.kt+9−75 app/src/main/java/soy/iko/opencode/ui/theme/Theme.kt−10
app/src/main/java/soy/iko/opencode/CoreViewModel.kt−5
@@ -23,9 +23,6 @@ class CoreViewModel(app: Application) : AndroidViewModel(app) {
2323 init {
2424 prefs.getString(KEY_URL, null)?.let { core.dispatch(Event.ServerUrlChanged(it)) }
2525 prefs.getString(KEY_USER, null)?.let { core.dispatch(Event.UsernameChanged(it)) }
26− // The password is stored in plain text in SharedPreferences — a deliberate
27− // convenience trade-off for a local dev tool so reconnecting is one tap.
28− prefs.getString(KEY_PASSWORD, null)?.let { core.dispatch(Event.PasswordChanged(it)) }
2926
3027 // On a fresh process after a configuration change, resume the SSE stream if
3128 // the core is already connected (no-op otherwise — it guards on `connected`).
@@ -47,7 +44,6 @@ class CoreViewModel(app: Application) : AndroidViewModel(app) {
4744 prefs.edit {
4845 putString(KEY_URL, state.serverUrl)
4946 putString(KEY_USER, state.username)
50− putString(KEY_PASSWORD, state.password)
5147 }
5248 }
5349 }
@@ -61,6 +57,5 @@ class CoreViewModel(app: Application) : AndroidViewModel(app) {
6157 private companion object {
6258 const val KEY_URL = "serverUrl"
6359 const val KEY_USER = "username"
64− const val KEY_PASSWORD = "password"
6560 }
6661}
app/src/main/java/soy/iko/opencode/core/HttpClient.kt−1
@@ -51,7 +51,6 @@ class HttpClient(
5151 ): Result<HttpResp> = withContext(Dispatchers.IO) {
5252 runCatching {
5353 val builder = Request.Builder().url(url).method()
54− builder.header("User-Agent", "opencode-android/1.0")
5554 if (auth != null) builder.header("Authorization", auth)
5655 await(okhttp.newCall(builder.build()))
5756 }
app/src/main/java/soy/iko/opencode/core/OpencodeCore.kt+6−69
@@ -60,18 +60,6 @@ class OpencodeCore(
6060 // Tracks the in-flight loadMessages coroutine. Rapidly switching sessions launches
6161 // several; cancel the prior one so only the newest fetch runs (saves needless requests).
6262 private var loadMessagesJob: Job? = null
63− // Tracks the in-flight probeHealth coroutine. Rapid double-taps on Connect would
64− // otherwise launch two concurrent health probes; cancel the prior one first.
65− private var connectJob: Job? = null
66− // Tracks the in-flight DeleteSession coroutine so navigating away can cancel it
67− // before its response handler mutates the sessions list / screen the user already left.
68− private var deleteSessionJob: Job? = null
69− // Tracks the in-flight sendMessage coroutine so navigating away or switching sessions
70− // can cancel it before its response handler touches stale message state.
71− private var sendMessageJob: Job? = null
72− // Tracks the in-flight abort coroutine (CancelGeneration) so rapid cancel taps don't
73− // fire multiple abort requests, and navigating away can cancel it.
74− private var abortJob: Job? = null
7563 // Message IDs removed via SSE; a late MessageUpdated for one must not resurrect it.
7664 private val removedMessageIds = mutableSetOf<String>()
7765
@@ -96,12 +84,10 @@ class OpencodeCore(
9684 // Leave authRequired as-is; probeHealth sets it from the response (true on
9785 // 401, false on success). Resetting it here just flickers the auth fields.
9886 loading = true; error = null; emit()
99− connectJob?.cancel()
100− connectJob = scope.launch { probeHealth() }
87+ scope.launch { probeHealth() }
10188 }
10289
10390 Event.LoadSessions -> {
104− if (!connected) { error = "Not connected"; emit(); return }
10591 loading = true; emit()
10692 loadSessionsJob?.cancel()
10793 loadSessionsJob = scope.launch { loadSessions() }
@@ -121,29 +107,22 @@ class OpencodeCore(
121107 generating = false
122108 error = null
123109 emit()
124− connectJob?.cancel()
125− abortJob?.cancel()
126− sendMessageJob?.cancel()
127− deleteSessionJob?.cancel()
128110 loadMessagesJob?.cancel()
129111 loadMessagesJob = scope.launch { loadMessages(event.id) }
130112 }
131113
132114 Event.CreateSession -> {
133− if (!connected) { error = "Not connected"; emit(); return }
134115 loading = true; error = null; emit()
135116 createSessionJob?.cancel()
136117 createSessionJob = scope.launch { createSession() }
137118 }
138119
139120 is Event.DeleteSession -> {
140− if (!connected) { error = "Not connected"; emit(); return }
141121 val id = event.id
142122 // Delete on the server first; only drop it from the UI once that
143123 // succeeds, so a failed request leaves the session recoverable.
144124 loading = true; error = null; emit()
145− deleteSessionJob?.cancel()
146− deleteSessionJob = scope.launch {
125+ scope.launch {
147126 http.delete("$serverUrl/session/$id", authHeader()).fold(
148127 onSuccess = { resp ->
149128 if (resp.code in 200..299) {
@@ -176,10 +155,7 @@ class OpencodeCore(
176155 messages.forEach { it.streaming = false }
177156 emit()
178157 val id = currentSessionId ?: return
179− // Debounce rapid cancel taps: cancel any in-flight abort before firing
180− // another so we don't stack duplicate abort requests.
181− abortJob?.cancel()
182− abortJob = scope.launch { http.postJson("$serverUrl/session/$id/abort", "{}", authHeader()) }
158+ scope.launch { http.postJson("$serverUrl/session/$id/abort", "{}", authHeader()) }
183159 }
184160
185161 Event.NavigateToSessions -> {
@@ -189,16 +165,9 @@ class OpencodeCore(
189165 removedMessageIds.clear()
190166 draft = ""
191167 generating = false
192− // Clear any error from the chat (e.g. a failed send) so it doesn't
193− // linger on the sessions list after the user navigates back.
194− error = null
195168 loading = true
196169 emit()
197− connectJob?.cancel()
198− abortJob?.cancel()
199170 createSessionJob?.cancel()
200− deleteSessionJob?.cancel()
201− sendMessageJob?.cancel()
202171 loadMessagesJob?.cancel()
203172 loadSessionsJob?.cancel()
204173 loadSessionsJob = scope.launch { loadSessions() }
@@ -217,11 +186,7 @@ class OpencodeCore(
217186 // Reset to the default so a late-firing close callback from the old
218187 // SSE connection can't flash the reconnecting banner on the next connect.
219188 sseConnected = true
220− connectJob?.cancel()
221− abortJob?.cancel()
222189 createSessionJob?.cancel()
223− deleteSessionJob?.cancel()
224− sendMessageJob?.cancel()
225190 loadMessagesJob?.cancel()
226191 closeSse()
227192 emit()
@@ -236,27 +201,13 @@ class OpencodeCore(
236201 if (connected && sse == null) startSse()
237202 }
238203
239− fun shutdown() {
240− // Cancel every tracked coroutine before tearing down the stream so none can
241− // emit into a cancelled scope after the ViewModel is cleared.
242− connectJob?.cancel()
243− loadSessionsJob?.cancel()
244− createSessionJob?.cancel()
245− loadMessagesJob?.cancel()
246− deleteSessionJob?.cancel()
247− sendMessageJob?.cancel()
248− abortJob?.cancel()
249− closeSse()
250− }
204+ fun shutdown() = closeSse()
251205
252206 // ── Effects ────────────────────────────────────────────────────────────────
253207 private fun sendMessage(raw: String) {
254208 val text = raw.trim()
255209 val session = currentSessionId ?: return
256210 if (text.isEmpty()) return
257− // Debounce rapid double-taps on send: a send is already in flight, so a second
258− // tap would create a duplicate user message and fire a duplicate request.
259− if (generating) return
260211 localSeq += 1
261212 val user = MsgState("local-$localSeq", "user", System.currentTimeMillis()).apply {
262213 status = MessageStatus.Pending
@@ -272,8 +223,7 @@ class OpencodeCore(
272223 emit()
273224
274225 val body = Protocol.json.encodeToString(PromptBody.serializer(), PromptBody(listOf(TextInput(text = text))))
275− sendMessageJob?.cancel()
276− sendMessageJob = scope.launch {
226+ scope.launch {
277227 val result = http.postJson("$serverUrl/session/$session/prompt_async", body, authHeader())
278228 result.fold(
279229 onSuccess = { resp ->
@@ -306,10 +256,6 @@ class OpencodeCore(
306256 when {
307257 resp.code == 401 -> {
308258 loading = false
309− // A prior connection may have succeeded (connected = true); a
310− // re-probe returning 401 (e.g. expired credentials) means we're
311− // no longer authenticated, so drop the connected flag.
312− connected = false
313259 // Always reveal the auth fields so the user can see/edit
314260 // their credentials — even when the ones supplied were wrong.
315261 authRequired = true
@@ -331,7 +277,6 @@ class OpencodeCore(
331277 }
332278 else -> {
333279 loading = false
334− connected = false
335280 error = "Server returned status ${resp.code}"
336281 emit()
337282 }
@@ -339,7 +284,6 @@ class OpencodeCore(
339284 },
340285 onFailure = { e ->
341286 loading = false
342− connected = false
343287 error = "Connection failed: ${e.message}"
344288 emit()
345289 },
@@ -372,10 +316,6 @@ class OpencodeCore(
372316 if (session != null) {
373317 if (sessions.none { it.id == session.id }) {
374318 sessions.add(0, SessionView(session.id, displayTitle(session.title)))
375− // Restore the alphabetical order immediately (matching loadSessions /
376− // SessionUpserted) so the new session doesn't sit out-of-order at the
377− // top until the SSE SessionUpserted event arrives to re-sort.
378− sessions.sortBy { it.title.lowercase() }
379319 }
380320 emit()
381321 // SelectSession takes over the loading state (loads messages).
@@ -482,7 +422,7 @@ class OpencodeCore(
482422 } else {
483423 messages.add(MsgState(info.id, "assistant", info.time.created).apply { this.streaming = streaming })
484424 }
485− info.error?.let { error = it.message(); messages.forEach { m -> m.streaming = false }; generating = false }
425+ info.error?.let { error = it.message(); generating = false }
486426 return true
487427 }
488428
@@ -545,9 +485,6 @@ class OpencodeCore(
545485 } else {
546486 sessions.add(0, SessionView(event.info.id, title))
547487 }
548− // Keep the list alphabetically sorted (matching loadSessions) so an
549− // upserted session doesn't jump to the top and break the ordering.
550− sessions.sortBy { it.title.lowercase() }
551488 if (isCurrent(event.info.id)) currentSessionTitle = title
552489 return true
553490 }
app/src/main/java/soy/iko/opencode/core/SseClient.kt−1
@@ -33,7 +33,6 @@ class SseClient(
3333
3434 fun connect() {
3535 val builder = Request.Builder().url(url).header("Accept", "text/event-stream")
36− builder.header("User-Agent", "opencode-android/1.0")
3736 if (auth != null) builder.header("Authorization", auth)
3837 source = EventSources.createFactory(client).newEventSource(builder.build(), listener)
3938 }
app/src/main/java/soy/iko/opencode/ui/OpencodeApp.kt+2−55
@@ -7,19 +7,13 @@ import androidx.compose.animation.slideOutHorizontally
77import androidx.compose.animation.togetherWith
88import androidx.compose.foundation.layout.fillMaxSize
99import androidx.compose.foundation.layout.padding
10−import androidx.compose.material3.AlertDialog
1110import androidx.compose.material3.Scaffold
1211import androidx.compose.material3.SnackbarDuration
1312import androidx.compose.material3.SnackbarHost
1413import androidx.compose.material3.SnackbarHostState
15−import androidx.compose.material3.Text
16−import androidx.compose.material3.TextButton
1714import androidx.compose.runtime.Composable
1815import androidx.compose.runtime.LaunchedEffect
19−import androidx.compose.runtime.getValue
20−import androidx.compose.runtime.mutableStateOf
2116import androidx.compose.runtime.remember
22−import androidx.compose.runtime.setValue
2317import androidx.compose.ui.Modifier
2418import soy.iko.opencode.core.Event
2519import soy.iko.opencode.core.Screen
@@ -31,8 +25,6 @@ import soy.iko.opencode.ui.screens.SessionsScreen
3125@Composable
3226fun OpencodeApp(state: UiState, dispatch: (Event) -> Unit) {
3327 val snackbar = remember { SnackbarHostState() }
34− var showStopConfirm by remember { mutableStateOf(false) }
35− var showDisconnectConfirm by remember { mutableStateOf(false) }
3628
3729 LaunchedEffect(state.error) {
3830 state.error?.let {
@@ -48,57 +40,12 @@ fun OpencodeApp(state: UiState, dispatch: (Event) -> Unit) {
4840
4941 BackHandler(enabled = state.screen != Screen.Connect) {
5042 when (state.screen) {
51− // Leaving mid-generation would silently drop the reply, so confirm first.
52− Screen.Chat -> if (state.generating) showStopConfirm = true else dispatch(Event.NavigateToSessions)
53− // Disconnecting drops the server session, so guard the back button.
54− Screen.Sessions -> showDisconnectConfirm = true
43+ Screen.Chat -> dispatch(Event.NavigateToSessions)
44+ Screen.Sessions -> dispatch(Event.NavigateToConnect)
5545 Screen.Connect -> Unit
5646 }
5747 }
5848
59− if (showStopConfirm) {
60− AlertDialog(
61− onDismissRequest = { showStopConfirm = false },
62− title = { Text("Stop generation?") },
63− text = { Text("Leaving will stop the current generation.") },
64− confirmButton = {
65− TextButton(onClick = {
66− showStopConfirm = false
67− dispatch(Event.CancelGeneration)
68− dispatch(Event.NavigateToSessions)
69− }) {
70− Text("Stop and leave")
71− }
72− },
73− dismissButton = {
74− TextButton(onClick = { showStopConfirm = false }) {
75− Text("Stay")
76− }
77− },
78− )
79− }
80−
81− if (showDisconnectConfirm) {
82− AlertDialog(
83− onDismissRequest = { showDisconnectConfirm = false },
84− title = { Text("Disconnect?") },
85− text = { Text("You will be disconnected from the server.") },
86− confirmButton = {
87− TextButton(onClick = {
88− showDisconnectConfirm = false
89− dispatch(Event.NavigateToConnect)
90− }) {
91− Text("Disconnect")
92− }
93− },
94− dismissButton = {
95− TextButton(onClick = { showDisconnectConfirm = false }) {
96− Text("Cancel")
97− }
98− },
99− )
100− }
101−
10249 Scaffold(snackbarHost = { SnackbarHost(snackbar) }) { padding ->
10350 AnimatedContent(
10451 targetState = state.screen,
app/src/main/java/soy/iko/opencode/ui/components/MessageBubble.kt+5−225
@@ -3,8 +3,6 @@ package soy.iko.opencode.ui.components
33import android.content.ClipData
44import android.content.ClipboardManager
55import android.content.Context
6−import android.content.Intent
7−import android.net.Uri
86import android.widget.Toast
97import androidx.compose.foundation.ExperimentalFoundationApi
108import androidx.compose.foundation.background
@@ -15,7 +13,6 @@ import androidx.compose.foundation.layout.Column
1513import androidx.compose.foundation.layout.Row
1614import androidx.compose.foundation.layout.fillMaxWidth
1715import androidx.compose.foundation.layout.padding
18−import androidx.compose.foundation.layout.size
1916import androidx.compose.foundation.layout.widthIn
2017import androidx.compose.foundation.shape.RoundedCornerShape
2118import androidx.compose.foundation.text.selection.SelectionContainer
@@ -26,9 +23,6 @@ import androidx.compose.material.icons.filled.ErrorOutline
2623import androidx.compose.material.icons.filled.ExpandLess
2724import androidx.compose.material.icons.filled.ExpandMore
2825import androidx.compose.material.icons.filled.Schedule
29−import androidx.compose.material.icons.filled.SmartToy
30−import androidx.compose.material3.DropdownMenu
31−import androidx.compose.material3.DropdownMenuItem
3226import androidx.compose.material3.Icon
3327import androidx.compose.material3.MaterialTheme
3428import androidx.compose.material3.Text
@@ -42,17 +36,10 @@ import androidx.compose.ui.Modifier
4236import androidx.compose.ui.draw.clip
4337import androidx.compose.ui.graphics.Color
4438import androidx.compose.ui.platform.LocalContext
45−import androidx.compose.ui.text.AnnotatedString
46−import androidx.compose.ui.text.LinkAnnotation
4739import androidx.compose.ui.text.SpanStyle
48−import androidx.compose.ui.text.TextLinkStyles
4940import androidx.compose.ui.text.buildAnnotatedString
50−import androidx.compose.ui.text.font.FontFamily
5141import androidx.compose.ui.text.font.FontStyle
52−import androidx.compose.ui.text.font.FontWeight
53−import androidx.compose.ui.text.withLink
5442import androidx.compose.ui.text.withStyle
55−import androidx.compose.ui.text.style.TextDecoration
5643import androidx.compose.ui.text.style.TextOverflow
5744import androidx.compose.ui.unit.dp
5845import androidx.compose.ui.unit.sp
@@ -65,7 +52,7 @@ private val timeFormat = java.time.format.DateTimeFormatter.ofPattern("HH:mm")
6552
6653@OptIn(ExperimentalFoundationApi::class)
6754@Composable
68−fun MessageBubble(message: MessageView, modifier: Modifier = Modifier, onRetry: () -> Unit = {}, compactSpacing: Boolean = false) {
55+fun MessageBubble(message: MessageView, modifier: Modifier = Modifier, onRetry: () -> Unit = {}) {
6956 val isUser = message.isUser
7057 val bubbleColor = if (isUser) MaterialTheme.colorScheme.primaryContainer else MaterialTheme.colorScheme.surfaceVariant
7158 val textColor = if (isUser) MaterialTheme.colorScheme.onPrimaryContainer else MaterialTheme.colorScheme.onSurface
@@ -78,20 +65,11 @@ fun MessageBubble(message: MessageView, modifier: Modifier = Modifier, onRetry:
7865 )
7966
8067 val context = LocalContext.current
81− var showMenu by remember { mutableStateOf(false) }
8268
8369 Row(
84− modifier = modifier.fillMaxWidth().padding(horizontal = 12.dp, vertical = if (compactSpacing) 1.dp else 4.dp),
70+ modifier = modifier.fillMaxWidth().padding(horizontal = 12.dp, vertical = 4.dp),
8571 horizontalArrangement = if (isUser) Arrangement.End else Arrangement.Start,
8672 ) {
87− if (!isUser) {
88− Icon(
89− Icons.Filled.SmartToy,
90− contentDescription = null,
91− tint = MaterialTheme.colorScheme.primary,
92− modifier = Modifier.align(Alignment.Top).padding(end = 6.dp, top = 2.dp).size(28.dp),
93− )
94− }
9573 Column(
9674 modifier = Modifier
9775 .fillMaxWidth(0.85f)
@@ -102,55 +80,21 @@ fun MessageBubble(message: MessageView, modifier: Modifier = Modifier, onRetry:
10280 onClick = {},
10381 onLongClick = {
10482 if (message.text.isNotEmpty()) {
105− showMenu = true
83+ copyToClipboard(context, message.text)
84+ Toast.makeText(context, "Copied", Toast.LENGTH_SHORT).show()
10685 }
10786 },
10887 )
10988 .padding(horizontal = 14.dp, vertical = 10.dp),
11089 ) {
111− DropdownMenu(expanded = showMenu, onDismissRequest = { showMenu = false }) {
112− DropdownMenuItem(
113− text = { Text("Copy") },
114− onClick = {
115− copyToClipboard(context, message.text)
116− Toast.makeText(context, "Copied", Toast.LENGTH_SHORT).show()
117− showMenu = false
118− },
119− )
120− DropdownMenuItem(
121− text = { Text("Share") },
122− onClick = {
123− shareText(context, message.text)
124− showMenu = false
125− },
126− )
127− }
128−
12990 message.reasoning?.let { ReasoningBlock(it, context) }
13091
131− // Give a quick overview of how many tools ran before listing them.
132− if (message.tools.size > 1) {
133− Text(
134− text = "${message.tools.size} tool calls",
135− style = MaterialTheme.typography.labelSmall,
136− color = MaterialTheme.colorScheme.onSurfaceVariant,
137− modifier = Modifier.padding(bottom = 4.dp),
138− )
139− }
140−
14192 message.tools.forEach { ToolRow(it) }
14293
14394 SelectionContainer {
14495 if (message.text.isNotEmpty()) {
145− val linkColor = MaterialTheme.colorScheme.primary
146− // Tint the code background off the bubble's own foreground colour so it
147− // contrasts on both bubble types (user bubbles use primaryContainer).
148− val codeBackground = (if (isUser) MaterialTheme.colorScheme.onPrimaryContainer else MaterialTheme.colorScheme.onSurface).copy(alpha = 0.08f)
149− val annotatedText = remember(message.text, message.streaming, linkColor, codeBackground, context) {
150− buildLinkedText(message.text, message.streaming, linkColor, codeBackground, context)
151− }
15296 Text(
153− text = annotatedText,
97+ text = message.text + if (message.streaming) " ▌" else "",
15498 color = textColor,
15599 // Give assistant replies (often long, code-heavy) extra line
156100 // spacing for readability; user bubbles keep the default.
@@ -186,170 +130,6 @@ private fun copyToClipboard(context: Context, text: String) {
186130 clipboard.setPrimaryClip(ClipData.newPlainText("message", text))
187131}
188132
189−private val urlRegex = Regex("""https?://[^\s]+""")
190−
191−/**
192− * Render [text] as an AnnotatedString. Triple-backtick fences split the text into
193− * prose and code segments: code segments are rendered monospace on a tinted
194− * [codeBackground] (fences dropped), while prose has each http(s) URL turned into a
195− * clickable link. The streaming cursor (" ▌") is appended outside any annotation.
196− */
197−private fun buildLinkedText(
198− text: String,
199− streaming: Boolean,
200− linkColor: Color,
201− codeBackground: Color,
202− context: Context,
203−): AnnotatedString = buildAnnotatedString {
204− // Odd-indexed segments sit between a pair of ``` fences, so they're code. An
205− // unclosed fence leaves the trailing segment styled as code, mirroring markdown.
206− val segments = text.split("```")
207− segments.forEachIndexed { index, segment ->
208− if (index % 2 == 1) {
209− withStyle(SpanStyle(fontFamily = FontFamily.Monospace, background = codeBackground)) {
210− append(segment)
211− }
212− } else {
213− appendLinkedText(segment, linkColor, codeBackground, context)
214− }
215− }
216− if (streaming) append(" ▌")
217−}
218−
219−/**
220− * Append [text] to the builder. Double-asterisk pairs are rendered bold; within each
221− * segment, single-backtick pairs are rendered as inline code (monospace, backticks
222− * dropped), and the remaining prose has each http(s) URL turned into a clickable link.
223− * Triple-backtick fences are already stripped upstream in [buildLinkedText], so only
224− * inline spans reach here.
225− */
226−private fun AnnotatedString.Builder.appendLinkedText(
227− text: String,
228− linkColor: Color,
229− codeBackground: Color,
230− context: Context,
231−) {
232− // Bold is the outermost inline layer: split on ** first so a bold span can wrap
233− // inline code and links inside it. Odd-indexed segments sit between a pair of **
234− // markers, so they're bold (markers dropped); even segments are ordinary prose.
235− // Only the non-bold (even) segments get single-* italic handling — splitting a bold
236− // segment on "*" would misfire on the leftover asterisks from the ** markers.
237− val segments = text.split("**")
238− // An even segment count means an odd number of ** markers, so the final ** is unclosed:
239− // its trailing segment isn't bold. Restore the literal ** and render it as ordinary prose.
240− val unclosed = segments.size % 2 == 0
241− segments.forEachIndexed { index, segment ->
242− val isUnclosedTail = unclosed && index == segments.size - 1
243− if (index % 2 == 1 && !isUnclosedTail) {
244− withStyle(SpanStyle(fontWeight = FontWeight.Bold)) {
245− appendInlineCode(segment, linkColor, codeBackground, context)
246− }
247− } else {
248− if (isUnclosedTail) append("**")
249− appendItalicText(segment, linkColor, codeBackground, context)
250− }
251− }
252−}
253−
254−/**
255− * Append [text] to the builder, rendering single-asterisk pairs as italic. Double
256− * asterisks are already consumed as bold upstream in [appendLinkedText], so only lone
257− * `*` markers reach here. Each segment then flows through inline-code and URL handling.
258− */
259−private fun AnnotatedString.Builder.appendItalicText(
260− text: String,
261− linkColor: Color,
262− codeBackground: Color,
263− context: Context,
264−) {
265− // Odd-indexed segments sit between a pair of single asterisks, so they're italic
266− // (markers dropped); even segments are ordinary prose.
267− val segments = text.split("*")
268− // An even segment count means an odd number of * markers, so the final * is unclosed:
269− // its trailing segment isn't italic. Restore the literal * and render it as prose.
270− val unclosed = segments.size % 2 == 0
271− segments.forEachIndexed { index, segment ->
272− val isUnclosedTail = unclosed && index == segments.size - 1
273− if (index % 2 == 1 && !isUnclosedTail) {
274− withStyle(SpanStyle(fontStyle = FontStyle.Italic)) {
275− appendInlineCode(segment, linkColor, codeBackground, context)
276− }
277− } else {
278− if (isUnclosedTail) append("*")
279− appendInlineCode(segment, linkColor, codeBackground, context)
280− }
281− }
282−}
283−
284−/**
285− * Append [text] to the builder, rendering single-backtick pairs as inline code
286− * (monospace, backticks dropped) and turning each http(s) URL in the remaining prose
287− * into a clickable link.
288− */
289−private fun AnnotatedString.Builder.appendInlineCode(
290− text: String,
291− linkColor: Color,
292− codeBackground: Color,
293− context: Context,
294−) {
295− // Odd-indexed segments sit between a pair of single backticks, so they're inline
296− // code. Even segments are ordinary prose and get URL linking applied.
297− val segments = text.split("`")
298− // An even segment count means an odd number of backtick markers, so the final backtick
299− // is unclosed: its trailing segment isn't code. Restore the literal ` and treat as prose.
300− val unclosed = segments.size % 2 == 0
301− segments.forEachIndexed { index, segment ->
302− val isUnclosedTail = unclosed && index == segments.size - 1
303− if (index % 2 == 1 && !isUnclosedTail) {
304− withStyle(SpanStyle(fontFamily = FontFamily.Monospace, background = codeBackground)) {
305− append(segment)
306− }
307− } else {
308− if (isUnclosedTail) append("`")
309− appendUrls(segment, linkColor, context)
310− }
311− }
312−}
313−
314−/** Append [text] to the builder, turning each http(s) URL into a clickable link. */
315−private fun AnnotatedString.Builder.appendUrls(
316− text: String,
317− linkColor: Color,
318− context: Context,
319−) {
320− val matches = urlRegex.findAll(text).toList()
321− var cursor = 0
322− for (match in matches) {
323− append(text.substring(cursor, match.range.first))
324− val url = match.value
325− withLink(
326− LinkAnnotation.Clickable(
327− tag = url,
328− styles = TextLinkStyles(
329− SpanStyle(color = linkColor, textDecoration = TextDecoration.Underline),
330− ),
331− linkInteractionListener = {
332− runCatching {
333− context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)))
334− }
335− },
336− ),
337− ) {
338− append(url)
339− }
340− cursor = match.range.last + 1
341− }
342− append(text.substring(cursor))
343−}
344−
345−private fun shareText(context: Context, text: String) {
346− val intent = Intent(Intent.ACTION_SEND).apply {
347− type = "text/plain"
348− putExtra(Intent.EXTRA_TEXT, text)
349− }
350− context.startActivity(Intent.createChooser(intent, null))
351−}
352−
353133@Composable
354134private fun ReasoningBlock(text: String, context: Context) {
355135 var expanded by remember { mutableStateOf(false) }
app/src/main/java/soy/iko/opencode/ui/screens/ChatScreen.kt+11−145
@@ -1,9 +1,5 @@
11package soy.iko.opencode.ui.screens
22
3−import android.content.ClipData
4−import android.content.ClipboardManager
5−import android.content.Context
6−import android.widget.Toast
73import androidx.compose.animation.AnimatedVisibility
84import androidx.compose.animation.core.RepeatMode
95import androidx.compose.animation.core.animateFloat
@@ -14,10 +10,8 @@ import androidx.compose.animation.fadeIn
1410import androidx.compose.animation.fadeOut
1511import androidx.compose.animation.scaleIn
1612import androidx.compose.animation.scaleOut
17−import androidx.compose.foundation.ExperimentalFoundationApi
1813import androidx.compose.foundation.background
1914import androidx.compose.foundation.clickable
20−import androidx.compose.foundation.combinedClickable
2115import androidx.compose.foundation.layout.Arrangement
2216import androidx.compose.foundation.layout.Box
2317import androidx.compose.foundation.layout.BoxScope
@@ -26,7 +20,6 @@ import androidx.compose.foundation.layout.Row
2620import androidx.compose.foundation.layout.Spacer
2721import androidx.compose.foundation.layout.fillMaxSize
2822import androidx.compose.foundation.layout.fillMaxWidth
29−import androidx.compose.foundation.layout.heightIn
3023import androidx.compose.foundation.layout.PaddingValues
3124import androidx.compose.foundation.layout.WindowInsets
3225import androidx.compose.foundation.layout.ime
@@ -43,10 +36,8 @@ import androidx.compose.foundation.text.KeyboardOptions
4336import androidx.compose.material.icons.Icons
4437import androidx.compose.material.icons.automirrored.filled.ArrowBack
4538import androidx.compose.material.icons.automirrored.filled.Send
46−import androidx.compose.material.icons.filled.ChatBubbleOutline
4739import androidx.compose.material.icons.filled.Close
4840import androidx.compose.material.icons.filled.KeyboardArrowDown
49−import androidx.compose.material.icons.filled.KeyboardArrowUp
5041import androidx.compose.material.icons.filled.Stop
5142import androidx.compose.material3.CircularProgressIndicator
5243import androidx.compose.material3.ExperimentalMaterial3Api
@@ -61,7 +52,6 @@ import androidx.compose.material3.OutlinedTextField
6152import androidx.compose.material3.Scaffold
6253import androidx.compose.material3.Surface
6354import androidx.compose.material3.Text
64−import androidx.compose.material3.TextButton
6555import androidx.compose.material3.TopAppBar
6656import androidx.compose.runtime.Composable
6757import androidx.compose.runtime.LaunchedEffect
@@ -75,8 +65,6 @@ import androidx.compose.ui.Alignment
7565import androidx.compose.ui.Modifier
7666import androidx.compose.ui.draw.clip
7767import androidx.compose.ui.hapticfeedback.HapticFeedbackType
78−import androidx.compose.ui.platform.LocalClipboardManager
79−import androidx.compose.ui.platform.LocalContext
8068import androidx.compose.ui.platform.LocalDensity
8169import androidx.compose.ui.platform.LocalHapticFeedback
8270import androidx.compose.ui.text.font.FontStyle
@@ -89,12 +77,11 @@ import soy.iko.opencode.core.Event
8977import soy.iko.opencode.core.UiState
9078import soy.iko.opencode.ui.components.MessageBubble
9179
92−@OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class)
80+@OptIn(ExperimentalMaterial3Api::class)
9381@Composable
9482fun ChatScreen(state: UiState, dispatch: (Event) -> Unit) {
9583 val listState = rememberLazyListState()
9684 val coroutineScope = rememberCoroutineScope()
97− val context = LocalContext.current
9885
9986 // Hide the jump-to-bottom FAB while the keyboard is up: it would otherwise
10087 // sit over the top of the IME. Reading the ime inset bottom during composition
@@ -113,12 +100,6 @@ fun ChatScreen(state: UiState, dispatch: (Event) -> Unit) {
113100 }
114101 }
115102
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−
122103 // Track how many messages the user has "seen" (i.e. was at the bottom for). While
123104 // they're scrolled up, any messages beyond that count are unseen — flag the FAB.
124105 var lastSeenCount by remember { mutableStateOf(0) }
@@ -148,20 +129,11 @@ fun ChatScreen(state: UiState, dispatch: (Event) -> Unit) {
148129 topBar = {
149130 TopAppBar(
150131 title = {
151− val title = state.currentSessionTitle.ifEmpty { "Chat" }
152132 Text(
153− text = if (state.messages.isNotEmpty()) "$title (${state.messages.size})" else title,
133+ text = state.currentSessionTitle.ifEmpty { "Chat" },
154134 maxLines = 1,
155135 overflow = TextOverflow.Ellipsis,
156− modifier = Modifier.combinedClickable(
157− onClick = { dispatch(Event.NavigateToSessions) },
158− onLongClick = {
159− state.currentSessionId?.let { id ->
160− copyToClipboard(context, id)
161− Toast.makeText(context, "Session ID copied", Toast.LENGTH_SHORT).show()
162− }
163− },
164− ),
136+ modifier = Modifier.clickable { dispatch(Event.NavigateToSessions) },
165137 )
166138 },
167139 navigationIcon = {
@@ -205,24 +177,12 @@ fun ChatScreen(state: UiState, dispatch: (Event) -> Unit) {
205177 }
206178 Box(Modifier.fillMaxWidth().weight(1f)) {
207179 if (state.messages.isEmpty() && !state.loading) {
208− Column(
180+ Text(
181+ text = "Send a message to start the conversation.",
182+ style = MaterialTheme.typography.bodyMedium,
183+ color = MaterialTheme.colorScheme.onSurfaceVariant,
209184 modifier = Modifier.align(Alignment.Center).padding(32.dp),
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− }
185+ )
226186 }
227187 LazyColumn(
228188 state = listState,
@@ -236,11 +196,9 @@ fun ChatScreen(state: UiState, dispatch: (Event) -> Unit) {
236196 if (shouldShowDateSeparator(previous, message)) {
237197 DateSeparator(message.time)
238198 }
239− val sameSenderAsPrevious = index > 0 && state.messages[index - 1].isUser == message.isUser
240199 MessageBubble(
241200 message,
242201 onRetry = { dispatch(Event.SendMessage(message.text)) },
243− compactSpacing = sameSenderAsPrevious,
244202 )
245203 }
246204 // While the assistant is spinning up but hasn't emitted a streaming
@@ -258,25 +216,11 @@ fun ChatScreen(state: UiState, dispatch: (Event) -> Unit) {
258216 onClick = {
259217 coroutineScope.launch {
260218 if (state.messages.isNotEmpty()) {
261− // When the typing indicator is showing it occupies the item
262− // just past the last message, so scroll one further to reach it.
263− val target = if (state.generating && state.messages.none { it.streaming })
264− state.messages.size
265− else
266− state.messages.size - 1
267− listState.animateScrollToItem(target)
219+ listState.animateScrollToItem(state.messages.size - 1)
268220 }
269221 }
270222 },
271223 )
272− ScrollToTopButton(
273− visible = showScrollTop,
274− onClick = {
275− coroutineScope.launch {
276− listState.animateScrollToItem(0)
277− }
278− },
279− )
280224 }
281225 }
282226 }
@@ -316,35 +260,6 @@ private fun BoxScope.ScrollToBottomButton(visible: Boolean, showBadge: Boolean,
316260 }
317261}
318262
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−
343−private fun copyToClipboard(context: Context, text: String) {
344− val clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
345− clipboard.setPrimaryClip(ClipData.newPlainText("session", text))
346−}
347−
348263private val dateSeparatorFormat = java.time.format.DateTimeFormatter.ofPattern("MMM d")
349264
350265/** Convert an epoch-millis timestamp to the local calendar day it falls on. */
@@ -497,56 +412,19 @@ private fun ChatInputBar(
497412 onStop: () -> Unit,
498413) {
499414 val haptic = LocalHapticFeedback.current
500− val clipboardManager = LocalClipboardManager.current
501415 Surface(tonalElevation = 3.dp) {
502− Column(
503− modifier = Modifier.fillMaxWidth().imePadding().padding(horizontal = 12.dp, vertical = 8.dp),
504− ) {
505416 Row(
506− modifier = Modifier.fillMaxWidth(),
417+ modifier = Modifier.fillMaxWidth().imePadding().padding(horizontal = 12.dp, vertical = 8.dp),
507418 verticalAlignment = Alignment.Bottom,
508419 horizontalArrangement = Arrangement.spacedBy(8.dp),
509420 ) {
510421 OutlinedTextField(
511422 value = draft,
512423 onValueChange = onDraftChange,
513− modifier = Modifier.weight(1f).heightIn(min = 48.dp),
424+ modifier = Modifier.weight(1f),
514425 enabled = !loading,
515426 placeholder = { Text("Message opencode…") },
516427 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− },
535− // Surface a running count once the draft gets long, so the user has a
536− // sense of scale before sending a wall of text.
537− supportingText = if (draft.length > 500) {
538− {
539− Text(
540− text = "${draft.length} characters",
541− style = MaterialTheme.typography.labelSmall,
542− color = MaterialTheme.colorScheme.onSurfaceVariant,
543− textAlign = TextAlign.End,
544− modifier = Modifier.fillMaxWidth(),
545− )
546− }
547− } else {
548− null
549− },
550428 keyboardOptions = KeyboardOptions(imeAction = ImeAction.Send),
551429 keyboardActions = KeyboardActions(onSend = {
552430 if (!generating && !loading && draft.isNotBlank()) onSend()
@@ -574,17 +452,5 @@ private fun ChatInputBar(
574452 }
575453 }
576454 }
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− }
589455 }
590456}
app/src/main/java/soy/iko/opencode/ui/screens/ConnectScreen.kt+2−37
@@ -113,18 +113,6 @@ fun ConnectScreen(state: UiState, dispatch: (Event) -> Unit) {
113113 )
114114 }
115115
116− // Nudge the user if the URL looks like it's missing a scheme — a bare host:port
117− // won't connect. Informational (tertiary), not an error, since it's a heuristic.
118− if (state.serverUrl.isNotBlank() && "://" !in state.serverUrl && !state.serverUrl.startsWith("http")) {
119− Spacer(Modifier.height(6.dp))
120− Text(
121− text = "Tip: Add http:// if connecting to a local server",
122− style = MaterialTheme.typography.bodySmall,
123− color = MaterialTheme.colorScheme.tertiary,
124− textAlign = TextAlign.Center,
125− )
126− }
127−
128116 if (state.authRequired) {
129117 Spacer(Modifier.height(12.dp))
130118 OutlinedTextField(
@@ -155,15 +143,7 @@ fun ConnectScreen(state: UiState, dispatch: (Event) -> Unit) {
155143 },
156144 modifier = Modifier.fillMaxWidth(),
157145 keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password, imeAction = ImeAction.Go),
158− keyboardActions = KeyboardActions(onGo = {
159− // Mirror the connect button's enabled condition so the keyboard's
160− // Go action can't fire a request the form isn't ready for.
161− if (!state.loading && state.serverUrl.isNotBlank() &&
162− (!state.authRequired || state.username.isNotBlank() || state.password.isNotBlank())
163− ) {
164− dispatch(Event.Connect)
165− }
166− }),
146+ keyboardActions = KeyboardActions(onGo = { dispatch(Event.Connect) }),
167147 enabled = !state.loading,
168148 )
169149 Spacer(Modifier.height(4.dp))
@@ -178,10 +158,7 @@ fun ConnectScreen(state: UiState, dispatch: (Event) -> Unit) {
178158
179159 Button(
180160 onClick = { dispatch(Event.Connect) },
181− // When auth is required, keep the button disabled until at least one
182− // credential is entered — otherwise it just triggers a validation error.
183− enabled = !state.loading && state.serverUrl.isNotBlank() &&
184− (!state.authRequired || state.username.isNotBlank() || state.password.isNotBlank()),
161+ enabled = !state.loading && state.serverUrl.isNotBlank(),
185162 modifier = Modifier.fillMaxWidth(),
186163 ) {
187164 if (state.loading) {
@@ -195,18 +172,6 @@ fun ConnectScreen(state: UiState, dispatch: (Event) -> Unit) {
195172 }
196173 }
197174
198− // While connecting (including auto-connect on launch), echo the target URL
199− // so the user knows what the spinner is waiting on.
200− if (state.loading) {
201− Spacer(Modifier.height(8.dp))
202− Text(
203− text = "Connecting to ${state.serverUrl}...",
204− style = MaterialTheme.typography.bodySmall,
205− color = MaterialTheme.colorScheme.onSurfaceVariant,
206− textAlign = TextAlign.Center,
207− )
208− }
209−
210175 // Surface the error inline as well, so it stays visible while the user
211176 // corrects the form (the snackbar is transient).
212177 if (state.error != null && !state.loading) {
app/src/main/java/soy/iko/opencode/ui/screens/SessionsScreen.kt+9−75
@@ -1,13 +1,7 @@
11package soy.iko.opencode.ui.screens
22
3−import android.content.ClipData
4−import android.content.ClipboardManager
5−import android.content.Context
6−import android.widget.Toast
7−import androidx.compose.foundation.ExperimentalFoundationApi
83import androidx.compose.foundation.background
94import androidx.compose.foundation.clickable
10−import androidx.compose.foundation.combinedClickable
115import androidx.compose.foundation.layout.Arrangement
126import androidx.compose.foundation.layout.Box
137import androidx.compose.foundation.layout.Column
@@ -21,8 +15,6 @@ import androidx.compose.foundation.layout.padding
2115import androidx.compose.foundation.layout.size
2216import androidx.compose.foundation.lazy.LazyColumn
2317import androidx.compose.foundation.lazy.items
24−import androidx.compose.foundation.lazy.rememberLazyListState
25−import androidx.compose.foundation.shape.CircleShape
2618import androidx.compose.material.icons.Icons
2719import androidx.compose.material.icons.automirrored.filled.ArrowBack
2820import androidx.compose.material.icons.filled.Add
@@ -58,12 +50,8 @@ import androidx.compose.runtime.remember
5850import androidx.compose.runtime.setValue
5951import androidx.compose.ui.Alignment
6052import androidx.compose.ui.Modifier
61−import androidx.compose.ui.draw.clip
62−import androidx.compose.ui.graphics.Color
6353import androidx.compose.ui.hapticfeedback.HapticFeedbackType
64−import androidx.compose.ui.platform.LocalContext
6554import androidx.compose.ui.platform.LocalHapticFeedback
66−import androidx.compose.ui.text.style.TextAlign
6755import androidx.compose.ui.text.style.TextOverflow
6856import androidx.compose.ui.unit.dp
6957import soy.iko.opencode.core.Event
@@ -77,15 +65,6 @@ fun SessionsScreen(state: UiState, dispatch: (Event) -> Unit) {
7765 var pendingDeleteId by remember { mutableStateOf<String?>(null) }
7866 var isPullRefreshing by remember { mutableStateOf(false) }
7967 var searchQuery by remember { mutableStateOf("") }
80− val sessionsListState = rememberLazyListState()
81−
82− // Bring a newly created session (which lands at the top of the list) into view.
83− // Only scroll when the list actually grows, not on every reload of the same sessions.
84− var prevSize by remember { mutableStateOf(state.sessions.size) }
85− LaunchedEffect(state.sessions.size) {
86− if (state.sessions.size > prevSize) sessionsListState.animateScrollToItem(0)
87− prevSize = state.sessions.size
88− }
8968
9069 // The pull-to-refresh spinner should only reflect a user-initiated pull, not
9170 // every loading operation. Clear it once the underlying load completes.
@@ -119,23 +98,7 @@ fun SessionsScreen(state: UiState, dispatch: (Event) -> Unit) {
11998 Scaffold(
12099 topBar = {
121100 TopAppBar(
122− title = {
123− Row(verticalAlignment = Alignment.CenterVertically) {
124− // A quick at-a-glance health dot for the SSE stream: green when
125− // connected, error-tinted when the stream is down (updates stall).
126− Box(
127− modifier = Modifier
128− .size(8.dp)
129− .clip(CircleShape)
130− .background(
131− if (state.sseConnected) Color(0xFF4CAF50)
132− else MaterialTheme.colorScheme.error,
133− ),
134− )
135− Spacer(Modifier.size(8.dp))
136− Text(if (state.sessions.isNotEmpty()) "Sessions (${state.sessions.size})" else "Sessions")
137− }
138− },
101+ title = { Text("Sessions") },
139102 navigationIcon = {
140103 IconButton(onClick = { dispatch(Event.NavigateToConnect) }) {
141104 Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Disconnect")
@@ -199,7 +162,6 @@ fun SessionsScreen(state: UiState, dispatch: (Event) -> Unit) {
199162 state = rememberPullToRefreshState(),
200163 ) {
201164 LazyColumn(
202− state = sessionsListState,
203165 modifier = Modifier.fillMaxSize(),
204166 contentPadding = PaddingValues(bottom = 88.dp),
205167 ) {
@@ -238,21 +200,13 @@ fun SessionsScreen(state: UiState, dispatch: (Event) -> Unit) {
238200 }
239201}
240202
241−@OptIn(ExperimentalFoundationApi::class)
242203@Composable
243204private fun SessionRow(session: SessionView, onOpen: () -> Unit, onDelete: () -> Unit) {
244− val context = LocalContext.current
245205 Row(
246206 modifier = Modifier
247207 .fillMaxWidth()
248208 .background(MaterialTheme.colorScheme.surface)
249− .combinedClickable(
250− onClick = onOpen,
251− onLongClick = {
252− copyToClipboard(context, session.id)
253− Toast.makeText(context, "Session ID copied", Toast.LENGTH_SHORT).show()
254− },
255− )
209+ .clickable(onClick = onOpen)
256210 .padding(start = 20.dp, end = 8.dp, top = 14.dp, bottom = 14.dp),
257211 verticalAlignment = Alignment.CenterVertically,
258212 ) {
@@ -287,13 +241,13 @@ private fun SessionRow(session: SessionView, onOpen: () -> Unit, onDelete: () ->
287241 Icon(
288242 Icons.Filled.DeleteOutline,
289243 contentDescription = "Delete session",
290− tint = MaterialTheme.colorScheme.error,
244+ tint = MaterialTheme.colorScheme.onSurfaceVariant,
291245 )
292246 }
293247 }
294248}
295249
296−/** Red background with a trailing delete icon and label, revealed while swiping a session row away. */
250+/** Red background with a trailing delete icon, revealed while swiping a session row away. */
297251@Composable
298252private fun SwipeDeleteBackground() {
299253 Box(
@@ -303,19 +257,11 @@ private fun SwipeDeleteBackground() {
303257 .padding(horizontal = 24.dp),
304258 contentAlignment = Alignment.CenterEnd,
305259 ) {
306− Row(verticalAlignment = Alignment.CenterVertically) {
307− Icon(
308− Icons.Filled.DeleteOutline,
309− contentDescription = null,
310− tint = MaterialTheme.colorScheme.onError,
311− )
312− Text(
313− text = "Delete",
314− style = MaterialTheme.typography.labelLarge,
315− color = MaterialTheme.colorScheme.onError,
316− modifier = Modifier.padding(start = 4.dp),
317− )
318− }
260+ Icon(
261+ Icons.Filled.DeleteOutline,
262+ contentDescription = null,
263+ tint = MaterialTheme.colorScheme.onError,
264+ )
319265 }
320266}
321267
@@ -345,11 +291,6 @@ private fun ReconnectingBanner() {
345291 }
346292}
347293
348−private fun copyToClipboard(context: Context, text: String) {
349− val clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
350− clipboard.setPrimaryClip(ClipData.newPlainText("session", text))
351−}
352−
353294/** Shorten a session ID for display: "abc12345…" instead of the full UUID. */
354295private fun shortSessionId(id: String): String =
355296 if (id.length > 12) id.take(8) + "…" else id
@@ -391,12 +332,5 @@ private fun EmptySessions() {
391332 style = MaterialTheme.typography.bodyMedium,
392333 color = MaterialTheme.colorScheme.onSurfaceVariant,
393334 )
394− Spacer(Modifier.height(8.dp))
395− Text(
396− text = "Sessions you create on this server will appear here.",
397− style = MaterialTheme.typography.bodySmall,
398− color = MaterialTheme.colorScheme.onSurfaceVariant,
399− textAlign = TextAlign.Center,
400− )
401335 }
402336}
app/src/main/java/soy/iko/opencode/ui/theme/Theme.kt−10
@@ -17,11 +17,6 @@ private val DarkColors = darkColorScheme(
1717 primaryContainer = Color(0xFF1A3D2A),
1818 onPrimaryContainer = Color(0xFFA8E6C1),
1919 secondary = EmeraldDark,
20− onSecondary = Color(0xFFE6E9EF),
21− secondaryContainer = Color(0xFF1A2A3D),
22− onSecondaryContainer = Color(0xFFA8C5E6),
23− tertiary = Color(0xFF6B7280),
24− onTertiary = Color(0xFFE6E9EF),
2520 tertiaryContainer = Color(0xFF2A2A3D),
2621 onTertiaryContainer = Color(0xFFC5C5E6),
2722 errorContainer = Color(0xFF4D2626),
@@ -38,11 +33,6 @@ private val LightColors = lightColorScheme(
3833 primaryContainer = Color(0xFFD7F5E3),
3934 onPrimaryContainer = Color(0xFF0A3D22),
4035 secondary = Emerald,
41− onSecondary = Color(0xFF1A1C1F),
42− secondaryContainer = Color(0xFFD7E8F5),
43− onSecondaryContainer = Color(0xFF0A2A4D),
44− tertiary = Color(0xFF6B7280),
45− onTertiary = Color(0xFFFFFFFF),
4636 tertiaryContainer = Color(0xFFE8E8F5),
4737 onTertiaryContainer = Color(0xFF2A2A4D),
4838 errorContainer = Color(0xFFFFE0E0),