1package soy.iko.opencode.data.model
3import androidx.compose.runtime.Immutable
4import kotlinx.serialization.Serializable
5import kotlinx.serialization.json.JsonElement
6import kotlinx.serialization.json.JsonArray
7import kotlinx.serialization.json.JsonPrimitive
10 * A permission request from `permission.updated`. The tool detail lives in [type] +
11 * [pattern] + [metadata]; [pattern] is a string or array of strings on the wire, so
12 * it's kept as a [JsonElement] and flattened for display.
18 val sessionID: String = "",
19 val type: String? = null,
20 val pattern: JsonElement? = null,
21 val messageID: String? = null,
22 val callID: String? = null,
23 val title: String? = null,
24 // JsonElement (not JsonObject) so a non-object `metadata` shape decodes instead of throwing,
25 // matching [pattern]. Not read by the UI today, but kept tolerant for forward-compat.
26 val metadata: JsonElement? = null,
27 val time: TimeInfo? = null,
29 val patternText: String?
30 get() = when (val p = pattern) {
32 is JsonPrimitive -> p.content
33 // Only a JSON array is flattened; any other shape (e.g. an object) would make
34 // the previous unguarded `p.jsonArray` throw during composition, so treat it
35 // as "no displayable pattern" instead.
36 is JsonArray -> p.mapNotNull { (it as? JsonPrimitive)?.content }.joinToString(", ").ifEmpty { null }
41/** Allowed values for the permission response body.
43 * [SESSION] is a client-side scope: it auto-responds [ONCE] to subsequent permission requests
44 * whose (type, pattern) match a remembered set, without showing the dialog. The set lives in
45 * [soy.iko.opencode.ui.chat.ChatViewModel] and is cleared on connection change. It is NOT sent
46 * to the server (the server only knows `once`/`always`/`reject`); the VM maps it to [ONCE] on
47 * the wire and tracks the grant locally. This gives users a middle ground between "allow once"
48 * (re-prompts on every file read) and "always" (persists in the server config outliving the app). */
49enum class PermissionResponse(val wire: String) {
56/** Body for `POST /session/:id/permissions/:permissionID`. */
58data class PermissionReplyBody(val response: String)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list