mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
fix(web): handle null values in permissionMode and modelMode using nullish coalescing
The settings popup in HappyComposer did not show any option selected when permissionMode or modelMode was null, since destructuring defaults only handle undefined, not null. This fix uses the ?? operator to properly handle both null and undefined cases, falling back to 'default' in both.
This commit is contained in:
@@ -59,8 +59,8 @@ export function HappyComposer(props: {
|
||||
}) {
|
||||
const {
|
||||
disabled = false,
|
||||
permissionMode = 'default',
|
||||
modelMode = 'default',
|
||||
permissionMode: rawPermissionMode,
|
||||
modelMode: rawModelMode,
|
||||
active = true,
|
||||
thinking = false,
|
||||
agentState,
|
||||
@@ -73,6 +73,10 @@ export function HappyComposer(props: {
|
||||
autocompleteSuggestions = defaultSuggestionHandler
|
||||
} = props
|
||||
|
||||
// Use ?? to handle both null and undefined (destructuring defaults only work for undefined)
|
||||
const permissionMode = rawPermissionMode ?? 'default'
|
||||
const modelMode = rawModelMode ?? 'default'
|
||||
|
||||
const api = useAssistantApi()
|
||||
const composerText = useAssistantState(({ composer }) => composer.text)
|
||||
const threadIsRunning = useAssistantState(({ thread }) => thread.isRunning)
|
||||
|
||||
Reference in New Issue
Block a user