mirror of
https://github.com/wu736139669/hapi.git
synced 2026-12-04 06:57:55 +00:00
feat(claude): add effort setting parity with model across stack (#353)
Co-authored-by: Xiaoyi <xiaoyizhang@microsoft.com>
This commit is contained in:
@@ -18,6 +18,7 @@ export function useSessionActions(
|
||||
setPermissionMode: (mode: PermissionMode) => Promise<void>
|
||||
setCollaborationMode: (mode: CodexCollaborationMode) => Promise<void>
|
||||
setModel: (model: string | null) => Promise<void>
|
||||
setEffort: (effort: string | null) => Promise<void>
|
||||
renameSession: (name: string) => Promise<void>
|
||||
deleteSession: () => Promise<void>
|
||||
isPending: boolean
|
||||
@@ -99,6 +100,16 @@ export function useSessionActions(
|
||||
onSuccess: () => void invalidateSession(),
|
||||
})
|
||||
|
||||
const effortMutation = useMutation({
|
||||
mutationFn: async (effort: string | null) => {
|
||||
if (!api || !sessionId) {
|
||||
throw new Error('Session unavailable')
|
||||
}
|
||||
await api.setEffort(sessionId, effort)
|
||||
},
|
||||
onSuccess: () => void invalidateSession(),
|
||||
})
|
||||
|
||||
const renameMutation = useMutation({
|
||||
mutationFn: async (name: string) => {
|
||||
if (!api || !sessionId) {
|
||||
@@ -131,6 +142,7 @@ export function useSessionActions(
|
||||
setPermissionMode: permissionMutation.mutateAsync,
|
||||
setCollaborationMode: collaborationMutation.mutateAsync,
|
||||
setModel: modelMutation.mutateAsync,
|
||||
setEffort: effortMutation.mutateAsync,
|
||||
renameSession: renameMutation.mutateAsync,
|
||||
deleteSession: deleteMutation.mutateAsync,
|
||||
isPending: abortMutation.isPending
|
||||
@@ -139,6 +151,7 @@ export function useSessionActions(
|
||||
|| permissionMutation.isPending
|
||||
|| collaborationMutation.isPending
|
||||
|| modelMutation.isPending
|
||||
|| effortMutation.isPending
|
||||
|| renameMutation.isPending
|
||||
|| deleteMutation.isPending,
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ type SpawnInput = {
|
||||
directory: string
|
||||
agent?: 'claude' | 'codex' | 'cursor' | 'gemini' | 'opencode'
|
||||
model?: string
|
||||
effort?: string
|
||||
modelReasoningEffort?: string
|
||||
yolo?: boolean
|
||||
sessionType?: 'simple' | 'worktree'
|
||||
@@ -34,7 +35,8 @@ export function useSpawnSession(api: ApiClient | null): {
|
||||
input.modelReasoningEffort,
|
||||
input.yolo,
|
||||
input.sessionType,
|
||||
input.worktreeName
|
||||
input.worktreeName,
|
||||
input.effort
|
||||
)
|
||||
},
|
||||
onSuccess: () => {
|
||||
|
||||
@@ -30,7 +30,7 @@ const RECONNECT_MAX_DELAY_MS = 30_000
|
||||
const RECONNECT_JITTER_MS = 500
|
||||
const INVALIDATION_BATCH_MS = 16
|
||||
|
||||
type SessionPatch = Partial<Pick<Session, 'active' | 'thinking' | 'activeAt' | 'updatedAt' | 'model' | 'permissionMode' | 'collaborationMode'>>
|
||||
type SessionPatch = Partial<Pick<Session, 'active' | 'thinking' | 'activeAt' | 'updatedAt' | 'model' | 'effort' | 'permissionMode' | 'collaborationMode'>>
|
||||
|
||||
function sortSessionSummaries(left: SessionSummary, right: SessionSummary): number {
|
||||
if (left.active !== right.active) {
|
||||
@@ -85,6 +85,10 @@ function getSessionPatch(value: unknown): SessionPatch | null {
|
||||
patch.model = value.model
|
||||
hasKnownPatch = true
|
||||
}
|
||||
if (value.effort === null || typeof value.effort === 'string') {
|
||||
patch.effort = value.effort
|
||||
hasKnownPatch = true
|
||||
}
|
||||
if (typeof value.permissionMode === 'string') {
|
||||
patch.permissionMode = value.permissionMode as Session['permissionMode']
|
||||
hasKnownPatch = true
|
||||
@@ -101,7 +105,7 @@ function hasUnknownSessionPatchKeys(value: unknown): boolean {
|
||||
if (!hasRecordShape(value)) {
|
||||
return false
|
||||
}
|
||||
const knownKeys = new Set(['active', 'thinking', 'activeAt', 'updatedAt', 'model', 'permissionMode', 'collaborationMode'])
|
||||
const knownKeys = new Set(['active', 'thinking', 'activeAt', 'updatedAt', 'model', 'effort', 'permissionMode', 'collaborationMode'])
|
||||
return Object.keys(value).some((key) => !knownKeys.has(key))
|
||||
}
|
||||
|
||||
@@ -386,7 +390,8 @@ export function useSSE(options: {
|
||||
thinking: patch.thinking ?? current.thinking,
|
||||
activeAt: patch.activeAt ?? current.activeAt,
|
||||
updatedAt: patch.updatedAt ?? current.updatedAt,
|
||||
model: Object.prototype.hasOwnProperty.call(patch, 'model') ? patch.model ?? null : current.model
|
||||
model: Object.prototype.hasOwnProperty.call(patch, 'model') ? patch.model ?? null : current.model,
|
||||
effort: Object.prototype.hasOwnProperty.call(patch, 'effort') ? patch.effort ?? null : current.effort
|
||||
}
|
||||
|
||||
patched = true
|
||||
|
||||
Reference in New Issue
Block a user