Repository navigation
fix: [Agent] User information on the debugging page is not clickable - #7757
Conversation
| <div class="mt-3 shrink-0" v-if="SHOW_PROFILE.includes(viewType)"> | ||
| <AccountMenu /> | ||
| </div> | ||
| </div> |
There was a problem hiding this comment.
The diff is valid and the intent is clear. No blocking issue from the shown code, but here are review points:
-
Import formatting
import { useViewType, VIEW_TYPE ,type ViewType} from '../../view/index'
Should be formatted as:
import { useViewType, VIEW_TYPE, type ViewType } from '../../view/index'
Or use a separate
import type { ViewType } ...if your lint rules prefer that. -
Verify
useViewType()return type
The existing computed:const authProfile = computed(() => (viewType === VIEW_TYPE.CHAT ? auth.authProfile : null))
compares
viewTypedirectly. IfuseViewType()returns aRef/ComputedRef, this is likely a bug and should useviewType.value.
In the template, refs are auto-unwrapped, so:v-if="SHOW_PROFILE.includes(viewType)"
probably works. But for consistency and testability, prefer:
const showAccountMenu = computed(() => SHOW_PROFILE.includes(viewType.value) )
and:
v-if="showAccountMenu"
Adjust
.valueonly ifviewTypeis actually a ref. -
Rename
SHOW_PROFILE
It is not a boolean; it is a list of view types controlling the account menu. A clearer name:const ACCOUNT_MENU_VIEW_TYPES: readonly ViewType[] = [ VIEW_TYPE.CHAT, VIEW_TYPE.PORTAL, ]
Then:
v-if="ACCOUNT_MENU_VIEW_TYPES.includes(viewType)"
-
v-ifdestroys/remountsAccountMenu
IfAccountMenuhas internal state or async initialization, switching view types will destroy and recreate it. Usev-showinstead if state preservation is needed, or keepv-ifif remounting is acceptable. -
Confirm product behavior
Hiding the account entry in all other view types may remove access to logout/settings. Make sure this is intentional. -
Type/export checks
EnsureViewTypeis exported from../../view/index, and thatVIEW_TYPE.PORTALis actually part of theViewTypeunion/enum. Otherwise TypeScript will fail. -
Minor optimization
Array.prototype.includesis fine for two values. If the list grows, use aSet<ViewType>and.has(...). The array is also recreated per component instance in<script setup>; negligible here, but it can be moved to module scope if desired.
Suggested small cleanup:
import { useViewType, VIEW_TYPE, type ViewType } from '../../view/index'
const ACCOUNT_MENU_VIEW_TYPES: readonly ViewType[] = [
VIEW_TYPE.CHAT,
VIEW_TYPE.PORTAL,
]<div
v-if="ACCOUNT_MENU_VIEW_TYPES.includes(viewType)"
class="mt-3 shrink-0"
>
<AccountMenu />
</div>
fix: [Agent] User information on the debugging page is not clickable