A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
refactor: replace lodash imports with built-in or custom (#8878)
Myles Scolnicke3a5c03222f2
diff --git a/frontend/src/components/ai/ai-model-dropdown.tsx b/frontend/src/components/ai/ai-model-dropdown.tsxindex e2518889c3..8b639a7e75 100644--- a/frontend/src/components/ai/ai-model-dropdown.tsx+++ b/frontend/src/components/ai/ai-model-dropdown.tsx@@ -2,7 +2,6 @@import type { Role } from "@marimo-team/llm-info";import { useAtomValue } from "jotai";-import { capitalize } from "lodash-es";import {BotIcon,BrainIcon,@@ -19,6 +18,7 @@ import {} from "@/core/ai/ids/ids";import { type AiModel, AiModelRegistry } from "@/core/ai/model-registry";import { aiAtom, completionAtom } from "@/core/config/config";+import { capitalize } from "@/utils/strings";import { useOpenSettingsToTab } from "../app-config/state";import {DropdownMenu,diff --git a/frontend/src/components/chat/acp/agent-panel.tsx b/frontend/src/components/chat/acp/agent-panel.tsxindex 3d7783e9dc..d19ac18005 100644--- a/frontend/src/components/chat/acp/agent-panel.tsx+++ b/frontend/src/components/chat/acp/agent-panel.tsx@@ -1,7 +1,6 @@/* Copyright 2026 Marimo. All rights reserved. */import { useAtom, useAtomValue } from "jotai";-import { capitalize } from "lodash-es";import {BotMessageSquareIcon,RefreshCwIcon,@@ -24,6 +23,7 @@ import { Button } from "@/components/ui/button";import { TooltipProvider } from "@/components/ui/tooltip";import { cn } from "@/utils/cn";import { Logger } from "@/utils/Logger";+import { capitalize } from "@/utils/strings";import { AgentDocs } from "./agent-docs";import { AgentSelector } from "./agent-selector";import { ModelSelector } from "./model-selector";@@ -95,7 +95,9 @@ interface AgentTitleProps {}const AgentTitle = memo<AgentTitleProps>(({ currentAgentId }) => (- <span className="text-sm font-medium">{capitalize(currentAgentId)}</span>+ <span className="text-sm font-medium">+ {capitalize(currentAgentId ?? "")}+ </span>));AgentTitle.displayName = "AgentTitle";diff --git a/frontend/src/components/chat/acp/blocks.tsx b/frontend/src/components/chat/acp/blocks.tsxindex 7990f6a3dc..6fe2456bbc 100644--- a/frontend/src/components/chat/acp/blocks.tsx+++ b/frontend/src/components/chat/acp/blocks.tsx@@ -5,7 +5,6 @@ import type {ToolCallContent,ToolCallLocation,} from "@zed-industries/agent-client-protocol";-import { capitalize } from "lodash-es";import {BotMessageSquareIcon,FileAudio2Icon,@@ -36,7 +35,7 @@ import {import { uniqueByTakeLast } from "@/utils/arrays";import { logNever } from "@/utils/assertNever";import { cn } from "@/utils/cn";-import { Strings } from "@/utils/strings";+import { capitalize, Strings } from "@/utils/strings";import { SimpleAccordion } from "./common";import type {AgentNotificationEvent,diff --git a/frontend/src/components/chat/acp/state.ts b/frontend/src/components/chat/acp/state.tsindex 6afe86ff52..3199636127 100644--- a/frontend/src/components/chat/acp/state.ts+++ b/frontend/src/components/chat/acp/state.ts@@ -2,9 +2,9 @@import { atom } from "jotai";import { atomWithStorage } from "jotai/utils";-import { capitalize } from "lodash-es";import { isPlatformWindows } from "@/core/hotkeys/shortcuts";import { jotaiJsonStorage } from "@/utils/storage/jotai";+import { capitalize } from "@/utils/strings";import type { TypedString } from "@/utils/typed";import { generateUUID } from "@/utils/uuid";import type { ExternalAgentSessionId, SessionSupportType } from "./types";diff --git a/frontend/src/components/chat/tool-call-accordion.tsx b/frontend/src/components/chat/tool-call-accordion.tsxindex 59172ff59f..47ef7b3380 100644--- a/frontend/src/components/chat/tool-call-accordion.tsx+++ b/frontend/src/components/chat/tool-call-accordion.tsx@@ -123,6 +123,7 @@ const ToolArgsRenderer: React.FC<{ input: unknown }> = ({ input }) => {const isObject =typeof input === "object" &&+ !Array.isArray(input) &&Object.keys(input as Record<string, unknown>).length > 0;return (diff --git a/frontend/src/components/data-table/charts/components/chart-items.tsx b/frontend/src/components/data-table/charts/components/chart-items.tsxindex a135fe663e..0efef68867 100644--- a/frontend/src/components/data-table/charts/components/chart-items.tsx+++ b/frontend/src/components/data-table/charts/components/chart-items.tsx@@ -1,7 +1,6 @@/* Copyright 2026 Marimo. All rights reserved. */import * as SelectPrimitive from "@radix-ui/react-select";-import { capitalize } from "lodash-es";import { ChevronDown } from "lucide-react";import React from "react";import { useFormContext, useWatch } from "react-hook-form";@@ -14,6 +13,7 @@ import {SelectValue,} from "@/components/ui/select";import type { DataType } from "@/core/kernel/messages";+import { capitalize } from "@/utils/strings";import { isFieldSet } from "../chart-spec/spec";import { convertDataTypeToSelectable } from "../chart-spec/types";import {diff --git a/frontend/src/components/data-table/charts/components/form-fields.tsx b/frontend/src/components/data-table/charts/components/form-fields.tsxindex 297d0f7fc5..065f686371 100644--- a/frontend/src/components/data-table/charts/components/form-fields.tsx+++ b/frontend/src/components/data-table/charts/components/form-fields.tsx@@ -1,6 +1,5 @@/* Copyright 2026 Marimo. All rights reserved. */-import { capitalize } from "lodash-es";import {ArrowDownWideNarrowIcon,ArrowUpWideNarrowIcon,@@ -36,6 +35,7 @@ import { Slider } from "@/components/ui/slider";import type { DataType } from "@/core/kernel/messages";import { Multiselect } from "@/plugins/impl/MultiselectPlugin";import { cn } from "@/utils/cn";+import { capitalize } from "@/utils/strings";import { convertDataTypeToSelectable } from "../chart-spec/types";import {AGGREGATION_TYPE_DESCRIPTIONS,diff --git a/frontend/src/components/data-table/charts/forms/common-chart.tsx b/frontend/src/components/data-table/charts/forms/common-chart.tsxindex 3fa8313d3c..288679032c 100644--- a/frontend/src/components/data-table/charts/forms/common-chart.tsx+++ b/frontend/src/components/data-table/charts/forms/common-chart.tsx@@ -1,10 +1,10 @@/* Copyright 2026 Marimo. All rights reserved. */-import { capitalize } from "lodash-es";import { InfoIcon, TriangleAlert } from "lucide-react";import { useFormContext, useWatch } from "react-hook-form";import { Accordion } from "@/components/ui/accordion";import { Tooltip } from "@/components/ui/tooltip";+import { capitalize } from "@/utils/strings";import { isFieldSet } from "../chart-spec/spec";import { ColorByAxis, Facet, XAxis, YAxis } from "../components/chart-items";import {diff --git a/frontend/src/components/data-table/charts/storage.ts b/frontend/src/components/data-table/charts/storage.tsindex ec0c85041e..1fe3e5336b 100644--- a/frontend/src/components/data-table/charts/storage.ts+++ b/frontend/src/components/data-table/charts/storage.ts@@ -1,11 +1,11 @@/* Copyright 2026 Marimo. All rights reserved. */import { atomWithStorage } from "jotai/utils";-import { capitalize } from "lodash-es";import { z } from "zod";import type { CellId } from "@/core/cells/ids";import { Logger } from "@/utils/Logger";import { NotebookScopedLocalStorage } from "@/utils/storage/typed";+import { capitalize } from "@/utils/strings";import type { TypedString } from "@/utils/typed";import { ChartSchema, type ChartSchemaType } from "./schemas";import type { ChartType } from "./types";diff --git a/frontend/src/components/data-table/column-header.tsx b/frontend/src/components/data-table/column-header.tsxindex 044c0f2238..08f51a059b 100644--- a/frontend/src/components/data-table/column-header.tsx+++ b/frontend/src/components/data-table/column-header.tsx@@ -2,7 +2,6 @@"use no memo";import type { Column, Table } from "@tanstack/react-table";-import { capitalize } from "lodash-es";import { FilterIcon, MinusIcon, TextIcon, XIcon } from "lucide-react";import { useMemo, useRef, useState } from "react";import { useLocale } from "react-aria";@@ -24,6 +23,7 @@ import type { OperatorType } from "@/plugins/impl/data-frames/utils/operators";import { logNever } from "@/utils/assertNever";import { cn } from "@/utils/cn";import { Logger } from "@/utils/Logger";+import { capitalize } from "@/utils/strings";import { Spinner } from "../icons/spinner";import { Button } from "../ui/button";import { Checkbox } from "../ui/checkbox";diff --git a/frontend/src/components/data-table/hooks/use-column-pinning.ts b/frontend/src/components/data-table/hooks/use-column-pinning.tsindex c8832deadc..e621792657 100644--- a/frontend/src/components/data-table/hooks/use-column-pinning.ts+++ b/frontend/src/components/data-table/hooks/use-column-pinning.ts@@ -2,7 +2,7 @@"use no memo";import type { ColumnPinningState } from "@tanstack/react-table";-import { isEqual } from "lodash-es";+import { dequal as isEqual } from "dequal";import React from "react";import { useInternalStateWithSync } from "@/hooks/useInternalStateWithSync";import { SELECT_COLUMN_ID } from "../types";diff --git a/frontend/src/components/data-table/pagination.tsx b/frontend/src/components/data-table/pagination.tsxindex 4286868406..dfc587e51c 100644--- a/frontend/src/components/data-table/pagination.tsx+++ b/frontend/src/components/data-table/pagination.tsx@@ -2,7 +2,6 @@"use no memo";import type { Table } from "@tanstack/react-table";-import { range } from "lodash-es";import {ChevronDown,ChevronLeft,@@ -22,6 +21,7 @@ import {DropdownMenuTrigger,} from "@/components/ui/dropdown-menu";import { Input } from "@/components/ui/input";+import { range } from "@/utils/arrays";import { cn } from "@/utils/cn";import { Events } from "@/utils/events";import { prettyNumber } from "@/utils/numbers";diff --git a/frontend/src/components/datasources/datasources.tsx b/frontend/src/components/datasources/datasources.tsxindex 32a3287b5c..8b7ef3029a 100644--- a/frontend/src/components/datasources/datasources.tsx+++ b/frontend/src/components/datasources/datasources.tsx@@ -2,7 +2,6 @@import { CommandList } from "cmdk";import { atom, useAtomValue, useSetAtom } from "jotai";-import { sortBy } from "lodash-es";import { PlusIcon, PlusSquareIcon, XIcon } from "lucide-react";import React from "react";import { dbDisplayName } from "@/components/databases/display";@@ -49,6 +48,7 @@ import { useRequestClient } from "@/core/network/requests";import { variablesAtom } from "@/core/variables/state";import type { VariableName } from "@/core/variables/types";import { useAsyncData } from "@/hooks/useAsyncData";+import { sortBy } from "@/utils/arrays";import { logNever } from "@/utils/assertNever";import { cn } from "@/utils/cn";import { Events } from "@/utils/events";diff --git a/frontend/src/components/editor/actions/useNotebookActions.tsx b/frontend/src/components/editor/actions/useNotebookActions.tsxindex 26c3f245eb..90304a1650 100644--- a/frontend/src/components/editor/actions/useNotebookActions.tsx+++ b/frontend/src/components/editor/actions/useNotebookActions.tsx@@ -1,7 +1,6 @@/* Copyright 2026 Marimo. All rights reserved. */import { useAtom, useAtomValue, useSetAtom } from "jotai";-import { startCase } from "lodash-es";import {BookMarkedIcon,CheckIcon,@@ -80,6 +79,7 @@ import {import { Filenames } from "@/utils/filenames";import { Objects } from "@/utils/objects";import type { ProgressState } from "@/utils/progress";+import { Strings } from "@/utils/strings";import { newNotebookURL } from "@/utils/urls";import { useRunAllCells } from "../cell/useRunCells";import { useChromeActions, useChromeState } from "../chrome/state";@@ -385,7 +385,7 @@ export function useNotebookActions() {return [];}return {- label: startCase(id),+ label: Strings.startCase(id),rightElement: renderCheckboxElement(selectedPanel === id),icon: <Icon size={14} strokeWidth={1.5} />,handle: () => toggleApplication(id),diff --git a/frontend/src/components/editor/chrome/wrapper/footer-items/backend-status.tsx b/frontend/src/components/editor/chrome/wrapper/footer-items/backend-status.tsxindex 4d349910b7..5a5694091d 100644--- a/frontend/src/components/editor/chrome/wrapper/footer-items/backend-status.tsx+++ b/frontend/src/components/editor/chrome/wrapper/footer-items/backend-status.tsx@@ -1,7 +1,6 @@/* Copyright 2026 Marimo. All rights reserved. */import { atom, useAtomValue, useSetAtom } from "jotai";-import { startCase } from "lodash-es";import { AlertCircleIcon, CheckCircle2Icon, PowerOffIcon } from "lucide-react";import type React from "react";import { Spinner } from "@/components/icons/spinner";@@ -18,6 +17,7 @@ import {} from "@/core/websocket/connection-utils";import { useAsyncData } from "@/hooks/useAsyncData";import { useInterval } from "@/hooks/useInterval";+import { Strings } from "@/utils/strings";const CHECK_HEALTH_INTERVAL_MS = 30_000;@@ -84,7 +84,7 @@ export const BackendConnectionStatus: React.FC = () => {return "Not connected to a runtime";}- const baseStatus = startCase(connection.toLowerCase());+ const baseStatus = Strings.startCase(connection.toLowerCase());const healthInfo = data?.lastChecked? data.isHealthy? "✓ Healthy"diff --git a/frontend/src/components/editor/connections/form-renderers.tsx b/frontend/src/components/editor/connections/form-renderers.tsxindex c1fb06839e..a624ba61ba 100644--- a/frontend/src/components/editor/connections/form-renderers.tsx+++ b/frontend/src/components/editor/connections/form-renderers.tsx@@ -1,6 +1,5 @@/* Copyright 2026 Marimo. All rights reserved. */-import { partition } from "lodash-es";import { KeyIcon, PlusCircleIcon } from "lucide-react";import { createContext, type ReactNode, use } from "react";import { z } from "zod";@@ -28,6 +27,7 @@ import { Input } from "@/components/ui/input";import { NumberField } from "@/components/ui/number-field";import { SECRETS_REGISTRY } from "@/core/secrets/request-registry";import { useAsyncData } from "@/hooks/useAsyncData";+import { partition } from "@/utils/arrays";import { cn } from "@/utils/cn";import { Functions } from "@/utils/functions";import {diff --git a/frontend/src/components/editor/renderers/grid-layout/grid-layout.tsx b/frontend/src/components/editor/renderers/grid-layout/grid-layout.tsxindex 8c52783dee..5bb156103e 100644--- a/frontend/src/components/editor/renderers/grid-layout/grid-layout.tsx+++ b/frontend/src/components/editor/renderers/grid-layout/grid-layout.tsx@@ -15,7 +15,6 @@ import type { GridLayout, GridLayoutCellSide } from "./types";import "react-grid-layout/css/styles.css";import "./styles.css";import { BorderAllIcon } from "@radix-ui/react-icons";-import { startCase } from "lodash-es";import {AlignEndVerticalIcon,AlignHorizontalSpaceAroundIcon,@@ -43,6 +42,7 @@ import { useIsDragging } from "@/hooks/useIsDragging";import { cn } from "@/utils/cn";import { Maps } from "@/utils/maps";import { Objects } from "@/utils/objects";+import { Strings } from "@/utils/strings";type Props = ICellRendererProps<GridLayout>;@@ -637,7 +637,7 @@ const GridHoverActions: React.FC<GridHoverActionsProps> = ({{Objects.entries(SIDE_TO_ICON).map(([option, Icon]) => (<DropdownMenuItem key={option} onSelect={() => setSide(option)}><Icon className={"h-4 w-3 mr-2"} />- <span className="flex-1">{startCase(option)}</span>+ <span className="flex-1">{Strings.startCase(option)}</span>{option === side && <CheckIcon className="h-4 w-4" />}</DropdownMenuItem>))}diff --git a/frontend/src/components/editor/renderers/layout-select.tsx b/frontend/src/components/editor/renderers/layout-select.tsxindex 2c77547f40..064a37f9b2 100644--- a/frontend/src/components/editor/renderers/layout-select.tsx+++ b/frontend/src/components/editor/renderers/layout-select.tsx@@ -1,6 +1,5 @@/* Copyright 2026 Marimo. All rights reserved. */-import { startCase } from "lodash-es";import {Grid3x3Icon,ListIcon,@@ -21,6 +20,7 @@ import { getFeatureFlag } from "@/core/config/feature-flag";import { useLayoutActions, useLayoutState } from "@/core/layout/layout";import { isWasm } from "@/core/wasm/utils";import { logNever } from "@/utils/assertNever";+import { Strings } from "@/utils/strings";import { LAYOUT_TYPES, type LayoutType } from "./types";export const LayoutSelect: React.FC = () => {@@ -82,5 +82,5 @@ export function getLayoutIcon(layoutType: LayoutType) {}export function displayLayoutName(layoutType: LayoutType) {- return startCase(layoutType);+ return Strings.startCase(layoutType);}diff --git a/frontend/src/components/variables/variables-table.tsx b/frontend/src/components/variables/variables-table.tsxindex 1dc839e3e9..199df9e1f0 100644--- a/frontend/src/components/variables/variables-table.tsx+++ b/frontend/src/components/variables/variables-table.tsx@@ -11,7 +11,6 @@ import {type SortingState,useReactTable,} from "@tanstack/react-table";-import { sortBy } from "lodash-es";import { SquareEqualIcon, WorkflowIcon } from "lucide-react";import React, { memo, useMemo } from "react";import { useLocale } from "react-aria";@@ -21,6 +20,7 @@ import type { CellId } from "@/core/cells/ids";import { isInternalCellName } from "@/core/cells/names";import { goToVariableDefinition } from "@/core/codemirror/go-to-definition/commands";import type { Variable, Variables } from "@/core/variables/types";+import { sortBy } from "@/utils/arrays";import { cn } from "@/utils/cn";import { DataTableColumnHeader } from "../data-table/column-header";import { CellLinkList } from "../editor/links/cell-link-list";diff --git a/frontend/src/core/cells/cells.ts b/frontend/src/core/cells/cells.tsindex 1e1b665b13..d725fc38a3 100644--- a/frontend/src/core/cells/cells.ts+++ b/frontend/src/core/cells/cells.ts@@ -1,9 +1,9 @@/* Copyright 2026 Marimo. All rights reserved. */import { historyField } from "@codemirror/commands";+import { dequal as isEqual } from "dequal";import { type Atom, atom, useAtom, useAtomValue } from "jotai";import { atomFamily, selectAtom, splitAtom } from "jotai/utils";-import { isEqual } from "lodash-es";import { createRef, type ReducerWithoutAction } from "react";import type { CellHandle } from "@/components/editor/notebook-cell";import {diff --git a/frontend/src/core/codemirror/rtc/extension.ts b/frontend/src/core/codemirror/rtc/extension.tsindex 310a38614b..a2c093ea67 100644--- a/frontend/src/core/codemirror/rtc/extension.ts+++ b/frontend/src/core/codemirror/rtc/extension.ts@@ -2,8 +2,8 @@import type { Extension } from "@codemirror/state";import { EditorView, ViewPlugin } from "@codemirror/view";+import { dequal as isEqual } from "dequal";import { atom } from "jotai";-import { isEqual } from "lodash-es";import { Awareness, LoroDoc, LoroMap, LoroText } from "loro-crdt";import ReconnectingWebSocket from "partysocket/ws";import type { CellId } from "@/core/cells/ids";diff --git a/frontend/src/core/network/requests-network.ts b/frontend/src/core/network/requests-network.tsindex ab85081999..c23e5f237e 100644--- a/frontend/src/core/network/requests-network.ts+++ b/frontend/src/core/network/requests-network.ts@@ -1,6 +1,6 @@/* Copyright 2026 Marimo. All rights reserved. */-import { once } from "lodash-es";+import { once } from "@/utils/once";import { getRuntimeManager } from "../runtime/config";import { API, createClientWithRuntimeManager } from "./api";import { waitForConnectionOpen } from "./connection";diff --git a/frontend/src/core/rtc/state.ts b/frontend/src/core/rtc/state.tsindex 451ef76679..ad3a124be0 100644--- a/frontend/src/core/rtc/state.ts+++ b/frontend/src/core/rtc/state.ts@@ -1,6 +1,6 @@/* Copyright 2026 Marimo. All rights reserved. */import { atomWithStorage } from "jotai/utils";-import { once } from "lodash-es";+import { once } from "@/utils/once";import { jotaiJsonStorage } from "@/utils/storage/jotai";import { getFeatureFlag } from "../config/feature-flag";diff --git a/frontend/src/core/saving/state.ts b/frontend/src/core/saving/state.tsindex c8dcf723d0..05ada2a550 100644--- a/frontend/src/core/saving/state.ts+++ b/frontend/src/core/saving/state.ts@@ -1,6 +1,7 @@/* Copyright 2026 Marimo. All rights reserved. */++import { dequal as isEqual } from "dequal";import { atom } from "jotai";-import { isEqual } from "lodash-es";import { arrayShallowEquals } from "@/utils/arrays";import { type NotebookState, notebookAtom } from "../cells/cells";import { type LayoutState, layoutStateAtom } from "../layout/layout";diff --git a/frontend/src/core/state/jotai.ts b/frontend/src/core/state/jotai.tsindex 1c96ee45c1..0eae3a1166 100644--- a/frontend/src/core/state/jotai.ts+++ b/frontend/src/core/state/jotai.ts@@ -1,6 +1,7 @@/* Copyright 2026 Marimo. All rights reserved. */++import { dequal as isEqual } from "dequal";import { type Atom, atom, createStore, useStore } from "jotai";-import { isEqual } from "lodash-es";import { useEffect } from "react";/**diff --git a/frontend/src/plugins/impl/RangeSliderPlugin.tsx b/frontend/src/plugins/impl/RangeSliderPlugin.tsxindex 5e70389669..0509a7db3f 100644--- a/frontend/src/plugins/impl/RangeSliderPlugin.tsx+++ b/frontend/src/plugins/impl/RangeSliderPlugin.tsx@@ -1,6 +1,6 @@/* Copyright 2026 Marimo. All rights reserved. */-import { isEqual } from "lodash-es";+import { dequal as isEqual } from "dequal";import { type JSX, useEffect, useId, useState } from "react";import { useLocale } from "react-aria";import { z } from "zod";diff --git a/frontend/src/plugins/impl/chat/chat-ui.tsx b/frontend/src/plugins/impl/chat/chat-ui.tsxindex ddc0414a56..90d3b1f0f0 100644--- a/frontend/src/plugins/impl/chat/chat-ui.tsx+++ b/frontend/src/plugins/impl/chat/chat-ui.tsx@@ -10,7 +10,6 @@ import {type TextUIPart,type UIMessageChunk,} from "ai";-import { startCase } from "lodash-es";import {BotMessageSquareIcon,HelpCircleIcon,@@ -57,6 +56,7 @@ import {import { cn } from "@/utils/cn";import { Logger } from "@/utils/Logger";import { Objects } from "@/utils/objects";+import { Strings } from "@/utils/strings";import { ErrorBanner } from "../common/error-banner";import type { PluginFunctions } from "./ChatPlugin";import type { ChatConfig } from "./types";@@ -670,7 +670,7 @@ const ConfigPopup: React.FC<{htmlFor={key}className="flex w-full justify-between col-span-3 align-end">- {startCase(key)}+ {Strings.startCase(key)}<TooltipdelayDuration={200}side="top"diff --git a/frontend/src/plugins/impl/data-editor/components.tsx b/frontend/src/plugins/impl/data-editor/components.tsxindex 166335bdd3..8794375789 100644--- a/frontend/src/plugins/impl/data-editor/components.tsx+++ b/frontend/src/plugins/impl/data-editor/components.tsx@@ -1,6 +1,5 @@/* Copyright 2026 Marimo. All rights reserved. */-import { capitalize } from "lodash-es";import { PencilIcon, PlusIcon } from "lucide-react";import { useState } from "react";import { Button } from "@/components/ui/button";@@ -20,6 +19,7 @@ import {SelectValue,} from "@/components/ui/select";import type { DataType } from "@/core/kernel/messages";+import { capitalize } from "@/utils/strings";interface RenameColumnSubProps {currentColumnName: string;diff --git a/frontend/src/plugins/impl/data-explorer/components/query-form.tsx b/frontend/src/plugins/impl/data-explorer/components/query-form.tsxindex 1625dc3623..3d9b126d85 100644--- a/frontend/src/plugins/impl/data-explorer/components/query-form.tsx+++ b/frontend/src/plugins/impl/data-explorer/components/query-form.tsx@@ -5,7 +5,6 @@ import { ExpandedType } from "compassql/build/src/query/expandedtype";import { PrimitiveType, type Schema } from "compassql/build/src/schema";import { SHORT_WILDCARD } from "compassql/build/src/wildcard";import { useAtomValue } from "jotai";-import { startCase } from "lodash-es";import { FunctionSquareIcon } from "lucide-react";import React from "react";import { Label } from "@/components/ui/label";@@ -19,6 +18,7 @@ import {SelectTrigger,SelectValue,} from "@/components/ui/select";+import { Strings } from "@/utils/strings";import type { EncodingChannel, FieldDefinition } from "../encoding";import {MULTI_TEMPORAL_FUNCTIONS,@@ -281,7 +281,7 @@ const FieldOptions = ({{label && <SelectLabel>{label}</SelectLabel>}{fns.map((fn) => (<SelectItem key={fn} value={fn ?? NONE_FN}>- {startCase(fn)}+ {Strings.startCase(fn)}</SelectItem>))}</SelectGroup>diff --git a/frontend/src/plugins/impl/data-explorer/functions/types.ts b/frontend/src/plugins/impl/data-explorer/functions/types.tsindex 17b89beb2e..f8f49919f7 100644--- a/frontend/src/plugins/impl/data-explorer/functions/types.ts+++ b/frontend/src/plugins/impl/data-explorer/functions/types.ts@@ -1,6 +1,5 @@/* Copyright 2026 Marimo. All rights reserved. */-import { isString } from "lodash-es";import type {ArgmaxDef,ArgminDef,@@ -59,7 +58,7 @@ type SupportedAggregateOp = (typeof SUPPORTED_AGGREGATE_OPS)[number];export const isAggregateOp: typeof isAggregateOpVega = (a: string | ArgminDef | ArgmaxDef,): a is AggregateOp => {- if (!isString(a)) {+ if (typeof a !== "string") {return false;}diff --git a/frontend/src/plugins/impl/data-frames/DataFramePlugin.tsx b/frontend/src/plugins/impl/data-frames/DataFramePlugin.tsxindex 47d7f5a23f..35c79bf919 100644--- a/frontend/src/plugins/impl/data-frames/DataFramePlugin.tsx+++ b/frontend/src/plugins/impl/data-frames/DataFramePlugin.tsx@@ -1,6 +1,6 @@/* Copyright 2026 Marimo. All rights reserved. */-import { isEqual } from "lodash-es";+import { dequal as isEqual } from "dequal";import { Code2Icon, DatabaseIcon, FunctionSquareIcon } from "lucide-react";import {type JSX,diff --git a/frontend/src/plugins/impl/plotly/PlotlyPlugin.tsx b/frontend/src/plugins/impl/plotly/PlotlyPlugin.tsxindex fe90fac039..c20f375683 100644--- a/frontend/src/plugins/impl/plotly/PlotlyPlugin.tsx+++ b/frontend/src/plugins/impl/plotly/PlotlyPlugin.tsx@@ -8,12 +8,13 @@ import type { Figure } from "./Plot";import "./plotly.css";import "./mapbox.css";-import { pick, set } from "lodash-es";+import { set } from "lodash-es";import { type JSX, lazy, memo, useMemo } from "react";import useEvent from "react-use-event-hook";import { useDeepCompareMemoize } from "@/hooks/useDeepCompareMemoize";import { useScript } from "@/hooks/useScript";import { Arrays } from "@/utils/arrays";+import { Objects } from "@/utils/objects";import { createParser, type PlotlyTemplateParser } from "./parse-from-template";import { usePlotlyLayout } from "./usePlotlyLayout";@@ -179,7 +180,9 @@ export const PlotlyComponent = memo(setValue((prev) => ({...prev,- points: evt.points.map((point) => pick(point, TREE_MAP_DATA_KEYS)),+ points: evt.points.map((point) =>+ Objects.pick(point, TREE_MAP_DATA_KEYS),+ ),}));})}onSunburstClick={useEvent((evt: Readonly<Plotly.PlotMouseEvent>) => {@@ -189,7 +192,9 @@ export const PlotlyComponent = memo(setValue((prev) => ({...prev,- points: evt.points.map((point) => pick(point, SUNBURST_DATA_KEYS)),+ points: evt.points.map((point) =>+ Objects.pick(point, SUNBURST_DATA_KEYS),+ ),}));})}config={plotlyConfig}@@ -264,7 +269,7 @@ function extractPoints(let parser: PlotlyTemplateParser | undefined;return points.map((point) => {- const standardPointFields = pick(point, STANDARD_POINT_KEYS);+ const standardPointFields = Objects.pick(point, STANDARD_POINT_KEYS);// Get the first hovertemplateconst hovertemplate = Array.isArray(point.data.hovertemplate)diff --git a/frontend/src/plugins/impl/plotly/usePlotlyLayout.ts b/frontend/src/plugins/impl/plotly/usePlotlyLayout.tsindex d151bb6a44..da3c968d93 100644--- a/frontend/src/plugins/impl/plotly/usePlotlyLayout.ts+++ b/frontend/src/plugins/impl/plotly/usePlotlyLayout.ts@@ -1,7 +1,7 @@/* Copyright 2026 Marimo. All rights reserved. */import { usePrevious } from "@uidotdev/usehooks";-import { isEqual, pick } from "lodash-es";+import { dequal as isEqual } from "dequal";import type * as Plotly from "plotly.js";import { useEffect, useState } from "react";import { Objects } from "@/utils/objects";@@ -50,7 +50,7 @@ export function computeLayoutOnFigureChange(): Partial<Plotly.Layout> {return {...createInitialLayout(nextFigure),- ...pick(prevLayout, PERSISTED_LAYOUT_KEYS),+ ...Objects.pick(prevLayout, PERSISTED_LAYOUT_KEYS),};}diff --git a/frontend/src/plugins/impl/vega/loader.ts b/frontend/src/plugins/impl/vega/loader.tsindex 28dd5e0602..538c2b2cfe 100644--- a/frontend/src/plugins/impl/vega/loader.ts+++ b/frontend/src/plugins/impl/vega/loader.ts@@ -1,7 +1,6 @@/* Copyright 2026 Marimo. All rights reserved. */import { tableFromIPC } from "@uwdata/flechette";-import { isNumber } from "lodash-es";import { Logger } from "@/utils/Logger";import { Objects } from "@/utils/objects";import { batchedArrowLoader, createBatchedLoader } from "./batched";@@ -42,7 +41,9 @@ const BIG_INT_MIDDLEWARE: Middleware = () => {}const parsedInt = Number.parseInt(v, 10);- if (isNumber(parsedInt)) {+ if (Number.isNaN(parsedInt)) {+ return v;+ } else {const needsBigInt = Math.abs(parsedInt) > Number.MAX_SAFE_INTEGER;if (!needsBigInt) {return previousIntegerParserWithoutNaN(v);@@ -54,8 +55,6 @@ const BIG_INT_MIDDLEWARE: Middleware = () => {// as BigIntreturn previousIntegerParserWithoutNaN(v);}- } else {- return "";}};typeParsers.number = (v: string) => {diff --git a/frontend/src/plugins/impl/vega/params.ts b/frontend/src/plugins/impl/vega/params.tsindex 5db7250c2b..5131e40143 100644--- a/frontend/src/plugins/impl/vega/params.ts+++ b/frontend/src/plugins/impl/vega/params.ts@@ -1,8 +1,8 @@/* Copyright 2026 Marimo. All rights reserved. */-import { uniq } from "lodash-es";import type { TopLevelSpec } from "vega-lite";import type { NonNormalizedSpec } from "vega-lite/types_unstable/spec/index.js";+import { uniq } from "@/utils/arrays";import { Marks } from "./marks";import {type Field,diff --git a/frontend/src/utils/__tests__/arrays.test.ts b/frontend/src/utils/__tests__/arrays.test.tsindex cae52d334f..7269d0a55b 100644--- a/frontend/src/utils/__tests__/arrays.test.ts+++ b/frontend/src/utils/__tests__/arrays.test.ts@@ -9,6 +9,10 @@ import {arrayShallowEquals,arrayToggle,getNextIndex,+ partition,+ range,+ sortBy,+ uniq,} from "../arrays";describe("arrays", () => {@@ -130,6 +134,120 @@ describe("arrays", () => {});});+describe("range", () => {+ it("should create an array of numbers from 0 to length - 1", () => {+ expect(range(5)).toEqual([0, 1, 2, 3, 4]);+ });++ it("should return empty array for 0", () => {+ expect(range(0)).toEqual([]);+ });++ it("should return single element for 1", () => {+ expect(range(1)).toEqual([0]);+ });+});++describe("uniq", () => {+ it("should remove duplicate numbers", () => {+ expect(uniq([1, 2, 2, 3, 1])).toEqual([1, 2, 3]);+ });++ it("should remove duplicate strings", () => {+ expect(uniq(["a", "b", "a", "c"])).toEqual(["a", "b", "c"]);+ });++ it("should handle empty array", () => {+ expect(uniq([])).toEqual([]);+ });++ it("should preserve order of first occurrence", () => {+ expect(uniq([3, 1, 2, 1, 3])).toEqual([3, 1, 2]);+ });+});++describe("sortBy", () => {+ it("should sort by a numeric key", () => {+ const items = [{ n: 3 }, { n: 1 }, { n: 2 }];+ expect(sortBy(items, (x) => x.n)).toEqual([{ n: 1 }, { n: 2 }, { n: 3 }]);+ });++ it("should sort by a string key", () => {+ const items = [{ name: "charlie" }, { name: "alice" }, { name: "bob" }];+ expect(sortBy(items, (x) => x.name)).toEqual([+ { name: "alice" },+ { name: "bob" },+ { name: "charlie" },+ ]);+ });++ it("should not mutate the original array", () => {+ const arr = [3, 1, 2];+ sortBy(arr, (x) => x);+ expect(arr).toEqual([3, 1, 2]);+ });++ it("should handle empty array", () => {+ expect(sortBy([], (x) => x)).toEqual([]);+ });++ it("should sort null/undefined keys last", () => {+ const items = [+ { name: "b", v: undefined },+ { name: "a", v: 1 },+ { name: "c", v: null },+ { name: "d", v: 2 },+ ];+ const result = sortBy(items, (x) => x.v);+ expect(result.map((x) => x.name)).toEqual(["a", "d", "b", "c"]);+ });++ it("should sort numeric keys correctly", () => {+ const items = [{ v: 10 }, { v: 2 }, { v: 1 }, { v: 20 }];+ expect(sortBy(items, (x) => x.v)).toEqual([+ { v: 1 },+ { v: 2 },+ { v: 10 },+ { v: 20 },+ ]);+ });+});++describe("partition", () => {+ it("should split array by predicate", () => {+ const [evens, odds] = partition([1, 2, 3, 4, 5], (n) => n % 2 === 0);+ expect(evens).toEqual([2, 4]);+ expect(odds).toEqual([1, 3, 5]);+ });++ it("should handle all matching", () => {+ const [pass, fail] = partition([2, 4, 6], (n) => n % 2 === 0);+ expect(pass).toEqual([2, 4, 6]);+ expect(fail).toEqual([]);+ });++ it("should handle none matching", () => {+ const [pass, fail] = partition([1, 3, 5], (n) => n % 2 === 0);+ expect(pass).toEqual([]);+ expect(fail).toEqual([1, 3, 5]);+ });++ it("should handle empty array", () => {+ const [pass, fail] = partition([], () => true);+ expect(pass).toEqual([]);+ expect(fail).toEqual([]);+ });++ it("should work with string predicates", () => {+ const [long, short] = partition(+ ["hi", "hello", "yo", "greetings"],+ (s) => s.length > 3,+ );+ expect(long).toEqual(["hello", "greetings"]);+ expect(short).toEqual(["hi", "yo"]);+ });+});+describe("getNextIndex", () => {it("should return 0 if listLength is 0", () => {expect(getNextIndex(null, 0, "up")).toBe(0);diff --git a/frontend/src/utils/__tests__/objects.test.ts b/frontend/src/utils/__tests__/objects.test.tsindex 1046c99f85..45462fb583 100644--- a/frontend/src/utils/__tests__/objects.test.ts+++ b/frontend/src/utils/__tests__/objects.test.ts@@ -260,4 +260,38 @@ describe("Objects", () => {expect(result).toEqual({ a: 1, b: 2 });});});++ describe("pick", () => {+ it("should pick specified keys", () => {+ const obj = { a: 1, b: 2, c: 3 };+ expect(Objects.pick(obj, ["a", "c"])).toEqual({ a: 1, c: 3 });+ });++ it("should omit keys not present on the object", () => {+ const obj = { a: 1, b: 2 };+ expect(Objects.pick(obj, ["a", "z"])).toEqual({ a: 1 });+ });++ it("should preserve undefined values for existing keys", () => {+ const obj = { a: undefined, b: 2 };+ const result = Objects.pick(obj, ["a", "b"]);+ expect(result).toEqual({ a: undefined, b: 2 });+ expect("a" in result).toBe(true);+ });++ it("should not pick inherited properties", () => {+ const parent = { inherited: true };+ const obj = Object.create(parent);+ obj.own = 1;+ expect(Objects.pick(obj, ["own", "inherited"])).toEqual({ own: 1 });+ });++ it("should return empty object when picking no keys", () => {+ expect(Objects.pick({ a: 1 }, [])).toEqual({});+ });++ it("should handle empty object", () => {+ expect(Objects.pick({}, ["a"])).toEqual({});+ });+ });});diff --git a/frontend/src/utils/__tests__/strings.test.ts b/frontend/src/utils/__tests__/strings.test.tsindex 7fe2a1a31d..1948cc3926 100644--- a/frontend/src/utils/__tests__/strings.test.ts+++ b/frontend/src/utils/__tests__/strings.test.ts@@ -1,6 +1,6 @@/* Copyright 2026 Marimo. All rights reserved. */import { describe, expect, it } from "vitest";-import { decodeUtf8, Strings } from "../strings";+import { capitalize, decodeUtf8, Strings } from "../strings";describe("Strings", () => {describe("startCase", () => {@@ -58,6 +58,32 @@ describe("Strings", () => {});});+describe("capitalize", () => {+ it("capitalizes the first character", () => {+ expect(capitalize("hello")).toBe("Hello");+ });++ it("returns empty string for empty input", () => {+ expect(capitalize("")).toBe("");+ });++ it("handles already-capitalized strings", () => {+ expect(capitalize("Hello")).toBe("Hello");+ });++ it("handles single character", () => {+ expect(capitalize("a")).toBe("A");+ });++ it("preserves the rest of the string", () => {+ expect(capitalize("hELLO")).toBe("HELLO");+ });++ it("handles non-letter first character", () => {+ expect(capitalize("123abc")).toBe("123abc");+ });+});+describe("decodeUtf8", () => {it("decodes UTF-8 array to string", () => {const encoder = new TextEncoder();diff --git a/frontend/src/utils/arrays.ts b/frontend/src/utils/arrays.tsindex 0d2bcdbfcf..cee9f428c5 100644--- a/frontend/src/utils/arrays.ts+++ b/frontend/src/utils/arrays.ts@@ -61,6 +61,73 @@ export const Arrays = {},};+/**+ * Create an array of numbers from 0 to length - 1.+ */+export function range(length: number): number[] {+ return Array.from({ length }, (_, i) => i);+}++/**+ * Remove duplicate values from an array.+ */+export function uniq<T>(arr: readonly T[]): T[] {+ return [...new Set(arr)];+}++/**+ * Sort an array by a key function, returning a new array.+ */+export function sortBy<T>(+ arr: readonly T[],+ key: (item: T) => string | number | undefined | null,+): T[] {+ // Decorate/sort/undecorate to compute keys once per element+ return arr+ .map((item) => [key(item), item] as const)+ .sort(([ka], [kb]) => {+ // Nullish values sort last+ if (ka == null && kb == null) {+ return 0;+ }+ if (ka == null) {+ return 1;+ }+ if (kb == null) {+ return -1;+ }+ if (ka < kb) {+ return -1;+ }+ if (ka > kb) {+ return 1;+ }+ return 0;+ })+ .map(([, item]) => item);+}++/**+ * Split an array into two groups based on a predicate.+ * Returns [pass, fail] where pass contains items that match+ * and fail contains items that don't.+ */+export function partition<T>(+ arr: readonly T[],+ predicate: (item: T) => boolean,+): [T[], T[]] {+ const pass: T[] = [];+ const fail: T[] = [];+ for (const item of arr) {+ if (predicate(item)) {+ pass.push(item);+ } else {+ fail.push(item);+ }+ }+ return [pass, fail];+}+export function arrayToggle<T>(arr: T[], item: T): T[] {if (!arr) {return [item];diff --git a/frontend/src/utils/objects.ts b/frontend/src/utils/objects.tsindex 805ef28dd0..15c0cfbf12 100644--- a/frontend/src/utils/objects.ts+++ b/frontend/src/utils/objects.ts@@ -105,4 +105,18 @@ export const Objects = {const set = new Set<K>(keys);return Objects.filter(obj, (_, key) => !set.has(key));},++ // eslint-disable-next-line @typescript-eslint/no-explicit-any+ pick<V extends Record<string, any>, K extends string>(+ obj: V,+ keys: readonly K[],+ ): Pick<V, K & keyof V> {+ const result = {} as Record<string, unknown>;+ for (const key of keys) {+ if (Object.hasOwn(obj, key)) {+ result[key] = obj[key];+ }+ }+ return result as Pick<V, K & keyof V>;+ },};diff --git a/frontend/src/utils/strings.ts b/frontend/src/utils/strings.tsindex c0bf7c79d9..b541bcb88d 100644--- a/frontend/src/utils/strings.ts+++ b/frontend/src/utils/strings.ts@@ -1,28 +1,48 @@/* Copyright 2026 Marimo. All rights reserved. */-import { startCase } from "lodash-es";import { Logger } from "./Logger";-export const Strings = {- /**- * startCase that can handle non-letters- */- startCase: (str: string): string => {- if (!str) {- return "";- }+/**+ * Capitalize the first character of a string.+ */+export function capitalize(str: string): string {+ if (!str) {+ return "";+ }+ return str.charAt(0).toUpperCase() + str.slice(1);+}- if (typeof str !== "string") {- Logger.error(str);- throw new TypeError(`Expected string, got ${typeof str}`);- }+/**+ * Convert a string to start case (capitalize each word).+ * Handles camelCase, snake_case, kebab-case, and space-separated strings.+ * Returns the original string unchanged if it contains no letters.+ */+export function startCase(str: string): string {+ if (!str) {+ return "";+ }- // If has no letters, return the string- if (!/[A-Za-z]/.test(str)) {- return str;- }+ if (typeof str !== "string") {+ Logger.error(str);+ throw new TypeError(`Expected string, got ${typeof str}`);+ }- return startCase(str);- },+ // If has no letters, return the string as-is+ if (!/[A-Za-z]/.test(str)) {+ return str;+ }++ return str+ .replaceAll(/([\da-z])([A-Z])/g, "$1 $2") // camelCase → camel Case+ .replaceAll(/([A-Z]+)([A-Z][a-z])/g, "$1 $2") // ABCDef → ABC Def+ .replaceAll(/[\s_-]+/g, " ") // snake_case/kebab-case → spaces+ .trim()+ .split(" ")+ .map(capitalize)+ .join(" ");+}++export const Strings = {+ startCase,htmlEscape: (str: string | undefined): string | undefined => {if (!str) {