πͺ’ Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix(search-bar): fix caret in safari, move back the time selector (#14339)
Nikita Kabardindee4118e8e9e
diff --git a/web/src/features/events/components/EventsTable.tsx b/web/src/features/events/components/EventsTable.tsxindex 54fd9fc809..ea462cbfab 100644--- a/web/src/features/events/components/EventsTable.tsx+++ b/web/src/features/events/components/EventsTable.tsx@@ -102,10 +102,8 @@ import { AddObservationsToDatasetDialog } from "@/src/features/batch-actions/comimport { useHasEntitlement } from "@/src/features/entitlements/hooks";import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";import { useSearchBarEnabled } from "@/src/features/search-bar/hooks/useSearchBarEnabled";-import { createPortal } from "react-dom";import { useEventsSearchBar } from "@/src/features/search-bar/hooks/useEventsSearchBar";import { EventsSearchBarRow } from "@/src/features/search-bar/components/EventsSearchBarRow";-import { EventsHeaderControls } from "@/src/features/search-bar/components/EventsHeaderControls";import { toObservedOptions } from "@/src/features/search-bar/lib/observed-options";export type EventsTableRow = {@@ -189,9 +187,6 @@ export type EventsTableProps = {externalDateRange?: TableDateRange;limitRows?: number;sessionId?: string;- /** Page-header DOM node to portal the time-range + refresh controls into- * when the search bar is active (keeps the otherwise-full toolbar slim). */- headerActionsContainer?: HTMLElement | null;};export default function ObservationsEventsTable({@@ -203,7 +198,6 @@ export default function ObservationsEventsTable({externalDateRange,limitRows,sessionId,- headerActionsContainer,}: EventsTableProps) {const peekContext = usePeekTableState();const router = useRouter();@@ -1478,42 +1472,19 @@ export default function ObservationsEventsTable({searchBarMode && "bg-background sticky top-0 z-30 pb-1.5",)}>- {/* Search bar row: (near) full-width query composer. In bar mode it- sticks together with the toolbar below, so the toolbar controls- cannot scroll underneath and render half-clipped. The time-range- + refresh controls render into the page header when the host page- provides a slot, and fall back to inline-by-the-bar otherwise. */}- {searchBarMode &&- (() => {- const controls = (- <EventsHeaderControls- timeRange={timeRange}- setTimeRange={setTimeRange}- refreshConfig={{- onRefresh: handleRefresh,- isRefreshing: observations.status === "loading",- interval: refreshInterval,- setInterval: setRefreshInterval,- }}- />- );- const hasHeaderSlot =- headerActionsContainer !== null &&- headerActionsContainer !== undefined;- return (- <>- <EventsSearchBarRow- projectId={projectId}- store={searchBarStore}- commit={searchBarCommit}- observed={observedOptions}- inlineControls={hasHeaderSlot ? undefined : controls}- />- {hasHeaderSlot &&- createPortal(controls, headerActionsContainer)}- </>- );- })()}+ {/* Search bar row: full-width query composer. In bar mode it sticks+ together with the toolbar below, so the toolbar controls cannot+ scroll underneath and render half-clipped. Time-range + refresh+ live in the toolbar row below, next to the filter toggle and+ views β not in the page header. */}+ {searchBarMode && (+ <EventsSearchBarRow+ projectId={projectId}+ store={searchBarStore}+ commit={searchBarCommit}+ observed={observedOptions}+ />+ )}{/* Toolbar spanning full width */}<DataTableToolbarcolumns={columns}@@ -1562,8 +1533,8 @@ export default function ObservationsEventsTable({orderByState={orderByState}rowHeight={rowHeight}setRowHeight={setRowHeight}- timeRange={searchBarMode ? undefined : timeRange}- setTimeRange={searchBarMode ? undefined : setTimeRange}+ timeRange={timeRange}+ setTimeRange={setTimeRange}// Disabled, for now moved to filter sidebar// TODO: remove this toggle once v4 looks good as is// viewModeToggle={@@ -1572,16 +1543,12 @@ export default function ObservationsEventsTable({// onViewModeChange={setViewMode}// />// }- refreshConfig={- searchBarMode- ? undefined- : {- onRefresh: handleRefresh,- isRefreshing: observations.status === "loading",- interval: refreshInterval,- setInterval: setRefreshInterval,- }- }+ refreshConfig={{+ onRefresh: handleRefresh,+ isRefreshing: observations.status === "loading",+ interval: refreshInterval,+ setInterval: setRefreshInterval,+ }}actionButtons={[<BatchExportTableButton{...{diff --git a/web/src/features/search-bar/README.md b/web/src/features/search-bar/README.mdindex 6d8a984666..7e8ee819a1 100644--- a/web/src/features/search-bar/README.md+++ b/web/src/features/search-bar/README.md@@ -177,10 +177,12 @@ committedText ββresetToβββΆ store.draft ββ(type/pick/remove)ββ`CompletionPlan`. Story: `AutocompleteListbox.stories`. `AutocompletePopover`only positions it.- `EventsSearchBarRow.tsx` (full-width composer; `EventsTable` owns the- sticky stack around the composer + toolbar),- `EventsHeaderControls.tsx` (time range + refresh, portaled into the page- header). The enablement toggle lives in the shared Feature Preview modal- (`features/feature-previews/`), not in this feature.+ sticky stack around the composer + toolbar). The time-range + refresh+ controls live in the toolbar row below the composer (next to the filter+ toggle and views), via `DataTableToolbar`'s `timeRange`/`refreshConfig`+ props β same as non-bar mode, not in the page header. The enablement toggle+ lives in the shared Feature Preview modal (`features/feature-previews/`),+ not in this feature.## Integration (EventsTable)@@ -190,11 +192,10 @@ mounted by both `/observations` and `/traces` in v4 mode (and embedded on theuser/session detail pages β page-scoped by `userId`/`sessionId` β and theevaluator form via `hideControls`, where the bar stays off). In bar mode thetoolbar's legacy search field is hidden (full-text search is inline in the-bar); the time-range/refresh controls (`EventsHeaderControls`) render into-the page header when the host page provides a header-actions slot-(`actionButtonsRight` with a callback-ref DOM node), and **fall back to inline-beside the bar** when it does not β so they are never dropped if a page forgets-the slot. The facet sidebar, view drawer, filter toggle, and AI filter all+bar); the time-range + refresh controls stay in the toolbar row (next to the+filter toggle and views), exactly as in non-bar mode β `EventsTable` passes+`timeRange`/`refreshConfig` to `DataTableToolbar` in both modes. The facet+sidebar, view drawer, filter toggle, and AI filter allstay. Because both the bar and the sidebar arecontrolled editors over the same source, they reflect each other with noexplicit sync. Saved views write through `setFilterState`, so they flow intodiff --git a/web/src/features/search-bar/components/ComposerTokens.tsx b/web/src/features/search-bar/components/ComposerTokens.tsxindex 7f0901d1a3..fa681ebd49 100644--- a/web/src/features/search-bar/components/ComposerTokens.tsx+++ b/web/src/features/search-bar/components/ComposerTokens.tsx@@ -26,17 +26,22 @@ export const WORD_JOINER = "β ";// Token spans must stay NON-positioned: `position: relative` would promote the// span's background above the editable root's in-flow paint phase (where// Chromium draws the text caret), hiding the caret inside the token.+//+// Keep the vertical padding small (py-0.5, not py-1): WebKit/Safari sizes the+// text caret to the inline box of the pill it sits in/next to, so taller pills+// produce a caret that towers over the text. py-0.5 keeps the chip readable+// while holding the Safari caret close to the text height.export const composerTokenVariants = cva("max-w-full", {variants: {kind: {filter:- "mr-1 inline rounded border px-1.5 py-1 border-border bg-secondary text-secondary-foreground shadow-sm transition-colors hover:border-ring hover:bg-accent",+ "mr-1 inline rounded border px-1.5 py-0.5 border-border bg-secondary text-secondary-foreground shadow-sm transition-colors hover:border-ring hover:bg-accent",freeText:- "mr-1 inline rounded border px-1.5 py-1 border-transparent bg-muted/70 text-foreground/90 transition-colors hover:border-border hover:bg-accent",+ "mr-1 inline rounded border px-1.5 py-0.5 border-transparent bg-muted/70 text-foreground/90 transition-colors hover:border-border hover:bg-accent",operator: "font-semibold uppercase text-qlang-keyword",paren: "text-muted-foreground",invalid:- "mr-1 inline rounded border border-dashed px-1.5 py-1 border-destructive/70 bg-destructive/10 text-destructive transition-colors hover:border-destructive",+ "mr-1 inline rounded border border-dashed px-1.5 py-0.5 border-destructive/70 bg-destructive/10 text-destructive transition-colors hover:border-destructive",},},defaultVariants: { kind: "freeText" },@@ -139,11 +144,15 @@ export function ComposerTokens({) : (segment.raw)}+ {/* Word-joiner INSIDE the pill. The caret at the token's trailing edge+ lands on this joiner, which sits BEFORE the pill's right padding β so+ WebKit/Safari paints the caret inside the pill at the glyph instead+ of past the chrome. A sibling joiner (outside the span) made Safari+ paint the caret past the padding + margin (the "caret renders outside+ the block" bug). */}+ {WORD_JOINER}</span>,);- out.push(- <React.Fragment key={`wj:${segment.id}`}>{WORD_JOINER}</React.Fragment>,- );cursor = segment.to;}if (cursor < draft.length) {diff --git a/web/src/features/search-bar/components/EventsHeaderControls.tsx b/web/src/features/search-bar/components/EventsHeaderControls.tsxdeleted file mode 100644index cf1b3c2934..0000000000--- a/web/src/features/search-bar/components/EventsHeaderControls.tsx+++ /dev/null@@ -1,47 +0,0 @@-// Time-range picker + refresh control, rendered into the page header (next to-// the "Tracing" title) when the search bar is active β the search bar itself-// takes the full width of its own row below.--import { TimeRangePicker } from "@/src/components/date-picker";-import {- DataTableRefreshButton,- type RefreshInterval,-} from "@/src/components/table/data-table-refresh-button";-import {- TABLE_AGGREGATION_OPTIONS,- type TimeRange,-} from "@/src/utils/date-range-utils";--export function EventsHeaderControls({- timeRange,- setTimeRange,- refreshConfig,-}: {- timeRange: TimeRange;- setTimeRange: (timeRange: TimeRange) => void;- refreshConfig?: {- onRefresh: () => void;- isRefreshing: boolean;- interval: RefreshInterval;- setInterval: (interval: RefreshInterval) => void;- };-}) {- return (- <>- <TimeRangePicker- timeRange={timeRange}- onTimeRangeChange={setTimeRange}- timeRangePresets={TABLE_AGGREGATION_OPTIONS}- className="my-0 max-w-full overflow-x-auto"- />- {refreshConfig && (- <DataTableRefreshButton- onRefresh={refreshConfig.onRefresh}- isRefreshing={refreshConfig.isRefreshing}- interval={refreshConfig.interval}- setInterval={refreshConfig.setInterval}- />- )}- </>- );-}diff --git a/web/src/features/search-bar/components/EventsSearchBarRow.tsx b/web/src/features/search-bar/components/EventsSearchBarRow.tsxindex 25866de899..d11fb3d368 100644--- a/web/src/features/search-bar/components/EventsSearchBarRow.tsx+++ b/web/src/features/search-bar/components/EventsSearchBarRow.tsx@@ -1,12 +1,8 @@-// Search-bar row: the query composer at (near) full width. EventsTable owns the+// Search-bar row: the query composer at full width. EventsTable owns the// sticky stack around this row + the toolbar so the toolbar cannot scroll under-// the composer. Time-range + refresh controls normally live in the page header-// (portaled by EventsTable). When the host page provides no header slot,-// EventsTable passes them here as `inlineControls` so they always render-// somewhere. Left padding matches the toolbar row below so the bar's left edge-// aligns with it.--import type { ReactNode } from "react";+// the composer. Time-range + refresh controls live in the toolbar row below+// (next to the filter toggle and views), not here. Left padding matches the+// toolbar row below so the bar's left edge aligns with it.import type { ObservedOptions } from "@/src/features/search-bar/lib/observed-options";import { SearchComposer } from "@/src/features/search-bar/components/SearchComposer";@@ -18,24 +14,17 @@ export function EventsSearchBarRow({store,commit,observed,- inlineControls,}: {projectId: string;store: SearchBarStore;commit: () => boolean;observed: ObservedOptions | undefined;- /** Time-range + refresh, rendered inline when the page provides no header- * slot. Undefined when those controls are portaled into the page header. */- inlineControls?: ReactNode;}) {return (- <div className="flex items-start gap-2 px-2 pt-2 pb-1">- <div className="min-w-0 flex-1">- <SearchBarStoreProvider store={store} commit={commit}>- <SearchComposer projectId={projectId} observed={observed} />- </SearchBarStoreProvider>- </div>- {inlineControls}+ <div className="min-w-0 px-2 pt-2 pb-1">+ <SearchBarStoreProvider store={store} commit={commit}>+ <SearchComposer projectId={projectId} observed={observed} />+ </SearchBarStoreProvider></div>);}diff --git a/web/src/features/search-bar/components/SearchComposer.tsx b/web/src/features/search-bar/components/SearchComposer.tsxindex 400e665ac7..9feec81e3d 100644--- a/web/src/features/search-bar/components/SearchComposer.tsx+++ b/web/src/features/search-bar/components/SearchComposer.tsx@@ -934,15 +934,12 @@ export function SearchComposer({return;}- // ArrowRight at the very end of the query "exits" the last token, like- // Space β minus the inserted space. Enter append mode (the next keystroke- // space-prefixes into a NEW token via applyTextInsert), open the field- // suggestions, AND move the caret PAST the pill's trailing zero-width- // WORD_JOINER so it visibly leaves the pill: the joiner is a root-level node- // after the pill span, so the after-joiner spot renders outside it. (The- // old behavior pinned the caret at the logical end β inside the pill β so- // the exit was invisible and felt like a dead keypress.) Backspace from the- // after-joiner spot is handled by the trailing-joiner fall-through below.+ // ArrowRight at the very end of the query inserts a trailing space to start+ // a NEW token β matching the muscle-memory of typing a space at the end.+ // (The old behavior set appendIntent and nudged the caret past the trailing+ // joiner, which read as a dead keypress.) Skip when+ // the draft already ends in whitespace so a repeat press doesn't pile up+ // spaces. The trailing space is trimmed on commit.if (event.key === "ArrowRight" &&!event.shiftKey &&@@ -951,19 +948,13 @@ export function SearchComposer({!event.metaKey &&selectionCollapsed &&caret === draft.length &&- draft.length > 0+ draft.length > 0 &&+ !/\s$/.test(draft)) {event.preventDefault();- const root = rootRef.current;- const selection = window.getSelection();- if (root !== null && selection !== null) {- const range = document.createRange();- range.selectNodeContents(root);- range.collapse(false); // to the very end, after the trailing joiner- selection.removeAllRanges();- selection.addRange(range);- }- setAppendIntent(true);+ const next = `${draft} `;+ setDraftWithSelection(next, next.length);+ setAppendIntent(false);setAutocompleteOpen(true);setHighlightedOptionId(null);return;@@ -1339,7 +1330,12 @@ export function SearchComposer({autoCapitalize="none"inputMode="text"data-testid="search-bar-input"- className="min-h-6 font-mono text-xs leading-7 break-words whitespace-pre-wrap caret-[hsl(var(--foreground))] outline-none"+ // leading-6 (not 7): WebKit/Safari sizes the text caret to the line+ // box, so a 28px (leading-7) line made the caret tower ~4px above/+ // below the ~24px pills ("too big"). 24px matches the pill height so+ // the caret aligns with the pills. Trade-off: tighter gap between+ // wrapped lines of pills (single-line is unaffected).+ className="min-h-6 font-mono text-xs leading-6 break-words whitespace-pre-wrap caret-[hsl(var(--foreground))] outline-none"onInput={(event) => {if (!(event.nativeEvent as InputEvent).isComposing) syncFromDom();}}diff --git a/web/src/pages/project/[projectId]/observations/index.tsx b/web/src/pages/project/[projectId]/observations/index.tsxindex 310f334dd2..e2b85ecc02 100644--- a/web/src/pages/project/[projectId]/observations/index.tsx+++ b/web/src/pages/project/[projectId]/observations/index.tsx@@ -1,4 +1,3 @@-import React, { useState } from "react";import { useRouter } from "next/router";import ObservationsTable from "@/src/components/table/use-cases/observations";import Page from "@/src/components/layouts/page";@@ -11,23 +10,12 @@ import {import { useV4Beta } from "@/src/features/events/hooks/useV4Beta";import ObservationsEventsTable from "@/src/features/events/components/EventsTable";import { useQueryProject } from "@/src/features/projects/hooks";-import { useSearchBarEnabled } from "@/src/features/search-bar/hooks/useSearchBarEnabled";export default function Generations() {const router = useRouter();const projectId = router.query.projectId as string;const { isBetaEnabled, isInitializing } = useV4Beta();const { project } = useQueryProject();- // The header-actions slot only has a consumer when the bar is actually- // active, so gate it the same way the table gates searchBarMode β otherwise- // it's a dead empty node in the header. The bar is a per-user Feature Preview- // opt-in and only renders on the v4 table, so it needs the v4 beta too.- const searchBarEnabled = useSearchBarEnabled();- const searchBarActive = isBetaEnabled && searchBarEnabled;- // Host for the events table's time-range + refresh controls, rendered into- // the page header (which is otherwise under-utilized). The events table- // portals into this node when the search bar is active.- const [headerActions, setHeaderActions] = useState<HTMLElement | null>(null);// Check if the user has tracing configured// Skip polling entirely if the project flag is already set in the session@@ -58,14 +46,6 @@ export default function Generations() {"An observation captures a single function call in an application. See docs to learn more.",href: "https://langfuse.com/docs/observability/data-model",},- // Only render the portal target when its sole consumer- // (ObservationsEventsTable) actually mounts β i.e. not during onboarding- // or the pre-beta-flag init window, where the slot would otherwise be a- // dead, empty <div> with a callback ref that never receives a portal.- actionButtonsRight:- searchBarActive && !showOnboarding && !isInitializing ? (- <div ref={setHeaderActions} className="flex items-center gap-2" />- ) : undefined,tabsProps:isBetaEnabled || isInitializing? undefined@@ -87,10 +67,7 @@ export default function Generations() {resolves. */}</>) : isBetaEnabled ? (- <ObservationsEventsTable- projectId={projectId}- headerActionsContainer={headerActions}- />+ <ObservationsEventsTable projectId={projectId} />) : (<ObservationsTable projectId={projectId} />)}diff --git a/web/src/pages/project/[projectId]/traces/index.tsx b/web/src/pages/project/[projectId]/traces/index.tsxindex fd735217a9..feee969b24 100644--- a/web/src/pages/project/[projectId]/traces/index.tsx+++ b/web/src/pages/project/[projectId]/traces/index.tsx@@ -1,4 +1,3 @@-import React, { useState } from "react";import { useRouter } from "next/router";import TracesTable from "@/src/components/table/use-cases/traces";import Page from "@/src/components/layouts/page";@@ -11,22 +10,12 @@ import {import { useV4Beta } from "@/src/features/events/hooks/useV4Beta";import ObservationsEventsTable from "@/src/features/events/components/EventsTable";import { useQueryProject } from "@/src/features/projects/hooks";-import { useSearchBarEnabled } from "@/src/features/search-bar/hooks/useSearchBarEnabled";export default function Traces() {const router = useRouter();const projectId = router.query.projectId as string;const { isBetaEnabled, isInitializing } = useV4Beta();const { project } = useQueryProject();- // The header-actions slot only has a consumer when the bar is actually- // active, so gate it the same way the table gates searchBarMode β otherwise- // it's a dead empty node in the header. The bar is a per-user Feature Preview- // opt-in and only renders on the v4 table, so it needs the v4 beta too.- const searchBarEnabled = useSearchBarEnabled();- const searchBarActive = isBetaEnabled && searchBarEnabled;- // Host for the events table's time-range + refresh controls in the page- // header (the events table is shown here in v4 mode and portals into it).- const [headerActions, setHeaderActions] = useState<HTMLElement | null>(null);// Check if the user has tracing configured// Skip polling entirely if the project flag is already set in the session@@ -89,14 +78,6 @@ export default function Traces() {),href: "https://langfuse.com/docs/observability/data-model",},- // Mirror observations/index.tsx: only mount the portal target when its- // consumer (the events table) does. Onboarding is handled by the early-- // return Page above; the remaining window to guard is the pre-beta-flag- // init transient.- actionButtonsRight:- searchBarActive && !isInitializing ? (- <div ref={setHeaderActions} className="flex items-center gap-2" />- ) : undefined,tabsProps:isBetaEnabled || isInitializing? undefined@@ -114,10 +95,7 @@ export default function Traces() {resolves. */}</>) : isBetaEnabled ? (- <ObservationsEventsTable- projectId={projectId}- headerActionsContainer={headerActions}- />+ <ObservationsEventsTable projectId={projectId} />) : (<TracesTable projectId={projectId} />)}