git.iko.soy/opencode-android
on 06fd41b help sign in
30 lines 1.2 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) = "$CHAT/${android.net.Uri.encode(sessionId)}"
24 const val FILE_VIEW = "file_view"
25 fun fileView(path: String, line: Int? = null): String {
26 val base = "$FILE_VIEW?path=${android.net.Uri.encode(path)}"
27 // A positive [line] scrolls the viewer to that 1-based line (from a search hit).
28 return if (line != null && line > 0) "$base&line=$line" else base
29 }