git.iko.soy/opencode-android
on ea52e62 help sign in
40 lines 1.4 kB history raw
1package soy.iko.opencode.data.model
3import androidx.compose.runtime.Immutable
4import kotlinx.serialization.Serializable
6/** A session as returned by `GET /session` and `POST /session`. */
7@Immutable
8@Serializable
9data class Session(
10 val id: String,
11 val parentID: String? = null,
12 val title: String? = null,
13 val version: String? = null,
14 val time: TimeInfo? = null,
15 // The absolute worktree/directory the agent runs in for this session. Set server-side
16 // from the `directory` query param at creation; persisted per session so the client
17 // needn't re-send it on follow-up calls (see OpencodeApiClient.createSession).
18 val directory: String? = null,
19 val projectID: String? = null,
20) {
21 val displayTitle: String get() = title?.takeIf { it.isNotBlank() } ?: "Untitled session"
23 /** A compact form of [directory] for list/subtitle display: the last path segment,
24 * or the full path when it has no separators. Null/blank when no directory is set. */
25 val displayDirectory: String?
26 get() = directory?.takeIf { it.isNotBlank() }?.trimEnd('/')?.substringAfterLast('/')?.takeIf { it.isNotBlank() }
29/** Body for `POST /session`. */
30@Serializable
31data class CreateSessionRequest(
32 val parentID: String? = null,
33 val title: String? = null,
36/** Body for `PATCH /session/:id`. */
37@Serializable
38data class UpdateSessionRequest(
39 val title: String? = null,