Merge lane-app2: keep the lane's reviewed work

This commit is contained in:
2026-10-17 15:03:22 +01:00
6 changed files with 195 additions and 9 deletions
+78
View File
@@ -5783,3 +5783,81 @@ Not verified in this pass: the search field, the directory sections and the
empty state on a device, and the narrow/wide layouts — the brief keeps
implementation verification to the build and the unit tests, and visual review
owns the operator's Pixel 9 Pro XL.
## The conversation header names the session's model (17 Oct 2026)
A chat session's model was only visible in the session list row; inside a
conversation there was nothing saying what was answering. The conversation header
now shows the session's model beside its `Operator` tag and its directory, read
from the session the server already reports. `android/` only; no dependency was
added beyond the already-declared material-icons-extended, nothing in the
Pipelines server, its Go source, the installer or the Docker files was touched,
and no run is started from the app.
- **One derivation, server-reported only.** `ui/chat/ChatFormat.kt` adds
`chatHeaderMeta(thread)`: the model id, the session's kind tag (through the
shared `sessionTagLabel`, refactored to a tag-value overload so the list row
and the header cannot label a tag differently) and the directory, joined with
` · `. Every part is a value the server reported; a blank part is omitted, so a
session the server reported without a model (or an older server that omits the
field) shows no model claim at all — never a guess and never a catalogue.
- **The open thread carries what the server reports.** `ChatThread` gains the
`tag` field (it already mirrored title/directory/model/agent/busy), and
`ChatStore` now folds the server's `model`/`agent`/`tag` into an already-open
thread on `sessionsLoaded` (not only on first `open`), and seeds them in the
`ensureThread` placeholder. So the header never shows a stale or missing model
after a list refresh or for a background chat.
- **The header surface.** `ChatScreen.ChatConversationPane`'s top bar title
becomes a two-line `Column`: the existing title, then the meta line in the
shared `pipelinesText().meta` role with `onSurfaceVariant`, ellipsised — no new
geometry literal.
**No model chooser is shipped, and why.** The brief asks to let the operator
choose a session's model and report the exact server change if the server has no
request for it. It does not: `ChatPromptRequest` carries `model`/`agent` on the
wire (`internal/protocol/chat.go`), but the endpoint drops them —
`handleChatPrompt` calls `broker.Prompt(ctx, sessionID, prompt.Text)` and
`opencode.Chat.Prompt` posts only `{"text": ...}` — and there is no request that
sets a session's model, nor any request that lists the endpoint's models or
agents to offer a choice from. Shipping a picker would be a control that does
nothing, so the create flow instead says so plainly ("This server has no request
for choosing a chat's model, so a new chat uses the server's default.") and the
header shows the model the server does report once the session exists.
The exact server change it would need: (1) forward the chosen model/agent —
extend `chatBroker.Prompt` and `opencode.Chat.Prompt` to accept them and include
`model`/`agent` in the `POST /api/session/{id}/prompt` body, and pass
`prompt.Model`/`prompt.Agent` from `handleChatPrompt`; (2) expose a catalogue
request (for example `chat_models`/`chat_agents`, answered from the endpoint's
model/agent list) so the client can offer only what the server reports; and
(3) optionally accept `model`/`agent` on `chat_create` so a session starts with
the operator's chosen default rather than the endpoint's. Until then the app is
honest: it shows what the server reports and does not pretend to set it.
Tests (4 new): in `ChatFormatTest`, that `chatHeaderMeta` shows the reported
model, tag and directory, that it never claims a model the server did not report
(blank thread → empty, tag only → `Operator`), and that a session tag and a
thread tag label the same; in `ChatSessionManagementTest`, that an open
conversation carries the model/agent/tag the server reports and that a later list
refresh folds the server's new model into the open thread.
Evidence (this run's implementer pass, macOS, Gradle 8.11.1 at
`~/.gradle/wrapper/dists/gradle-8.11.1-bin/bpt9gzteqjrbo1mjrsomdt32c/gradle-8.11.1/bin/gradle`
with `JAVA_HOME="/Applications/Android Studio.app/Contents/jbr/Contents/Home"`
(JDK 17) and `ANDROID_HOME=/Users/alan/Library/Android/sdk`):
`gradle --offline --no-daemon :app:testDebugUnitTest` → `BUILD SUCCESSFUL`; the
JUnit XMLs total **55 suites / 505 tests / 0 failures / 0 errors / 0 skipped** (4
new). `gradle --offline --no-daemon :app:assembleDebug` → `BUILD SUCCESSFUL`; the
APK was published to this run's artifacts directory as
`pipelines-debug-wip-8e6cb39.apk` (18,706,104 bytes, sha256
`b52f2be1fcfce2654b90b9735ce03683fbf91e0a651b2b0ad49e92488d81ad05`; `8e6cb39` is
`git rev-parse --short HEAD`, the tree being uncommitted WIP on top of it) and is
served at
`http://10.0.0.75:8080/artifacts/272/1/pipelines-debug-wip-8e6cb39.apk`
(`HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
`Content-Length: 18706104`).
Not verified in this pass: the header meta on a device and the create-flow note —
the brief keeps implementation verification to the build and the unit tests, and
visual review owns the operator's Pixel 9 Pro XL. No packaged skill reference was
touched: this is an app-UI change and no reference describes the chat surface.
@@ -93,12 +93,33 @@ internal fun sessionTitle(session: ChatSession): String =
* session shows no chip. This only *labels*; the app never filters on the tag,
* because the server already lists operator sessions only.
*/
internal fun sessionTagLabel(session: ChatSession): String? = when {
session.tag.isBlank() -> null
session.tag == ChatProtocol.TAG_OPERATOR -> OPERATOR_TAG_LABEL
else -> session.tag
internal fun sessionTagLabel(session: ChatSession): String? = sessionTagLabel(session.tag)
/**
* The kind chip label for a session's own tag value (see [sessionTagLabel]).
* Kept as the single mapping so a session and the conversation it opens cannot
* label the same tag differently.
*/
internal fun sessionTagLabel(tag: String): String? = when {
tag.isBlank() -> null
tag == ChatProtocol.TAG_OPERATOR -> OPERATOR_TAG_LABEL
else -> tag
}
/**
* The one-line meta under a conversation's own title: the model the server
* reports is answering, the session's kind tag and its directory. Every part is
* a value the server reported (a model id, the wire tag, the directory), so
* nothing is guessed and no catalogue is invented; a blank part is omitted, so a
* session the server reported without a model (or an older server that omits the
* field) shows no model claim at all.
*/
internal fun chatHeaderMeta(thread: ChatThread): String = listOfNotNull(
thread.model.takeIf { it.isNotBlank() },
sessionTagLabel(thread.tag),
thread.directory.takeIf { it.isNotBlank() },
).joinToString(" · ")
private const val OPERATOR_TAG_LABEL = "Operator"
/**
@@ -628,6 +628,19 @@ private fun NewChatPane(
modifier = Modifier.padding(horizontal = CHAT_GUTTER, vertical = CHAT_ITEM_GAP),
)
}
// The brokered server exposes no request for choosing a
// session's model: chat_prompt carries model/agent fields but
// the server does not forward them, and there is no catalogue
// request to offer a choice from. So the flow says so plainly
// rather than shipping a picker that would do nothing. The
// conversation header then shows whatever model the server
// reports for the created session.
Text(
text = "This server has no request for choosing a chat's model, so a new chat uses the server's default.",
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier.padding(horizontal = CHAT_GUTTER, vertical = CHAT_ITEM_GAP),
)
NewChatActions(
directory = selected?.createDirectory ?: create.directory,
creating = create.creating,
@@ -851,11 +864,28 @@ private fun ChatConversationPane(
topBar = {
TopAppBar(
title = {
Text(
text = thread.title.ifBlank { sessionTitle(ChatSession(id = thread.sessionId)) },
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
Column {
Text(
text = thread.title.ifBlank { sessionTitle(ChatSession(id = thread.sessionId)) },
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
// The model the server reports is answering this session,
// beside the session's kind tag and its directory, so what
// is replying is always visible without leaving the
// conversation. Every part is server-reported; a blank one
// is simply omitted.
val meta = chatHeaderMeta(thread)
if (meta.isNotBlank()) {
Text(
text = meta,
style = pipelinesText().meta,
color = MaterialTheme.colorScheme.onSurfaceVariant,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
}
}
},
navigationIcon = {
IconButton(onClick = vm::showChatList) {
@@ -52,6 +52,8 @@ data class ChatThread(
val directory: String = "",
val model: String = "",
val agent: String = "",
/** The session's kind tag the server reported (see [ChatSession.tag]). */
val tag: String = "",
val updatedAt: Long = 0,
/** The server reports another client (or an active run) holds this session. */
val busy: Boolean = false,
@@ -298,6 +300,9 @@ class ChatStore(
thread.copy(
title = renamed[thread.sessionId] ?: session.title.ifBlank { thread.title },
directory = session.directory.ifBlank { thread.directory },
model = session.model.ifBlank { thread.model },
agent = session.agent.ifBlank { thread.agent },
tag = session.tag.ifBlank { thread.tag },
busy = session.busy,
)
}
@@ -446,6 +451,7 @@ class ChatStore(
directory = session.directory,
model = session.model,
agent = session.agent,
tag = session.tag,
updatedAt = session.updatedAt,
busy = session.busy,
)
@@ -455,6 +461,9 @@ class ChatStore(
val merged = existing.copy(
title = title.ifBlank { existing.title },
directory = session.directory.ifBlank { existing.directory },
model = session.model.ifBlank { existing.model },
agent = session.agent.ifBlank { existing.agent },
tag = session.tag.ifBlank { existing.tag },
busy = session.busy,
)
_state.value = _state.value.copy(
@@ -720,6 +729,9 @@ class ChatStore(
sessionId = sessionId,
title = _state.value.overrides.titles[sessionId] ?: session?.title ?: "",
directory = session?.directory ?: "",
model = session?.model ?: "",
agent = session?.agent ?: "",
tag = session?.tag ?: "",
busy = session?.busy ?: false,
)
_state.value = _state.value.copy(open = _state.value.open + placeholder)
@@ -152,4 +152,32 @@ class ChatFormatTest {
assertEquals("Named", sessionTitle(ChatSession(id = "ses_1", title = "Named")))
assertEquals("ses_abcdefghijklmn", sessionTitle(ChatSession(id = "ses_abcdefghijklmnop")))
}
@Test
fun chatHeaderMetaShowsTheReportedModelTagAndDirectory() {
// The conversation header names what is answering beside the session's
// kind tag and its directory, every part the server's own value.
val thread = ChatThread(
sessionId = "ses_1",
model = "deepseek-v4.1-flash",
tag = ChatProtocol.TAG_OPERATOR,
directory = "/home/op/work",
)
assertEquals("deepseek-v4.1-flash · Operator · /home/op/work", chatHeaderMeta(thread))
}
@Test
fun chatHeaderMetaNeverClaimsAModelTheServerDidNotReport() {
// A session the server reported without a model (or an older server that
// omits the field) shows no model claim, never a guess or a catalogue.
assertEquals("", chatHeaderMeta(ChatThread(sessionId = "ses_1")))
assertEquals("Operator", chatHeaderMeta(ChatThread(sessionId = "ses_1", tag = ChatProtocol.TAG_OPERATOR)))
}
@Test
fun aSessionTagAndAThreadTagLabelTheSame() {
assertEquals(sessionTagLabel(ChatSession(tag = ChatProtocol.TAG_OPERATOR)), sessionTagLabel(ChatProtocol.TAG_OPERATOR))
assertEquals("scratch", sessionTagLabel("scratch"))
assertNull(sessionTagLabel(""))
}
}
@@ -143,6 +143,23 @@ class ChatSessionManagementTest {
assertTrue(store.value.visibleSessions == listed)
}
@Test
fun anOpenConversationCarriesTheModelAndTagTheServerReports() {
val store = ChatStore()
store.sessionsLoaded(listOf(session("a").copy(model = "deepseek-v4.1-flash", agent = "build")))
store.open(store.value.sessions.single())
// The header reads the server's own values, so opening a session shows
// what is answering without a second request.
assertEquals("deepseek-v4.1-flash", store.value.thread("a")!!.model)
assertEquals("build", store.value.thread("a")!!.agent)
assertEquals(ChatProtocol.TAG_OPERATOR, store.value.thread("a")!!.tag)
// A later list refresh folds the server's reported model into the open
// conversation too, so the header never shows a stale model id.
store.sessionsLoaded(listOf(session("a").copy(model = "gpt-x", agent = "build")))
assertEquals("gpt-x", store.value.thread("a")!!.model)
}
@Test
fun theCoveredPaneCountMatchesTheVisibleList() {
val store = ChatStore()