Make model and permission choices provider-specific
This commit is contained in:
1 parent
6a0202b1b5
commit
7ee88dfd9c
10 files changed
+269
-60
No files matched your search
@@ -305,6 +305,7 @@ fun SessionScreen(
|
||||
// The models this provider actually offers, asked of the server rather than listed here: a
|
||||
// hardcoded list is a claim about a machine.
|
||||
var offeredModels by remember { mutableStateOf<List<String>>(emptyList()) }
|
||||
var offeredPermissionModes by remember { mutableStateOf<List<String>>(emptyList()) }
|
||||
val lifecycleOwner = LocalLifecycleOwner.current
|
||||
// The resume cursor, written from the stream's IO thread.
|
||||
val lastSeq = remember { AtomicLong(0) }
|
||||
@@ -1017,22 +1018,28 @@ fun SessionScreen(
|
||||
|
||||
// Only for the model picker, which a subagent does not have.
|
||||
if (!isSubagent) {
|
||||
LaunchedEffect(summary.setupName, summary.provider) {
|
||||
offeredModels =
|
||||
try {
|
||||
withContext(Dispatchers.IO) {
|
||||
fetchSetups(settings)
|
||||
.firstOrNull { it.name == summary.setupName }
|
||||
?.providers
|
||||
?.firstOrNull { it.name == summary.provider }
|
||||
?.models
|
||||
.orEmpty()
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
// Not worth reporting: the picker simply has nothing to offer, which is
|
||||
// visible.
|
||||
emptyList()
|
||||
LaunchedEffect(summary.setup, summary.provider) {
|
||||
val provider = runCatching {
|
||||
withContext(Dispatchers.IO) {
|
||||
fetchSetups(settings)
|
||||
.firstOrNull { it.id == summary.setup }
|
||||
?.providers
|
||||
?.firstOrNull { it.name == summary.provider }
|
||||
}
|
||||
}
|
||||
.getOrNull()
|
||||
offeredPermissionModes = provider?.permissionModes.orEmpty()
|
||||
offeredModels =
|
||||
provider
|
||||
?.let {
|
||||
runCatching {
|
||||
withContext(Dispatchers.IO) {
|
||||
fetchProviderModels(settings, summary.setup, summary.provider)
|
||||
}
|
||||
}
|
||||
.getOrDefault(emptyList())
|
||||
}
|
||||
.orEmpty()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1840,13 +1847,21 @@ fun SessionScreen(
|
||||
},
|
||||
)
|
||||
}
|
||||
PickerButton(
|
||||
current = permissionMode,
|
||||
options = PERMISSION_MODES,
|
||||
onPick = { chosen ->
|
||||
act { setSessionPermissionMode(settings, summary.id, chosen) }
|
||||
},
|
||||
)
|
||||
if (offeredPermissionModes.isNotEmpty()) {
|
||||
PickerButton(
|
||||
current = permissionMode,
|
||||
options = offeredPermissionModes,
|
||||
onPick = { chosen ->
|
||||
act {
|
||||
setSessionPermissionMode(
|
||||
settings,
|
||||
summary.id,
|
||||
chosen,
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
// The same filled shape as the button beside it, not an outlined one: these
|
||||
// are two things you can do about the session, and weighting one as
|
||||
|
||||
Reference in new issue
Block a user