SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
Feat/quick filters resizable (#11998)
Yunus Mff4f18985c34
diff --git a/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/CheckboxValueRow.tsx b/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/CheckboxValueRow.tsxindex 090c98569f..66c4c18013 100644--- a/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/CheckboxValueRow.tsx+++ b/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/CheckboxValueRow.tsx@@ -2,6 +2,7 @@ import { Button } from 'antd';import { Checkbox } from '@signozhq/ui/checkbox';import { Typography } from '@signozhq/ui/typography';import cx from 'classnames';+import { TooltipSimple } from '@signozhq/ui/tooltip';interface CheckboxValueRowProps {value: string;@@ -46,9 +47,11 @@ function CheckboxValueRow({{customRendererForValue ? (customRendererForValue(value)) : (- <Typography.Text className="value-string" truncate={1}>- {String(value)}- </Typography.Text>+ <TooltipSimple title={value} side="top" align="center" arrow>+ <Typography.Text className="value-string" truncate={1}>+ {String(value)}+ </Typography.Text>+ </TooltipSimple>)}<Button type="text" className="only-btn">{onlyButtonLabel}diff --git a/frontend/src/constants/localStorage.ts b/frontend/src/constants/localStorage.tsindex e8c50d3c14..04db78d541 100644--- a/frontend/src/constants/localStorage.ts+++ b/frontend/src/constants/localStorage.ts@@ -31,6 +31,7 @@ export enum LOCALSTORAGE {METRICS_LIST_OPTIONS = 'METRICS_LIST_OPTIONS',SHOW_EXCEPTIONS_QUICK_FILTERS = 'SHOW_EXCEPTIONS_QUICK_FILTERS',QUICK_FILTERS_SETTINGS_ANNOUNCEMENT = 'QUICK_FILTERS_SETTINGS_ANNOUNCEMENT',+ QUICK_FILTERS_WIDTH_LOGS = 'QUICK_FILTERS_WIDTH_LOGS',FUNNEL_STEPS = 'FUNNEL_STEPS',SPAN_DETAILS_PINNED_ATTRIBUTES = 'SPAN_DETAILS_PINNED_ATTRIBUTES',LAST_USED_CUSTOM_TIME_RANGES = 'LAST_USED_CUSTOM_TIME_RANGES',diff --git a/frontend/src/pages/LogsExplorer/LogsExplorer.styles.scss b/frontend/src/pages/LogsExplorer/LogsExplorer.styles.scssindex effff3065c..290ee2b052 100644--- a/frontend/src/pages/LogsExplorer/LogsExplorer.styles.scss+++ b/frontend/src/pages/LogsExplorer/LogsExplorer.styles.scss@@ -33,15 +33,19 @@}&.filter-visible {+ // Width is owned by ResizableBox (inline style); this section is the+ // ResizableBox root, so it stays position: relative for the drag handle..log-quick-filter-left-section {- width: 260px;height: 100%;overflow: visible;min-height: 0;- position: relative;z-index: 2;- display: flex;- flex-direction: column;++ .resizable-box__content {+ display: flex;+ flex-direction: column;+ overflow: visible;+ }.quick-filters-container {flex: 1;@@ -50,7 +54,9 @@}.log-module-right-section {- width: calc(100% - 260px);+ flex: 1;+ width: auto;+ min-width: 0;}}}diff --git a/frontend/src/pages/LogsExplorer/index.tsx b/frontend/src/pages/LogsExplorer/index.tsxindex 113be512c8..68f7479d58 100644--- a/frontend/src/pages/LogsExplorer/index.tsx+++ b/frontend/src/pages/LogsExplorer/index.tsx@@ -26,6 +26,8 @@ import {import { useIsAIAssistantEnabled } from 'hooks/useIsAIAssistantEnabled';import { defaultTo, isEmpty, isNull } from 'lodash-es';import ErrorBoundaryFallback from 'pages/ErrorBoundaryFallback/ErrorBoundaryFallback';+import { ResizableBox } from 'periscope/components/ResizableBox';+import usePanelWidth from 'periscope/components/ResizableBox/usePanelWidth';import { EventSourceProvider } from 'providers/EventSource';import { Warning } from 'types/api';import { DataSource } from 'types/common/queryBuilder';@@ -44,9 +46,23 @@ import { ExplorerViews } from './utils';import './LogsExplorer.styles.scss';+const QUICK_FILTERS_DEFAULT_WIDTH = 260;+const QUICK_FILTERS_MIN_WIDTH = 240;+const QUICK_FILTERS_MAX_WIDTH = 500;+function LogsExplorer(): JSX.Element {const [showLiveLogs, setShowLiveLogs] = useState<boolean>(false);+ const {+ initialWidth: quickFiltersInitialWidth,+ persistWidth: persistQuickFiltersWidth,+ } = usePanelWidth({+ storageKey: LOCALSTORAGE.QUICK_FILTERS_WIDTH_LOGS,+ defaultWidth: QUICK_FILTERS_DEFAULT_WIDTH,+ minWidth: QUICK_FILTERS_MIN_WIDTH,+ maxWidth: QUICK_FILTERS_MAX_WIDTH,+ });+// Get panel type from URLconst panelTypesFromUrl = useGetPanelTypesQueryParam(PANEL_TYPES.LIST);@@ -226,14 +242,25 @@ function LogsExplorer(): JSX.Element {className={cx('logs-module-page', showFilters ? 'filter-visible' : '')}>{showFilters && (- <section className={cx('log-quick-filter-left-section')}>+ <ResizableBox+ handle="right"+ defaultWidth={QUICK_FILTERS_DEFAULT_WIDTH}+ initialWidth={quickFiltersInitialWidth}+ minWidth={QUICK_FILTERS_MIN_WIDTH}+ maxWidth={QUICK_FILTERS_MAX_WIDTH}+ onResize={persistQuickFiltersWidth}+ resetToDefaultOnDoubleClick+ withHandle+ className="log-quick-filter-left-section"+ handleTestId="quick-filters-resize-handle"+ ><QuickFiltersclassName="qf-logs-explorer"signal={SignalType.LOGS}source={QuickFiltersSource.LOGS_EXPLORER}handleFilterVisibilityChange={handleFilterVisibilityChange}/>- </section>+ </ResizableBox>)}<section className={cx('log-module-right-section')}><Toolbardiff --git a/frontend/src/periscope/components/ResizableBox/ResizableBox.styles.scss b/frontend/src/periscope/components/ResizableBox/ResizableBox.styles.scssindex a4630fafeb..32b62a31f1 100644--- a/frontend/src/periscope/components/ResizableBox/ResizableBox.styles.scss+++ b/frontend/src/periscope/components/ResizableBox/ResizableBox.styles.scss@@ -18,6 +18,17 @@z-index: 10;background: var(--l2-border);+ // Extend the interactive area beyond the 1px visual line so the handle+ // is easy to grab and double-click, without changing its appearance.+ &::before {+ content: '';+ position: absolute;+ top: -4px;+ right: -4px;+ bottom: -4px;+ left: -4px;+ }+&:hover,&:active {background: var(--primary);@@ -55,4 +66,29 @@right: 0;}}++ // Visible grip indicator (opt-in via the `withHandle` prop). Purely visual —+ // pointer events fall through to the handle so it still owns drag + reset.+ &__grip {+ position: absolute;+ top: 50%;+ left: 50%;+ transform: translate(-50%, -50%);+ display: flex;+ align-items: center;+ justify-content: center;+ width: 14px;+ height: 26px;+ border: 1px solid var(--l2-border);+ border-radius: 4px;+ background: var(--l1-background);+ color: var(--l2-foreground);+ pointer-events: none;+ }++ &__handle:hover &__grip,+ &__handle:active &__grip {+ border-color: var(--primary);+ color: var(--primary);+ }}diff --git a/frontend/src/periscope/components/ResizableBox/ResizableBox.tsx b/frontend/src/periscope/components/ResizableBox/ResizableBox.tsxindex c2b8aec19c..eac774b1e7 100644--- a/frontend/src/periscope/components/ResizableBox/ResizableBox.tsx+++ b/frontend/src/periscope/components/ResizableBox/ResizableBox.tsx@@ -1,3 +1,4 @@+import { GripVertical } from '@signozhq/icons';import { useCallback, useRef, useState } from 'react';import './ResizableBox.styles.scss';@@ -11,15 +12,28 @@ export interface ResizableBoxProps {// resize (width). Dragging the handle away from the content grows the box;// dragging it toward the content shrinks it.handle?: ResizableBoxHandle;+ // Canonical default size, and the target that double-click reset restores to.defaultHeight?: number;minHeight?: number;maxHeight?: number;defaultWidth?: number;minWidth?: number;maxWidth?: number;+ // Starting size when different from the default (e.g. a persisted value).+ // Falls back to defaultWidth/defaultHeight when omitted, preserving the+ // behavior of callers that don't opt in.+ initialWidth?: number;+ initialHeight?: number;+ // When true, double-clicking the handle resets the size to+ // defaultWidth/defaultHeight and fires onResize with that value.+ resetToDefaultOnDoubleClick?: boolean;+ // When true, renders a visible grip indicator on the handle so it is+ // discoverable as a draggable affordance.+ withHandle?: boolean;onResize?: (size: number) => void;disabled?: boolean;className?: string;+ handleTestId?: string;}function ResizableBox({@@ -31,13 +45,22 @@ function ResizableBox({defaultWidth = 200,minWidth = 50,maxWidth = Infinity,+ initialWidth,+ initialHeight,+ resetToDefaultOnDoubleClick = false,+ withHandle = false,onResize,disabled = false,className,+ handleTestId,}: ResizableBoxProps): JSX.Element {const isHorizontal = handle === 'left' || handle === 'right';const isStartHandle = handle === 'top' || handle === 'left';- const [size, setSize] = useState(isHorizontal ? defaultWidth : defaultHeight);+ const [size, setSize] = useState(+ isHorizontal+ ? (initialWidth ?? defaultWidth)+ : (initialHeight ?? defaultHeight),+ );const containerRef = useRef<HTMLDivElement>(null);const handleMouseDown = useCallback(@@ -83,6 +106,21 @@ function ResizableBox({],);+ const handleDoubleClick = useCallback((): void => {+ if (!resetToDefaultOnDoubleClick) {+ return;+ }+ const nextSize = isHorizontal ? defaultWidth : defaultHeight;+ setSize(nextSize);+ onResize?.(nextSize);+ }, [+ resetToDefaultOnDoubleClick,+ isHorizontal,+ defaultWidth,+ defaultHeight,+ onResize,+ ]);+const containerStyle = disabled? undefined: isHorizontal@@ -99,7 +137,22 @@ function ResizableBox({style={containerStyle}><div className="resizable-box__content">{children}</div>- {!disabled && <div className={handleClass} onMouseDown={handleMouseDown} />}+ {!disabled && (+ <div+ role="separator"+ aria-orientation={isHorizontal ? 'vertical' : 'horizontal'}+ className={handleClass}+ onMouseDown={handleMouseDown}+ onDoubleClick={handleDoubleClick}+ data-testid={handleTestId}+ >+ {withHandle && (+ <span className="resizable-box__grip">+ <GripVertical size={12} />+ </span>+ )}+ </div>+ )}</div>);}diff --git a/frontend/src/periscope/components/ResizableBox/__tests__/ResizableBox.test.tsx b/frontend/src/periscope/components/ResizableBox/__tests__/ResizableBox.test.tsxnew file mode 100644index 0000000000..a70e3f89f9--- /dev/null+++ b/frontend/src/periscope/components/ResizableBox/__tests__/ResizableBox.test.tsx@@ -0,0 +1,137 @@+import { fireEvent, render, screen } from '@testing-library/react';++import ResizableBox from '../ResizableBox';++const HANDLE_TEST_ID = 'resize-handle';++describe('ResizableBox', () => {+ it('starts at defaultWidth when initialWidth is omitted', () => {+ render(+ <ResizableBox+ handle="right"+ defaultWidth={260}+ handleTestId={HANDLE_TEST_ID}+ >+ <div>content</div>+ </ResizableBox>,+ );++ const box = screen.getByTestId(HANDLE_TEST_ID).parentElement as HTMLElement;+ expect(box.style.width).toBe('260px');+ });++ it('starts at initialWidth when provided', () => {+ render(+ <ResizableBox+ handle="right"+ defaultWidth={260}+ initialWidth={340}+ handleTestId={HANDLE_TEST_ID}+ >+ <div>content</div>+ </ResizableBox>,+ );++ const box = screen.getByTestId(HANDLE_TEST_ID).parentElement as HTMLElement;+ expect(box.style.width).toBe('340px');+ });++ it('resets to defaultWidth and fires onResize on double-click when enabled', () => {+ const onResize = jest.fn();+ render(+ <ResizableBox+ handle="right"+ defaultWidth={260}+ initialWidth={480}+ onResize={onResize}+ resetToDefaultOnDoubleClick+ handleTestId={HANDLE_TEST_ID}+ >+ <div>content</div>+ </ResizableBox>,+ );++ const handle = screen.getByTestId(HANDLE_TEST_ID);+ const box = handle.parentElement as HTMLElement;+ expect(box.style.width).toBe('480px');++ fireEvent.doubleClick(handle);++ expect(box.style.width).toBe('260px');+ expect(onResize).toHaveBeenCalledWith(260);+ });++ it('does nothing on double-click when reset is not enabled', () => {+ const onResize = jest.fn();+ render(+ <ResizableBox+ handle="right"+ defaultWidth={260}+ initialWidth={480}+ onResize={onResize}+ handleTestId={HANDLE_TEST_ID}+ >+ <div>content</div>+ </ResizableBox>,+ );++ const handle = screen.getByTestId(HANDLE_TEST_ID);+ const box = handle.parentElement as HTMLElement;++ fireEvent.doubleClick(handle);++ expect(box.style.width).toBe('480px');+ expect(onResize).not.toHaveBeenCalled();+ });++ it('renders a visible grip only when withHandle is set', () => {+ const { rerender, container } = render(+ <ResizableBox+ handle="right"+ defaultWidth={260}+ handleTestId={HANDLE_TEST_ID}+ >+ <div>content</div>+ </ResizableBox>,+ );+ expect(container.querySelector('.resizable-box__grip')).toBeNull();++ rerender(+ <ResizableBox+ handle="right"+ defaultWidth={260}+ withHandle+ handleTestId={HANDLE_TEST_ID}+ >+ <div>content</div>+ </ResizableBox>,+ );+ expect(container.querySelector('.resizable-box__grip')).not.toBeNull();+ });++ it('clamps drag to maxWidth and reports the clamped size via onResize', () => {+ const onResize = jest.fn();+ render(+ <ResizableBox+ handle="right"+ defaultWidth={260}+ minWidth={240}+ maxWidth={500}+ onResize={onResize}+ handleTestId={HANDLE_TEST_ID}+ >+ <div>content</div>+ </ResizableBox>,+ );++ const handle = screen.getByTestId(HANDLE_TEST_ID);+ const box = handle.parentElement as HTMLElement;++ fireEvent.mouseDown(handle, { clientX: 0 });+ fireEvent.mouseMove(document, { clientX: 1000 });+ fireEvent.mouseUp(document);++ expect(box.style.width).toBe('500px');+ expect(onResize).toHaveBeenLastCalledWith(500);+ });+});diff --git a/frontend/src/periscope/components/ResizableBox/__tests__/usePanelWidth.test.ts b/frontend/src/periscope/components/ResizableBox/__tests__/usePanelWidth.test.tsnew file mode 100644index 0000000000..907a5073f9--- /dev/null+++ b/frontend/src/periscope/components/ResizableBox/__tests__/usePanelWidth.test.ts@@ -0,0 +1,89 @@+import { act, renderHook } from '@testing-library/react';+import getLocalStorageKey from 'api/browser/localstorage/get';+import setLocalStorageKey from 'api/browser/localstorage/set';+import { LOCALSTORAGE } from 'constants/localStorage';++import usePanelWidth from '../usePanelWidth';++jest.mock('api/browser/localstorage/get');+jest.mock('api/browser/localstorage/set');++const mockedGet = getLocalStorageKey as jest.MockedFunction<+ typeof getLocalStorageKey+>;+const mockedSet = setLocalStorageKey as jest.MockedFunction<+ typeof setLocalStorageKey+>;++const ARGS = {+ storageKey: LOCALSTORAGE.QUICK_FILTERS_WIDTH_LOGS,+ defaultWidth: 260,+ minWidth: 240,+ maxWidth: 500,+};++describe('usePanelWidth', () => {+ beforeEach(() => {+ jest.clearAllMocks();+ jest.useFakeTimers();+ });++ afterEach(() => {+ jest.runOnlyPendingTimers();+ jest.useRealTimers();+ });++ it('returns defaultWidth when nothing is persisted', () => {+ mockedGet.mockReturnValue(null);+ const { result } = renderHook(() => usePanelWidth(ARGS));+ expect(result.current.initialWidth).toBe(260);+ });++ it('returns the persisted width when present', () => {+ mockedGet.mockReturnValue('340');+ const { result } = renderHook(() => usePanelWidth(ARGS));+ expect(result.current.initialWidth).toBe(340);+ });++ it('clamps an out-of-bounds persisted width on read', () => {+ mockedGet.mockReturnValue('9999');+ const { result } = renderHook(() => usePanelWidth(ARGS));+ expect(result.current.initialWidth).toBe(500);+ });++ it('falls back to defaultWidth for an invalid persisted value', () => {+ mockedGet.mockReturnValue('not-a-number');+ const { result } = renderHook(() => usePanelWidth(ARGS));+ expect(result.current.initialWidth).toBe(260);+ });++ it('persists a clamped width (debounced)', () => {+ mockedGet.mockReturnValue(null);+ const { result } = renderHook(() => usePanelWidth(ARGS));++ act(() => {+ result.current.persistWidth(320);+ jest.advanceTimersByTime(200);+ });++ expect(mockedSet).toHaveBeenCalledWith(+ LOCALSTORAGE.QUICK_FILTERS_WIDTH_LOGS,+ '320',+ );+ });++ it('clamps below-min widths before persisting', () => {+ mockedGet.mockReturnValue(null);+ const { result } = renderHook(() => usePanelWidth(ARGS));++ act(() => {+ result.current.persistWidth(10);+ jest.advanceTimersByTime(200);+ });++ expect(mockedSet).toHaveBeenCalledWith(+ LOCALSTORAGE.QUICK_FILTERS_WIDTH_LOGS,+ '240',+ );+ });+});diff --git a/frontend/src/periscope/components/ResizableBox/usePanelWidth.ts b/frontend/src/periscope/components/ResizableBox/usePanelWidth.tsnew file mode 100644index 0000000000..035eb005d3--- /dev/null+++ b/frontend/src/periscope/components/ResizableBox/usePanelWidth.ts@@ -0,0 +1,68 @@+import getLocalStorageKey from 'api/browser/localstorage/get';+import setLocalStorageKey from 'api/browser/localstorage/set';+import { LOCALSTORAGE } from 'constants/localStorage';+import debounce from 'lodash-es/debounce';+import { useCallback, useMemo, useRef } from 'react';++const PERSIST_DEBOUNCE_MS = 150;++interface UsePanelWidthArgs {+ /** Per-page localStorage key the width is persisted under. */+ storageKey: LOCALSTORAGE;+ /** Canonical default width, used when nothing is persisted. */+ defaultWidth: number;+ minWidth: number;+ maxWidth: number;+}++interface UsePanelWidthReturn {+ /** Width to start from: the persisted value (clamped) or the default. */+ initialWidth: number;+ /** Clamp and persist a width. Debounced to avoid a write per mousemove. */+ persistWidth: (width: number) => void;+}++const clamp = (value: number, min: number, max: number): number =>+ Math.min(max, Math.max(min, value));++/**+ * Per-page localStorage persistence for a resizable panel width. Mirrors the+ * getLocalStorageKey/setLocalStorageKey idiom used for the trace span-details+ * panel position. Pairs with ResizableBox: feed initialWidth into its+ * initialWidth prop and persistWidth into its onResize.+ */+function usePanelWidth({+ storageKey,+ defaultWidth,+ minWidth,+ maxWidth,+}: UsePanelWidthArgs): UsePanelWidthReturn {+ // Read once on mount. Kept in a ref so a re-render doesn't re-read storage.+ const initialWidthRef = useRef<number | null>(null);+ if (initialWidthRef.current === null) {+ const stored = getLocalStorageKey(storageKey);+ const parsed = stored !== null && stored !== '' ? Number(stored) : NaN;+ initialWidthRef.current = Number.isFinite(parsed)+ ? clamp(parsed, minWidth, maxWidth)+ : defaultWidth;+ }++ const debouncedWrite = useMemo(+ () =>+ debounce((width: number): void => {+ setLocalStorageKey(storageKey, String(width));+ }, PERSIST_DEBOUNCE_MS),+ [storageKey],+ );++ const persistWidth = useCallback(+ (width: number): void => {+ debouncedWrite(clamp(width, minWidth, maxWidth));+ },+ [debouncedWrite, minWidth, maxWidth],+ );++ return { initialWidth: initialWidthRef.current, persistWidth };+}++export default usePanelWidth;