fix: treat embedded session chat as desktop surface
Prevents narrow embedded session chat panels from being misdetected as mobile Uses the ocPanel=session-chat query parameter to पहचान desktop-like layout Keeps device detection aligned with other desktop shell runtimes
This commit is contained in:
@@ -35,6 +35,11 @@ const DEFAULT_DEVICE_INFO: DeviceInfo = {
|
|||||||
hasTouchOnlyPointer: false,
|
hasTouchOnlyPointer: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isEmbeddedSessionChat = (): boolean => {
|
||||||
|
if (typeof window === 'undefined') return false;
|
||||||
|
return new URLSearchParams(window.location.search).get('ocPanel') === 'session-chat';
|
||||||
|
};
|
||||||
|
|
||||||
const getNavigatorDeviceHints = (maxTouchPoints: number) => {
|
const getNavigatorDeviceHints = (maxTouchPoints: number) => {
|
||||||
if (typeof navigator === 'undefined') {
|
if (typeof navigator === 'undefined') {
|
||||||
return { isExplicitTablet: false };
|
return { isExplicitTablet: false };
|
||||||
@@ -103,8 +108,8 @@ export function getDeviceInfo(): DeviceInfo {
|
|||||||
const prefersCoarsePointer = pointerQuery?.matches ?? false;
|
const prefersCoarsePointer = pointerQuery?.matches ?? false;
|
||||||
const noHover = hoverQuery?.matches ?? false;
|
const noHover = hoverQuery?.matches ?? false;
|
||||||
const maxTouchPoints = typeof navigator !== 'undefined' ? navigator.maxTouchPoints ?? 0 : 0;
|
const maxTouchPoints = typeof navigator !== 'undefined' ? navigator.maxTouchPoints ?? 0 : 0;
|
||||||
// VS Code is a desktop surface — don't misdetect a narrow panel as mobile (#1261)
|
// Desktop panels are desktop surfaces even when their viewport is narrow.
|
||||||
const isDesktopShellRuntime = isDesktopShell() || isVSCodeRuntime();
|
const isDesktopShellRuntime = isDesktopShell() || isVSCodeRuntime() || isEmbeddedSessionChat();
|
||||||
const { isExplicitTablet } = getNavigatorDeviceHints(maxTouchPoints);
|
const { isExplicitTablet } = getNavigatorDeviceHints(maxTouchPoints);
|
||||||
|
|
||||||
const hasTouchInput = prefersCoarsePointer || noHover || maxTouchPoints > 0;
|
const hasTouchInput = prefersCoarsePointer || noHover || maxTouchPoints > 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user