mirror of
https://github.com/stablyai/orca.git
synced 2026-11-17 19:34:29 +00:00
fix(chat): show deferred Claude permission picks
This commit is contained in:
+1
@@ -29,6 +29,7 @@ export function structuredStatusSummariesEqual(
|
||||
a.latestPrompt === b.latestPrompt &&
|
||||
a.model === b.model &&
|
||||
a.permissionMode === b.permissionMode &&
|
||||
a.launchPermissionMode === b.launchPermissionMode &&
|
||||
a.runtimePermission?.fence === b.runtimePermission?.fence &&
|
||||
a.runtimePermission?.mode === b.runtimePermission?.mode &&
|
||||
(a.runtimePermission === undefined) === (b.runtimePermission === undefined) &&
|
||||
|
||||
+3
@@ -87,6 +87,9 @@ export function structuredAgentSessionStatusSummary({
|
||||
: {}),
|
||||
...(model ? { model } : {}),
|
||||
...(isAgentChatPermissionMode(permissionMode) ? { permissionMode } : {}),
|
||||
...(session.child?.permissionMode
|
||||
? { launchPermissionMode: session.child.permissionMode }
|
||||
: {}),
|
||||
...(effort ? { effort } : {}),
|
||||
...(fastMode ? { fastMode } : {}),
|
||||
...(serviceTier ? { serviceTier } : {}),
|
||||
|
||||
+4
-3
@@ -31,10 +31,11 @@ import { runSessionOptionSurfaceCall } from './native-chat-session-option-surfac
|
||||
export function NativeChatPermissionModeName(props: {
|
||||
mode: AgentChatPermissionMode
|
||||
truncate?: boolean
|
||||
label?: string
|
||||
}): React.JSX.Element {
|
||||
const t = useTranslate()
|
||||
const Icon = NATIVE_CHAT_PERMISSION_MODE_ICONS[props.mode]
|
||||
const label = nativeChatPermissionModeLabel(props.mode, t)
|
||||
const label = props.label ?? nativeChatPermissionModeLabel(props.mode, t)
|
||||
const body = (
|
||||
<>
|
||||
<Icon className="size-3.5 shrink-0" aria-hidden />
|
||||
@@ -129,7 +130,7 @@ function NativeChatPermissionModePickerInner({
|
||||
className="max-w-40 min-w-0 shrink"
|
||||
>
|
||||
{isAgentChatPermissionMode(current) ? (
|
||||
<NativeChatPermissionModeName mode={current} truncate />
|
||||
<NativeChatPermissionModeName mode={current} label={currentLabel} truncate />
|
||||
) : (
|
||||
<>
|
||||
<Settings2 className="size-3.5 shrink-0" aria-hidden />
|
||||
@@ -189,7 +190,7 @@ export function NativeChatComposerPermissionPicker({
|
||||
<NativeChatPermissionModePicker
|
||||
current={current}
|
||||
modes={modes}
|
||||
currentLabel={descriptor.description}
|
||||
currentLabel={descriptor.valueSource === 'dispatched' ? descriptor.description : undefined}
|
||||
agent={agent ?? null}
|
||||
disabled={!descriptor.settable}
|
||||
onSelect={(mode) => {
|
||||
|
||||
+12
-6
@@ -65,11 +65,8 @@ export function useStructuredAgentSessionOptionState(args: {
|
||||
target,
|
||||
worktree
|
||||
} = args
|
||||
const { permissionReport, observation } = useStructuredAgentSessionPermissionStatus(
|
||||
sessionId,
|
||||
target,
|
||||
fence
|
||||
)
|
||||
const { permissionReport, launchPermissionMode, observation } =
|
||||
useStructuredAgentSessionPermissionStatus(sessionId, target, fence)
|
||||
const [reader] = useState(() =>
|
||||
createStructuredAgentSessionOptionsReadOwner(
|
||||
firstFrameOptionState(agent, target, {
|
||||
@@ -227,9 +224,18 @@ export function useStructuredAgentSessionOptionState(args: {
|
||||
),
|
||||
permissionReport
|
||||
),
|
||||
...(launchPermissionMode === undefined ? {} : { launchPermissionMode }),
|
||||
permissionOwnSupported
|
||||
}),
|
||||
[reader, owner, controller, permissionReport, fence, permissionOwnSupported]
|
||||
[
|
||||
reader,
|
||||
owner,
|
||||
controller,
|
||||
permissionReport,
|
||||
launchPermissionMode,
|
||||
fence,
|
||||
permissionOwnSupported
|
||||
]
|
||||
)
|
||||
const takesSendOptions = useStructuredAgentSessionHostCapability(
|
||||
target,
|
||||
|
||||
+7
-1
@@ -32,6 +32,7 @@ export function useStructuredAgentSessionPermissionStatus(
|
||||
fence: number | null
|
||||
): {
|
||||
permissionReport: ReturnType<typeof runtimePermissionReport>
|
||||
launchPermissionMode: string | undefined
|
||||
observation: 'live' | 'unverifiable'
|
||||
} {
|
||||
const { feed, subscribe } = useSessionFeed(sessionId, target)
|
||||
@@ -45,7 +46,12 @@ export function useStructuredAgentSessionPermissionStatus(
|
||||
() => feed.getSessionObservation(sessionId),
|
||||
() => 'unverifiable' as const
|
||||
)
|
||||
return { permissionReport, observation }
|
||||
const launchPermissionMode = useSyncExternalStore(
|
||||
subscribe,
|
||||
() => feed.getSnapshot().get(sessionId)?.launchPermissionMode,
|
||||
() => undefined
|
||||
)
|
||||
return { permissionReport, launchPermissionMode, observation }
|
||||
}
|
||||
|
||||
export function useStructuredAgentSessionOptionStamp(
|
||||
|
||||
@@ -215,6 +215,8 @@ export type AgentSessionStatusSummary = {
|
||||
reportedModel?: string
|
||||
/** The chat's saved permission mode; a client re-reads options when it or `model` moves. */
|
||||
permissionMode?: string
|
||||
/** Permission choice used to start the currently fenced provider child. */
|
||||
launchPermissionMode?: string
|
||||
runtimePermission?: { fence: number; mode: string | null } | null
|
||||
/** The chat's saved effort, Fast and speed picks, encoded; another device's pick moves them so a
|
||||
* client re-reads options. Absent from older hosts. */
|
||||
|
||||
@@ -72,6 +72,8 @@ export type StructuredAgentSessionOptionState = {
|
||||
defaultsUnsent?: true
|
||||
/** The permission mode the host or launch last stated; null shows no picker. */
|
||||
permissionMode: string | null
|
||||
/** Optional live-host launch choice; absent on older hosts. */
|
||||
launchPermissionMode?: string
|
||||
interactionModeSupported?: boolean
|
||||
reportedPermissionMode?: string | null
|
||||
permissionOwnSupported?: boolean | null
|
||||
|
||||
@@ -99,4 +99,46 @@ describe('the permission mode picker', () => {
|
||||
)
|
||||
).toBe(true)
|
||||
})
|
||||
|
||||
it('labels only a saved choice that differs from the fenced child launch choice as deferred', () => {
|
||||
const state = { ...live('claude', { permissionMode: 'ask' }), permissionOwnSupported: true }
|
||||
expect(
|
||||
permission({ ...state, permissionMode: 'full-access', launchPermissionMode: 'ask' })
|
||||
).toMatchObject({
|
||||
description: 'Full access — Applies to your next message',
|
||||
valueSource: 'dispatched'
|
||||
})
|
||||
expect(
|
||||
permission({ ...state, permissionMode: 'own', launchPermissionMode: 'own' })
|
||||
).toMatchObject({
|
||||
description: "Agent's own settings",
|
||||
valueSource: 'applied'
|
||||
})
|
||||
expect(
|
||||
permission({ ...state, permissionMode: 'ask', launchPermissionMode: 'full-access' })
|
||||
).toMatchObject({
|
||||
description: 'Ask for approval — Applies to your next message',
|
||||
valueSource: 'dispatched'
|
||||
})
|
||||
expect(permission({ ...state, permissionMode: 'full-access' })).toMatchObject({
|
||||
description: 'Full access',
|
||||
valueSource: 'applied'
|
||||
})
|
||||
expect(
|
||||
permission({
|
||||
...state,
|
||||
permissionMode: 'full-access',
|
||||
launchPermissionMode: 'ask',
|
||||
reportedPermissionMode: 'plan'
|
||||
})
|
||||
).toMatchObject({ valueSource: 'dispatched' })
|
||||
expect(
|
||||
permission({
|
||||
...state,
|
||||
permissionMode: 'full-access',
|
||||
launchPermissionMode: 'ask',
|
||||
reportedPermissionMode: 'unknown-mode'
|
||||
})
|
||||
).toMatchObject({ valueSource: 'dispatched' })
|
||||
})
|
||||
})
|
||||
|
||||
@@ -55,6 +55,7 @@ export function structuredAgentSessionPermissionDescriptor(state: {
|
||||
record: StructuredAgentSessionOptionRecord
|
||||
permissionMode: string | null
|
||||
permissionOwnSupported?: boolean | null
|
||||
launchPermissionMode?: string
|
||||
reportedPermissionMode?: string | null
|
||||
}): SessionOptionDescriptor | null {
|
||||
const support = agentChatPermissionModes(state.record.agent)
|
||||
@@ -73,8 +74,10 @@ export function structuredAgentSessionPermissionDescriptor(state: {
|
||||
: current === 'read-only'
|
||||
? 'Read only'
|
||||
: (current ?? 'Permissions')
|
||||
const deferred =
|
||||
state.launchPermissionMode !== undefined && state.launchPermissionMode !== current
|
||||
return {
|
||||
description: label,
|
||||
description: deferred ? `${label} — Applies to your next message` : label,
|
||||
id: AGENT_CHAT_PERMISSION_MODE_OPTION_ID,
|
||||
label: 'Permissions',
|
||||
category: 'mode',
|
||||
@@ -87,7 +90,7 @@ export function structuredAgentSessionPermissionDescriptor(state: {
|
||||
description: agentDescriptions(state.record.agent)[value] ?? MODE_COPY[value].description
|
||||
}))
|
||||
},
|
||||
valueSource: 'applied',
|
||||
valueSource: deferred ? 'dispatched' : 'applied',
|
||||
transport: 'agent-session',
|
||||
settable: state.permissionOwnSupported !== null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user