Build and lint fixes.

This commit is contained in:
Enrico Ros
2024-10-12 00:49:05 -07:00
parent 61df9819e6
commit 950e1c8779
7 changed files with 40 additions and 12 deletions
+1 -1
View File
@@ -55,4 +55,4 @@ ensure that your proxy is configured to support streaming output as described ab
- For Kubernetes deployments, see our [Kubernetes Deployment Guide](deploy-k8s.md) - For Kubernetes deployments, see our [Kubernetes Deployment Guide](deploy-k8s.md)
- For general installation instructions, see our [Installation Guide](installation.md) - For general installation instructions, see our [Installation Guide](installation.md)
If you continue to experience issues, please reach out to our [community support channels](README.md#support-and-community). If you continue to experience issues, please reach out to our [community support channels](../README.md#-get-involved).
+3 -3
View File
@@ -8,19 +8,19 @@ export function getIsMobile() {
} }
export function useIsMobile(): boolean { export function useIsMobile(): boolean {
return _useMatchMedia(_isMobileQuery, false); return useMatchMedia(_isMobileQuery, false);
} }
export function useIsTallScreen(): boolean { export function useIsTallScreen(): boolean {
// Adjust the aspect ratio value as needed (e.g., 10/9 for a slightly taller than square ratio) // Adjust the aspect ratio value as needed (e.g., 10/9 for a slightly taller than square ratio)
return _useMatchMedia('(max-aspect-ratio: 10/9)', false); return useMatchMedia('(max-aspect-ratio: 10/9)', false);
} }
// the query was was ${appTheme.breakpoints.values.md: { xs: 0, sm: 600, md: 900, lg: 1200, xl: 1536 } - 1}px // the query was was ${appTheme.breakpoints.values.md: { xs: 0, sm: 600, md: 900, lg: 1200, xl: 1536 } - 1}px
const _isMobileQuery: string = `(max-width: 899px)`; const _isMobileQuery: string = `(max-width: 899px)`;
function _useMatchMedia(query: string, ssrValue: boolean): boolean { function useMatchMedia(query: string, ssrValue: boolean): boolean {
const [matches, setMatches] = React.useState(isBrowser ? window.matchMedia(query).matches : ssrValue); const [matches, setMatches] = React.useState(isBrowser ? window.matchMedia(query).matches : ssrValue);
React.useEffect(() => { React.useEffect(() => {
@@ -5,17 +5,17 @@ import { OptimaPortalId, useOptimaPortalsStore } from './store-optima-portals';
export function OptimaDrawerIn(props: { children: React.ReactNode }) { export function OptimaDrawerIn(props: { children: React.ReactNode }) {
const portalElement = _useOptimaPortalTargetElement('optima-portal-drawer'); const portalElement = useOptimaPortalTargetElement('optima-portal-drawer');
return portalElement ? createPortal(props.children, portalElement) : null; return portalElement ? createPortal(props.children, portalElement) : null;
} }
export function OptimaPanelIn(props: { children: React.ReactNode }) { export function OptimaPanelIn(props: { children: React.ReactNode }) {
const portalElement = _useOptimaPortalTargetElement('optima-portal-panel'); const portalElement = useOptimaPortalTargetElement('optima-portal-panel');
return portalElement ? createPortal(props.children, portalElement) : null; return portalElement ? createPortal(props.children, portalElement) : null;
} }
export function OptimaToolbarIn(props: { children: React.ReactNode }) { export function OptimaToolbarIn(props: { children: React.ReactNode }) {
const portalElement = _useOptimaPortalTargetElement('optima-portal-toolbar'); const portalElement = useOptimaPortalTargetElement('optima-portal-toolbar');
return portalElement ? createPortal(props.children, portalElement) : null; return portalElement ? createPortal(props.children, portalElement) : null;
} }
@@ -23,7 +23,7 @@ export function OptimaToolbarIn(props: { children: React.ReactNode }) {
/** /**
* Hook to get the target element for a portal. * Hook to get the target element for a portal.
*/ */
function _useOptimaPortalTargetElement(targetPortalId: OptimaPortalId) { function useOptimaPortalTargetElement(targetPortalId: OptimaPortalId) {
// get the output element // get the output element
const targetPortalEl = useOptimaPortalsStore(state => state.portals[targetPortalId]?.element ?? null); const targetPortalEl = useOptimaPortalsStore(state => state.portals[targetPortalId]?.element ?? null);
+29
View File
@@ -50,3 +50,32 @@ export function ellipsizeMiddle(text: string, maxLength: number) {
const half = Math.floor(maxLength / 2); const half = Math.floor(maxLength / 2);
return text.slice(0, half) + '…' + text.slice(-(maxLength - half - 1)); return text.slice(0, half) + '…' + text.slice(-(maxLength - half - 1));
} }
export function ellipsizeEnd(text: string, maxLength: number, maxLines?: number) {
let wasTruncated = false;
// Handle maxLines if specified
if (maxLines !== undefined && maxLines > 0) {
const lines = text.split('\n');
if (lines.length > maxLines) {
text = lines.slice(0, maxLines).join('\n');
wasTruncated = true;
}
}
// Check if text exceeds maxLength and truncate if necessary
if (text.length > maxLength) {
text = text.slice(0, maxLength - 1) + '…';
// wasTruncated = true; // not useful here
} else if (wasTruncated) {
// If text was truncated by lines but not by length, add ellipsis if possible
if (text.length + 1 <= maxLength) {
text += '…';
} else if (maxLength > 0) {
// Truncate one character to add ellipsis without exceeding maxLength
text = text.slice(0, maxLength - 1) + '…';
}
}
return text;
}
+1 -1
View File
@@ -99,5 +99,5 @@ export function useAutoBlocksMemoSemiStable(text: string, forceCodeWithTitle: st
prevTextRef.current = text; prevTextRef.current = text;
return recycledBlocks; return recycledBlocks;
}, [forceCodeWithTitle, forceMarkdown, forceSanityTextDiffs, text]); }, [forceCodeWithTitle, forceMarkdown, forceSanityTextDiffs, selectSingleCodeBlock, text]);
} }
@@ -8,9 +8,8 @@ import { default as remarkGfm } from 'remark-gfm';
import { default as remarkMath } from 'remark-math'; import { default as remarkMath } from 'remark-math';
import { remarkMark } from 'remark-mark-highlight'; import { remarkMark } from 'remark-mark-highlight';
import { Box, Button, Tooltip } from '@mui/joy'; import { Box, Button } from '@mui/joy';
import DownloadIcon from '@mui/icons-material/Download'; import DownloadIcon from '@mui/icons-material/Download';
import ContentCopyIcon from '@mui/icons-material/ContentCopy';
import { copyToClipboard } from '~/common/util/clipboardUtils'; import { copyToClipboard } from '~/common/util/clipboardUtils';
+1 -1
View File
@@ -74,7 +74,7 @@ export function OpenAIServiceSetup(props: { serviceId: DModelsServiceId }) {
{advanced.on && <FormTextField {advanced.on && <FormTextField
autoCompleteId='openai-org' autoCompleteId='openai-org'
title='Organization ID' title='Organization ID'
description={<Link level='body-sm' href={`${Brand.URIs.OpenRepo}/issues/63`} target='_blank'>What is this</Link>} description={<Link level='body-sm' href={Brand.URIs.OpenRepo + '/issues/63'} target='_blank'>What is this</Link>}
placeholder='Optional, for enterprise users' placeholder='Optional, for enterprise users'
value={oaiOrg} value={oaiOrg}
onChange={text => updateSettings({ oaiOrg: text })} onChange={text => updateSettings({ oaiOrg: text })}