Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

2.2 KB
Raw Blame
import { useSoupFilterPersistence } from '@app/features/next-soup/use-soup-filter-persistence';
import { useFeatureFlag } from '@app/lib/analytics/posthog';
import {
  clearAllDebugSettings,
  DEBUG_SETTINGS,
  type DebugSettingDef,
  debugSettings,
  getDebugSetting,
  setDebugSetting,
} from '@app/lib/debugSettings';
import { enableSoupFilterPersistence } from '@core/constant/featureFlags';
import { Button, ToggleSwitch } from '@ui';
import { For, Show } from 'solid-js';
import { SettingsCard, SettingsPage, SettingsRow } from './primitives';

function DebugSettingRow(props: { setting: DebugSettingDef }) {
  const checked = () => getDebugSetting(props.setting.key);

  return (
    <SettingsRow
      label={props.setting.label}
      description={props.setting.description}
    >
      <ToggleSwitch
        size="md"
        checked={checked()}
        onChange={(value) => setDebugSetting(props.setting.key, value)}
      />
    </SettingsRow>
  );
}

export function Admin() {
  const hasActiveSettings = () => Object.keys(debugSettings()).length > 0;
  const soupFilterPersistenceFlag = useFeatureFlag(enableSoupFilterPersistence);
  const [shouldPersistSoupFilters, setShouldPersistSoupFilters] =
    useSoupFilterPersistence();

  return (
    <SettingsPage
      title="Debug"
      description="Local toggles for debugging — only visible to Macro staff."
      actions={
        <Button
          variant="secondary"
          size="sm"
          disabled={!hasActiveSettings()}
          onClick={clearAllDebugSettings}
        >
          Reset all
        </Button>
      }
    >
      <Show when={soupFilterPersistenceFlag().enabled}>
        <SettingsCard>
          <SettingsRow
            label="Persist list filters"
            description="Keep soup filters and the last selected tab across reloads on this device."
          >
            <ToggleSwitch
              size="md"
              checked={shouldPersistSoupFilters()}
              onChange={setShouldPersistSoupFilters}
            />
          </SettingsRow>
        </SettingsCard>
      </Show>

      <SettingsCard>
        <For each={DEBUG_SETTINGS}>
          {(setting) => <DebugSettingRow setting={setting} />}
        </For>
      </SettingsCard>
    </SettingsPage>
  );
}