git.iko.soy/opencode-android
on c4151ca help sign in
39 lines 1.6 kB history raw
1package soy.iko.opencode.ui
3/** String routes for the app's NavHost. Kept simple and centralized. */
4object Routes {
5 const val SERVERS = "servers"
6 const val SESSIONS = "sessions"
7 const val SETTINGS = "settings"
8 const val DIAGNOSTICS = "diagnostics"
9 const val USAGE = "usage"
10 const val MCP = "mcp"
11 const val FILES = "files"
12 const val SEARCH = "search"
14 const val SERVER_EDIT = "server_edit"
15 fun serverEdit(id: String? = null) =
16 if (id.isNullOrEmpty()) SERVER_EDIT else "$SERVER_EDIT?id=${android.net.Uri.encode(id)}"
18 /** Open the editor seeded with [sourceId]'s fields but creating a new profile. */
19 fun serverEditDuplicate(sourceId: String) = "$SERVER_EDIT?dup=${android.net.Uri.encode(sourceId)}"
21 const val CHAT = "chat"
22 fun chat(sessionId: String, focusMessageId: String? = null): String {
23 val base = "$CHAT/${android.net.Uri.encode(sessionId)}"
24 // An optional focusMessageId scrolls the chat to (and briefly highlights) that message,
25 // used by global search to jump directly to the matched message instead of the tail.
26 return if (focusMessageId != null && focusMessageId.isNotBlank()) {
27 "$base?focus=${android.net.Uri.encode(focusMessageId)}"
28 } else {
29 base
30 }
31 }
33 const val FILE_VIEW = "file_view"
34 fun fileView(path: String, line: Int? = null): String {
35 val base = "$FILE_VIEW?path=${android.net.Uri.encode(path)}"
36 // A positive [line] scrolls the viewer to that 1-based line (from a search hit).
37 return if (line != null && line > 0) "$base&line=$line" else base
38 }