git.iko.soy/opencode-android
on d518ef7 help sign in
44 lines 1.4 kB history raw
1package soy.iko.opencode.data.model
3import androidx.compose.runtime.Immutable
4import kotlinx.serialization.Serializable
6/** Entry from `GET /file?path=` (directory listing). */
7@Immutable
8@Serializable
9data class FileNode(
10 val name: String = "",
11 val path: String = "",
12 val type: String? = null,
13 // Size in bytes and last-modified epoch-ms. The server doesn't currently emit these, so
14 // they default to null and the browser renders nothing extra; optional + defaulted keeps
15 // the client forward-compatible (resilient decoding) so the moment the server adds them
16 // the listing shows size/date with no client change.
17 val size: Long? = null,
18 val mtime: Long? = null,
19) {
20 val isDirectory: Boolean get() = type == "directory"
23/** Response of `GET /file/content?path=`. */
24@Immutable
25@Serializable
26data class FileContent(
27 val type: String? = null, // "text" | "binary"
28 val content: String = "",
29 val diff: String? = null,
30 val mimeType: String? = null,
31 val encoding: String? = null,
32) {
33 val isBinary: Boolean get() = type == "binary" || encoding == "base64"
36/** Entry from `GET /file/status` (VCS status). */
37@Immutable
38@Serializable
39data class FileStatusEntry(
40 val path: String = "",
41 val added: Int = 0,
42 val removed: Int = 0,
43 val status: String? = null, // "added" | "deleted" | "modified"