mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-19 03:40:50 +00:00
fix(codex): drop safe-yolo from Codex permission modes (#2183)
* fix(codex): drop safe-yolo from Codex permission modes Every Codex session runs on the native shared runtime (runCodex is runSharedCodex), which rejects safe-yolo. The mode stayed in CODEX_PERMISSION_MODES and six filters hid it again in the web picker, composer, hub permission-mode route, hapi set-mode and both native apps. API callers that validate against the flavor catalog (e.g. a spawn with permissionMode: 'safe-yolo') still passed it through and only failed inside the runner. Remove it from the Codex catalog (shared, iOS, Android, fixture) and delete the filters. autoReview is the native replacement. Safe Yolo stays for Gemini, Kimi and Copilot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(ios): Codex option list now has four modes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
fe2fbb881d
commit
ffd950a220
@@ -1671,9 +1671,7 @@ class ChatViewModel(
|
||||
active = detail?.active ?: summary?.active ?: false,
|
||||
controlledByUser = terminalControlled(detail),
|
||||
permissionMode = detail?.permissionMode,
|
||||
permissionModes = PermissionModes.forFlavor(flavor).filter {
|
||||
detail?.metadata?.capabilities?.concurrentClients != true || it != PermissionMode.SafeYolo
|
||||
},
|
||||
permissionModes = PermissionModes.forFlavor(flavor),
|
||||
model = model,
|
||||
modelOptions = modelOptions,
|
||||
modelOptionsLoading = modelOptionsLoading,
|
||||
|
||||
@@ -25,9 +25,7 @@ import app.hapi.protocol.catalog.PermissionModes
|
||||
* it only when the flavor offers it, and hide `default` everywhere except
|
||||
* copilot (model=auto sessions still surface the bottom-right mode chip).
|
||||
*
|
||||
* This consults the *unfiltered* flavor catalog: the concurrent-clients
|
||||
* Safe-Yolo carve-out only narrows the switcher, never the chip. Unknown
|
||||
* wire ids stay hidden (no raw fallback — same as the web span, which keys
|
||||
* Unknown wire ids stay hidden (no raw fallback — same as the web span, which keys
|
||||
* off `isPermissionModeAllowedForFlavor`).
|
||||
*/
|
||||
object PermissionModeChipRule {
|
||||
|
||||
@@ -126,7 +126,7 @@ object NewSessionLogic {
|
||||
}
|
||||
val permissionMode = if (usesSharedPermissionModeState(agent)) {
|
||||
stored?.permissionMode
|
||||
?.takeIf { mode -> PermissionModes.forLaunch(agent).any { it.wireId == mode } }
|
||||
?.takeIf { mode -> PermissionModes.forFlavor(agent).any { it.wireId == mode } }
|
||||
?: "default"
|
||||
} else {
|
||||
null
|
||||
@@ -352,7 +352,7 @@ object NewSessionLogic {
|
||||
sessionType = draft.sessionType,
|
||||
worktreeName = draft.worktreeName,
|
||||
)
|
||||
val allowedModes = PermissionModes.forLaunch(base.agent).map { it.wireId }
|
||||
val allowedModes = PermissionModes.forFlavor(base.agent).map { it.wireId }
|
||||
val sessionType = if (base.sessionType == SESSION_TYPE_WORKTREE) SESSION_TYPE_WORKTREE else SESSION_TYPE_SIMPLE
|
||||
return base.copy(
|
||||
permissionMode = if (base.permissionMode in allowedModes) base.permissionMode else "default",
|
||||
|
||||
+1
-1
@@ -940,7 +940,7 @@ class NewSessionViewModel(
|
||||
val permission: PermissionUi = when {
|
||||
agent == "pi" || agent == "dsh" -> PermissionUi.Managed
|
||||
usesNativePermissionSelect(agent) -> PermissionUi.NativeSelect(
|
||||
PermissionModes.forLaunch(agent).map { mode ->
|
||||
PermissionModes.forFlavor(agent).map { mode ->
|
||||
val unavailable = grokAutoUnavailable && mode == PermissionMode.Auto
|
||||
OptionItem(
|
||||
value = mode.wireId,
|
||||
|
||||
@@ -51,11 +51,4 @@ class PermissionModeChipTest {
|
||||
assertNull(PermissionModeChipRule.displayMode(null, "claude"))
|
||||
assertNull(PermissionModeChipRule.displayMode("", "copilot"))
|
||||
}
|
||||
|
||||
@Test fun safeYoloShowsOnTheChipEvenThoughTheSwitcherFiltersIt() {
|
||||
// The concurrent-clients carve-out (buildConfigUi) narrows the
|
||||
// switcher only; the chip consults the unfiltered flavor catalog,
|
||||
// like the web span.
|
||||
assertEquals(PermissionMode.SafeYolo, PermissionModeChipRule.displayMode("safe-yolo", "codex"))
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -415,7 +415,7 @@ class NewSessionLogicTest {
|
||||
NewSessionForm(agent = "codex", permissionMode = "safe-yolo"),
|
||||
)
|
||||
assertEquals("default", staleMode.permissionMode)
|
||||
assertEquals(listOf("default", "read-only", "autoReview", "yolo"), app.hapi.protocol.catalog.PermissionModes.forLaunch("codex").map { it.wireId })
|
||||
assertEquals(listOf("default", "read-only", "autoReview", "yolo"), app.hapi.protocol.catalog.PermissionModes.forFlavor("codex").map { it.wireId })
|
||||
assertEquals("safe-yolo", NewSessionLogic.sanitizeDraft(NewSessionForm(agent = "kimi", permissionMode = "safe-yolo")).permissionMode)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user