Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

812 B
Raw Blame
import { useSQLEditorTabState } from "@/modules/sql-editor/store/tab";
import { resolveAdminTheme } from "./derive";
import type { SQLEditorTheme } from "./types";
import { useWorkspaceSQLEditorTheme } from "./useWorkspaceSQLEditorTheme";

/**
 * The SQL Editor theme that should currently apply to the foreground code
 * surface: the selected theme in saved query mode, or its admin resolution
 * (selected-if-dark-else-dark) in admin mode. Used both for the chrome's
 * Monaco theme name and to drive the global Monaco theme controller.
 */
export function useActiveSQLEditorTheme(): SQLEditorTheme {
  const selected = useWorkspaceSQLEditorTheme();
  const mode = useSQLEditorTabState(
    (s) => s.tabsById.get(s.currentTabId)?.mode
  );
  return mode === "ADMIN" ? resolveAdminTheme(selected) : selected;
}