Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
4617aa4
Key v2 live text parts by assistant message (B2-1, B1-1, B4-1)
ivanfenenko Oct 1, 2026
5da55e7
Order live v2 replies by step start and delivery (K3, B1-1, B4-1)
ivanfenenko Oct 1, 2026
86bb527
Let REST info win on authoritative reload (B5-2)
ivanfenenko Oct 1, 2026
1641100
Send v2 permission reply as decision (K1)
ivanfenenko Oct 1, 2026
fad5106
Treat v2 forks as top-level sessions (B4-5)
ivanfenenko Oct 1, 2026
01c0842
Refetch the model catalog on model/provider updates (B5-1)
ivanfenenko Oct 1, 2026
c3cc512
Drop reverted v2 messages on revert commit (B4-2)
ivanfenenko Oct 1, 2026
29c38d6
Show v2 compaction as a marker, not reply text (B4-3)
ivanfenenko Oct 1, 2026
5e50c28
Order the sender's steer/queue prompts by delivery (B4-1)
ivanfenenko Oct 1, 2026
7e475e8
Refetch the model catalog on reconnect and retry when empty (B5-1)
ivanfenenko Oct 1, 2026
0913be6
Open an iOS fork as a top-level session (B4-5)
ivanfenenko Oct 1, 2026
7a481d9
Publish iOS sync states inside the critical section that sets them
ivanfenenko Oct 2, 2026
b89a72e
Render partial tables while streaming on Android (B1-3)
ivanfenenko Oct 2, 2026
00f3c91
Clearer tool chips: v2 read paths, custom tool titles, failed exits, …
ivanfenenko Oct 2, 2026
d820bce
Render the compaction summary sheet as markdown (B4-3 follow-up)
ivanfenenko Oct 2, 2026
5ea7cc5
Keep the scroll anchor when older messages load (B5-3)
ivanfenenko Oct 2, 2026
6895237
Restore the iOS prepend anchor after rows settle (B5-3)
ivanfenenko Oct 2, 2026
5a8fbd7
Show the Idle status pill on Android Home (B1-2)
ivanfenenko Oct 2, 2026
a866e89
Keep Ready focus when moving between sessions (B2-9)
ivanfenenko Oct 2, 2026
0bcc778
Hide v2 synthetic inbox items such as Plan mode's reminder (B4-6)
ivanfenenko Oct 2, 2026
2642998
Treat the server's "default" variant as Default; order variants by ef…
ivanfenenko Oct 2, 2026
1988b3d
List projects from GET /api/project on v2 (K2)
ivanfenenko Oct 2, 2026
f54d078
Label the composer send button plain "Send" when idle
ivanfenenko Oct 2, 2026
d3d8d33
Wait for v2 compaction to finish before reporting success (B4-4)
ivanfenenko Oct 2, 2026
3e4a7dd
Confirm the cache when the network frame matches it (Syncing stuck)
ivanfenenko Oct 2, 2026
74ac385
Show a delivered prompt as a bubble right away; keep its meta line (B…
ivanfenenko Oct 2, 2026
b773ee5
Label icon buttons on the clickable node (B3-8)
ivanfenenko Oct 2, 2026
540fbbd
Show short reply errors with the server's reason (B3-1)
ivanfenenko Oct 2, 2026
5b50812
Honour form maxItems/minItems and custom; head forms with their title…
ivanfenenko Oct 2, 2026
2e25bb1
Show the user's own Stop/Deny as neutral, not as an error (B3-5)
ivanfenenko Oct 2, 2026
4359915
Keep a note under cut-off and interrupted replies (B3-6)
ivanfenenko Oct 2, 2026
2bb4d94
Permission dock: Always, file summary, hide to reach the composer (B3…
ivanfenenko Oct 2, 2026
f5a378a
Open the Android diff viewer at the top of the file (B2-8)
ivanfenenko Oct 2, 2026
7949000
Keep the step-finish helper ahead of the assistant-info KDoc (B3-6)
ivanfenenko Oct 2, 2026
eb5e375
Track a compaction from the moment it starts (review: compaction wait…
ivanfenenko Oct 2, 2026
7b5235c
Sum up a multi-tool Explored group in its subtitle (B2-2)
ivanfenenko Oct 2, 2026
1147cb6
Give live v2 prompts the agent and model REST records (B2-5)
ivanfenenko Oct 2, 2026
1a21186
Merge main (squash of #337) into fix/sim-run-minor-issues
ivanfenenko Oct 2, 2026
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: 2 additions & 0 deletions android/app/src/main/java/dev/opencode/mobile/Navigation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ import dev.opencode.mobile.ui.componentgallery.components.IconsGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.ListGroupGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.ListItemGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.MessageListGalleryDetailScreen
import dev.opencode.mobile.ui.componentgallery.components.MessageNoteGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.OutgoingMessageGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.OverflowMenuGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.PendingPromptsStripGalleryScreen
Expand Down Expand Up @@ -534,6 +535,7 @@ fun MainNavigation() {
ComponentGalleryEntryId.AssistantMessage -> AssistantMessageGalleryScreen()
ComponentGalleryEntryId.ToolCallCard -> ToolCallCardGalleryScreen()
ComponentGalleryEntryId.ToolChip -> ToolChipGalleryScreen()
ComponentGalleryEntryId.MessageNote -> MessageNoteGalleryScreen()
ComponentGalleryEntryId.ChildSessionRow -> ChildSessionRowGalleryScreen()
ComponentGalleryEntryId.TopBar -> TopBarGalleryScreen()
ComponentGalleryEntryId.OverflowMenu -> OverflowMenuGalleryScreen()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package dev.opencode.mobile.data.remote

import io.ktor.client.plugins.ResponseException
import io.ktor.client.statement.HttpResponse

/**
* A non-2xx response whose body was read, so callers can surface the server's
* own error `message` instead of Ktor's request description.
*/
class HttpBodyResponseException(
response: HttpResponse,
val bodyText: String,
) : ResponseException(response, bodyText)
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dev.opencode.mobile.data.remote

import dev.opencode.mobile.data.remote.dto.ProjectDto
import dev.opencode.mobile.data.remote.dto.V2LocationInfoDto
import dev.opencode.mobile.data.remote.dto.V2ProjectDto
import dev.opencode.mobile.network.OpencodeHttpClient
import dev.opencode.mobile.network.applyDirectory
import dev.opencode.mobile.network.applyLocationDirectory
Expand All @@ -18,6 +19,13 @@ class ProjectsApi private constructor(

suspend fun listProjects(): List<ProjectDto> = httpClient.get().get("project").body()

suspend fun listProjectsV2(): List<ProjectDto> =
httpClient
.get()
.get("api/project")
.body<List<V2ProjectDto>>()
.map { ProjectDto(id = it.id, directory = it.canonical) }

suspend fun getCurrentProject(directory: String? = null): ProjectDto =
httpClient
.get()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ class SessionsApi private constructor(
.post("session/$sessionId/permissions/$permissionId") {
applyDirectory(directory)
setJsonBody(json, body)
}.body()
}.bodyOnSuccess()

suspend fun replyToQuestion(
requestId: String,
Expand All @@ -352,7 +352,7 @@ class SessionsApi private constructor(
.post("question/$requestId/reply") {
applyDirectory(directory)
setJsonBody(json, body)
}.body()
}.bodyOnSuccess()

suspend fun rejectQuestion(
requestId: String,
Expand All @@ -362,7 +362,7 @@ class SessionsApi private constructor(
.get()
.post("question/$requestId/reject") {
applyDirectory(directory)
}.body()
}.bodyOnSuccess()

suspend fun listPendingPermissionsV2(directory: String? = null): List<V2PermissionRequestDto> =
httpClient
Expand Down Expand Up @@ -604,20 +604,22 @@ class SessionsApi private constructor(
* which skips the question→form fallback.
*/
private suspend inline fun <reified T> HttpResponse.bodyOnSuccess(): T {
if (!status.isSuccess()) {
throw ResponseException(this, "HTTP ${status.value}: ${status.description}")
}
if (!status.isSuccess()) throw failure()
return body()
}

private suspend fun HttpResponse.ensureSuccess(): Boolean {
if (!status.isSuccess()) {
throw ResponseException(this, "HTTP ${status.value}: ${status.description}")
}
if (!status.isSuccess()) throw failure()
bodyAsText()
return true
}

/** Keeps the error body (v2 sends `{"_tag":…,"message":…}`) for user-facing messages. */
private suspend fun HttpResponse.failure(): ResponseException {
val text = runCatching { bodyAsText() }.getOrDefault("")
return HttpBodyResponseException(this, text.ifBlank { "HTTP ${status.value}: ${status.description}" })
}

private fun interface ClientProvider {
fun get(): HttpClient
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ data class MessageInfoDto(
val cost: Double? = null,
val waiting: Boolean? = null,
val delivery: String? = null,
val finish: String? = null,
)

@Serializable
Expand Down Expand Up @@ -117,6 +118,8 @@ data class MessageToolStateDto(
val error: String? = null,
val time: MessageToolTimeDto? = null,
val metadata: JsonObject? = null,
/** Set by the v2 live projection when `tool.failed` reports `error.type: "aborted"`. */
val interrupted: Boolean? = null,
)

@Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,11 @@ data class ProjectDto(
?: directory?.takeIf { it.isNotBlank() }
?: error("Project requires worktree or directory")
}

/** v2 `GET /api/project` item: the project root is `canonical`. */
@Serializable
data class V2ProjectDto(
val id: String,
val canonical: String,
val name: String? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ data class V2FormFieldDto(
val options: List<V2FormFieldOptionDto> = emptyList(),
val custom: Boolean? = null,
val multiple: Boolean? = null,
val minItems: Int? = null,
val maxItems: Int? = null,
)

@Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ data class V2SessionMessageDto(
val cost: Double? = null,
val tokens: MessageTokensDto? = null,
val error: V2UnknownErrorDto? = null,
val finish: String? = null,
val time: V2MessageTimeDto? = null,
val reason: String? = null,
val summary: String? = null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.opencode.mobile.domain.event

import dev.opencode.mobile.domain.message.AttachmentDataUrl
import dev.opencode.mobile.domain.message.ToolInterruption
import dev.opencode.mobile.domain.message.ToolPartIdentity
import dev.opencode.mobile.domain.message.V2ContentPartId
import dev.opencode.mobile.domain.session.SessionActivity
Expand Down Expand Up @@ -186,7 +187,7 @@ class EventDomainAdapter(
"session.execution.started" -> listOf(statusEvent(properties, "busy"))
"session.next.step.ended",
"session.step.ended",
-> listOfNotNull(assistantMessageUpdated(properties))
-> listOfNotNull(assistantMessageUpdated(properties, finish = properties.string("finish")))
"session.execution.succeeded",
"session.execution.interrupted",
-> listOf(event("session.idle", properties))
Expand All @@ -200,7 +201,7 @@ class EventDomainAdapter(
"session.step.failed" ->
listOfNotNull(
event("session.error", properties),
assistantMessageUpdated(properties),
assistantMessageUpdated(properties, finish = failedStepFinish(properties)),
)
"session.next.retried",
"session.retry.scheduled",
Expand Down Expand Up @@ -271,12 +272,13 @@ class EventDomainAdapter(
"session.text.ended",
-> listOf(textPartUpdated(properties))
"session.next.moved",
"session.moved",
-> listOf(event("session.updated", properties))
"session.next.agent.switched",
"session.next.model.switched",
"session.moved",
"session.agent.selected",
"session.model.selected",
-> listOf(event("session.updated", properties))
-> listOfNotNull(event("session.updated", properties), messageContext(properties))
"session.renamed" -> listOf(renamedToUpdated(properties))
"session.forked" -> listOf(forkedToCreated(properties))
"session.usage.updated",
Expand Down Expand Up @@ -382,7 +384,12 @@ class EventDomainAdapter(
val messageId = userMessageId(properties)
val parts = mutableListOf<OpencodeEvent>()
val text = prompt?.string("text") ?: properties.string("text")
text?.takeIf { it.isNotBlank() }?.let { parts += userTextPartUpdated(sessionId, messageId, it) }
// v2 inbox `synthetic` items (e.g. Plan mode's system-reminder) are server-injected
// context, not something the user typed: keep the part but mark it hidden.
val synthetic = (properties["item"] as? JsonObject)?.string("type") == "synthetic"
text?.takeIf { it.isNotBlank() }?.let {
parts += userTextPartUpdated(sessionId, messageId, it, synthetic = synthetic)
}
if (prompt == null) return parts
val files = prompt["files"] as? JsonArray ?: return parts
files.forEachIndexed { index, element ->
Expand All @@ -396,6 +403,7 @@ class EventDomainAdapter(
sessionId: String?,
messageId: String?,
text: String,
synthetic: Boolean = false,
): OpencodeEvent {
val part =
buildJsonObject {
Expand All @@ -404,6 +412,7 @@ class EventDomainAdapter(
messageId?.let { put("messageID", it) }
put("type", "text")
put("text", text)
if (synthetic) put("synthetic", true)
}
return event("message.part.updated", buildJsonObject { put("part", part) })
}
Expand Down Expand Up @@ -456,10 +465,34 @@ class EventDomainAdapter(

private fun stepStarted(properties: JsonObject): List<OpencodeEvent> =
listOfNotNull(
assistantMessageUpdated(properties, stampCreated = true),
assistantMessageUpdated(properties, stampCreated = true, withAgentAndModel = true),
statusEvent(properties, "busy"),
)

/**
* A v2 agent or model switch, for the message store: prompts delivered after it are
* recorded with it (`message.context` is client-only).
*/
private fun messageContext(properties: JsonObject): OpencodeEvent? {
val agent = properties.string("agent")
val model = properties["model"] as? JsonObject
if (agent == null && model == null) return null
val context =
buildJsonObject {
sessionIdFromProperties(properties)?.let { put("sessionID", it) }
agent?.let { put("agent", it) }
model?.let { put("model", it) }
properties.long("created")?.let { put("created", it) }
}
return event(MESSAGE_CONTEXT_EVENT, context)
}

/** An aborted step projects as `finish: "aborted"` so the reply keeps an Interrupted note. */
private fun failedStepFinish(properties: JsonObject): String? {
val type = (properties["error"] as? JsonObject)?.string("type")
return if (ToolInterruption.isAbortedType(type)) "aborted" else "error"
}

/**
* v2 has no assistant `message.updated`; synthesize one. Only `step.started`
* stamps `time.created` (the envelope time) so a live reply orders after the
Expand All @@ -468,6 +501,8 @@ class EventDomainAdapter(
private fun assistantMessageUpdated(
properties: JsonObject,
stampCreated: Boolean = false,
finish: String? = null,
withAgentAndModel: Boolean = false,
): OpencodeEvent? {
val sessionId = sessionIdFromProperties(properties)
val assistantId = properties.string("assistantMessageID") ?: properties.string("messageID") ?: return null
Expand All @@ -476,11 +511,24 @@ class EventDomainAdapter(
put("id", assistantId)
sessionId?.let { put("sessionID", it) }
put("role", "assistant")
finish?.let { put("finish", it) }
if (stampCreated) {
properties.long("created")?.let { created ->
put("time", buildJsonObject { put("created", created) })
}
}
// `step.started` carries the agent and model the step runs with.
if (withAgentAndModel) {
properties.string("agent")?.let { agent ->
put("agent", agent)
put("mode", agent)
}
(properties["model"] as? JsonObject)?.let { model ->
model.string("id")?.let { put("modelID", it) }
model.string("providerID")?.let { put("providerID", it) }
model.string("variant")?.let { put("variant", it) }
}
}
}
return event("message.updated", buildJsonObject { put("info", info) })
}
Expand All @@ -499,10 +547,9 @@ class EventDomainAdapter(
val name = resolvedToolName(properties)
val callId = properties.string("callID")
val partId = properties.string("id") ?: callId
val error =
properties["error"]
?.jsonObject
?.string("message")
val errorObject = properties["error"] as? JsonObject
val error = errorObject?.string("message")
val interrupted = status == "error" && ToolInterruption.isAbortedType(errorObject?.string("type"))
val output =
properties.string("output")
?: properties["content"]
Expand All @@ -529,6 +576,9 @@ class EventDomainAdapter(
output = output,
error = error,
metadata = metadata,
// v2 `tool.progress` carries the live title in metadata (v1: state.title).
title = metadata?.string("title")?.takeIf { it.isNotEmpty() },
interrupted = interrupted,
)
}

Expand Down Expand Up @@ -660,11 +710,13 @@ class EventDomainAdapter(
error: String? = null,
metadata: JsonObject? = null,
title: String? = null,
interrupted: Boolean = false,
): OpencodeEvent {
val sessionId = sessionIdFromProperties(properties)
val state =
buildJsonObject {
put("status", status)
if (interrupted) put("interrupted", true)
title?.let { put("title", it) }
if (input is JsonObject) put("input", input)
output?.let { put("output", it) }
Expand Down Expand Up @@ -993,6 +1045,9 @@ class EventDomainAdapter(
}

companion object {
/** Client-only projection of a v2 agent/model switch for the message store. */
const val MESSAGE_CONTEXT_EVENT = "message.context"

private val WRAPPER_KEYS =
setOf(
"payload",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,18 @@ class DefaultSessionReadyStore
// Leave while Working: keep a watch even if debounced status never
// delivered a busy snapshot before unfocus.
val priorId = focusedSessionId
val priorDirectory = focusedDirectory
if (priorId != null && priorDirectory != null) {
val type = previousTypes[priorDirectory]?.get(priorId)
if (type.isBusy()) {
startWatchLocked(priorId, priorDirectory, reason = "leave-while-busy")
}
}
armLeaveWhileBusyLocked()
focusedSessionId = null
focusedDirectory = null
if (priorId != null) {
logI("focus cleared session=$priorId")
}
} else {
if (focusedSessionId != sessionId) {
// Moving straight to another session (child, parent, fork) leaves
// the prior one just like navigating away from it.
armLeaveWhileBusyLocked()
}
focusedSessionId = sessionId
focusedDirectory = directory
// Opening Session Chat acknowledges Ready. Drop Ready and any
Expand Down Expand Up @@ -120,6 +119,28 @@ class DefaultSessionReadyStore
}
}

override fun releaseFocusedSession(sessionId: String) {
synchronized(lock) {
if (focusedSessionId != sessionId) {
if (focusedSessionId != null) {
logI("focus release ignored session=$sessionId focused=$focusedSessionId")
}
return
}
// synchronized is reentrant; clearing under the same lock keeps the check atomic.
setFocusedSession(null)
}
}

private fun armLeaveWhileBusyLocked() {
val priorId = focusedSessionId ?: return
val priorDirectory = focusedDirectory ?: return
val type = previousTypes[priorDirectory]?.get(priorId)
if (type.isBusy()) {
startWatchLocked(priorId, priorDirectory, reason = "leave-while-busy")
}
}

override fun bindProfile(profileId: String?) {
val directoriesToObserve: Set<String>
synchronized(lock) {
Expand Down
Loading